:root {
  --paper: #f3f6f5;
  --ink: #0e1a16;
  --muted: #5b6b66;
  --line: rgba(6, 37, 31, 0.08);
  --card: #ffffff;
  --forest: #06251f;
  --forest-2: #0d3d34;
  --mint: #1f8a70;
  --mint-bright: #3ddc97;
  --gold: #1f8a70;
  --gold-soft: #e4f6ef;
  --coral: #b42318;
  --ok: #0f766e;
  --accent-in: #1f8a70;
  --accent-extra: #4f46e5;
  --accent-fixed: #c2410c;
  --accent-daily: #be123c;
  --shadow: 0 1px 2px rgba(6, 37, 31, 0.04), 0 12px 32px rgba(6, 37, 31, 0.05);
  --radius: 20px;
  --nav-h: 76px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --max: 430px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 50% -80px, #d7efe6 0%, transparent 58%),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  letter-spacing: -0.011em;
}

.app {
  width: min(var(--max), 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 18px calc(var(--nav-h) + var(--safe-b) + 20px);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand img, .mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}
.mark {
  background: var(--forest);
  color: var(--mint-bright);
  display: grid;
  place-items: center;
  font-family: "Sora", sans-serif;
  font-weight: 600;
  font-size: 16px;
}
.brand h1 {
  font-family: "Sora", sans-serif;
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.04em;
  font-weight: 600;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

select, input, textarea, button {
  font: inherit;
}
.month-pick {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow);
}

.hero {
  background:
    linear-gradient(180deg, rgba(61, 220, 151, 0.12), transparent 42%),
    linear-gradient(160deg, #08332b, #06251f 72%);
  color: #edf8f3;
  border-radius: 28px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -48px;
  top: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(61, 220, 151, 0.22), transparent 70%);
  pointer-events: none;
}
.hero .kicker {
  position: relative;
  z-index: 1;
  color: rgba(237, 248, 243, 0.72);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 12px;
}
.hero .big {
  font-family: "Sora", sans-serif;
  font-size: 2.05rem;
  margin: 8px 0 6px;
  letter-spacing: -0.04em;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.hero .sub { opacity: 0.72; font-size: 0.86rem; line-height: 1.4; }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}
.hero-grid div {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 12px 14px;
}
.hero-grid span { display: block; font-size: 0.68rem; opacity: 0.62; letter-spacing: 0.04em; text-transform: uppercase; }
.hero-grid strong { font-size: 0.98rem; font-weight: 600; }

.donut-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 148px minmax(132px, 220px);
  gap: 18px;
  align-items: center;
  justify-content: start;
}
.donut {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#e8efec 0 100%);
}
.donut.empty { background: conic-gradient(#e8efec 0 100%); }
.donut-hole {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.donut-hole small {
  font-size: 0.58rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.donut-hole strong {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legend li {
  display: grid;
  grid-template-columns: 10px auto 44px;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}
.donut-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.donut-legend em { font-style: normal; color: var(--muted); font-weight: 600; }
.hero .donut { background: conic-gradient(#1a4a42 0 100%); }
.hero .donut.empty { background: conic-gradient(#1a4a42 0 100%); }
.hero .donut-hole {
  background: #06251f;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.hero .donut-hole small { color: rgba(237, 248, 243, 0.68); }
.hero .donut-hole strong { color: #edf8f3; }
.hero .donut-legend li { color: #edf8f3; }
.hero .donut-legend em { color: rgba(237, 248, 243, 0.7); }
.daily-can {
  position: relative;
  z-index: 1;
  margin: 16px 0 0;
  padding: 12px 14px;
  background: rgba(61, 220, 151, 0.12);
  border-radius: 16px;
  font-size: 0.86rem;
  color: #c8f5e0;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.45;
}
.daily-can .ui-ico { flex-shrink: 0; margin-top: 1px; opacity: 0.9; }
.daily-can strong { font-weight: 700; color: #edf8f3; }

.wallets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.wallet {
  position: relative;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px 14px 12px 18px;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.wallet::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 0 99px 99px 0;
  background: var(--accent, var(--mint));
}
.wallet span {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.wallet span em {
  font-style: normal;
  flex: 1;
  min-width: 0;
}
.wallet .ui-ico { width: 16px; height: 16px; color: var(--accent, var(--mint)); flex-shrink: 0; }
.wallet.tap .ui-ico:last-child { color: var(--muted); opacity: 0.55; }
.wallet strong { font-family: "Sora", sans-serif; font-size: 1.02rem; font-weight: 600; overflow-wrap: anywhere; color: var(--ink); }
.wallet.w-in { --accent: var(--accent-in); background: #f7fbf9; }
.wallet.w-extra { --accent: var(--accent-extra); background: #f7f7fd; }
.wallet.w-fixed { --accent: var(--accent-fixed); background: #fdf8f5; }
.wallet.w-daily { --accent: var(--accent-daily); background: #fdf7f8; }

.grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
.home-pair { display: none; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.btn, .tab, .chip {
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.btn:active, .card.tap:active { transform: scale(0.98); }
.goal-actions .btn { flex: 1 1 100%; }
.card.wide { width: 100%; }
.card.tap, .wallet.tap { cursor: pointer; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}
.card-head h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.ico-box {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--gold-soft);
  color: var(--mint);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.chev { color: var(--muted); opacity: 0.55; display: grid; }
.card.tap, .wallet.tap {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
@media (hover: hover) {
  .card.tap:hover, .wallet.tap:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(6, 37, 31, 0.08);
    border-color: rgba(31, 138, 112, 0.22);
  }
}
.card.tap:focus-visible, .wallet.tap:focus-visible, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid rgba(31, 138, 112, 0.45);
  outline-offset: 2px;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--ink);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.card .val {
  font-family: "Sora", sans-serif;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  font-weight: 600;
}
.muted { color: var(--muted); line-height: 1.55; }
.ok { color: var(--ok); }
.warn { color: var(--coral); }

.goal-row { margin-bottom: 16px; padding-bottom: 8px; }
.goal-row .progress { margin: 10px 0 12px; }
.goal-actions { margin: 0; flex-wrap: wrap; }
.progress {
  height: 8px;
  background: #e8efec;
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--mint-bright), var(--mint));
}
.progress > i.warn {
  background: linear-gradient(90deg, #e6b325, #c9841a);
}
.progress > i.over {
  background: linear-gradient(90deg, #e08b7a, var(--coral));
}
.alert {
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  background: #fff4e5;
  color: #9a6700;
}
.alert.danger {
  background: #f8e6e4;
  color: var(--coral);
}
.remind-banner p { margin: 6px 0 10px; font-weight: 400; }
.bars { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.bar-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 0.86rem;
}
.bar {
  height: 10px;
  background: #e8efec;
  border-radius: 99px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--mint-bright), var(--mint));
}
.bar i.over { background: var(--coral); }
.bar-row em { font-style: normal; font-variant-numeric: tabular-nums; color: var(--muted); }
.year-bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  height: 120px;
  align-items: end;
  margin-top: 8px;
}
.year-col { display: flex; flex-direction: column; align-items: center; height: 100%; }
.year-stack {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.year-stack b, .year-stack i {
  display: block;
  width: 50%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
}
.year-stack b { background: var(--mint); }
.year-stack i { background: #c45c3e; opacity: 0.85; }
.year-col small { font-size: 0.62rem; color: var(--muted); margin-top: 4px; }
.chart-key { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key.in { background: var(--mint); }
.key.out { background: #c45c3e; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.row > :first-child { min-width: 0; flex: 1; }
.row strong { overflow-wrap: anywhere; }
.row .muted { overflow-wrap: anywhere; }
.bucket-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.row:last-child { border-bottom: 0; }

.list { display: flex; flex-direction: column; gap: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .btn, .tab {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #e8efec;
  color: var(--ink);
  font-weight: 600;
}
.chip.active, .tab.active {
  background: var(--forest);
  color: #edf8f3;
}
.btn.primary {
  background: var(--forest);
  color: #edf8f3;
}
.btn.gold { background: var(--mint); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: #f8e6e4; color: var(--coral); }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 16px; border-radius: 14px; font-weight: 600; }
button { cursor: pointer; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn.lg { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.add-list { margin-top: 16px; gap: 10px; }
.add-row {
  justify-content: flex-start !important;
  background: #fff !important;
  border: 1px solid var(--line);
  text-align: left;
  padding: 14px 16px;
}
.add-row .ui-ico:last-child { margin-left: auto; color: var(--muted); opacity: 0.5; }
.add-row .ui-ico:first-child { color: var(--mint); }

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fx-pair {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.fx-pair input { flex: 1; min-width: 0; }
.fx-pair select { width: 38%; flex-shrink: 0; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}
input[type="text"], input[type="number"], input[type="date"], input[type="month"], textarea, select.field {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 138, 112, 0.28);
  border-color: var(--mint);
}

.nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(var(--max), 100%);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px calc(10px + var(--safe-b));
  z-index: 20;
}
.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 4px 0;
}
.nav a.add-link { color: transparent; font-size: 0; }
.nav a.active { color: var(--forest); font-weight: 650; }
.nav svg { display: block; margin: 0 auto 3px; }
.nav .add {
  width: 48px;
  height: 48px;
  margin: -20px auto 0;
  border-radius: 50%;
  background: var(--forest);
  color: var(--mint-bright);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(6, 37, 31, 0.28);
}

.hidden { display: none !important; }
.section-title {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 1.32rem;
  margin: 2px 0 16px;
  letter-spacing: -0.04em;
  font-weight: 700;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.tx {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.tx .ico {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold-soft);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--mint);
}
.tx .amt.in { color: var(--ok); font-weight: 800; }
.tx .amt.out { color: var(--ink); font-weight: 800; }

.empty {
  text-align: center;
  padding: 24px 8px;
  color: var(--muted);
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(6, 21, 18, 0.48);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet.hidden { display: none; }
.sheet .panel {
  width: min(var(--max), 100%);
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(22px + var(--safe-b));
  max-height: 92dvh;
  overflow: auto;
  animation: sheetUp 0.22s ease;
}
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}
.workspace-pick { margin: 8px 0 14px; }
.pick-label { font-size: 0.82rem; font-weight: 600; margin: 0 0 8px; }
.pick-card {
  display: flex;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.pick-card strong { display: block; }
.pick-card em { font-style: normal; color: var(--muted); font-size: 0.82rem; }
.sr-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.scan-card h3 { margin-top: 0; }
.scan-drop {
  position: relative;
  border: 1px dashed rgba(31, 138, 112, 0.45);
  background: #eef7f3;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  text-align: center;
}
.scan-drop.compact { padding: 12px; }
.source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 14px;
}
.scan-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.scan-preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 12px;
}
.scan-row {
  display: grid;
  grid-template-columns: auto 1fr 90px;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.scan-row select { grid-column: 2 / -1; }
.scan-keep {
  flex-direction: row !important;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}
.scan-sum {
  font-family: "Sora", sans-serif;
  font-weight: 600;
  margin: 8px 0 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th, .table td {
  text-align: left;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.kind {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: #e8efec;
  text-transform: capitalize;
}
.kind.cash { background: #dcefe8; }
.kind.budget { background: var(--gold-soft); }
.kind.sinking { background: #f8e6e4; }

@media (min-width: 800px) {
  :root { --max: 920px; }
  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .home-pair, .card.wide { grid-column: 1 / -1; }
  .wallets { grid-template-columns: repeat(4, 1fr); }
  .donut-wrap { grid-template-columns: 168px minmax(160px, 240px); }
  .donut { width: 168px; height: 168px; }
  .donut-hole { width: 104px; height: 104px; }
}

body.locked .app,
body.locked .nav { display: none; }
.gate {
  display: none;
  min-height: 100dvh;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  overflow: auto;
}
body.locked .gate { display: flex !important; }
.gate-card {
  width: min(430px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 22px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  margin: auto;
}
.gate-card img {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}
.gate-card h1 {
  font-family: "Sora", sans-serif;
  margin: 14px 0 6px;
  letter-spacing: -0.04em;
  font-weight: 600;
}
.gate-tagline {
  color: var(--ink) !important;
  font-size: 1.02rem !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  margin: 0 0 10px !important;
}
.gate-intro {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 14px !important;
}
.gate-points {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gate-points li {
  background: #f7fbf9;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink);
}
.gate-points strong { color: var(--forest); font-weight: 700; }
.gate-card p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  margin: 0 0 20px;
}
.gate-card .form { text-align: left; }
.auth-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.text-link {
  background: none;
  border: 0;
  color: var(--mint);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
#login-hint { margin: 0 0 10px; }
.gate-help {
  margin: 18px 0 0 !important;
  font-size: 0.86rem !important;
  color: var(--muted);
}
.gate-help a {
  color: var(--mint);
  font-weight: 700;
  text-decoration: none;
}
.contact-card { margin-top: 16px; }
.contact-card a.btn { text-decoration: none; }
input[name="code"] {
  letter-spacing: 0.28em;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
}

