/* Expense Analyzer — app styles. Tokens first; components never use raw hex. */

:root {
  --font: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --r: 16px;          /* every container */
  --r-ctl: 12px;      /* inputs, buttons */
  --r-sm: 8px;
  --r-full: 999px;
  --top-h: 60px;
  --side-w: 256px;
  --side-closed: 76px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 150ms; --t: 220ms; --t-slow: 320ms;
  --pad: 24px;
  --ok: #16A34A; --ok-soft: #E7F6EC; --warn: #B45309; --warn-soft: #FDF3E1; --bad: #DC2626; --bad-soft: #FDECEC; --info: #2563EB; --info-soft: #E8F0FE;
  --sh-1: 0 1px 2px rgba(17, 24, 39, .05), 0 0 0 1px rgba(17, 24, 39, .04);
  --sh-2: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 14px -2px rgba(17, 24, 39, .07), 0 0 0 1px rgba(17, 24, 39, .035);
  --sh-3: 0 2px 6px rgba(17, 24, 39, .05), 0 16px 40px -8px rgba(17, 24, 39, .16), 0 0 0 1px rgba(17, 24, 39, .04);
  --sh-4: 0 30px 80px -16px rgba(17, 24, 39, .35), 0 0 0 1px rgba(17, 24, 39, .06);
  --overlay: rgba(12, 14, 18, .42);
}

/* ---------- themes */
[data-theme="slate"] {
  --bg: #F2F3F5; --surface: #FFFFFF; --surface-2: #F6F7F9; --surface-3: #ECEEF1; --text: #15181C; --text-2: #565E69; --text-3: #8B929C;
  --line: #E4E7EB; --line-strong: #CFD4DA; --accent: #FFD43B; --accent-ink: #1A1D21; --accent-soft: #FFF5CC; --accent-strong: #B88A00;
  --hero: #22252A; --hero-ink: #FFFFFF; --hero-2: rgba(255,255,255,.62); --hero-line: rgba(255,255,255,.12); --hero-bar: rgba(255,255,255,.14);
  --glass: rgba(242, 243, 245, .82);
}
[data-theme="slate"][data-scheme="dark"] {
  --bg: #0E1013; --surface: #16191D; --surface-2: #1B1F24; --surface-3: #23272D; --text: #EEF0F3; --text-2: #A4ABB5; --text-3: #6F7782;
  --line: #262A30; --line-strong: #353A42; --accent-soft: rgba(255, 212, 59, .13); --accent-strong: #FFD43B;
  --hero: #1F2329; --glass: rgba(14, 16, 19, .8);
}
[data-theme="tide"] {
  --bg: #EDECE5; --surface: #FFFFFF; --surface-2: #F6F5F0; --surface-3: #EBEAE3; --text: #0E2A33; --text-2: #4A6067; --text-3: #7E9096;
  --line: #E2E0D7; --line-strong: #CFCDC2; --accent: #C6F432; --accent-ink: #0E2A33; --accent-soft: #EEFAC8; --accent-strong: #5C7A00;
  --hero: #0E2A33; --hero-ink: #FFFFFF; --hero-2: rgba(255,255,255,.64); --hero-line: rgba(255,255,255,.12); --hero-bar: rgba(255,255,255,.14);
  --glass: rgba(237, 236, 229, .82);
}
[data-theme="tide"][data-scheme="dark"] {
  --bg: #07161A; --surface: #0D2026; --surface-2: #11272E; --surface-3: #173139; --text: #E6EFEC; --text-2: #9AB0AE; --text-3: #66807F;
  --line: #19343B; --line-strong: #24464F; --accent-soft: rgba(198, 244, 50, .12); --accent-strong: #C6F432;
  --hero: #0F3540; --glass: rgba(7, 22, 26, .8);
}
[data-theme="sky"] {
  --bg: #EAF0F7; --surface: #FFFFFF; --surface-2: #F7F5FD; --surface-3: #ECEFF7; --text: #12223A; --text-2: #4E5E77; --text-3: #8190A5;
  --line: #DEE5EF; --line-strong: #C9D3E1; --accent: #FFB38A; --accent-ink: #3A1603; --accent-soft: #FFEBDF; --accent-strong: #C2501A;
  --hero: #B9D3EE; --hero-ink: #12223A; --hero-2: rgba(18,34,58,.64); --hero-line: rgba(18,34,58,.12); --hero-bar: rgba(18,34,58,.12);
  --glass: rgba(234, 240, 247, .82);
}
[data-theme="sky"][data-scheme="dark"] {
  --bg: #0B131E; --surface: #111C2A; --surface-2: #162233; --surface-3: #1C2A3D; --text: #E7EDF5; --text-2: #A0AFC3; --text-3: #6B7B91;
  --line: #1F2E43; --line-strong: #2B3D57; --accent-soft: rgba(255, 179, 138, .14); --accent-strong: #FFB38A;
  --hero: #1C3656; --hero-ink: #FFFFFF; --hero-2: rgba(255,255,255,.64); --hero-line: rgba(255,255,255,.12); --hero-bar: rgba(255,255,255,.14);
  --glass: rgba(11, 19, 30, .8);
}
[data-scheme="dark"] {
  color-scheme: dark;
  --ok: #34D27B; --ok-soft: rgba(52, 210, 123, .13); --warn: #F5B544; --warn-soft: rgba(245, 181, 68, .13);
  --bad: #F87171; --bad-soft: rgba(248, 113, 113, .13); --info: #6EA8FF; --info-soft: rgba(110, 168, 255, .13);
  --sh-1: 0 0 0 1px var(--line);
  --sh-2: 0 0 0 1px var(--line), 0 6px 18px -6px rgba(0, 0, 0, .55);
  --sh-3: 0 0 0 1px var(--line-strong), 0 18px 44px -10px rgba(0, 0, 0, .7);
  --sh-4: 0 0 0 1px var(--line-strong), 0 30px 80px -16px rgba(0, 0, 0, .8);
  --overlay: rgba(0, 0, 0, .58);
}

/* ---------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: auto; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body {
  font: 400 15px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11"; letter-spacing: -.005em;
  min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

.ico { width: 20px; height: 20px; flex: none; }
.ico-16 { width: 16px; height: 16px; }
.ico-18 { width: 18px; height: 18px; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; white-space: normal !important; overflow-wrap: anywhere; min-width: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* ---------- shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; transition: grid-template-columns var(--t-slow) var(--ease); }
[data-side="closed"] .app { grid-template-columns: var(--side-closed) minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; }

.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  background: var(--surface); box-shadow: 1px 0 0 var(--line); z-index: 30; min-width: 0; overflow: hidden;
  padding-left: var(--safe-l);
}
.side-head { display: flex; align-items: center; gap: 8px; height: calc(var(--top-h) + 4px); padding: 0 12px 0 16px; flex: none; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; border-radius: 12px; }
.brand .logo-mark { flex: none; border-radius: 9px; box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 0 0 1px rgba(0,0,0,.04); }
.brand-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { white-space: nowrap; font-size: 15.5px; font-weight: 650; letter-spacing: -.025em; }
.brand-txt small { font-size: 12px; color: var(--text-3); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; overflow-wrap: anywhere; }
.side-collapse { margin-right: -4px; color: var(--text-3); }
.side-collapse .ico { transition: transform var(--t-slow) var(--ease); }
[data-side="closed"] .side-collapse .ico { transform: scaleX(-1); }

.side-proj { padding: 4px 12px 8px; flex: none; }
.proj-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-ctl);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); text-align: left; transition: background var(--t-fast);
}
.proj-btn:hover { background: var(--surface-3); }
.proj-btn .pb-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--sh-1); color: var(--text-2); flex: none; }
.proj-btn b { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.proj-btn small { display: block; font-size: 11.5px; color: var(--text-3); }
.proj-btn .chev { color: var(--text-3); margin-left: auto; }

.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 4px 12px 16px; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.nav-a {
  position: relative; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 11px;
  color: var(--text-2); font-size: 14.5px; font-weight: 500; letter-spacing: -.012em; white-space: nowrap; transition: background var(--t-fast), color var(--t-fast);
}
.nav-a .ico { color: var(--text-3); transition: color var(--t-fast); }
.nav-a:hover { background: var(--surface-2); color: var(--text); }
.nav-a:hover .ico { color: var(--text-2); }
.nav-a.on { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-a.on .ico { color: var(--text); }
.nav-a.on::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav-a .nav-n { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.nav-group { margin-top: 10px; }
.nav-gh {
  display: flex; align-items: center; width: 100%; height: 30px; padding: 0 12px; border-radius: 9px; font-size: 12px; font-weight: 600;
  color: var(--text-3); letter-spacing: .02em; text-transform: uppercase; transition: color var(--t-fast);
}
.nav-gh:hover { color: var(--text-2); }
.nav-gh .ico { width: 14px; height: 14px; margin-left: auto; transition: transform var(--t) var(--ease); }
.nav-group.shut .nav-gh .ico { transform: rotate(-90deg); }
.nav-gb { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--t-slow) var(--ease); }
.nav-gb > div { overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.nav-group.shut .nav-gb { grid-template-rows: 0fr; }

.side-foot { flex: none; padding: 10px 12px calc(12px + var(--safe-b)); box-shadow: 0 -1px 0 var(--line); }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-ctl); width: 100%; text-align: left; transition: background var(--t-fast); }
.me-chip:hover { background: var(--surface-2); }
.me-chip b { display: block; font-size: 13.5px; font-weight: 600; }
.me-chip small { display: block; font-size: 12px; color: var(--text-3); }

/* collapsed sidebar (desktop) */
@media (min-width: 900px) {
  [data-side="closed"] .brand-txt, [data-side="closed"] .nav-a span, [data-side="closed"] .nav-a .nav-n,
  [data-side="closed"] .proj-btn .pb-txt, [data-side="closed"] .proj-btn .chev, [data-side="closed"] .me-chip .grow,
  [data-side="closed"] .nav-gh span, [data-side="closed"] .nav-gh .ico { display: none; }
  [data-side="closed"] .side-head { flex-direction: column; justify-content: center; height: auto; padding: 14px 0 6px; gap: 10px; }
  [data-side="closed"] .brand { flex: none; }
  [data-side="closed"] .side-collapse { margin: 0; }
  [data-side="closed"] .proj-btn { justify-content: center; padding: 6px; background: transparent; box-shadow: none; }
  [data-side="closed"] .nav-a { justify-content: center; padding: 0; }
  [data-side="closed"] .nav-gh { height: 1px; padding: 0; margin: 8px 10px; background: var(--line); pointer-events: none; }
  [data-side="closed"] .nav-group.shut .nav-gb { grid-template-rows: 1fr; }
  [data-side="closed"] .me-chip { justify-content: center; }
}

/* topbar */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) calc(var(--pad) + var(--safe-r)) 0 var(--pad);
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 1px 0 transparent; transition: box-shadow var(--t);
}
.top.scrolled { box-shadow: 0 1px 0 var(--line); }
.top-title { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 10px; }
.top-title h1 { font-size: 20px; font-weight: 650; letter-spacing: -.03em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title span { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.top .menu-btn, .top .top-logo { display: none; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); line-height: 1; }

.view { padding: 8px calc(var(--pad) + var(--safe-r)) calc(40px + var(--safe-b)) var(--pad); width: 100%; max-width: 1480px; margin: 0 auto; outline: none; min-width: 0; }
.view.enter { animation: viewIn var(--t-slow) var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* phone shell */
@media (max-width: 899.98px) {
  :root { --pad: 16px; --top-h: 56px; }
  .app, [data-side="closed"] .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(304px, 86vw); transform: translateX(-104%);
    transition: transform var(--t-slow) var(--ease-out); box-shadow: var(--sh-4); z-index: 60; border-radius: 0 var(--r) var(--r) 0;
    padding-top: var(--safe-t);
  }
  .side.open { transform: none; }
  .side .side-collapse { display: none; }
  .top .menu-btn { display: inline-grid; margin-left: -8px; }
  .top .top-logo { display: block; }
  .top-logo .logo-mark { border-radius: 8px; }
  .top-title h1 { font-size: 18px; }
  .top-title span { display: none; }
}
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 55; opacity: 0; transition: opacity var(--t-slow) var(--ease); }
.scrim.on { opacity: 1; }

/* ---------- buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r-ctl); font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; user-select: none;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  background: var(--surface); color: var(--text); box-shadow: var(--sh-1);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 0 -1px 0 rgba(0,0,0,.08), inset 0 0 0 1px rgba(0,0,0,.04); }
.btn-primary:hover { background: var(--accent); filter: brightness(.97); }
.btn-ghost { background: var(--surface-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-text { background: transparent; box-shadow: none; padding: 0 10px; color: var(--text-2); }
.btn-text:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.btn-danger:hover { background: var(--bad-soft); filter: brightness(.97); }
.btn-danger-solid { background: var(--bad); color: #fff; box-shadow: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-sm .ico { width: 16px; height: 16px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor;
  border-color: var(--text-3) var(--text-3) var(--text-3) transparent; animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--accent-ink) var(--accent-ink) var(--accent-ink) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-ctl); color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.solid { background: var(--surface); box-shadow: var(--sh-1); }
.fab-add { width: 40px; padding: 0; }
@media (max-width: 899.98px) { .btn-add-label { display: none; } }

/* tooltips (desktop) */
@media (hover: hover) and (min-width: 900px) {
  [data-tip] { position: relative; }
  [data-tip]:hover::after {
    content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); z-index: 90;
    background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; padding: 5px 8px; border-radius: 7px; white-space: nowrap; pointer-events: none;
    animation: fadeIn var(--t-fast) var(--ease) .35s both;
  }
  [data-side="closed"] .side [data-tip]:hover::after { left: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- cards & grid */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.s12 { grid-column: span 12; } .s8 { grid-column: span 8; } .s7 { grid-column: span 7; } .s6 { grid-column: span 6; } .s5 { grid-column: span 5; } .s4 { grid-column: span 4; } .s3 { grid-column: span 3; }
@media (max-width: 1180px) { .s8, .s7, .s5 { grid-column: span 12; } .s4 { grid-column: span 6; } .s4.keep { grid-column: span 4; } }
@media (max-width: 760px) { .grid { gap: 12px; } .s6, .s4, .s4.keep, .s3 { grid-column: span 12; } }

.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-2); min-width: 0; display: flex; flex-direction: column; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 4px; min-height: 52px; }
.card-t { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.card-s { font-size: 12.5px; color: var(--text-3); }
.card-b { padding: 12px 18px 18px; flex: 1; min-width: 0; }
.card-f { padding: 12px 18px; box-shadow: 0 -1px 0 var(--line); display: flex; align-items: center; gap: 10px; }
.card-scroll { overflow-y: auto; overscroll-behavior: contain; max-height: 380px; }
.link { color: var(--text-2); font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; border-radius: 8px; }
.link:hover { color: var(--text); }
.link .ico { width: 16px; height: 16px; }

/* hero */
.hero { background: var(--hero); color: var(--hero-ink); position: relative; overflow: hidden; }
.hero .card-s, .hero .muted, .hero .faint { color: var(--hero-2); }
.hero::after { content: ""; position: absolute; right: -80px; top: -120px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(closest-side, var(--accent), transparent); opacity: .16; pointer-events: none; }
.hero-n { font-size: clamp(30px, 4.6vw, 46px); font-weight: 650; letter-spacing: -.045em; line-height: 1.05; }
.hero-n small { font-size: .5em; font-weight: 600; letter-spacing: -.02em; opacity: .7; margin-right: 6px; }
.hero-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.hero-split > div { min-width: 0; }
@media (max-width: 480px) { .hero-split { grid-template-columns: 1fr 1fr; } .hero-split > div:last-child { grid-column: span 2; padding-top: 10px; box-shadow: 0 -1px 0 var(--hero-line); } .hero-split .val { font-size: 17px; } }
.hero-split .lbl { font-size: 12.5px; color: var(--hero-2); display: flex; align-items: center; gap: 6px; }
.hero-split .val { font-size: 18px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.dotc { width: 8px; height: 8px; border-radius: 3px; flex: none; }

.bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 8px; transition: width var(--t-slow) var(--ease-out); }
.hero .bar { background: var(--hero-bar); height: 10px; }
.hero .bar > i { background: var(--accent); }
.bar.thin { height: 5px; }

/* stat strip */
.stats { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.stat { padding: 14px 18px; min-width: 0; }
.stat + .stat { box-shadow: -1px 0 0 var(--line); }
.stat .lbl { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat .val { font-size: 21px; font-weight: 650; letter-spacing: -.03em; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--text-3); }
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .stat:first-child:nth-last-child(2n+1) { grid-column: span 2; }
  .stats .stat { box-shadow: 0 1px 0 var(--line); }
  .stats .stat:nth-child(even):not(:first-child:nth-last-child(2n+1) ~ *) { box-shadow: -1px 0 0 var(--line), 0 1px 0 var(--line); }
  .stats .stat:first-child:nth-last-child(2n+1) ~ .stat:nth-child(odd) { box-shadow: -1px 0 0 var(--line), 0 1px 0 var(--line); }
  .stats .stat:only-child { grid-column: span 2; }
  .stat { padding: 12px 14px; }
  .stat .val { font-size: 18px; }
}

/* list rows (dashboard) */
.lrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-width: 0; border-radius: 10px; }
.lrow + .lrow { box-shadow: 0 -1px 0 var(--line); }
button.lrow, a.lrow { text-align: left; cursor: pointer; transition: background var(--t-fast); padding-left: 8px; padding-right: 8px; margin: 0 -8px; width: calc(100% + 16px); position: relative; }
button.lrow + .lrow, a.lrow + .lrow, .lrow + button.lrow, .lrow + a.lrow { box-shadow: none; }
button.lrow + .lrow::before, a.lrow + .lrow::before, .lrow + button.lrow::before, .lrow + a.lrow::before { content: ""; position: absolute; top: 0; left: 8px; right: 8px; height: 1px; background: var(--line); }
button.lrow:hover, a.lrow:hover { background: var(--surface-2); }
.lrow .t { overflow-wrap: anywhere; font-size: 14px; font-weight: 550; letter-spacing: -.01em; }
.lrow .s { font-size: 12.5px; color: var(--text-3); }
.lrow .a { font-size: 14px; font-weight: 600; margin-left: auto; text-align: right; }
.lrow .chev { color: var(--text-3); width: 16px; height: 16px; }
.frow { padding: 10px 0; }
.frow + .frow { box-shadow: 0 -1px 0 var(--line); }
.frow .row { flex-wrap: wrap; row-gap: 2px; }
.frow .row > span { white-space: nowrap; }
.frow .top-line { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }

/* chart */
.chart { width: 100%; height: 200px; }
.chart text { font: 500 11px var(--font); fill: var(--text-3); }
.chart .gl { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .b { fill: var(--surface-3); transition: fill var(--t-fast); }
.chart .b.on { fill: var(--accent); }
.chart g:hover .b { fill: var(--text-3); }
.chart g:hover .b.on { fill: var(--accent-strong); }

/* ---------- avatars & pills */
.av { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12.5px; font-weight: 650; letter-spacing: 0; background: var(--surface-3); color: var(--text-2); overflow: hidden; object-fit: cover; }
.av.sm { width: 26px; height: 26px; font-size: 10.5px; }
.av.lg { width: 64px; height: 64px; font-size: 20px; }
.av.xl { width: 88px; height: 88px; font-size: 28px; }
img.av { background: var(--surface-3); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.no-dot::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.acc { background: var(--accent-soft); color: var(--accent-strong); }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 7px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); max-width: 100%; overflow-wrap: anywhere; line-height: 1.35; }

/* ---------- toolbar, filters */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 16px; min-width: 0; }
.search { position: relative; flex: 1 1 240px; min-width: 0; max-width: 420px; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 18px; height: 18px; pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 36px 0 38px; border-radius: var(--r-ctl); border: 0; background: var(--surface); box-shadow: var(--sh-1); outline: none; font-size: 14.5px; }
.search input:focus { box-shadow: 0 0 0 2px var(--accent-strong); }
.search .clear { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; }
.search input::-webkit-search-cancel-button { display: none; }
.filter-btn .cnt { min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; display: grid; place-items: center; padding: 0 5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 11px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 13px; font-weight: 500; }
.chip button { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; color: var(--text-2); }
.chip button:hover { background: rgba(0,0,0,.06); color: var(--text); }
.chip .ico { width: 14px; height: 14px; }
@media (max-width: 760px) {
  .toolbar { gap: 8px; }
  .search { flex: 1 1 0; max-width: none; order: 0; }
  .toolbar .filter-btn, .toolbar [data-print], .toolbar [data-range] { order: 1; }
  .toolbar .filter-btn { width: 40px; padding: 0; }
  .toolbar .filter-btn > span:not(.cnt) { display: none; }
  .toolbar .filter-btn .cnt { position: absolute; top: -4px; right: -4px; }
  .toolbar .seg { flex: 1 1 100%; order: 2; }
  .toolbar .seg button { flex: 1; padding: 0 6px; }
}

/* segmented control with sliding thumb */
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: var(--r-ctl); background: var(--surface-3); gap: 0; min-width: 0; max-width: 100%; }
.seg button { text-overflow: clip !important; display: inline-flex; align-items: center; justify-content: center; gap: 6px; position: relative; z-index: 1; height: 34px; padding: 0 14px; border-radius: 9px; font-size: 13.5px; font-weight: 550; color: var(--text-2); white-space: nowrap; transition: color var(--t) var(--ease); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.seg button:hover { color: var(--text); }
.seg button.on { color: var(--text); }
.seg .seg-thumb { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; border-radius: 9px; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 2px 8px -2px rgba(0,0,0,.1); transition: transform var(--t-slow) var(--ease-out), width var(--t-slow) var(--ease-out); }
[data-scheme="dark"] .seg .seg-thumb { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-strong); }
.seg.block { display: flex; width: 100%; }
.seg.block button { flex: 1; }
.seg.lg button { height: 40px; }

/* ---------- tables */
.tcard { overflow: visible; }
.tbl thead th:first-child { border-top-left-radius: var(--r); }
.tbl thead th:last-child { border-top-right-radius: var(--r); }
.tbl tbody tr:last-child td:first-child, .tbl tfoot tr:last-child td:first-child { border-bottom-left-radius: var(--r); }
.tbl tbody tr:last-child td:last-child, .tbl tfoot tr:last-child td:last-child { border-bottom-right-radius: var(--r); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th { position: sticky; top: calc(var(--top-h) + var(--safe-t)); z-index: 2; background: var(--surface); text-align: left; font-size: 12.5px; font-weight: 550; color: var(--text-3); padding: 12px 14px; box-shadow: inset 0 -1px 0 var(--line); white-space: nowrap; }
.tbl td { padding: 12px 14px; box-shadow: inset 0 -1px 0 var(--line); vertical-align: middle; }
.tbl tr:last-child td { box-shadow: none; }
.tbl tbody tr { cursor: pointer; transition: background var(--t-fast); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .r { text-align: right; }
.tbl .w-date { width: 108px; }
.tbl .w-amt { width: 132px; }
.tbl .w-st { width: 118px; }
.tbl .w-sm { width: 140px; }
.tbl .t1 { font-weight: 550; letter-spacing: -.01em; overflow-wrap: anywhere; }
.tbl .t2 { font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }
.tbl td.num, .tbl td .num { font-weight: 550; }
.tbl tfoot td { font-weight: 650; background: var(--surface-2); box-shadow: inset 0 1px 0 var(--line); }
.clip-ico { display: inline-block; vertical-align: -3px; color: var(--text-3); width: 15px; height: 15px; margin-left: 4px; }

/* phone cards instead of tables */
.mlist { display: none; flex-direction: column; gap: 10px; }
.mcard { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-2); padding: 14px 14px 12px; display: block; width: 100%; text-align: left; transition: transform var(--t-fast) var(--ease); }
.mcard:active { transform: scale(.985); }
.mcard .l1 { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.mcard .l1 .t { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.mcard .l1 .a { flex: none; font-size: 15px; font-weight: 650; }
.mcard .l2 { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; margin-top: 4px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.mcard .l2 > span { min-width: 0; white-space: nowrap; }
.mcard .l2 > span:first-child { white-space: normal; overflow-wrap: anywhere; }
.mcard .l2 .sep { flex: none; }
.mcard .l3 { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; }
.mcard .l3 .bar { flex: 1; height: 5px; }
@media (max-width: 760px) {
  .tcard.has-m { display: none; }
  .mlist { display: flex; }
}

/* standalone select */
.sel { height: 40px; border: 0; border-radius: var(--r-ctl); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%238B929C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 7 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center; box-shadow: var(--sh-1); padding: 0 36px 0 12px; font-size: 14px; font-weight: 550; -webkit-appearance: none; appearance: none; max-width: 100%; min-width: 0; }
.sel.sm { height: 36px; background-color: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }

/* pager */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 4px 0; font-size: 13px; color: var(--text-3); flex-wrap: wrap; }
.pager select { height: 32px; border-radius: 9px; border: 0; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238B929C' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 8px center; box-shadow: var(--sh-1); padding: 0 28px 0 10px; font-size: 13px; font-weight: 550; color: var(--text); -webkit-appearance: none; appearance: none; }
.pager .pg { display: flex; align-items: center; gap: 4px; margin-left: auto; }

/* ---------- forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.fsec { display: flex; flex-direction: column; gap: 14px; }
.fsec-t { font-size: 12.5px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; text-transform: uppercase; margin-bottom: -4px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .flabel { font-size: 13.5px; font-weight: 550; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field > label .opt { font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface-2);
  font-size: 15.5px; outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast); min-width: 0;
  -webkit-appearance: none; appearance: none;
}
.field textarea { height: auto; min-height: 88px; padding: 11px 14px; resize: vertical; line-height: 1.45; }
.field select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%238B929C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 7 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field input[type="date"] { line-height: 44px; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-strong); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .is-err, .field input.is-err, .field select.is-err, .field textarea.is-err { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field-err { font-size: 12.5px; color: var(--bad); min-height: 0; font-weight: 500; }
.field-err:empty { display: none; }
.hint { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
.form-err { padding: 10px 12px; border-radius: var(--r-ctl); background: var(--bad-soft); color: var(--bad); font-size: 13.5px; font-weight: 500; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-right: 46px !important; }
.input-btn { position: absolute; right: 4px; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); }
.input-btn:hover { background: var(--surface-3); color: var(--text); }
.money { position: relative; }
.money > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 14px; font-weight: 600; color: var(--text-3); pointer-events: none; }
.money input { padding-left: 44px !important; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.money.big input { height: 56px !important; font-size: 24px !important; letter-spacing: -.02em; }
.money.big > span { font-size: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: 1.2fr .8fr 1fr; gap: 12px; }
@media (max-width: 420px) { .three { grid-template-columns: 1fr 1fr; } .three > :first-child { grid-column: span 2; } }
.qchips { display: flex; gap: 6px; flex-wrap: wrap; }
.qchip { height: 30px; padding: 0 11px; border-radius: 9px; background: var(--surface-3); font-size: 13px; font-weight: 550; color: var(--text-2); transition: background var(--t-fast), color var(--t-fast); }
.qchip:hover { color: var(--text); }
.qchip.on { background: var(--accent); color: var(--accent-ink); }
.calc { padding: 10px 12px; border-radius: var(--r-ctl); background: var(--surface-2); font-size: 13px; color: var(--text-2); display: flex; justify-content: space-between; gap: 10px; }

/* choice cards (kind picker) */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { display: flex; flex-direction: column; justify-content: flex-start; text-align: left; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow var(--t-fast), background var(--t-fast); min-width: 0; }
.choice button b { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.choice button span { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 3px; line-height: 1.35; }
.choice button .rd { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-strong); flex: none; transition: box-shadow var(--t-fast); }
.choice button.on { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent-strong); }
.choice button.on .rd { box-shadow: inset 0 0 0 5px var(--accent-strong); }

/* toggle */
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: var(--line-strong); transition: background var(--t) var(--ease); }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--t) var(--ease-out); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* checkbox day picker */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; }
.days span { display: grid; place-items: center; height: 38px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all var(--t-fast); }
.days input:checked + span { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.days input:focus-visible + span { outline: 2px solid var(--accent-strong); }

/* ---------- settings-style lists */
.slist { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-2); overflow: hidden; }
.slist-h { font-size: 12.5px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; text-transform: uppercase; padding: 0 4px 8px; }
.srow { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 16px; width: 100%; text-align: left; position: relative; }
.srow + .srow::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
button.srow, a.srow, label.srow { cursor: pointer; transition: background var(--t-fast); }
button.srow:hover, a.srow:hover, label.srow:hover { background: var(--surface-2); }
.srow .si { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.srow .si .ico { width: 18px; height: 18px; }
.srow .st { flex: 1; min-width: 0; }
.srow .st b { display: block; font-size: 14.5px; font-weight: 550; letter-spacing: -.01em; }
.srow .st small { display: block; font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }
.srow .sv { font-size: 14px; color: var(--text-3); white-space: nowrap; }
.srow .chev { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.srow.danger { color: var(--bad); }
.srow.danger .si { background: var(--bad-soft); color: var(--bad); }

/* accordion */
.acc { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-2); overflow: hidden; }
.acc + .acc { margin-top: 12px; }
.acc > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; user-select: none; transition: background var(--t-fast); }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary:hover { background: var(--surface-2); }
.acc > summary .chev { margin-left: auto; width: 18px; height: 18px; color: var(--text-3); transition: transform var(--t) var(--ease); }
.acc[open] > summary .chev { transform: rotate(180deg); }
.acc > summary small { font-weight: 500; color: var(--text-3); font-size: 12.5px; }
.acc-b { padding: 4px 16px 16px; }
.acc.flat { background: var(--surface-2); box-shadow: none; }
.acc.flat > summary:hover { background: var(--surface-3); }

/* ---------- sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 70; }
.sheet-dim { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity var(--t-slow) var(--ease); }
.sheet {
  position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(540px, calc(100vw - 20px)); display: flex; flex-direction: column;
  background: var(--bg); border-radius: calc(var(--r) + 4px); box-shadow: var(--sh-4); transform: translateX(calc(100% + 24px));
  transition: transform var(--t-slow) var(--ease-out); overflow: hidden; outline: none;
}
.sheet.narrow { width: min(440px, calc(100vw - 20px)); }
.sheet-wrap.on .sheet-dim { opacity: 1; }
.sheet-wrap.on .sheet { transform: none; }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 14px; min-height: 60px; flex: none; background: var(--bg); position: relative; z-index: 2; }
.sheet-h.scrolled { box-shadow: 0 1px 0 var(--line); }
.sheet-h h2 { font-size: 17px; font-weight: 650; letter-spacing: -.025em; flex: 1; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; line-height: 1.25; }
.sheet-b { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 4px 18px 24px; -webkit-overflow-scrolling: touch; }
.sheet-f { flex: none; display: flex; gap: 10px; padding: 12px 18px calc(12px + var(--safe-b)); background: var(--bg); box-shadow: 0 -1px 0 var(--line); }
.sheet-f .btn { flex: 1; }
.sheet-f .btn.icon-only { flex: none; width: 48px; padding: 0; }
.sheet-swap { animation: swapIn var(--t) var(--ease-out); }
.sheet-swap.back { animation: swapBack var(--t) var(--ease-out); }
@keyframes swapIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes swapBack { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) {
  .sheet, .sheet.narrow { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; padding-top: var(--safe-t); }
  .sheet-b { padding: 4px 16px 24px; }
  .sheet-f { padding: 12px 16px calc(12px + var(--safe-b)); }
  .sheet.bottom { top: auto; height: auto; max-height: 88vh; max-height: 88dvh; border-radius: calc(var(--r) + 4px) calc(var(--r) + 4px) 0 0; transform: translateY(100%); padding-top: 0; }
  .sheet-wrap.on .sheet.bottom { transform: none; }
  .sheet.bottom::before { content: ""; position: absolute; top: 6px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line-strong); z-index: 3; }
}

/* detail blocks inside sheets */
.dhero { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-2); padding: 18px; }
.dhero .k { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.dhero .big { font-size: 34px; font-weight: 650; letter-spacing: -.04em; line-height: 1.1; margin: 2px 0 12px; }
.dhero .big.okc { color: var(--ok); }
.dgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.dgrid > div { min-width: 0; }
.dgrid .k { font-size: 12px; }
.dgrid .v { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.dsec { margin-top: 18px; }
.dsec-h { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; }
.dsec-h h3 { font-size: 13px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; text-transform: uppercase; flex: 1; }
.kv { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 10px 14px; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; color: var(--text-2); line-height: 1.5; }
.actions-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.actions-row .btn { flex: 1 1 auto; }
.mini-list { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-2); overflow: hidden; }
.mini-list .mrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-width: 0; width: 100%; text-align: left; position: relative; }
.mini-list .mrow + .mrow::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
.mini-list button.mrow { cursor: pointer; transition: background var(--t-fast); }
.mini-list button.mrow:hover { background: var(--surface-2); }
.mrow .mi { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.mrow .mi.ok { background: var(--ok-soft); color: var(--ok); }
.mrow .mi.warn { background: var(--warn-soft); color: var(--warn); }
.mrow .mi.bad { background: var(--bad-soft); color: var(--bad); }
.mrow .mi .ico { width: 18px; height: 18px; }
.mrow .mt { flex: 1; min-width: 0; }
.mrow .mt b { display: block; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.mrow .mt small { display: block; font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }
.mrow .ma { font-weight: 600; font-size: 14px; text-align: right; }
.mrow .ma small { display: block; font-weight: 500; font-size: 12px; color: var(--text-3); }
.empty-mini { padding: 18px; text-align: center; font-size: 13.5px; color: var(--text-3); }

/* menu popover */
.menu-pop { position: fixed; z-index: 95; min-width: 220px; max-width: calc(100vw - 24px); background: var(--surface); border-radius: var(--r-ctl); box-shadow: var(--sh-3); padding: 6px; animation: popIn var(--t-fast) var(--ease-out); transform-origin: top right; max-height: 70vh; overflow-y: auto; }
.menu-pop button, .menu-pop a { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 9px; font-size: 14px; font-weight: 500; text-align: left; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); }
.menu-pop .ico { width: 18px; height: 18px; color: var(--text-3); }
.menu-pop .danger { color: var(--bad); }
.menu-pop .danger .ico { color: var(--bad); }
.menu-pop hr { border: 0; height: 1px; background: var(--line); margin: 6px 4px; }
.menu-pop .on { background: var(--surface-2); font-weight: 600; }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }

/* confirm dialog */
.dlg-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.dlg-wrap .sheet-dim { opacity: 1; animation: fadeIn var(--t) var(--ease); }
.dlg { position: relative; width: min(400px, 100%); background: var(--surface); border-radius: calc(var(--r) + 4px); box-shadow: var(--sh-4); padding: 22px; animation: dlgIn var(--t-slow) var(--ease-out); }
.dlg h3 { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.dlg p { margin-top: 6px; font-size: 14px; color: var(--text-2); }
.dlg .dlg-b { display: flex; gap: 10px; margin-top: 20px; }
.dlg .dlg-b .btn { flex: 1; }
.dlg .field { margin-top: 14px; }
@keyframes dlgIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

/* toasts */
.toasts { position: fixed; z-index: 110; right: 20px; bottom: calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 8px 8px 14px; max-width: min(440px, calc(100vw - 32px)); border-radius: 14px; background: var(--text); color: var(--bg); box-shadow: var(--sh-4); font-size: 14px; font-weight: 500; animation: toastIn var(--t-slow) var(--ease-out); }
.toast.out { animation: toastOut var(--t) var(--ease) forwards; }
.toast .ico { width: 20px; height: 20px; flex: none; }
.toast .tic.ok { color: var(--ok); }
.toast .tic.bad { color: #FF8A8A; }
.toast .tt { flex: 1; min-width: 0; padding-right: 6px; }
.toast .tt small { display: block; opacity: .7; font-size: 12.5px; font-weight: 400; }
.toast button { height: 32px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 13.5px; background: rgba(127,127,127,.22); color: inherit; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
@media (max-width: 760px) { .toasts { left: 16px; right: 16px; align-items: stretch; } .toast { max-width: none; } }

/* ---------- skeletons, empty, banners */
.sk { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: shimmer 1.3s infinite; }
[data-scheme="dark"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; }
.sk-card { height: 120px; border-radius: var(--r); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 20px; gap: 8px; }
.empty .ei { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); margin-bottom: 6px; }
.empty .ei .ico { width: 26px; height: 26px; }
.empty h3 { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.empty p { color: var(--text-2); font-size: 14px; max-width: 380px; }
.empty .btn { margin-top: 10px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--text); margin-bottom: 16px; font-size: 14px; }
.banner .ico { color: var(--info); }
.banner .grow b { font-weight: 600; }
.banner.warn { background: var(--warn-soft); } .banner.warn .ico { color: var(--warn); }

/* ---------- uploads */
.drop { border-radius: var(--r-ctl); border: 1.5px dashed var(--line-strong); padding: 14px; display: flex; flex-direction: column; gap: 12px; transition: border-color var(--t-fast), background var(--t-fast); }
.drop.over { border-color: var(--accent-strong); background: var(--accent-soft); }
.drop-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.drop-btns .btn { flex: 1 1 120px; }
.drop .hint { text-align: center; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
.thumb > button.open { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .pdf { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; font-size: 11px; font-weight: 600; color: var(--text-2); text-align: center; }
.thumb .pdf .ico { width: 26px; height: 26px; color: var(--bad); }
.thumb .pdf span { max-width: 100%; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.thumb .rm { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; z-index: 2; }
.thumb .rm .ico { width: 14px; height: 14px; }
.thumb .prog { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 4px; border-radius: 3px; background: rgba(0,0,0,.25); overflow: hidden; }
.thumb .prog i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.thumb.err { box-shadow: inset 0 0 0 2px var(--bad); }

/* ---------- lightbox */
.lb { position: fixed; inset: 0; z-index: 120; background: rgb(8, 9, 11); display: flex; flex-direction: column; animation: fadeIn var(--t) var(--ease); touch-action: none; }
.lb-top { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; color: #fff; flex: none; }
.lb-top .cap { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; opacity: .85; }
.lb .icon-btn { color: #fff; background: rgba(255,255,255,.1); }
.lb .icon-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.lb-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 8px 64px calc(16px + var(--safe-b)); }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; user-select: none; -webkit-user-drag: none; transition: transform var(--t) var(--ease-out); cursor: zoom-in; touch-action: none; }
.lb-stage img.zoomed { cursor: grab; transition: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px !important; height: 48px !important; border-radius: 50% !important; z-index: 2; }
.lb-nav.prev { left: 10px; } .lb-nav.next { right: 10px; }
.lb-count { font-size: 13px; color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; padding: 0 6px; }
@media (max-width: 760px) { .lb-stage { padding: 8px 8px calc(76px + var(--safe-b)); } .lb-nav { top: auto; bottom: calc(14px + var(--safe-b)); transform: none; } .lb-nav.prev { left: calc(50% - 64px); } .lb-nav.next { right: calc(50% - 64px); } }

/* ---------- pull to refresh */
.ptr { position: fixed; left: 50%; top: calc(var(--top-h) + var(--safe-t) + 6px); width: 38px; height: 38px; margin-left: -19px; border-radius: 50%; background: var(--surface); box-shadow: var(--sh-3); display: grid; place-items: center; z-index: 25; opacity: 0; transform: translateY(-50px) scale(.6); pointer-events: none; }
.ptr span { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--accent-strong); border-right-color: transparent; }
.ptr.spin span { animation: spin .7s linear infinite; }
.ptr.back { transition: transform var(--t-slow) var(--ease-out), opacity var(--t-slow); }

/* ---------- calendar */
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head h3 { font-size: 17px; font-weight: 650; letter-spacing: -.02em; flex: 1; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.cal .dn { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-3); padding-bottom: 4px; }
.cal .d { position: relative; min-height: 76px; border-radius: 12px; padding: 7px 8px; text-align: left; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 2px; transition: transform var(--t-fast), box-shadow var(--t-fast); min-width: 0; }
.cal button.d:hover { box-shadow: inset 0 0 0 1.5px var(--text-3); }
.cal button.d:active { transform: scale(.96); }
.cal .d .dd { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal .d .ds { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; margin-top: auto; }
.cal .d .ds .ico { width: 14px; height: 14px; stroke-width: 2.4; }
.cal .d .dl { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.cal .d .dl .ico { width: 12px; height: 12px; }
.cal .d .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; margin-top: auto; }
.cal .d.work { background: var(--ok-soft); box-shadow: inset 0 0 0 1px transparent; }
.cal .d.work .ds { color: #fff; background: var(--ok); }
.cal .d.off { background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, var(--surface-2) 6px 12px); }
.cal .d.off .ds { color: var(--text-2); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.cal .d.closed-ov .ds { color: #fff; background: var(--bad); box-shadow: none; }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--accent-strong); }
.cal .d.future, .cal .d.before { opacity: .45; }
.cal .d.blank { background: transparent; box-shadow: none; }
.cal .d .note-dot { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--info); }
@media (max-width: 560px) { .cal { gap: 4px; } .cal .d { min-height: 56px; padding: 5px; border-radius: 10px; align-items: center; } .cal .d .dl { display: none; } .cal .d .dd { font-size: 13px; } .cal .d .foot { justify-content: center; } .cal .d .ds { width: 18px; height: 18px; } .cal .d .note-dot { top: 5px; right: 5px; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* ---------- matrix report */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.matrix th, .matrix td { padding: 10px 12px; box-shadow: inset 0 -1px 0 var(--line); text-align: right; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); white-space: normal; min-width: 140px; }
.matrix thead th { font-size: 12.5px; color: var(--text-3); font-weight: 550; }
.matrix tfoot td, .matrix .tot { font-weight: 650; background: var(--surface-2) !important; }
.matrix td.z { color: var(--text-3); }
.mx-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.fcards { display: none; flex-direction: column; gap: 10px; }
@media (max-width: 760px) { .mx-card { display: none; } .fcards { display: flex; } }

/* ---------- theme picker */
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tpick { border-radius: var(--r-ctl); padding: 8px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); text-align: left; transition: box-shadow var(--t-fast); min-width: 0; }
.tpick.on { box-shadow: inset 0 0 0 2px var(--accent-strong); }
.tpick .pv { height: 64px; border-radius: 9px; display: grid; grid-template-columns: 30% 1fr; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.tpick .pv i { display: block; }
.tpick .pv .pv-m { padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.tpick .pv .pv-m span { display: block; height: 7px; border-radius: 4px; }
.tpick b { display: block; font-size: 13.5px; font-weight: 600; margin-top: 8px; padding: 0 2px; }
.tpick small { display: block; font-size: 12px; color: var(--text-3); padding: 0 2px 2px; }

/* profile */
.prof { display: flex; flex-direction: row; align-items: center; gap: 16px; padding: 18px; }
.prof .av-wrap { position: relative; }
.prof .av-edit { position: absolute; right: -4px; bottom: -4px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 0 0 3px var(--surface); }
.prof .av-edit .ico { width: 16px; height: 16px; }
.prof h2 { font-size: 20px; font-weight: 650; letter-spacing: -.03em; overflow-wrap: anywhere; }

/* page sections */
.sec-gap { margin-top: 16px; }
.page-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .page-cols { grid-template-columns: minmax(0, 1fr); } }
.narrow-page { max-width: 760px; }

/* ---------- auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 20px; }
.auth { width: min(420px, 100%); }
.auth-card { padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-brand .logo-mark { border-radius: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.auth-brand b { display: block; font-size: 22px; font-weight: 650; letter-spacing: -.035em; }
.auth-brand span { display: block; font-size: 13.5px; color: var(--text-3); }
.auth form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-3); margin-top: 16px; }
.shake { animation: shake .35s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* setup wizard */
.wiz { max-width: 560px; margin: 4vh auto 0; }
.wiz-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.wiz-steps i { flex: 1; height: 4px; border-radius: 3px; background: var(--surface-3); transition: background var(--t); }
.wiz-steps i.on { background: var(--accent-strong); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .app, #sheets, .toasts, .lb { display: none !important; }
}
