:root {
  --bg: #070708;
  --bg-elev: rgba(18, 18, 20, 0.72);
  --bg-soft: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(214, 201, 176, 0.28);
  --text: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.55);
  --accent: #d6c9b0;
  --accent-2: #9a8f78;
  --good: #8fbf9a;
  --bad: #c98989;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --nav-h: 74px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  cursor: pointer;
}

.marble {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(214, 201, 176, 0.12), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(120, 120, 130, 0.18), transparent 50%),
    radial-gradient(700px 500px at 50% 110%, rgba(214, 201, 176, 0.07), transparent 45%),
    linear-gradient(160deg, #0a0a0c 0%, #070708 45%, #0d0d10 100%);
}
.marble::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    repeating-linear-gradient(115deg, transparent 0 18px, rgba(255,255,255,0.015) 18px 19px),
    repeating-linear-gradient(25deg, transparent 0 28px, rgba(214,201,176,0.02) 28px 29px);
  mix-blend-mode: soft-light;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 18px);
  animation: fadeIn 0.45s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.back-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 18px;
  flex-shrink: 0;
}
.back-btn.hidden { display: none; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: #111;
  background: linear-gradient(145deg, #efe6d4, #b9ab91);
  box-shadow: 0 8px 24px rgba(214, 201, 176, 0.18);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.08em;
  line-height: 1;
  font-weight: 700;
}
.brand-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 18px;
}

.view { display: grid; gap: 14px; }

.hero {
  padding: 22px 20px 20px;
  border-radius: 24px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(160deg, rgba(214,201,176,0.10), transparent 42%),
    rgba(14, 14, 16, 0.85);
  box-shadow: var(--shadow);
  animation: rise 0.5s ease both;
}
.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}
.metric {
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
}
.metric .label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.metric .value {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.metric .value.good { color: var(--good); }
.metric .value.bad { color: var(--bad); }
.metric .value.accent { color: var(--accent); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 2px 0;
}
.section-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
}
.section-title span { color: var(--muted); font-size: 12px; }

.list {
  display: grid;
  gap: 8px;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px 14px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.row.task-row {
  grid-template-columns: auto 1fr;
}
.row:active { transform: scale(0.985); }
.row.done {
  opacity: 0.55;
}
.row.done .row-title {
  text-decoration: line-through;
  color: var(--muted);
}
.row-main { min-width: 0; }
.row-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-side {
  display: flex;
  align-items: center;
  gap: 8px;
}
.amount { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.amount.plus { color: var(--good); }
.amount.minus { color: var(--bad); }

.check {
  width: 28px; height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  color: transparent;
  background: transparent;
  flex-shrink: 0;
}
.check.on {
  background: linear-gradient(145deg, #efe6d4, #b9ab91);
  color: #111;
  border-color: transparent;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  margin-top: 10px;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8f8370, #d6c9b0);
  transition: width 0.45s ease;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: max-content;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.tab.active {
  background: rgba(214, 201, 176, 0.14);
  color: var(--accent);
}

.actions {
  display: flex;
  gap: 8px;
}
.btn {
  flex: 1;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  font-weight: 600;
  font-size: 14px;
}
.btn.primary {
  background: linear-gradient(145deg, #efe6d4, #b9ab91);
  color: #14120f;
  border: 0;
}
.btn.danger {
  color: var(--bad);
  border-color: rgba(201, 137, 137, 0.35);
}
.btn.ghost { background: transparent; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--accent-2);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
}
.stat-card .k { color: var(--muted); font-size: 12px; }
.stat-card .v {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.stat-card.wide { grid-column: 1 / -1; }

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 10px 10px calc(10px + var(--safe-b));
  background: rgba(8, 8, 10, 0.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index: 20;
}
.nav-btn {
  display: grid;
  gap: 4px;
  place-items: center;
  color: var(--muted);
  padding: 6px 2px;
}
.nav-btn span { font-size: 16px; line-height: 1; }
.nav-btn em {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.02em;
}
.nav-btn.active { color: var(--accent); }

.sheet.hidden { display: none; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.62);
}
.sheet-wrap {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  max-height: min(90dvh, 860px);
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.28s ease both;
}
@keyframes sheetUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.sheet-panel {
  width: 100%;
  max-height: min(90dvh, 860px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #101012;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(22px + var(--safe-b));
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.sheet-back, .sheet-close {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 4px;
}
.sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 26px;
  margin-bottom: 14px;
}
.form { display: grid; gap: 10px; }
.field { display: grid; gap: 6px; }
.field label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  outline: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--line-strong);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 50;
  padding: 12px 16px;
  border-radius: 14px;
  background: #17171a;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: sheetUp 0.25s ease both;
}
.toast.hidden { display: none; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(5,5,6,0.92);
  padding: 24px;
}
.gate.hidden { display: none; }
.gate-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 28px 22px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: #101012;
}
.gate-card p { color: var(--muted); line-height: 1.5; }

.mini {
  font-size: 12px;
  color: var(--muted);
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.seg .btn.active, .seg .btn.primary {
  background: linear-gradient(145deg, #efe6d4, #b9ab91);
  color: #14120f;
  border: 0;
}
