/* ============================================================
   DuitTrack – design system
   Modern fintech: deep navy sidebar, soft cards, indigo/teal accents
   ============================================================ */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: #e5e9f2;
    --line-strong: #d3dae8;

    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --teal: #0d9488;
    --teal-soft: #ecfdf5;

    --income: #059669;
    --income-soft: #ecfdf5;
    --expense: #e11d48;
    --expense-soft: #fff1f2;
    --warn: #d97706;
    --warn-soft: #fffbeb;
    --info: #0284c7;
    --info-soft: #f0f9ff;

    --nav-bg: #0b1220;
    --nav-bg-2: #121d33;
    --nav-ink: #cbd5e1;
    --nav-ink-active: #ffffff;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, .22);

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }

/* Inline icon sizing – keeps hand-rolled SVGs from blowing up a layout. */
.ico { width: 17px; height: 17px; flex: 0 0 auto; }
.nav-link .ico { width: 18px; height: 18px; }
.btn .ico { width: 16px; height: 16px; }
.btn--icon .ico { width: 15px; height: 15px; }
.kpi__label .ico { width: 14px; height: 14px; opacity: .8; }
.section-title h2 .ico { display: inline-block; vertical-align: -3px; margin-right: 2px; }
.card__head h2 .ico { width: 15px; height: 15px; display: inline-block; vertical-align: -2px; }
.flash .ico { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
.insight__icon .ico { width: 18px; height: 18px; }
.goal-card__head .cat-icon .ico { width: 16px; height: 16px; }
.pagination .ico { width: 14px; height: 14px; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------ layout */

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

.sidebar {
    width: 252px;
    flex: 0 0 252px;
    background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
    color: var(--nav-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 20px 18px;
}

.brand-mark {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #6366f1, #0d9488);
    display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: 16px;
    letter-spacing: -.03em;
    box-shadow: 0 6px 16px -6px rgba(99, 102, 241, .9);
}

.brand-text { display: flex; flex-direction: column; }
.brand-text strong { color: #fff; font-size: 16.5px; letter-spacing: -.02em; }
.brand-text span { color: #7c8ba1; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }

.sidebar__nav {
    padding: 6px 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
}

.nav-group-label {
    color: #64748b;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 14px 10px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 10px;
    color: var(--nav-ink);
    font-size: 13.8px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-link.is-active {
    background: linear-gradient(90deg, rgba(79, 70, 229, .35), rgba(13, 148, 136, .18));
    color: var(--nav-ink-active);
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .25);
}
.nav-link.is-active svg { opacity: 1; }

.sidebar__foot {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: 12px;
    background: rgba(255, 255, 255, .04);
}
.avatar {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #14b8a6);
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 12.5px;
}
.sidebar-user__meta { min-width: 0; flex: 1; }
.sidebar-user__meta strong {
    display: block; color: #fff; font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user__meta span {
    display: block; color: #7c8ba1; font-size: 11.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 26px;
    background: rgba(244, 246, 251, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar__title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.topbar__title h1 { font-size: 19px; font-weight: 700; }
.topbar__title span { color: var(--muted); font-size: 12.5px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.content { padding: 24px 26px 56px; max-width: 1420px; width: 100%; }

.nav-toggle {
    display: none;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; width: 38px; height: 38px;
    align-items: center; justify-content: center; cursor: pointer;
    color: var(--ink-2);
}
.scrim { display: none; }

/* ------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card--pad { padding: 18px 20px; }
.card__head {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.card__head h2 { font-size: 14.5px; font-weight: 700; }
.card__head p { color: var(--muted); font-size: 12.3px; }
.card__head .spacer { margin-left: auto; }
.card__body { padding: 18px 20px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--2-1 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.grid--1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }

/* --------------------------------------------------------------- KPI */

.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.kpi__label {
    display: flex; align-items: center; gap: 7px;
    color: var(--muted); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
}
.kpi__value { font-size: 24px; font-weight: 700; letter-spacing: -.03em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.kpi__meta { color: var(--muted); font-size: 12.3px; margin-top: 4px; }
.kpi__dot { width: 8px; height: 8px; border-radius: 50%; }
.kpi--income .kpi__value { color: var(--income); }
.kpi--expense .kpi__value { color: var(--expense); }
.kpi--accent { background: linear-gradient(135deg, #1e1b4b, #0f172a 55%, #134e4a); border-color: transparent; }
.kpi--accent .kpi__label { color: #a5b4fc; }
.kpi--accent .kpi__value { color: #fff; }
.kpi--accent .kpi__meta { color: #94a3b8; }

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

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13.3px; font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border-color: transparent; color: #fff;
    box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .95);
}
.btn--primary:hover { background: linear-gradient(135deg, #4338ca, #3730a3); }

.btn--teal { background: var(--teal); border-color: transparent; color: #fff; }
.btn--teal:hover { background: #0f766e; }
.btn--danger { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.btn--danger:hover { background: #ffe4e6; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--sm { padding: 6px 11px; font-size: 12.4px; border-radius: 9px; }
.btn--block { width: 100%; }
.btn--icon { padding: 7px; width: 32px; height: 32px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

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

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field > label { font-size: 12.6px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 11.8px; color: var(--muted); }

.input, .select, textarea.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted-2); }
.input:focus, .select:focus, textarea.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.input--amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 12px;
    padding-right: 32px;
}
.input-group { position: relative; }
.input-group > span {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: 13px; font-weight: 600; pointer-events: none;
}
.input-group .input { padding-left: 40px; }

.segmented {
    display: inline-flex; padding: 3px; gap: 3px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 11px;
}
.segmented a, .segmented button {
    padding: 7px 13px; border-radius: 8px;
    font-size: 12.8px; font-weight: 600; color: var(--muted);
    border: 0; background: transparent; cursor: pointer;
}
.segmented a:hover, .segmented button:hover { text-decoration: none; color: var(--ink); }
.segmented .is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented .is-active.seg--income { color: var(--income); }
.segmented .is-active.seg--expense { color: var(--expense); }

/* ------------------------------------------------------------ budgets */

.progress {
    height: 8px; border-radius: 99px;
    background: #eef1f7; overflow: hidden;
}
.progress > span {
    display: block; height: 100%; border-radius: 99px;
    background: var(--brand);
    transition: width .6s cubic-bezier(.4, 0, .2, 1);
}
.progress--good > span { background: linear-gradient(90deg, #10b981, #059669); }
.progress--warn > span { background: linear-gradient(90deg, #fbbf24, #d97706); }
.progress--danger > span { background: linear-gradient(90deg, #fb7185, #e11d48); }
.progress--thin { height: 6px; }

/* ------------------------------------------------------------- badges */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 99px;
    font-size: 11.6px; font-weight: 600; letter-spacing: .01em;
    background: var(--surface-2); color: var(--muted);
    border: 1px solid var(--line);
    white-space: nowrap;
}
.badge--good { background: var(--income-soft); color: #047857; border-color: #a7f3d0; }
.badge--warn { background: var(--warn-soft); color: #b45309; border-color: #fde68a; }
.badge--danger { background: var(--expense-soft); color: #be123c; border-color: #fecdd3; }
.badge--info { background: var(--info-soft); color: #0369a1; border-color: #bae6fd; }
.badge--brand { background: var(--brand-soft); color: var(--brand-dark); border-color: #c7d2fe; }

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

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 12px 18px; text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table th {
    font-size: 11.4px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--muted);
    background: var(--surface-2);
    white-space: nowrap;
}
.table tbody tr:hover { background: #fbfcff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .amount--income { color: var(--income); font-weight: 600; }
.table .amount--expense { color: var(--expense); font-weight: 600; }
.table .actions { text-align: right; white-space: nowrap; }
.table tfoot td { background: var(--surface-2); font-weight: 700; }

.cat-chip {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 500; color: var(--ink-2);
}
.cat-chip .dot {
    width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
}
.cat-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--surface-2); font-size: 15px;
    border: 1px solid var(--line);
    flex: 0 0 34px;
}

.table-primary { display: flex; align-items: center; gap: 11px; min-width: 0; }
.table-primary__meta { min-width: 0; }
.table-primary__meta strong { display: block; font-weight: 600; font-size: 13.6px; }
.table-primary__meta span { display: block; color: var(--muted); font-size: 12px; }

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

.section-title {
    display: flex; align-items: center; gap: 10px;
    margin: 4px 0 12px;
}
.section-title h2 { font-size: 15.5px; font-weight: 700; }
.section-title .spacer { margin-left: auto; }

.empty {
    padding: 40px 20px; text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }
.empty p { font-size: 12.8px; max-width: 380px; margin: 0 auto 14px; }

.flash-wrap { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    font-size: 13.2px; border: 1px solid transparent;
    animation: flashIn .25s ease;
}
.flash--success { background: var(--income-soft); color: #065f46; border-color: #a7f3d0; }
.flash--error { background: var(--expense-soft); color: #9f1239; border-color: #fecdd3; }
.flash--info { background: var(--info-soft); color: #075985; border-color: #bae6fd; }
.flash--warning { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.form-error {
    background: var(--expense-soft); border: 1px solid #fecdd3; color: #9f1239;
    padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px;
}

.muted { color: var(--muted); }
.small { font-size: 12.3px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-income { color: var(--income); } .text-expense { color: var(--expense); }
.text-warn { color: var(--warn); }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.filter-bar .field { gap: 4px; }
.filter-bar .input, .filter-bar .select { padding: 8px 10px; font-size: 13px; background: #fff; }
.filter-bar .field > label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.pagination { display: flex; gap: 6px; align-items: center; padding: 14px 18px; }
.pagination a, .pagination span {
    min-width: 32px; height: 32px; padding: 0 9px;
    display: grid; place-items: center;
    border: 1px solid var(--line-strong); border-radius: 9px;
    font-size: 12.8px; color: var(--ink-2); background: #fff;
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }

/* ------------------------------------------------------------- charts */

.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart-legend {
    display: flex; flex-wrap: wrap; gap: 12px;
    margin-top: 10px; font-size: 12.2px; color: var(--muted);
}
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 9px; height: 9px; border-radius: 3px; }
.chart-tooltip {
    position: absolute; pointer-events: none; z-index: 5;
    background: #0f172a; color: #fff;
    padding: 7px 10px; border-radius: 8px;
    font-size: 11.8px; line-height: 1.45;
    box-shadow: var(--shadow-lg);
    opacity: 0; transition: opacity .12s;
    white-space: nowrap;
    transform: translate(-50%, -115%);
}
.chart-tooltip.is-visible { opacity: 1; }
.chart-legend-list { display: flex; flex-direction: column; gap: 9px; }
.chart-legend-list--2col { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 16px; margin-top: 4px; }
.chart-legend-list--2col .legend-row { font-size: 12.2px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-row .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-row .legend-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* --------------------------------------------------------- goal cards */

.goal-card { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.goal-card__head { display: flex; align-items: flex-start; gap: 12px; }
.goal-card__head h3 { font-size: 15px; font-weight: 700; }
.goal-amount { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.goal-metrics { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.3px; color: var(--muted); }
.goal-metrics strong { display: block; color: var(--ink); font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- insights */

.insight {
    display: flex; gap: 13px;
    padding: 15px 17px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.insight__icon {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 11px; display: grid; place-items: center;
    font-size: 16px;
}
.insight--good .insight__icon { background: var(--income-soft); }
.insight--warn .insight__icon { background: var(--warn-soft); }
.insight--bad .insight__icon { background: var(--expense-soft); }
.insight--info .insight__icon { background: var(--info-soft); }
.insight__body { min-width: 0; }
.insight__body h3 { font-size: 13.8px; font-weight: 700; margin-bottom: 3px; }
.insight__body p { font-size: 12.9px; color: var(--muted); line-height: 1.55; }

/* -------------------------------------------------------- survival box */

.survival-hero {
    background: linear-gradient(135deg, #111c33 0%, #1e1b4b 50%, #0f3d3a 100%);
    color: #fff; border-radius: var(--radius-lg);
    padding: 26px 28px;
    box-shadow: var(--shadow-lg);
    position: relative; overflow: hidden;
}
.survival-hero::after {
    content: ""; position: absolute; right: -60px; top: -80px;
    width: 260px; height: 260px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, .38), transparent 68%);
}
.survival-hero__label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em;
    color: #a5b4fc; font-weight: 700;
}
.survival-hero__value {
    font-size: 40px; font-weight: 800; letter-spacing: -.035em;
    margin: 6px 0 2px; font-variant-numeric: tabular-nums;
}
.survival-hero__sub { color: #94a3b8; font-size: 13px; }
.survival-hero .row { margin-top: 20px; gap: 26px; position: relative; z-index: 1; }
.survival-stat { min-width: 0; }
.survival-stat span { display: block; color: #94a3b8; font-size: 11.6px; text-transform: uppercase; letter-spacing: .07em; }
.survival-stat strong { display: block; font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 6px; }
.day-cell {
    aspect-ratio: 1; border-radius: 8px;
    display: grid; place-items: center;
    font-size: 10.5px; font-weight: 600;
    background: var(--surface-2); color: var(--muted-2);
    border: 1px solid var(--line);
}
.day-cell.is-past { background: var(--brand-soft); color: var(--brand-dark); border-color: #c7d2fe; }
.day-cell.is-today { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .18); }
.day-cell.is-over { background: var(--expense-soft); color: #be123c; border-color: #fecdd3; }

/* -------------------------------------------------------------- auth */

.auth {
    min-height: 100vh; display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: var(--bg);
}
.auth__aside {
    background: linear-gradient(155deg, #0b1220 0%, #1e1b4b 55%, #0f3d3a 100%);
    color: #fff; padding: 46px 52px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth__aside::after {
    content: ""; position: absolute; left: -90px; bottom: -120px;
    width: 380px; height: 380px; border-radius: 50%;
    background: radial-gradient(circle, rgba(13, 148, 136, .3), transparent 68%);
}
.auth__brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth__brand strong { font-size: 20px; letter-spacing: -.02em; }
.auth__pitch { max-width: 420px; position: relative; z-index: 1; }
.auth__pitch h2 {
    font-size: 32px; line-height: 1.2; font-weight: 800; letter-spacing: -.03em;
    margin-bottom: 14px;
}
.auth__pitch p { color: #b6c2d4; font-size: 14.5px; line-height: 1.65; }
.auth__features { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth__features li { display: flex; align-items: flex-start; gap: 10px; font-size: 13.4px; color: #d7dfea; }
.auth__features svg { width: 17px; height: 17px; margin-top: 2px; color: #34d399; flex: 0 0 17px; }
.auth__foot { color: #64748b; font-size: 12px; position: relative; z-index: 1; }

.auth__panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { font-size: 25px; font-weight: 800; letter-spacing: -.025em; }
.auth-box > p.sub { color: var(--muted); font-size: 13.6px; margin: 6px 0 22px; }
.auth-box form { display: flex; flex-direction: column; gap: 14px; }
.auth-box .field > label { font-size: 12.4px; }
.auth-alt { margin-top: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-note {
    margin-top: 18px; padding: 11px 13px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--line);
    font-size: 12px; color: var(--muted); line-height: 1.55;
}

/* --------------------------------------------------------- responsive */

@media (max-width: 1180px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--2-1, .grid--1-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .scrim {
        display: block; position: fixed; inset: 0;
        background: rgba(15, 23, 42, .45); z-index: 35;
    }
    .nav-toggle { display: inline-flex; }
    .content { padding: 18px 16px 48px; }
    .topbar { padding: 12px 16px; }
    .auth { grid-template-columns: 1fr; }
    .auth__aside { display: none; }
}

@media (max-width: 760px) {
    .grid--3, .grid--2, .grid--4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .kpi__value { font-size: 21px; }
    .survival-hero { padding: 20px; }
    .survival-hero__value { font-size: 32px; }
    .table th, .table td { padding: 10px 12px; }
    .topbar__title h1 { font-size: 16.5px; }
    .topbar__title span { display: none; }
    .hide-sm { display: none !important; }
    .filter-bar { padding: 12px; }
    .filter-bar .field { flex: 1 1 140px; }
    .card__body { padding: 14px; }
}

@media print {
    .sidebar, .topbar__actions, .nav-toggle, .btn, .filter-bar { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ddd; }
}

/* ------------------------------------------------ DuitTrack (FastAPI) additions */
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.hide-sm { display: inline; }
.break-all { word-break: break-all; }
.nowrap { white-space: nowrap; }

.cat-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.cat-inline .dot { width: 8px; height: 8px; border-radius: 50%; }

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.donut { width: 190px; height: 190px; }
.donut circle { transition: stroke-dasharray .4s ease; }
.donut-value { font-family: var(--font); font-size: 11px; font-weight: 700; fill: var(--ink); }
.donut-label { font-family: var(--font); font-size: 7.5px; fill: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.donut-legend { list-style: none; padding: 0; margin: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; }
.donut-legend li { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.donut-legend span { flex: 1; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend strong { font-variant-numeric: tabular-nums; }
.donut-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }

.kpi__dot { display: inline-block; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }
.auth-note { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 8px 10px; }
.table .btn--icon { width: 30px; height: 30px; padding: 5px; }
.insight { display: flex; gap: 11px; align-items: flex-start; }
.insight__icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); flex: 0 0 30px; }

/* ------------------------------------------------------------- DuitBot chat */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.chat-card { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 520px; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.chat-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #0d9488); color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 14px -8px rgba(79, 70, 229, .9);
}
.chat-head__meta { display: flex; flex-direction: column; line-height: 1.25; }
.chat-head__meta strong { font-size: 14px; }
.chat-head__meta span { color: var(--muted); font-size: 11.8px; }

.chat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: #f8fafc; scroll-behavior: smooth; }
.chat-row { display: flex; }
.chat-row--user { justify-content: flex-end; }
.chat-bubble { max-width: 78%; padding: 10px 13px; border-radius: 14px; font-size: 13.4px; line-height: 1.55; box-shadow: var(--shadow-sm); }
.chat-bubble p { margin: 0; }
.chat-bubble--bot { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.chat-bubble--user { background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; border-bottom-right-radius: 5px; }
.chat-bubble--user strong { color: #fff; }
.chat-name { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.chat-bubble--user .chat-name { color: #c7d2fe; }
.chat-bubble strong { font-weight: 700; }

.chat-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px 0; background: #fff; border-top: 1px solid var(--line); }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2);
  border-radius: 999px; padding: 6px 11px; font-size: 12.2px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip:hover { background: var(--brand-soft); border-color: #c7d2fe; color: var(--brand-dark); }

.chat-composer { display: flex; gap: 9px; align-items: flex-end; padding: 12px 14px; background: #fff; }
.chat-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 9px 12px; font: inherit; font-size: 13.4px; line-height: 1.45; max-height: 120px;
  min-height: 40px; color: var(--ink); background: #fff;
}
.chat-composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.chat-send { width: 40px; height: 40px; padding: 0; border-radius: 12px; flex: 0 0 40px; }
.chat-hint { margin: 0; padding: 0 16px 12px; font-size: 11px; color: var(--muted); background: #fff; }
.chat-side .card { margin-bottom: 0; }

/* floating widget */
.chat-widget { position: fixed; right: 22px; bottom: 22px; z-index: 60; }
.chat-launcher {
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #0d9488); color: #fff;
  display: grid; place-items: center; box-shadow: 0 12px 28px -10px rgba(79, 70, 229, .9);
  position: relative; transition: transform .15s ease;
}
.chat-launcher:hover { transform: translateY(-2px); }
.chat-launcher .ico { width: 24px; height: 24px; }
.chat-launcher__dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #34d399; border: 2px solid #fff; }
.chat-panel {
  position: absolute; right: 0; bottom: 66px; width: 360px; max-width: calc(100vw - 32px);
  height: min(540px, calc(100vh - 130px)); background: #fff; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-panel__head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-panel .chat-body { padding: 14px; gap: 10px; }
.chat-panel .chat-bubble { max-width: 86%; font-size: 12.8px; }
.chat-panel .chat-suggest { padding: 8px 12px 0; }
.chat-panel__link { text-align: center; font-size: 12px; padding: 8px; border-top: 1px solid var(--line); background: #fff; }

@media (max-width: 960px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-card { height: calc(100vh - 170px); min-height: 460px; }
  .chat-widget { right: 14px; bottom: 76px; }
  .chat-panel { width: calc(100vw - 28px); height: min(520px, calc(100vh - 180px)); }
}
