@font-face { font-family: Inter; src: url(../fonts/inter-latin.woff2) format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Inter; src: url(../fonts/inter-latin-ext.woff2) format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;
  --bg: #fff;
  --bg-soft: #fafafa;
  --bg-hover: #f5f5f5;
  --line: #e9eaeb;
  --line-strong: #d5d7da;
  --text: #181d27;
  --text-2: #414651;
  --text-3: #535862;
  --text-4: #717680;
  --text-5: #a4a7ae;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --income: #067647;
  --expense: #b42318;
  --shadow-xs: 0 1px 2px rgb(10 13 18 / 5%);
  --skeu: inset 0 0 0 1px rgb(10 13 18 / 18%), inset 0 -2px 0 rgb(10 13 18 / 5%), 0 1px 2px rgb(10 13 18 / 5%);
  --shadow-lg: 0 20px 24px -4px rgb(10 13 18 / 8%), 0 8px 8px -4px rgb(10 13 18 / 3%);
  --on-accent: #fff;
  --primary: #181d27;
  --primary-hover: #252b37;
  --surface: #fff;
  --field: #fff;
  --chart-in: #0e9384;
  --chart-out: #e04f16;
  --placeholder: #717680;
  --tab-active: #fff;
  --tab-edge: #d5d7da;
  --btn-bg: #fff;
  --btn-hover: #fafafa;
  --dialog-edge: transparent;
  --backdrop: rgb(10 13 18 / 55%);
  --focus-border: #717680;
  --focus-ring: rgb(10 13 18 / 8%);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23717680' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --danger-solid: #b42318;
  --danger-edge: #fda29b;
  --pill-base: #fff;
  --pill-ink: #101828;
  --pill-meta: #535862;
  --pill-text: 72%;
  --pill-tint: 7%;
  --pill-hover: 14%;
  --pill-edge: 24%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e12;
  --bg-soft: #13161b;
  --bg-hover: #22262f;
  --line: #22262f;
  --line-strong: #373a41;
  --text: #f7f7f7;
  --text-2: #cecfd2;
  --text-3: #94979c;
  --text-4: #85888e;
  --text-5: #61656c;
  --danger: #f97066;
  --danger-bg: #2c1412;
  --income: #47cd89;
  --expense: #f97066;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 40%);
  --skeu: inset 0 0 0 1px #373a41, 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-lg: 0 20px 24px -4px rgb(0 0 0 / 50%), 0 8px 8px -4px rgb(0 0 0 / 30%);
  --on-accent: #0c0e12;
  --primary: #e4e5e7;
  --primary-hover: #cecfd2;
  --surface: #191c23;
  --field: #22262f;
  --chart-in: #0ea08f;
  --chart-out: #e8591a;
  --placeholder: #94979c;
  --tab-active: #2c3039;
  --tab-edge: rgb(255 255 255 / 10%);
  --btn-bg: transparent;
  --btn-hover: #22262f;
  --dialog-edge: rgb(255 255 255 / 9%);
  --backdrop: rgb(0 0 0 / 68%);
  --focus-border: #94979c;
  --focus-ring: rgb(255 255 255 / 12%);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394979c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --danger-edge: #7a271a;
  --pill-base: #13161b;
  --pill-ink: #fff;
  --pill-meta: #cecfd2;
  --pill-text: 42%;
  --pill-tint: 14%;
  --pill-hover: 24%;
  --pill-edge: 34%;
}

:root[data-theme="dark"] .brand-mark { filter: invert(1); }
:root:not([data-theme="dark"]) .if-dark, :root[data-theme="dark"] .if-light { display: none; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/20px Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss03"; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.67; stroke-linecap: round; stroke-linejoin: round; }
.grow { flex: 1; }
.muted { color: var(--text-3); }

/* Layout */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100dvh; }
.main { padding: 24px 24px 32px 32px; min-width: 0; }

/* Sidebar */
.sidebar { position: sticky; top: 8px; height: calc(100dvh - 16px); margin: 8px 0 8px 8px; padding: 20px 12px 12px; display: flex; flex-direction: column;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: block; }
.icon-btn.sidebar-close { display: none; }
.side-label { margin: 16px 8px 6px; font-size: 12px; font-weight: 600; color: var(--text-4); letter-spacing: .02em; text-transform: uppercase; }
.side-label-row { display: flex; align-items: center; justify-content: space-between; text-transform: none; }
.side-label-row span { text-transform: uppercase; }
.link-btn { font-size: 12px; font-weight: 600; color: var(--text-3); }
.link-btn:hover { color: var(--text); }
.side-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 14.5px; font-weight: 600; color: var(--text-2); text-align: left; }
.side-link .ic { color: var(--text-4); }
.side-link:hover, .side-link.active { background: var(--bg-hover); color: var(--text); }
.side-cat { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-weight: 600; color: var(--text-2); text-align: left; }
.side-cat:hover { background: var(--bg-hover); }
.side-cat .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-cat .swatch { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); margin: 0 4px; }
.side-cat .count { min-width: 22px; padding: 0 6px; font-size: 12px; line-height: 20px; text-align: center; color: var(--text-3); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.side-cat[aria-pressed="false"] { color: var(--text-5); }
.side-cat[aria-pressed="false"] .swatch { background: var(--line-strong); box-shadow: none; }
.side-foot { margin-top: auto; padding-top: 12px; }
.mobile-actions { display: flex; align-items: center; gap: 4px; margin: -8px; }

/* Header */
.mobile-bar { display: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin: 0 0 24px; }
h1 { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 12px; }
.tabs { display: inline-flex; gap: 2px; max-width: 100%; overflow-x: auto; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; height: 34px; padding: 0 12px; margin: -1px; font-weight: 600; color: var(--text-4); border: 1px solid transparent; border-radius: 10px; }
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: var(--text); background: var(--tab-active); border-color: var(--tab-edge); box-shadow: var(--shadow-xs); }
.searchbox { display: flex; align-items: center; gap: 8px; width: 290px; height: 40px; padding: 0 8px 0 12px; font-size: 16px; color: var(--text-4); text-align: left; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-xs); }
.searchbox span { flex: 1; }
kbd { padding: 0 5px; font: 500 12px/18px Inter, sans-serif; color: var(--text-4); border: 1px solid var(--line); border-radius: 4px; }

/* Calendar card */
.cal { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-xs); overflow: hidden; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 20px; }
.cal-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.date-chip { display: flex; flex-direction: column; flex: none; width: 56px; overflow: hidden; text-align: center; border: 1px solid var(--line); border-radius: 8px; }
.date-chip span { padding: 4px 0 2px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--text-4); background: var(--bg-soft); text-transform: uppercase; }
.date-chip strong { padding: 3px 0 5px; font-size: 18px; line-height: 24px; font-weight: 700; }
h2 { font-size: 18px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; }
.period-sub { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--text-3); }
.totals { display: inline-flex; gap: 10px; font-weight: 500; font-variant-numeric: tabular-nums; }
.totals .in { color: var(--income); }
.totals .out { color: var(--expense); }
.cal-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; color: var(--text-4); border-radius: 8px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-2); }
.navgroup { display: flex; height: 40px; background: var(--bg); border-radius: 8px; box-shadow: var(--skeu); overflow: hidden; }
.navgroup button { display: grid; place-items: center; width: 40px; color: var(--text-4); }
.navgroup .nav-today { width: auto; padding: 0 14px; font-weight: 600; color: var(--text-2); border-inline: 1px solid var(--line-strong); }
.navgroup button:hover { background: var(--bg-soft); }
.select-wrap { position: relative; display: block; }
.select-wrap select { appearance: none; height: 40px; padding: 0 36px 0 14px; font-weight: 600; color: var(--text-2); background: var(--bg); border: 0; border-radius: 8px; box-shadow: var(--skeu); cursor: pointer; }
.select-wrap .ic { position: absolute; right: 10px; top: 10px; color: var(--text-4); pointer-events: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 14px; font-weight: 600; color: var(--text-2); background: var(--btn-bg); border-radius: 8px; box-shadow: var(--skeu); white-space: nowrap; }
.btn:hover { background: var(--btn-hover); }
.btn-primary { color: var(--on-accent); background: var(--primary); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%), 0 1px 2px rgb(10 13 18 / 10%); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-edge); }
.btn-danger:hover, .btn-danger.confirm { color: #fff; background: var(--danger-solid); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.view { transition: opacity .12s; }
.view.loading { opacity: .55; }

/* Month grid */
.weekdays, .month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { border-block: 1px solid var(--line); }
.weekdays span { padding: 8px 0; font-size: 12px; font-weight: 600; line-height: 18px; text-align: center; color: var(--text-3); }
.weekdays span + span { border-left: 1px solid var(--line); }
.weekdays b { font-weight: 600; }
.weekdays .short { display: none; }
.day { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 132px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; }
.day:nth-child(7n) { border-right: 0; }
.month > .day:nth-last-child(-n+7) { border-bottom: 0; }
.day:hover { background: var(--bg-soft); }
.day.other { background: var(--bg-soft); }
.day.other .num { color: var(--text-4); }
.day.other .pill { opacity: .6; }
.num { display: grid; place-items: center; width: 24px; height: 24px; margin: -1px 0 3px -3px; font-size: 12px; font-weight: 600; color: var(--text-2); border-radius: 50%; }
.day.today .num { color: var(--on-accent); background: var(--text); }
.pill { --c: #717680; display: flex; align-items: center; gap: 4px; width: 100%; min-height: 24px; padding: 2px 7px; font-size: 12px; font-weight: 600; line-height: 18px; text-align: left;
  color: color-mix(in srgb, var(--c) var(--pill-text), var(--pill-ink)); background: color-mix(in srgb, var(--c) var(--pill-tint), var(--pill-base)); border: 1px solid color-mix(in srgb, var(--c) var(--pill-edge), var(--pill-base)); border-radius: 6px; }
.pill:hover { background: color-mix(in srgb, var(--c) var(--pill-hover), var(--pill-base)); }
.pill .dot { width: 6px; height: 6px; flex: none; margin-right: 2px; border-radius: 50%; background: var(--c); }
.pill .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill .m { flex: none; font-weight: 400; font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--c) var(--pill-text), var(--pill-meta)); }
.more { padding: 0 8px; font-size: 12px; font-weight: 600; line-height: 18px; text-align: left; color: var(--text-4); }
.more:hover { color: var(--text); }
.dots { display: none; }

/* Year */
.year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 32px; padding: 24px 20px 28px; border-top: 1px solid var(--line); }
.mini-title { display: block; width: 100%; margin-bottom: 8px; padding: 2px 6px; font-weight: 600; text-align: left; border-radius: 6px; }
.mini-title:hover { background: var(--bg-hover); }
.mini { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; }
.mini-wd { font-size: 11px; line-height: 20px; font-weight: 600; text-align: center; color: var(--text-4); }
.mini-day { position: relative; display: grid; place-items: center; aspect-ratio: 1; font-size: 12px; color: var(--text-2); border-radius: 50%; }
.mini-day:hover { background: var(--bg-hover); }
.mini-day.has { font-weight: 700; color: var(--text); }
.mini-day.has::after { content: ""; position: absolute; bottom: 8%; width: 4px; height: 4px; border-radius: 50%; background: var(--c); }
.mini-day.today { color: var(--on-accent); background: var(--text); }
.mini-day.today::after { background: var(--on-accent); }

/* List */
.list { padding: 8px 20px 20px; border-top: 1px solid var(--line); }
.list-day { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-day:last-child { border-bottom: 0; }
.list-date { font-weight: 600; }
.list-date small { display: block; font-size: 12px; font-weight: 400; color: var(--text-4); }
.list-items { display: grid; gap: 4px; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-4); }
.list .pill, .day-list .pill, .search-results .pill { min-height: 36px; padding: 6px 10px; font-size: 14px; line-height: 20px; }

/* Finance */
.fin { max-width: 1120px; }
.fin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.fin-head h1 { margin: 0; white-space: nowrap; }
.year-nav .nav-today { min-width: 76px; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi, .panel { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-xs); }
.kpi { padding: 16px 20px; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-3); }
.kpi-value { margin-top: 8px; font-size: 26px; line-height: 34px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-value small { margin-left: 4px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--text-4); }
.swatch-in, .swatch-out { width: 10px; height: 10px; flex: none; border-radius: 3px; }
.swatch-in { background: var(--chart-in); }
.swatch-out { background: var(--chart-out); }
.panel { margin-bottom: 16px; overflow: hidden; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 16px 20px; }
.panel-head h2 { font-size: 16px; line-height: 24px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; font-size: 13px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart { position: relative; padding: 0 20px 16px; }
.chart svg { display: block; width: 100%; }
.chart text { font: 500 11px Inter, sans-serif; fill: var(--text-4); }
.chart text.sel { fill: var(--text); font-weight: 700; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-in { fill: var(--chart-in); }
.chart .bar-out { fill: var(--chart-out); }
.chart .future { opacity: .45; }
.chart .band { fill: transparent; cursor: pointer; }
.chart .band:hover { fill: var(--bg-hover); fill-opacity: .55; }
.chart .band.sel { fill: var(--bg-hover); fill-opacity: .9; }
.tip { position: absolute; z-index: 5; width: 190px; padding: 10px 12px; font-size: 13px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-lg); pointer-events: none; }
.tip strong { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.tip b { margin-left: auto; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.fin-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fin-table th, .fin-table td { padding: 11px 20px; text-align: right; white-space: nowrap; border-top: 1px solid var(--line); }
.fin-table thead th { border-top: 0; }
.fin-table th { font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--bg-soft); }
.fin-table th:first-child, .fin-table td:first-child { text-align: left; }
.fin-table td:first-child { font-weight: 600; }
.fin-table button { font-weight: 600; }
.fin-table tbody tr { cursor: pointer; }
.fin-table tbody tr:hover { background: var(--bg-soft); }
.fin-table tbody tr.sel { background: var(--bg-hover); }
.fin-table tr.future td { color: var(--text-4); }
.fin-table tfoot td { font-weight: 700; background: var(--bg-soft); }
.tag { margin-left: 6px; padding: 1px 6px; font-size: 11px; font-weight: 500; color: var(--text-4); border: 1px solid var(--line); border-radius: 5px; }
.items { padding: 0 20px 8px; }
.item { display: grid; grid-template-columns: 10px 64px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.item-date { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-title { min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { padding: 0 2px 8px; font-size: 13px; color: var(--text-4); }

/* Debts */
.kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-value div + div { margin-top: 2px; }
.debt-bar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.debts { display: grid; gap: 12px; }
.debt { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-xs); }
.debt-open { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; width: 100%; padding: 16px 20px 12px; text-align: left; border-radius: 12px 12px 0 0; }
.debt-open:hover { background: var(--bg-soft); }
.debt-name { font-size: 16px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; }
.debt-title { margin-top: 2px; color: var(--text-3); overflow-wrap: anywhere; }
.debt-sum { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.debt-sum strong { display: block; font-size: 18px; line-height: 26px; font-weight: 600; white-space: nowrap; }
.debt-sum small { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.debt-bar { height: 6px; margin: 0 20px; overflow: hidden; background: var(--bg-hover); border-radius: 3px; }
.debt-bar i { display: block; height: 100%; background: var(--text-2); border-radius: 3px; }
.debt-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 20px 14px; color: var(--text-3); font-size: 13px; }
.debt-foot .grow { min-width: 0; }
.debt-foot .btn { height: 34px; padding: 0 12px; }
.badge { display: inline-flex; align-items: center; padding: 1px 8px; font-size: 12px; font-weight: 500; line-height: 20px; color: var(--text-3); border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; }
.badge.late { color: var(--danger); border-color: var(--danger-edge); }
.detail-rows { display: grid; gap: 8px; margin-bottom: 16px; }
.detail-row { display: flex; justify-content: space-between; gap: 16px; }
.detail-row span:first-child { color: var(--text-3); }
.detail-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.detail-note { margin-bottom: 16px; padding: 8px 12px; color: var(--text-2); background: var(--field); border-radius: 8px; overflow-wrap: anywhere; }
.sub-title { margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.pay-grid { margin-top: 14px; }
.pay-list { display: grid; gap: 2px; max-height: 34dvh; overflow-y: auto; }
.pay { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.pay-main { flex: 1; min-width: 0; }
.pay-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.pay-meta { font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
.pay .confirm { color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: 8px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; flex: none; margin: 1px 0 0; accent-color: var(--text); }

/* Dialogs */
.dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--dialog-edge); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: auto; }
.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.dialog-body { padding: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dialog-head .icon-btn { margin: -8px -8px -8px 0; }
h3 { font-size: 18px; line-height: 28px; font-weight: 600; }
.dialog-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field span { font-size: 14px; font-weight: 500; color: var(--text-2); }
.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea, .cat-form input:not([type="color"]) { width: 100%; min-height: 42px; padding: 9px 12px; font-size: 16px; line-height: 22px; background-color: var(--field); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-xs); }
.field select { appearance: none; padding-right: 38px; background-image: var(--chevron); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; cursor: pointer; }
.field textarea { resize: vertical; }
.field :focus, .cat-form input:focus { outline: 0; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
::placeholder { color: var(--placeholder); opacity: 1; }
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }
::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.hint { margin-top: 12px; padding: 8px 12px; font-size: 13px; color: var(--text-3); background: var(--field); border-radius: 8px; }
.day-list { display: grid; gap: 6px; max-height: 50dvh; overflow-y: auto; padding: 2px; }
.day-list .empty { padding: 20px 16px 8px; }
.dialog-search { width: min(620px, calc(100vw - 32px)); margin-top: 12vh; }
.dialog-search .dialog-body { padding: 0; }
.search-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; color: var(--text-4); border-bottom: 1px solid var(--line); }
.search-row input { flex: 1; min-width: 0; height: 44px; font-size: 16px; color: var(--text); background: none; border: 0; outline: 0; }
.search-results { display: grid; gap: 4px; min-height: 96px; max-height: 56dvh; padding: 8px; overflow-y: auto; }
.result-date { font-size: 12px; font-weight: 400; color: var(--text-4); white-space: nowrap; }
.cat-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-bottom: 16px; }
.cat-row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 2px 4px 2px 10px; border-radius: 8px; }
.cat-row:hover { background: var(--field); }
.cat-row .swatch { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--c); }
.cat-row .name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row small { color: var(--text-4); white-space: nowrap; }
.cat-rename input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; font-size: 16px; background-color: var(--field); border: 1px solid var(--line-strong); border-radius: 8px; }
.cat-rename input:focus { outline: 0; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.cat-rename .btn { flex: none; height: 36px; padding: 0 12px; }
.cat-rename .icon-btn { width: 36px; height: 36px; }
.cat-form { display: flex; gap: 8px; }
.cat-form input[type="color"] { width: 42px; height: 42px; flex: none; padding: 3px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; }
.cat-form input[name="name"] { flex: 1; min-width: 0; }
.toast { position: fixed; inset: auto auto 24px 50%; z-index: 60; margin: 0; border: 0; max-width: calc(100vw - 32px); padding: 10px 14px; font-weight: 500; color: var(--on-accent); background: var(--text); border-radius: 8px; box-shadow: var(--shadow-lg); transform: translateX(-50%); }
.toast.error { color: #fff; background: var(--danger-solid); }
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--backdrop); }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 16px; background: var(--bg-soft); }
.login-card { width: min(400px, 100%); padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-xs); }
.login-card h1 { margin: 24px 0 4px; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.alert { margin-top: 16px; padding: 10px 12px; font-weight: 500; color: var(--danger); background: var(--danger-bg); border-radius: 8px; }

@media (max-width: 1320px) {
  .btn span { display: inline; }
  .searchbox { width: 240px; }
  .cal-head { flex-wrap: wrap; }
  .pill .m { display: none; }
  .year { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .shell { display: block; }
  .main { padding: 0; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw); height: auto; margin: 0; border-width: 0 1px 0 0; border-radius: 0; background: var(--surface); transform: translateX(-102%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .sidebar.open { transform: none; visibility: visible; }
  .icon-btn.sidebar-close { display: inline-grid; margin: -8px; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
  .mobile-bar .icon-btn { color: var(--text-3); }
  .page-head { display: block; margin: 12px 0 0; padding: 0 16px 20px; border-bottom: 1px solid var(--line); }
  .page-head h1 { margin-bottom: 16px; }
  .searchbox { width: 100%; margin-top: 0; }
  .page-head > div { display: contents; }
  .page-head .searchbox { order: 1; margin-bottom: 16px; }
  .page-head { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .page-head h1 { order: 0; }
  .tabs { order: 2; align-self: flex-start; }
  kbd { display: none; }
  .cal { border: 0; border-radius: 0; box-shadow: none; }
  .cal-head { display: block; padding: 20px 16px; }
  .date-chip { display: none; }
  .cal-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 12px 8px; margin-top: 16px; }
  .select-wrap { order: 1; }
  .select-wrap select { width: 100%; }
  #add-event { order: 2; min-width: 0; padding: 0 8px; }
  .search-mini { order: 3; }
  .navgroup { order: 4; grid-column: 1 / -1; }
  .navgroup .nav-today { flex: 1; }
  .weekdays .long { display: none; }
  .weekdays .short { display: inline; }
  .weekdays { border-top: 1px solid var(--line); }
  .day { min-height: 88px; gap: 6px; padding: 8px 4px 6px 6px; }
  .num { margin: 0; font-size: 14px; width: 28px; height: 28px; margin-left: -2px; }
  .pill, .more { display: none; }
  .dots { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding-left: 2px; font-size: 12px; font-weight: 600; line-height: 14px; color: var(--text-5); }
  .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
  .list .pill, .day-list .pill, .search-results .pill { display: flex; }
  .year { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 20px; padding: 20px 16px; }
  .list { padding: 4px 16px 16px; }
  .list-day { grid-template-columns: 1fr; gap: 8px; }
  .dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .dialog-search { margin: 0 0 auto; border-radius: 0 0 16px 16px; }
}

@media (max-width: 960px) {
  .fin { padding: 8px 16px 24px; }
  .kpis, .kpis-2 { grid-template-columns: 1fr; gap: 8px; }
  .kpi-value { text-align: right; }
  .kpi { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
  .kpi-value { margin: 0; font-size: 18px; line-height: 26px; }
  .kpi-value small { font-size: 12px; }
  .panel-head { padding: 14px 16px; }
  .chart { padding: 0 8px 12px; }
  .fin-table th, .fin-table td { padding: 10px 8px; font-size: 13px; }
  .fin-table th:first-child, .fin-table td:first-child { padding-left: 16px; }
  .fin-table th:last-child, .fin-table td:last-child { padding-right: 16px; }
  .tag { display: none; }
  .items { padding: 0 16px 8px; }
  .item { grid-template-columns: 10px 52px minmax(0, 1fr) auto; }
  .debt-open { padding: 14px 16px 10px; }
  .debt-sum strong { font-size: 16px; line-height: 24px; }
  .debt-bar { margin: 0 16px; }
  .debt-foot { padding: 10px 16px 12px; }
}

@media (max-width: 374px) {
  .fin-table th, .fin-table td { padding: 10px 4px; font-size: 12px; }
  .fin-table th:first-child, .fin-table td:first-child { padding-left: 12px; }
  .fin-table th:last-child, .fin-table td:last-child { padding-right: 12px; }
  .fin-head h1 { font-size: 20px; }
  .year-nav button { width: 34px; }
  .year-nav .nav-today { width: auto; min-width: 54px; padding: 0 8px; }
  #add-event .ic { display: none; }
  .select-wrap select { padding-left: 10px; padding-right: 28px; }
  .select-wrap .ic { right: 6px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.server-note{margin:10px 0 0;padding:8px 12px;border-radius:8px;background:rgba(34,160,90,.12);color:#1f8a4c;font-size:13px;font-weight:600;text-align:center}
