/* CashSetu — one stylesheet, no framework. Tokens first, then the app shell, then components. */

:root {
    --ink: #10404A;          /* deep teal — headers, sidebar, primary buttons */
    --ink-soft: #1B5A66;
    --accent: #E8A33D;       /* amber — the brand dot, highlights */
    --in: #1B7F4B;           /* cash in */
    --out: #C0392B;          /* cash out */
    --transfer: #5E5AA8;     /* mode-to-mode movement */
    --paper: #F7F7F4;
    --card: #FFFFFF;
    --line: #E3E2DC;
    --line-soft: #F0EFEA;
    --muted: #6B6F7B;
    --text: #23252B;
    --sidebar-w: 220px;
    --bottom-nav-h: 58px;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
    background: var(--paper);
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--ink); }

/* ---------------- app shell ---------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--ink);
    color: #E9F1F2;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 1rem 1.1rem;
    color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.brand-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); display: inline-block; }
.brand-sub { display: block; font-size: 0.68rem; font-weight: 400; color: #9FC0C5; letter-spacing: 0.04em; }

.side-workspace { padding: 0.8rem 1.1rem 0.4rem; font-size: 0.82rem; color: #9FC0C5; }
.side-workspace strong { display: block; color: #fff; font-size: 0.95rem; font-weight: 600; }

.book-switch { padding: 0.3rem 1.1rem 0.9rem; }
.book-switch select {
    width: 100%; background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px; padding: 0.35rem 0.5rem; font-size: 0.85rem;
}
.book-switch select option { color: #23252B; }

.side-nav { display: flex; flex-direction: column; padding: 0.4rem 0.5rem 1.5rem; gap: 1px; }
.side-nav a {
    color: #D6E5E7; text-decoration: none; padding: 0.5rem 0.65rem; border-radius: 8px; font-size: 0.92rem;
    display: flex; align-items: center; gap: 0.55rem;
}
.side-nav a:hover { background: rgba(255,255,255,0.09); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,0.16); color: #fff; font-weight: 600; }
.side-nav .group { color: #7FA5AC; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.9rem 0.65rem 0.25rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
    background: var(--card); border-bottom: 1px solid var(--line); padding: 0.6rem 1.2rem;
    position: sticky; top: 0; z-index: 20;
}
.topbar .who { font-size: 0.85rem; color: var(--muted); }
.topbar .who strong { color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.mobile-brand { display: none; font-weight: 700; color: var(--ink); }

.page { padding: 1.1rem 1.2rem 2rem; max-width: 1280px; width: 100%; }

.footer { color: var(--muted); font-size: 0.78rem; padding: 0 1.2rem 1.4rem; }

/* ---------------- mobile ---------------- */

.bottom-nav { display: none; }

@media (max-width: 860px) {
    .sidebar { display: none; }
    .mobile-brand { display: block; }
    .page { padding: 0.8rem 0.8rem calc(var(--bottom-nav-h) + 1.4rem); }
    .footer { padding-bottom: calc(var(--bottom-nav-h) + 1rem); }

    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-h);
        background: var(--card); border-top: 1px solid var(--line); z-index: 30;
    }
    .bottom-nav a {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; font-size: 0.68rem; color: var(--muted); text-decoration: none;
    }
    .bottom-nav a.active { color: var(--ink); font-weight: 600; }
    .bottom-nav .ico { font-size: 1.15rem; line-height: 1; }
    .bottom-nav .add .ico {
        background: var(--ink); color: #fff; width: 34px; height: 34px; border-radius: 50%;
        display: flex; align-items: center; justify-content: center; margin-top: -14px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    }
}

/* ---------------- banners & flashes ---------------- */

.support-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap;
    padding: 0.5rem 1.2rem; color: #fff; font-size: 0.88rem;
    background: repeating-linear-gradient(45deg, #B3261E, #B3261E 14px, #8E1B15 14px, #8E1B15 28px);
}
.support-banner form { margin: 0; }

.flash { border-radius: 10px; padding: 0.6rem 1rem; margin: 0 0 0.9rem; font-size: 0.92rem; }
.flash-ok { background: #E8F5E9; color: #17612F; border: 1px solid #A5D6A7; }
.flash-err { background: #FDECEA; color: #A02318; border: 1px solid #F5C6C0; }
.errors { color: #A02318; font-size: 0.88rem; }
.errors ul { margin: 0.4rem 0; padding-left: 1.1rem; }

.locked-note { background: #FFF6E5; border: 1px solid #F0D9A8; color: #7A5A12; border-radius: 10px; padding: 0.55rem 0.9rem; font-size: 0.87rem; margin-bottom: 0.9rem; }

/* ---------------- headings ---------------- */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.page-head h1 { color: var(--ink); margin: 0; font-size: 1.35rem; }
.page-head .sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.head-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }

h2 { color: var(--ink); font-size: 1.05rem; margin: 0 0 0.6rem; }

/* ---------------- cards, tiles ---------------- */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card-narrow { max-width: 430px; margin: 2.2rem auto; }
.card h1 { color: var(--ink); font-size: 1.3rem; margin: 0 0 0.3rem; }
.card-lede { color: var(--muted); font-size: 0.88rem; margin: 0 0 1rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; }
.tile .label { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; }
.tile .value { font-size: 1.45rem; font-weight: 700; color: var(--ink); margin-top: 0.15rem; letter-spacing: -0.01em; }
.tile .value.in { color: var(--in); }
.tile .value.out { color: var(--out); }
.tile .value.neg { color: var(--out); }
.tile .foot { color: var(--muted); font-size: 0.76rem; margin-top: 0.2rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }

/* ---------------- totals bar (the cash book header) ---------------- */

.totals-bar {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.1rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.9rem;
}
.totals-bar .cell { padding: 0.7rem 0.9rem; border-right: 1px solid var(--line-soft); }
.totals-bar .cell:last-child { border-right: none; }
.totals-bar .label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.totals-bar .amount { font-size: 1.15rem; font-weight: 700; margin-top: 0.1rem; }
.totals-bar .amount.in { color: var(--in); }
.totals-bar .amount.out { color: var(--out); }
.totals-bar .amount.net { color: var(--ink); }
.totals-bar .amount.neg { color: var(--out); }

/* ---------------- tables ---------------- */

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.grid th {
    text-align: left; color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase;
    letter-spacing: 0.04em; padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: #FBFBF8;
}
table.grid td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tfoot td { background: #FBFBF8; font-weight: 700; border-top: 1px solid var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-in { color: var(--in); font-weight: 600; }
.amount-out { color: var(--out); font-weight: 600; }
.balance { font-weight: 600; font-variant-numeric: tabular-nums; }
.balance.neg { color: var(--out); }
.row-deleted { opacity: 0.55; text-decoration: line-through; }
.row-actions { white-space: nowrap; text-align: right; }
.empty { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.empty .big { font-size: 1.05rem; color: var(--text); margin-bottom: 0.3rem; }

.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; }
.remark { color: var(--muted); font-size: 0.85rem; }
.stamp { color: var(--muted); font-size: 0.76rem; }

/* ---------------- chips ---------------- */

.chip { display: inline-block; background: #F1F1EC; color: var(--muted); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.74rem; white-space: nowrap; }
.chip-in { background: #E8F5E9; color: #17612F; }
.chip-out { background: #FDECEA; color: #A02318; }
.chip-transfer { background: #EDECF8; color: #413C86; }
.chip-warn { background: #FFF3E0; color: #96590A; }
.chip-ok { background: #E8F5E9; color: #17612F; }
.chip-muted { background: #EFEFEA; color: var(--muted); }
.chip-edited { background: #FFF6E5; color: #8A6314; }

/* ---------------- forms ---------------- */

label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.7rem 0 0.2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
    width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 8px;
    font-size: 0.95rem; background: #fff; color: var(--text); font-family: inherit;
}
textarea { min-height: 66px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink-soft); outline-offset: -1px; border-color: var(--ink-soft); }
input[type=file] { font-size: 0.85rem; }
.hint { font-size: 0.78rem; color: var(--muted); margin: 0.25rem 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.15rem 0.9rem; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.check-row { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; margin: 0.5rem 0; }
.check-row input[type=checkbox] { width: auto; }

/* Kind selector — the Cash In / Cash Out / Transfer switch */
.kind-switch { display: flex; gap: 0.5rem; margin: 0.3rem 0 0.2rem; flex-wrap: wrap; }
.kind-switch label {
    flex: 1; min-width: 110px; margin: 0; text-align: center; cursor: pointer;
    border: 1.5px solid var(--line); border-radius: 10px; padding: 0.55rem 0.5rem; font-size: 0.92rem;
    color: var(--muted); background: #fff; font-weight: 600;
}
.kind-switch input { position: absolute; opacity: 0; pointer-events: none; }
/* The radio itself is invisible, so the label wears its focus ring — otherwise a keyboard user
   tabbing through Cash In / Cash Out / Transfer would have nothing to see. */
.kind-switch label:focus-within { outline: 2px solid var(--ink-soft); outline-offset: 2px; }
.kind-switch label.sel-in { border-color: var(--in); color: var(--in); background: #F1F9F3; }
.kind-switch label.sel-out { border-color: var(--out); color: var(--out); background: #FDF3F2; }
.kind-switch label.sel-transfer { border-color: var(--transfer); color: var(--transfer); background: #F2F1FA; }

/* ---------------- buttons ---------------- */

.btn {
    display: inline-block; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
    padding: 0.5rem 0.95rem; font-size: 0.9rem; text-decoration: none; text-align: center;
    background: #EDEDE8; color: var(--text); font-family: inherit;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-in { background: var(--in); color: #fff; }
.btn-out { background: var(--out); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-light { background: #fff; color: #A02318; }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 0.28rem 0.6rem; font-size: 0.8rem; }
.btn-link { background: none; border: none; color: var(--ink); text-decoration: underline; cursor: pointer; padding: 0.2rem; font-size: 0.85rem; }
.btn-danger-link { background: none; border: none; color: #A02318; cursor: pointer; padding: 0.2rem; font-size: 0.85rem; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* ---------------- filter bar ---------------- */

.filter-bar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; margin-bottom: 0.9rem; }
.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; }
.filter-row .f { flex: 1 1 150px; min-width: 130px; }
.filter-row label { margin: 0 0 0.15rem; }
.filter-row input, .filter-row select { padding: 0.38rem 0.5rem; font-size: 0.87rem; }
.presets { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.presets a { font-size: 0.8rem; padding: 0.22rem 0.6rem; border-radius: 999px; background: #F1F1EC; color: var(--muted); text-decoration: none; }
.presets a.active, .presets a:hover { background: var(--ink); color: #fff; }

/* ---------------- charts (inline SVG, no library) ---------------- */

.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 0.3rem; }

.bar-list { display: flex; flex-direction: column; gap: 0.55rem; }
.bar-row .bar-head { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.2rem; }
.bar-track { background: var(--line-soft); border-radius: 999px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }

/* ---------------- pager ---------------- */

.pager { display: flex; gap: 0.5rem; align-items: center; justify-content: center; margin-top: 0.9rem; font-size: 0.85rem; color: var(--muted); }
.pager a { padding: 0.3rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; }

/* ---------------- misc ---------------- */

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-variant-numeric: tabular-nums; }
.alt-links { text-align: center; font-size: 0.87rem; margin-top: 1rem; }
.otp-input { letter-spacing: 0.5em; font-size: 1.3rem; text-align: center; }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 0.35rem 1rem; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.status-ok { color: var(--in); font-weight: 600; }
.status-bad { color: var(--out); font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }

/* ---------------- landing ---------------- */

.hero { text-align: center; padding: 2.4rem 1rem 1rem; }
.hero h1 { color: var(--ink); font-size: 2.1rem; margin: 0 0 0.4rem; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 1.2rem; }
.hero-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.9rem; margin: 1.6rem auto; max-width: 980px; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.feature h3 { margin: 0 0 0.3rem; color: var(--ink); font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.87rem; }

/* ---------------- print ---------------- */

@media print {
    .sidebar, .topbar, .bottom-nav, .filter-bar, .head-actions, .pager, .footer, .no-print { display: none !important; }
    body { background: #fff; font-size: 12px; }
    .page { padding: 0; max-width: none; }
    .card, .table-wrap, .totals-bar { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
    table.grid th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .print-head { display: block !important; margin-bottom: 0.8rem; }
    a { text-decoration: none; color: #000; }
}
.print-head { display: none; }
