:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --ink: #17221d;
  --muted: #5d6b64;
  --line: #e2e7e3;
  --green: #0f6b4f;
  --green-2: #e6f2ec;
  --red: #c0392b;
  --red-2: #fbeae8;
  --gold: #b7851c;
  --gold-2: #fbf3e1;
  --blue: #2563a8;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --card: #18201c; --ink: #e8eee9; --muted: #9aa8a1; --line: #26302b;
    --green: #3fbf8f; --green-2: #15302a; --red: #ef7b6e; --red-2: #3a1d1a; --gold: #e3b553; --gold-2: #33291a;
    --blue: #7fb2ea; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Hind Siliguri", system-ui, sans-serif; font-size: 17px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
h2 { font-size: 22px; margin: 6px 0 8px; }
h3 { font-size: 18px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.err { color: var(--red); min-height: 1em; margin: 4px 0; }
.ok { color: var(--green); min-height: 1em; margin: 6px 0 0; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.auth-card form { text-align: left; margin-top: 14px; }
.logo { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 18px; background: var(--green); color: #fff; font-size: 36px; font-weight: 700; display: grid; place-items: center; }
.app-name { margin: 4px 0; font-size: 28px; }
.link { background: none; border: 0; color: var(--green); font: inherit; margin-top: 12px; cursor: pointer; }

/* layout */
main { max-width: 560px; margin: 0 auto; padding: 0 16px calc(90px + env(safe-area-inset-bottom)); }
.top { padding: calc(14px + env(safe-area-inset-top)) 0 6px; }
.hello { font-size: 15px; color: var(--muted); }
.month-row { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 700; }
.icon-btn { border: 0; background: var(--card); color: var(--ink); width: 34px; height: 34px; border-radius: 10px; font-size: 22px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }

.card { background: var(--card); border-radius: 16px; padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card:empty { display: none; }
label { display: block; font-size: 15px; color: var(--muted); margin: 10px 0 0; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .btn { margin-top: 14px; }

.btn { font: inherit; font-weight: 600; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 10px 16px; min-height: 46px; cursor: pointer; }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.big { width: 100%; font-size: 19px; margin-top: 16px; min-height: 54px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }

/* quick entry */
.quick { background: var(--card); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); margin-top: 8px; }
.quick textarea { border: 0; background: transparent; resize: none; font-size: 18px; min-height: 56px; padding: 6px 4px; }
.quick-actions { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.mic { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--green); color: #fff; font-size: 26px; cursor: pointer; flex: none; }
.mic.live { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,.45); } 50% { box-shadow: 0 0 0 12px rgba(192,57,43,0); } }
.hint { font-size: 14px; color: var(--muted); margin: 6px 4px 0; min-height: 0; }
.hint:empty { display: none; }

/* preview of what the AI understood */
.pv { border: 2px solid var(--green); }
.pv-reply { margin: 0 0 8px; }
.pv-item { border-top: 1px solid var(--line); padding: 8px 0; }
.pv-item:first-of-type { border-top: 0; }
.pv-row { display: grid; grid-template-columns: 1.3fr 1fr .8fr; gap: 8px; }
.pv-row2 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.pv input, .pv select { min-height: 42px; padding: 8px; font-size: 16px; margin-top: 0; }
.pv-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.x { border: 0; background: none; color: var(--red); font-size: 14px; cursor: pointer; padding: 4px 0; }

/* home numbers */
.hero { background: linear-gradient(135deg, #0f6b4f, #138a63); color: #fff; }
.hero-label { opacity: .9; }
.hero-num { font-size: 36px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.hero-sub { opacity: .85; font-size: 14px; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: 14px; }
.stat b { font-size: 21px; }
.stat small { display: block; color: var(--muted); font-size: 13px; }
.left-card { display: flex; justify-content: space-between; align-items: center; }
.left-card b { font-size: 22px; }
.pos { color: var(--green); } .neg { color: var(--red); }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--green); }
.warn { background: var(--gold-2); }
.danger-card { background: var(--red-2); }
.rate { text-align: center; color: var(--muted); font-size: 13px; }
.chip { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 20px; background: var(--green-2); color: var(--green); }
.chip.red { background: var(--red-2); color: var(--red); }
.chip.gold { background: var(--gold-2); color: var(--gold); }

/* history */
.day { font-size: 14px; color: var(--muted); margin: 14px 4px 4px; }
.entry { display: flex; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px 14px; margin: 6px 0; box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; border: 0; font: inherit; color: inherit; }
.entry .what { font-weight: 600; }
.entry .sub { font-size: 14px; color: var(--muted); }
.entry .amt { font-weight: 700; white-space: nowrap; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs button { background: none; border: 0; font: inherit; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; cursor: pointer; }
.tabs button i { font-style: normal; font-size: 22px; }
.tabs button.on { color: var(--green); font-weight: 700; }

/* sheet + toast */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-card { width: 100%; max-width: 560px; background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90vw; }
