/* KothaFin — mobile-first styles. Light and dark themes via tokens. */

/* Fonts, served from /fonts (the security policy allows fonts from this site only).
   Plus Jakarta Sans for Latin and numbers; Hind Siliguri for Bangla (and ৳), picked per character.
   Hind Siliguri is drawn smaller than Jakarta at the same size, so it is scaled up 12% to match. */
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plus-jakarta-sans-latin.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plus-jakarta-sans-latin-ext.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Hind Siliguri"; src: url("/fonts/hind-siliguri-bengali-400.woff2") format("woff2"); size-adjust: 112%; font-weight: 400; font-display: swap; unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0-1CF9, U+200C-200D, U+20B9, U+25CC, U+A8F1; }
@font-face { font-family: "Hind Siliguri"; src: url("/fonts/hind-siliguri-bengali-500.woff2") format("woff2"); size-adjust: 112%; font-weight: 500; font-display: swap; unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0-1CF9, U+200C-200D, U+20B9, U+25CC, U+A8F1; }
@font-face { font-family: "Hind Siliguri"; src: url("/fonts/hind-siliguri-bengali-600.woff2") format("woff2"); size-adjust: 112%; font-weight: 600; font-display: swap; unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0-1CF9, U+200C-200D, U+20B9, U+25CC, U+A8F1; }
@font-face { font-family: "Hind Siliguri"; src: url("/fonts/hind-siliguri-bengali-700.woff2") format("woff2"); size-adjust: 112%; font-weight: 700 800; font-display: swap; unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0-1CF9, U+200C-200D, U+20B9, U+25CC, U+A8F1; }

/* Bangla digits ০–৯ only, from Noto Sans Bengali: Hind Siliguri draws "১" as a small clipped-looking hook. */
@font-face { font-family: "KothaFin Bangla Digits"; src: url("/fonts/noto-sans-bengali-vf.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+09E6-09EF; }

:root {
  /* KothaFin logo: navy #132c4a and teal #20a796. The brand teal is a shade deeper so white text on it stays readable. */
  --navy: #132c4a;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --border: #e6eaf0;
  --text: #132c4a;
  --muted: #6b7a8c;
  --brand: #137c6f;
  --brand-strong: #0d6258;
  --brand-soft: #dff4ef;
  --on-brand: #ffffff;
  /* Primary buttons, active tabs and the active menu item: a soft teal tint with deep teal text (no solid or gradient fill). */
  --primary: #132c4a;
  --primary-hover: #1f4570;
  --primary-bg: #dff4ef;
  --primary-bg-hover: #cbece4;
  --on-primary: #0d6258;
  --card-border: transparent;
  /* Selected toggles (sidebar item, tab pills, switches): a soft blue-navy shade. */
  --nav-active-bg: #dce6f5;
  --action: #20a796;
  /* Chart colours: brighter than the text colours (which stay dark enough to read). */
  --chart-income: #20a796;
  --chart-expense: #f97066;
  --chart-asset: #3b82f6;
  --action-hover: #1b927f;
  --nav-active-text: #132c4a;
  --btn-stroke: #132c4a; /* button outline: the logo's navy ("Kotha") */
  --hero: linear-gradient(135deg, #137c6f, #132c4a);
  --income: #15803d;
  --income-soft: #dcfce7;
  --expense: #c2410c;
  --expense-soft: #ffedd5;
  --transfer: #4f46e5;
  --transfer-soft: #e0e7ff;
  --invest: #0e7490;
  --invest-soft: #cffafe;
  --loan: #be123c;
  --loan-soft: #ffe4e6;
  --danger: #b91c1c;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(19, 44, 74, .04), 0 6px 24px rgba(19, 44, 74, .06);
  --shadow-lift: 0 2px 4px rgba(19, 44, 74, .06), 0 12px 32px rgba(19, 44, 74, .10);
  --radius: 20px;
  --font: "Plus Jakarta Sans", "KothaFin Bangla Digits", "Hind Siliguri", "Segoe UI", "Nirmala UI", "Noto Sans Bengali", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1420; --surface: #111e2e; --surface-2: #18283b; --border: #22364b; --text: #e8eef5; --muted: #95a6b8;
    --primary: #2cc4ae; --primary-hover: #52d3c0; --on-primary: #6adcca; --primary-bg: #123f3d; --primary-bg-hover: #17504c; --card-border: #1b2d42; --btn-stroke: #4a6a90; --nav-active-bg: #1b3252; --nav-active-text: #dbe6f3;
    --brand: #2cc4ae; --brand-strong: #6adcca; --brand-soft: #103a3a; --on-brand: #04201d;
    --hero: linear-gradient(135deg, #137c6f, #1d4f73);
    --income: #4ade80; --income-soft: #12301f; --expense: #fb923c; --expense-soft: #3a2413;
    --transfer: #a5b4fc; --transfer-soft: #1f2447; --invest: #67e8f9; --invest-soft: #0f3440; --loan: #fda4af; --loan-soft: #3b1219; --danger: #f87171; --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22); --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1420; --surface: #111e2e; --surface-2: #18283b; --border: #22364b; --text: #e8eef5; --muted: #95a6b8;
  --primary: #2cc4ae; --primary-hover: #52d3c0; --on-primary: #6adcca; --primary-bg: #123f3d; --primary-bg-hover: #17504c; --card-border: #1b2d42; --btn-stroke: #4a6a90; --nav-active-bg: #1b3252; --nav-active-text: #dbe6f3;
  --brand: #2cc4ae; --brand-strong: #6adcca; --brand-soft: #103a3a; --on-brand: #04201d;
  --hero: linear-gradient(135deg, #137c6f, #1d4f73);
  --income: #4ade80; --income-soft: #12301f; --expense: #fb923c; --expense-soft: #3a2413;
  --transfer: #a5b4fc; --transfer-soft: #1f2447; --invest: #67e8f9; --invest-soft: #0f3440; --loan: #fda4af; --loan-soft: #3b1219; --danger: #f87171; --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22); --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 500 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 1.55rem; letter-spacing: -.025em; }
h2 { font-size: 1.05rem; }
h1.greeting { font-size: 1.2rem; font-weight: 700; } /* the user's name on the dashboard: quieter than page titles */
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.01em; }
.income { color: var(--income); }
.expense { color: var(--expense); }
.transfer { color: var(--transfer); }
.investment { color: var(--invest); }
.loan { color: var(--loan); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; width: 100%; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.topbar h1 { white-space: nowrap; }
/* Global header, phones and the Android app only: logo left; first name and picture right.
   Pinned to the top with a soft drop shadow. It spans the full width (it undoes .main's side padding). */
.app-header {
  position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -16px -16px 16px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); box-shadow: 0 2px 14px rgba(19, 44, 74, .10), 0 1px 0 var(--border);
}
.app-header-brand { display: block; flex: none; line-height: 0; }
.app-header-brand img { width: 108px; height: auto; }
.app-header-user { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1rem; }
.app-header-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 900px) { .app-header { display: none; } } /* desktop: the sidebar has the logo */
/* Dashboard on phones: the header shows the name, so only the month picker, on the right. */
@media (max-width: 899px) {
  .dash-head .topbar { justify-content: flex-end; margin-bottom: 16px; }
  .dash-head .topbar .title { display: none; }
  .dash-head .month-btn { font-size: .86rem; min-height: 40px; padding: 8px 12px; }
}
.topbar .title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 700; flex: none; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(19, 44, 74, .05);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; }
.bottom-nav a.active { color: var(--text); font-weight: 700; }
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav .mic-slot { position: relative; }
.fab-mic {
  position: absolute; left: 50%; top: -30px; transform: translateX(-50%); width: 62px; height: 62px; border-radius: 50%; border: 4px solid var(--bg);
  background: var(--hero); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lift); cursor: pointer;
}
.fab-mic svg { width: 28px; height: 28px; }

@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; width: 240px; flex: none; padding: 22px 16px; background: var(--surface);
    border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  }
  .sidebar a.brand { display: flex; align-items: center; padding: 4px 10px 20px; text-decoration: none; }
  .sidebar a.brand:hover { background: none; }
  .sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; text-decoration: none; transition: background .15s, color .15s; }
  .sidebar a:hover { background: var(--surface-2); color: var(--text); }
  /* "Download for Android": an outlined pill in the logo teal, under Sign out. */
  .sidebar a.download-android { margin-top: 24px; margin-bottom: 20px; /* lifted off the bottom edge */ /* keeps Sign out a little above it */ justify-content: center; gap: 8px; padding: 10px 10px; border: 1.5px solid var(--action); color: var(--action); font-weight: 700; font-size: .88rem; white-space: nowrap; }
  .sidebar a.download-android:hover { background: var(--brand-soft); color: var(--brand-strong); }
  .sidebar a.download-android svg { color: #3ddc84; } /* Android green */
  .sidebar a.active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 700; } /* soft shade of the logo's navy ("Kotha") */
  .sidebar svg { width: 19px; height: 19px; }
  .sidebar .voice-btn { margin: 6px 0 16px; }
  .sidebar .spacer { flex: 1; }
  .bottom-nav { display: none; }
  .main { padding: 28px 32px 48px; }
}

/* General | Asset tabs: a neutral full-width switch above the dashboard (no colour; the card below carries it) */
.dash-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 5px; margin-bottom: 18px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--card-border); }
.dash-tabs button {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 0; cursor: pointer;
  border-radius: 999px; background: transparent; color: var(--muted); font-weight: 700; font-size: .95rem;
  transition: background .15s, color .15s;
}
.dash-tabs button svg { width: 18px; height: 18px; }
.dash-tabs button:hover:not(.on) { color: var(--text); background: var(--surface-2); }
.dash-tabs button.on { background: var(--nav-active-bg); color: var(--nav-active-text); }
.hero.asset-hero { background: var(--hero); } /* same gradient as General */
.transfer-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.transfer-actions .btn { flex-direction: column; gap: 2px; padding: 14px 12px; border-radius: 18px; }
.transfer-actions .btn small { font-weight: 500; color: var(--muted); font-size: .75rem; }
.flow-note { margin: -4px 0 12px; color: var(--muted); }
.flow-note.error { color: var(--danger); font-weight: 600; }

/* Asset sheet: what you have − what you owe = asset value */
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 1.02rem;
  padding: 8px 0 4px; border-bottom: 2px solid var(--border); }
.sheet .sheet-head.owe { margin-top: 14px; }
.sheet .sheet-sub { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 10px 0 2px; }
.sheet .cat-list li { padding: 6px 0; }
.sheet .sheet-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding: 12px 14px;
  border-radius: 16px; background: var(--invest-soft); color: var(--invest); font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }

/* Month picker with the page's entry button underneath (Investments, Loans) */
.topbar-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
@media (max-width: 600px) { .topbar-stack { align-items: stretch; width: 100%; } }
/* Invest | Sell / return and Borrow | Repay switches */
.focus-seg button.on[data-focus="invest"], .focus-seg button.on[data-focus="sell"] { color: var(--invest); }
.focus-seg button.on[data-focus="loan"], .focus-seg button.on[data-focus="repay"] { color: var(--loan); }

.warn-text { color: var(--warn) !important; font-weight: 600; }

.empty .btn svg { width: 18px; height: 18px; opacity: 1; }

.linklike { background: none; border: 0; padding: 0; margin-left: 8px; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* Profile picture (photo or initials) */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar-initials { color: #fff; font-weight: 700; letter-spacing: .02em; }
.avatar-link { display: inline-flex; border-radius: 50%; text-decoration: none; }
.avatar-link:hover .avatar { box-shadow: 0 0 0 3px var(--brand-soft); }
/* The profile picture sits beside the page title ("Hi, Karim") on every screen size. */

/* Split button: main action + dropdown of alternatives */
.split-btn { position: relative; display: flex; }
.split-btn > .btn:first-child { flex: 1; white-space: nowrap; border-radius: 999px 0 0 999px; padding-left: 14px; padding-right: 10px; }
.split-btn .split-caret { width: 42px; padding: 0; border-radius: 0 999px 999px 0; border-left: 1px solid rgba(19, 124, 111, .22); }
.split-btn .split-caret[aria-expanded="true"] svg { transform: rotate(180deg); }
/* "Add with Voice": the one solid button, in the logo's teal ("Fin"). */
/* "Add with Voice" is an action button (see .btn-primary): solid teal; a light divider before the arrow. */
.voice-btn .split-caret { border-left: 1px solid rgba(255, 255, 255, .35); }
.menu {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 30; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lift); padding: 6px;
}
.menu [role=menuitem] {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 11px;
  cursor: pointer; text-align: left; font-weight: 600;
}
.menu [role=menuitem]:hover, .menu [role=menuitem]:focus-visible { background: var(--surface-2); }
.menu [role=menuitem] svg { width: 18px; height: 18px; color: var(--brand); }

/* ---------- components ---------- */
/* Cards: white, borderless, softly lifted (a thin border only on the dark theme). */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.card-head h2 { font-size: 1.08rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack > * + * { margin-top: 16px; }

/* Buttons: pills. Default is a soft grey pill; primary is solid navy (teal on the dark theme). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--btn-stroke); background: var(--surface-2);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); min-height: 42px;
  transition: background .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
/* Action buttons (Save, Update, Add…): solid logo teal with white text and no outline, like "Add with Voice". */
.btn-primary { background: var(--action); border-color: transparent; color: #ffffff; font-weight: 700; }
.btn-primary:hover { background: var(--action-hover); }
/* Page shortcuts in Settings (Budgets, Investments, Loans, Administration): white tiles with a teal icon. */
.btn-shortcut { background: var(--surface); box-shadow: var(--shadow); min-height: 48px; }
.btn-shortcut svg { color: var(--action); }
.btn-shortcut:hover { background: var(--nav-active-bg); }
@media (min-width: 900px) { .settings-shortcuts { display: none; } } /* the sidebar links to these pages */
.btn-danger { color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; min-height: 34px; font-size: .84rem; }
.icon-btn { width: 42px; height: 42px; padding: 0; }

/* Fields: filled, borderless inputs with a clear focus ring. */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 5px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px; border: 1px solid transparent; border-radius: 14px; background: var(--surface-2); min-height: 46px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.input:hover { border-color: var(--border); }
.input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea.input { min-height: 84px; resize: vertical; }
.input-amount { font-size: 1.9rem; font-weight: 800; text-align: center; letter-spacing: -.02em; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 999px; gap: 4px; }
.segmented button { border: 0; background: transparent; padding: 9px; border-radius: 999px; cursor: pointer; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.segmented button.on { background: var(--nav-active-bg); color: var(--nav-active-text); }
.segmented button.on[data-kind="income"] { color: var(--income); }
.segmented button.on[data-kind="expense"] { color: var(--expense); }
.segmented button.on[data-kind="transfer"] { color: var(--transfer); }
.segmented button.on[data-kind="investment"], .segmented button.on[data-dir] { color: var(--invest); }
.segmented button.on[data-kind="loan"], .dir-seg[data-kind="loan"] button.on { color: var(--loan); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.chip.income { background: var(--income-soft); color: var(--income); }
.chip.expense { background: var(--expense-soft); color: var(--expense); }
.chip.transfer { background: var(--transfer-soft); color: var(--transfer); }
.chip.investment { background: var(--invest-soft); color: var(--invest); }
.chip.loan { background: var(--loan-soft); color: var(--loan); }
.chip.warn { background: var(--expense-soft); color: var(--warn); }
/* How a record was entered: Voice or Manual. */
.chip.src { padding: 1px 7px; font-size: .68rem; vertical-align: 1px; }
.chip.src.voice { background: var(--transfer-soft); color: var(--transfer); }
.chip.src.pending { background: var(--expense-soft); color: var(--warn); }
/* Offline / syncing strip under the header. */
.net-banner { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border-radius: 14px; font-size: .86rem; font-weight: 500; }
.net-banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.net-banner.offline { background: var(--expense-soft); color: var(--warn); }
.net-banner.syncing { background: var(--nav-active-bg); color: var(--nav-active-text); }
.net-banner.syncing svg { animation: spin 1.2s linear infinite; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* Month picker: a pill button that opens our own list (native pickers ignore styling on phones). */
.month-select { position: relative; display: inline-block; }
.month-btn {
  display: inline-flex; align-items: center; gap: 10px; max-width: 78vw; min-height: 44px; padding: 10px 14px 10px 14px; cursor: pointer;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; border: 1px solid var(--card-border);
  border-radius: 999px; box-shadow: var(--shadow);
}
.month-btn:hover { border-color: var(--brand); }
.month-btn svg { width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform .15s; }
.month-btn svg:first-child { color: var(--brand); }
.month-btn[aria-expanded="true"] svg:last-child { transform: rotate(180deg); }
.month-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 100%; width: max-content; max-width: 86vw;
  max-height: min(60vh, 380px); overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lift);
}
.month-year { padding: 10px 12px 4px; font-size: .8rem; font-weight: 800; letter-spacing: .04em; color: var(--text); }
.month-year:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 12px; }
.month-opt { display: block; width: 100%; text-align: left; padding: 9px 12px 9px 22px; border: 0; background: none; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 500; color: var(--text); }
.month-opt:hover { background: var(--surface-2); }
.month-opt.on { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 700; }

/* ---------- dashboard ---------- */
/* Stat cards: a quiet label, then a big confident number. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; }
.stat .label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.6rem; font-weight: 800; margin-top: 6px; letter-spacing: -.025em; line-height: 1.15; }
.stat .sub { font-size: .78rem; color: var(--muted); margin-top: 6px; font-weight: 500; }
/* Hero: the brand gradient with a soft light glow in the corner. */
.hero {
  position: relative; overflow: hidden; background: var(--hero); color: #ffffff; border: 0; border-radius: 24px; padding: 24px;
  box-shadow: 0 10px 30px rgba(19, 44, 74, .18);
}
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 70%); pointer-events: none; }
.hero .label { opacity: .8; font-size: .86rem; font-weight: 600; }
.hero .value { font-size: 2.5rem; font-weight: 800; margin: 4px 0 16px; letter-spacing: -.035em; line-height: 1.1; }
.hero .split { display: flex; gap: 12px 28px; flex-wrap: wrap; font-size: .82rem; }
.hero .split > div { opacity: .92; }
.hero .split b { display: block; font-size: 1.08rem; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }

.accounts-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.acct { flex: none; min-width: 140px; padding: 14px; border-radius: 16px; background: var(--surface-2); border-left: 4px solid var(--brand); }
.acct .name { font-size: .82rem; color: var(--muted); font-weight: 600; }
.acct .bal { font-weight: 700; font-size: 1.05rem; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 0; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar.over > i { background: var(--danger); }
.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-wrap .cat-list { width: 100%; } }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
/* Phone charts are shrunk to about half size, so their text is drawn twice as big (≈ 11px on screen). */
.chart.chart-lg text { font-size: 21px; font-weight: 600; }
.legend { flex-wrap: wrap; }

.history-table .month-cell b { white-space: nowrap; }
/* History table on phones: each month becomes a card of label: value pairs. */
@media (max-width: 600px) {
  .table-wrap:has(.history-table) { padding: 6px; background: transparent; box-shadow: none; border: 0; }
  .history-table thead { display: none; }
  .history-table, .history-table tbody { display: block; }
  .history-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 14px 16px; margin-bottom: 12px;
    background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--card-border); }
  table.data.history-table td { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 3px 0; border: 0; text-align: right; min-width: 0; }
  .history-table td::before { content: attr(data-label); font-size: .76rem; font-weight: 600; color: var(--muted); text-align: left; }
  table.data.history-table td.month-cell { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline;
    padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); text-align: left; font-size: 1.02rem; }
  .history-table td.month-cell::before { content: none; }
  .history-table td[data-label="Top spend"] { grid-column: 1 / -1; }
  .history-table tr.clickable:hover td { background: none; }
}
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- transactions ---------- */
.tx-group + .tx-group { margin-top: 18px; }
.tx-group-head { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; color: var(--muted); padding: 0 6px 8px; }
.tx-list { list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .tx-list { padding: 0; }
/* Rows: round category icon, title + detail, amount on the right. */
.tx { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 12px; cursor: pointer; border: 0; width: 100%; background: none; text-align: left; border-radius: 14px; transition: background .12s; }
.tx-list li + li .tx { box-shadow: 0 -1px 0 var(--border); }
.tx:hover { background: var(--surface-2); box-shadow: none !important; }
.tx .ic { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: #fff; }
.tx .ic svg { width: 19px; height: 19px; }
.tx .t1 { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .t2 { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.tx .amt { font-weight: 800; letter-spacing: -.01em; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1; min-width: 160px; }
/* Transactions filters: account, category, entered by, sort. */
/* Filters stretch to fill the row and wrap on narrow screens; search, Add and CSV sit below them. */
.filters { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; margin-bottom: 16px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 10px 12px; }
.filters .filter { display: block; min-width: 0; flex: 1 1 160px; }
.filters .toolbar { margin: 0; }
/* Custom date range: From and To on their own line, each as wide as one filter above. */
.filters .range-row .filter { flex: 0 1 calc(25% - 9px); }
.filters .filter > span { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.filters select.input { min-height: 42px; padding: 8px 12px; }
.filters-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.filters-foot .linklike { display: inline-flex; align-items: center; gap: 4px; }
.filters-foot .linklike svg { width: 14px; height: 14px; }
@media (max-width: 720px) { .filters .range-row .filter { flex: 1 1 calc(50% - 6px); } }
@media (max-width: 480px) { .filters .filter { flex-basis: calc(50% - 6px); } }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .5; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 12px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
table.data tr:last-child td { border-bottom: 0; }
table.data td.r, table.data th.r { text-align: right; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 22, 38, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 26px 26px 0 0;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom)); animation: up .2s ease-out; box-shadow: var(--shadow-lift);
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } .modal { border-radius: 26px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 1.2rem; }
.modal-foot { display: flex; gap: 10px; margin-top: 20px; }
.modal-foot .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }

/* Confirmation dialog: centred on every screen size, above any open form */
.confirm-backdrop { z-index: 70; align-items: center; padding: 16px; }
.modal.confirm { max-width: 400px; border-radius: 26px; text-align: center; padding: 28px 24px 22px; }
.modal.confirm h2 { font-size: 1.1rem; margin-top: 12px; }
.modal.confirm p { margin: 8px 0 0; font-size: .92rem; line-height: 1.5; }
.modal.confirm .modal-foot { margin-top: 22px; }
.confirm-icon {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.confirm-icon.danger { background: var(--expense-soft); color: var(--danger); }
.confirm-icon svg { width: 24px; height: 24px; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #991b1b; border-color: #991b1b; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

/* ---------- voice ---------- */
.voice-stage { text-align: center; padding: 8px 0 4px; }
.mic-big {
  width: 108px; height: 108px; border-radius: 50%; border: 0; background: var(--hero); color: #fff; cursor: pointer; display: inline-grid; place-items: center;
  box-shadow: 0 12px 30px rgba(19, 124, 111, .35); transition: transform .15s;
}
.mic-big:hover { transform: scale(1.03); }
.mic-big svg { width: 44px; height: 44px; }
.mic-big.listening { background: var(--danger); animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .45); } 70% { box-shadow: 0 0 0 22px rgba(185, 28, 28, 0); } 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); } }
.transcript { min-height: 60px; margin: 16px 0 8px; font-size: 1.1rem; padding: 12px 16px; border-radius: 16px; background: var(--surface-2); text-align: left; }
.transcript .interim { color: var(--muted); }
summary svg { width: 16px; height: 16px; vertical-align: -3px; }
.hint-list { text-align: left; font-size: .85rem; color: var(--muted); margin: 8px 0 0; padding-left: 18px; }
.draft { border: 1px solid var(--border); border-radius: 18px; padding: 14px; margin-top: 12px; background: var(--surface); }
.draft.low { border-color: var(--danger); }
.draft.medium { border-color: var(--warn); }
.draft .draft-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.draft .field { margin-bottom: 8px; }
.draft .field > span { font-size: .75rem; }
.draft .input { min-height: 38px; padding: 7px 10px; }
.guess { outline: 2px dashed var(--warn); outline-offset: 1px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%), var(--bg); }
.auth .card { width: 100%; max-width: 420px; padding: 30px 28px; border-radius: 28px; box-shadow: var(--shadow-lift); }
/* Full logo (name and tagline) on a white tile, so it also reads on the dark theme. */
.auth-logo { display: flex; justify-content: center; margin: -4px 0 14px; }
.auth-logo img { width: 180px; height: 180px; border-radius: 22px; background: #ffffff; }
/* "Kotha" in the text colour (navy in light), "Fin" in the brand teal, as in the logo. */
.wordmark { font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; color: var(--text); }
.wordmark b { color: var(--brand); font-weight: 800; }
/* Horizontal logo (name + tagline) in the sidebar. The dark theme swaps in a copy with light text. */
.brand-logo { display: block; width: 136px; max-width: 100%; height: auto; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.notice { padding: 12px 16px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-strong); font-size: .9rem; font-weight: 600; margin-bottom: 16px; }
.notice.error { background: var(--expense-soft); color: var(--danger); }

/* ---------- misc ---------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
/* Tab pills: white, the active one solid navy (teal on dark). */
/* Wrap onto more lines on narrow screens, so no tab is ever hidden off the edge. */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; padding: 2px; }
/* Phones: an even grid of equal-width tabs instead of ragged rows. */
@media (max-width: 600px) {
  .tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .tabs button { width: 100%; text-align: center; padding: 9px 10px; }
  .tabs button:last-child:nth-child(odd) { grid-column: 1 / -1; } /* an odd one out spans the row */
}
.tabs button { border: 1.5px solid var(--btn-stroke); background: var(--surface); padding: 9px 18px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; color: var(--muted); box-shadow: 0 1px 2px rgba(19, 44, 74, .05); transition: background .15s, color .15s; }
.tabs button:hover:not(.on) { color: var(--text); }
.tabs button.on { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 700; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: .72rem; display: inline-grid; place-items: center; font-weight: 700; }
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600; z-index: 60; box-shadow: var(--shadow-lift); transition: .2s; max-width: min(520px, calc(100% - 32px)); width: max-content; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }
@media (min-width: 900px) { #toast { bottom: 24px; } }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* On/off switch: "Label [pill]". The knob slides and the track fills with the brand gradient when on. */
.switch { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 2px; cursor: pointer; font-weight: 600; font-size: .85rem; }
.switch-label { color: var(--text); }
.switch-track { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--border); transition: background .25s; flex: none; }
.switch.on .switch-track { background: linear-gradient(135deg, #20a796, #137c6f); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(19, 44, 74, .3); transition: transform .25s cubic-bezier(.4, 0, .2, 1); }
.switch.on .switch-knob { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 8px; }

/* ---------- app feel (phones and the Android app) ---------- */
/* No pull-to-refresh or rubber-band bounce: the app scrolls like an app, not a web page. */
html, body { overscroll-behavior-y: none; }
/* Taps: no blue flash, no 300 ms double-tap-zoom wait; images can't be dragged out. */
* { -webkit-tap-highlight-color: transparent; }
a, button, select, input, label, .tx, [data-action] { touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; }
@media (hover: none) and (pointer: coarse) {
  /* Long-press doesn't select interface text or open the copy menu; typing fields still can. */
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea, select, [contenteditable], .transcript { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  /* Pressed feedback, like native buttons. */
  .btn:active, .tx:active, .tabs button:active, .dash-tabs button:active, .segmented button:active, .month-btn:active,
  .app-header-user:active, .switch:active, .month-opt:active, .menu [role=menuitem]:active { transform: scale(.97); }
  .tx:active { background: var(--surface-2); }
  .bottom-nav a { transition: transform .1s; }
  .bottom-nav a:active { transform: scale(.92); }
  .fab-mic:active { transform: translateX(-50%) scale(.94); }
}
/* A new screen slides in gently. */
.view-enter { animation: view-in .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Launch screen: the logo, then a small spinner. */
.boot-logo { display: grid; justify-items: center; gap: 22px; }
.boot-logo img { width: 96px; height: 96px; border-radius: 22px; }
/* Phone: stack the categories header (tabs, then the voice tag switch) and the export dates. */
.switch-label { white-space: nowrap; }
@media (max-width: 600px) {
  .cat-head { flex-direction: column; align-items: stretch; }
  .cat-head .tabs { width: 100%; }
  .cat-head .head-tools { justify-content: space-between; }
  .export-row { grid-template-columns: 1fr; }
  .export-row .input { min-width: 0; width: 100%; }
}

/* Tab labels with a Bangla subtitle: inline on wide screens, two lines on phones. */
.tab-lbl small { font-size: .82em; font-weight: 600; opacity: .75; margin-left: 5px; }
.tab-lbl small::before { content: '('; }
.tab-lbl small::after { content: ')'; }
@media (max-width: 600px) {
  .tab-lbl { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.2; text-align: left; }
  .tab-lbl small { margin-left: 0; }
  .tab-lbl small::before, .tab-lbl small::after { content: none; }
}

/* Phones: the month picker sits on the right, as on the web layout. */
@media (max-width: 600px) {
  .topbar > .row { width: 100%; justify-content: flex-end; }
  .topbar > .row:empty { display: none; }
  .topbar-stack > .month-select { align-self: flex-end; }
}
