/* ExpenseHub
   Warm paper surfaces, deep-green brand, ink-dark hero. System fonts only.
   Light + dark themes follow the device setting. */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --sunken: #eeece5;
  --line: #e6e3da;
  --line-strong: #d3cfc3;
  --ink: #16191d;
  --ink-2: #474c55;
  --ink-3: #6b707a;

  --brand: #0d6b55;
  --brand-hover: #0a5a47;
  --brand-ink: #ffffff;
  --brand-soft: #e1f0e9;
  --mint: #3cc29c;
  --mint-ink: #04271d;
  --focus: #0d6b55;

  --warn: #8f5500;
  --warn-soft: #fcefd6;
  --danger: #b3321f;
  --danger-soft: #fbe7e2;
  --up: #b3321f;
  --up-soft: #fbe7e2;
  --down: #0d6b55;
  --down-soft: #e1f0e9;

  --side-bg: #0f1513;
  --side-ink: #a5b1ab;
  --side-ink-strong: #f2f5f3;
  --side-hover: #18211e;
  --side-active: #1e2b26;
  --side-line: #1d2724;

  --hero-bg: radial-gradient(120% 160% at 0% 0%, #1d4136 0%, #12211c 45%, #0e1613 100%);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-1: 0 1px 2px rgba(22, 25, 29, 0.05);
  --shadow-2: 0 12px 32px -14px rgba(22, 25, 29, 0.22), 0 2px 6px rgba(22, 25, 29, 0.05);
  --shadow-3: 0 28px 70px -24px rgba(10, 18, 15, 0.45), 0 4px 14px rgba(10, 18, 15, 0.08);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c100f;
    --surface: #141a18;
    --surface-2: #19201d;
    --sunken: #1e2623;
    --line: #252e2b;
    --line-strong: #34403b;
    --ink: #edf1ef;
    --ink-2: #b4bdb8;
    --ink-3: #8a948f;

    --brand: #2fb38e;
    --brand-hover: #3cc29c;
    --brand-ink: #04241b;
    --brand-soft: #13302a;
    --focus: #3cc29c;

    --warn: #f1b75c;
    --warn-soft: #32260f;
    --danger: #ff8b77;
    --danger-soft: #391c17;
    --up: #ff9a87;
    --up-soft: #391c17;
    --down: #5fd3b0;
    --down-soft: #13302a;

    --side-bg: #090c0b;
    --side-hover: #131a17;
    --side-active: #18231f;
    --side-line: #161e1b;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
    --shadow-3: 0 30px 70px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

/* ---- category tints (one variable set per colour) ---- */
.tint-blue   { --c: #2f6bd8; --c-soft: #e8effc; --c-ink: #1d4fa6; }
.tint-teal   { --c: #0f9488; --c-soft: #dff3f0; --c-ink: #0b6a61; }
.tint-amber  { --c: #d58a00; --c-soft: #fcf0d9; --c-ink: #875500; }
.tint-rose   { --c: #d6456a; --c-soft: #fbe7ec; --c-ink: #a3284a; }
.tint-violet { --c: #7656e8; --c-soft: #eeeafd; --c-ink: #5536c2; }
.tint-green  { --c: #3d9a3d; --c-soft: #e5f3e3; --c-ink: #296d29; }
.tint-orange { --c: #e5622b; --c-soft: #fde9de; --c-ink: #a84012; }
.tint-slate  { --c: #66707d; --c-soft: #edeff2; --c-ink: #444e5a; }
@media (prefers-color-scheme: dark) {
  .tint-blue   { --c: #6b9bff; --c-soft: #17223a; --c-ink: #abc4ff; }
  .tint-teal   { --c: #34c3b4; --c-soft: #0f2f2b; --c-ink: #8fe2d8; }
  .tint-amber  { --c: #f2b13c; --c-soft: #32260f; --c-ink: #f6cd84; }
  .tint-rose   { --c: #ff7a9c; --c-soft: #391a24; --c-ink: #ffb2c5; }
  .tint-violet { --c: #a08bff; --c-soft: #231e3c; --c-ink: #cabdff; }
  .tint-green  { --c: #6cc96c; --c-soft: #152f19; --c-ink: #a9e3a9; }
  .tint-orange { --c: #ff8a57; --c-soft: #392014; --c-ink: #ffbc9c; }
  .tint-slate  { --c: #9aa5b3; --c-soft: #222930; --c-ink: #c8d0d9; }
}

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
svg { flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 200;
  padding: 10px 14px; border: 0; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg); font-weight: 600; cursor: pointer;
}
.skip-link:focus { top: 12px; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--ink); }
.brand-company { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-bg { fill: var(--brand); }
.logo-paper { fill: #ffffff; }
.logo-ink { fill: none; stroke: #0d6b55; stroke-width: 1.7; stroke-linecap: round; }
.logo-lane { fill: none; stroke: rgba(255, 255, 255, 0.75); stroke-width: 2; stroke-linecap: round; }
.sidebar .logo-bg, .auth-aside .logo-bg { fill: var(--mint); }
.sidebar .logo-lane, .auth-aside .logo-lane { stroke: rgba(4, 39, 29, 0.55); }

/* ---- buttons ---- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px;
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(13, 107, 85, 0.25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-1); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.94); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-mint { background: var(--mint); color: var(--mint-ink); }
.btn-mint:hover:not(:disabled) { background: #52d0ac; }
.btn-block { width: 100%; }
.btn-lg { height: 48px; font-size: 15px; border-radius: 12px; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(22, 25, 29, 0.25); border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-busy::after, .btn-danger.is-busy::after { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
  cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.is-busy { opacity: 0.5; pointer-events: none; }
.icon-btn-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.link-btn { padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--brand); font-weight: 600; font-size: 14px; cursor: pointer; }
.link-btn:hover { background: var(--brand-soft); }
.link-danger { color: var(--danger); }
.link-danger:hover { background: var(--danger-soft); }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 16px;
  background: var(--side-bg); color: var(--side-ink);
}
.sidebar .brand { padding: 0 8px; }
.sidebar .brand-name { color: var(--side-ink-strong); }
.sidebar .brand-company { color: var(--side-ink); }
.nav { display: grid; gap: 2px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--side-ink); text-decoration: none; font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--side-hover); color: var(--side-ink-strong); }
.nav-link[aria-current="page"] { background: var(--side-active); color: var(--side-ink-strong); }
.nav-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--mint);
}
.nav-link[aria-current="page"] svg { color: var(--mint); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 14px 8px 0; border-top: 1px solid var(--side-line); }
.sidebar-user { flex: 1; font-size: 13px; }
.sidebar-icon { color: var(--side-ink); }
.sidebar-icon:hover:not(:disabled) { background: var(--side-hover); color: var(--side-ink-strong); }
.workspace { min-width: 0; }
.view { max-width: 1140px; margin: 0 auto; padding: 34px 40px 72px; outline: none; }
.topbar, .tabbar { display: none; }

.view.is-entering > *, .view.is-entering .dash-grid > * { animation: rise 0.38s var(--ease) both; }
.view.is-entering > :nth-child(2) { animation-delay: 0.03s; }
.view.is-entering > :nth-child(3) { animation-delay: 0.06s; }
.view.is-entering .dash-grid > :nth-child(2) { animation-delay: 0.05s; }
.view.is-entering .dash-grid > :nth-child(3) { animation-delay: 0.09s; }
.view.is-entering .dash-grid > :nth-child(4) { animation-delay: 0.13s; }

/* ---- page header ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-title { font-family: var(--font-display); font-size: 30px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; }
.page-subtitle { margin-top: 4px; color: var(--ink-3); font-size: 15px; }
.page-actions { display: flex; gap: 10px; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 650; letter-spacing: -0.005em; }
.card-meta { font-size: 13px; color: var(--ink-3); }
.card-link { display: inline-flex; align-items: center; gap: 2px; font-size: 13.5px; font-weight: 600; text-decoration: none; color: var(--brand); border-radius: 6px; }
.card-link:hover { text-decoration: underline; }
.card-text { color: var(--ink-2); font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-divider { height: 1px; background: var(--line); margin: 20px 0 14px; }

/* ---- dashboard ---- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.dash-grid > .hero { grid-column: 1 / -1; }
.dash-grid > :nth-child(2) { grid-column: span 7; }
.dash-grid > :nth-child(3) { grid-column: span 5; }
.dash-grid > :nth-child(4) { grid-column: 1 / -1; }

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 36px;
  padding: 30px 32px; border: 1px solid transparent;
  background: var(--hero-bg); color: #e9efec;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.hero .skeleton-bar { background: rgba(255, 255, 255, 0.08); animation: none; }
.hero-main { display: flex; flex-direction: column; align-items: flex-start; }
.hero-label { color: rgba(233, 239, 236, 0.72); font-weight: 500; margin-bottom: 8px; }
.hero-amount { font-family: var(--font-display); font-size: clamp(38px, 4.8vw, 54px); font-weight: 650; letter-spacing: -0.035em; line-height: 1.05; color: #fff; margin-bottom: 14px; }
.hero .delta.is-up { background: rgba(255, 140, 120, 0.15); color: #ffb4a6; }
.hero .delta.is-down { background: rgba(60, 194, 156, 0.16); color: #84e2c6; }
.hero .delta.is-flat { background: rgba(255, 255, 255, 0.08); color: #dfe7e3; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 14px 30px; width: 100%; margin: auto 0 0; padding-top: 22px; }
.hero-facts > div { min-width: 0; }
.hero-facts dt { font-size: 12.5px; color: rgba(233, 239, 236, 0.58); }
.hero-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 15.5px; color: #fff; }
.hero-chart { min-height: 210px; display: flex; }

.columns { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; align-items: stretch; }
.column { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.column-value { font-size: 12px; color: rgba(233, 239, 236, 0.6); min-height: 18px; white-space: nowrap; }
.column-track { flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.column-fill {
  width: 100%; height: calc(var(--scale, 0) * 100%); min-height: 0;
  border-radius: 10px; background: rgba(255, 255, 255, 0.2);
  transition: height 0.9s var(--ease);
}
.column.is-current .column-fill { background: linear-gradient(180deg, #6fe0bd, var(--mint)); box-shadow: 0 8px 24px -8px rgba(60, 194, 156, 0.6); }
.column.is-current .column-value { color: #fff; font-weight: 600; }
.column-label { font-size: 12.5px; color: rgba(233, 239, 236, 0.55); }
.column.is-current .column-label { color: #fff; font-weight: 600; }

.delta { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.delta.is-up { background: var(--up-soft); color: var(--up); }
.delta.is-down { background: var(--down-soft); color: var(--down); }
.delta.is-flat { background: var(--sunken); color: var(--ink-2); padding-left: 10px; }

.cat-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.cat-bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 14px; }
.cat-bar-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; min-width: 0; }
.cat-bar-amount { display: inline-flex; align-items: baseline; gap: 10px; font-weight: 600; }
.cat-bar-share { min-width: 38px; text-align: right; color: var(--ink-3); font-weight: 500; font-size: 13px; }
.cat-bar-track { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.cat-bar-fill { height: 100%; width: calc(var(--scale, 0) * 100%); border-radius: inherit; background: var(--c); transition: width 0.9s var(--ease); }

.due-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.due-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 8px 2px; }
.due-item + .due-item { border-top: 1px solid var(--line); }
.due-date { width: 46px; height: 50px; display: grid; place-content: center; text-align: center; line-height: 1.05; border-radius: 12px; background: var(--sunken); }
.due-date.is-today { background: var(--warn-soft); color: var(--warn); }
.due-day { font-size: 17px; font-weight: 700; }
.due-month { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.due-date.is-today .due-month { color: inherit; }
.due-main { display: grid; min-width: 0; }
.due-vendor { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-when { font-size: 13px; color: var(--ink-3); }
.due-amount { font-weight: 600; }

/* ---- expense rows ---- */
.expense-list { list-style: none; margin: 0; padding: 4px; }
.expense-list > li + li { border-top: 1px solid var(--line); }
.card.expense-list { padding: 4px; }
.expense-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  width: 100%; padding: 11px 12px;
  border: 0; border-radius: 12px; background: transparent; text-align: left; cursor: pointer;
  transition: background-color 0.15s;
}
.expense-row:hover { background: var(--surface-2); }
.expense-main { display: grid; min-width: 0; }
.expense-vendor { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.expense-meta { font-size: 13px; color: var(--ink-3); }
.expense-amount { font-weight: 650; }
.row-flag { display: inline-flex; color: var(--ink-3); }
.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 11px; background: var(--c-soft); color: var(--c-ink);
  font-weight: 700; font-size: 15px;
}

/* ---- toolbar & filters ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.toolbar-filters { display: flex; flex: 1; justify-content: flex-end; gap: 10px; min-width: 0; }
.period-nav { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-1); }
.period-label { min-width: 168px; padding: 0 6px; text-align: center; font-weight: 600; font-size: 14.5px; }
.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 320px; }
.search svg { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.search .search-input { padding-left: 38px; }
.select { width: auto; min-width: 180px; }
.results-summary { display: flex; justify-content: space-between; align-items: baseline; margin: 0 6px 14px; color: var(--ink-3); font-size: 14px; }
.results-summary strong { color: var(--ink); font-size: 15px; }
.day { margin-bottom: 20px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 8px; }
.day-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.day-total { font-size: 13px; color: var(--ink-3); }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--sunken); }
.segment { position: relative; }
.segment input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segment span { display: block; padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink-2); transition: background-color 0.15s, color 0.15s, box-shadow 0.15s; }
.segment:hover span { color: var(--ink); }
.segment input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(22, 25, 29, 0.12); }
.segment input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.field .segmented { display: flex; }
.field .segment { flex: 1; text-align: center; }
.field .segment span { padding-left: 6px; padding-right: 6px; }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { min-width: 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.stat-label { font-size: 13px; color: var(--ink-3); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.stat-value-sm { font-family: var(--font); font-size: 16px; font-weight: 600; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 6px; }
.stat-note { margin-top: 6px; font-size: 13px; color: var(--ink-3); }
.stat-lead { background: var(--hero-bg); border-color: transparent; color: #e9efec; box-shadow: var(--shadow-2); }
.stat-lead .stat-label { color: rgba(233, 239, 236, 0.7); }
.stat-lead .stat-value { color: #fff; font-size: 30px; margin-bottom: 10px; }
.stat-lead .delta.is-up { background: rgba(255, 140, 120, 0.15); color: #ffb4a6; }
.stat-lead .delta.is-down { background: rgba(60, 194, 156, 0.16); color: #84e2c6; }
.stat-lead .delta.is-flat { background: rgba(255, 255, 255, 0.08); color: #dfe7e3; }

/* ---- recurring ---- */
.pay-list { list-style: none; margin: 0; padding: 4px; }
.pay-row { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.pay-row + .pay-row { border-top: 1px solid var(--line); }
.pay-main {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 13px 12px; border: 0; border-radius: 12px; background: transparent; text-align: left; cursor: pointer;
  transition: background-color 0.15s;
}
.pay-main:hover { background: var(--surface-2); }
.pay-text { display: grid; min-width: 0; }
.pay-vendor { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.pay-meta { font-size: 13px; color: var(--ink-3); }
.pay-amount { display: grid; justify-items: end; font-weight: 650; }
.pay-per { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.pay-actions { display: flex; gap: 2px; }
.pay-row.is-paused .avatar, .pay-row.is-paused .pay-amount { opacity: 0.55; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); font-size: 11.5px; font-weight: 650; letter-spacing: 0.02em; white-space: nowrap; }

/* ---- reports ---- */
.report { display: grid; gap: 20px; }
.report > .stats { margin-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 10px 20px; text-align: left; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-row { cursor: pointer; transition: background-color 0.12s; }
.table-row:hover td, .table-row:focus-visible td { background: var(--surface-2); }
.table-row:focus-visible { outline-offset: -2px; }
.table tfoot th, .table tfoot td { padding: 14px 20px; background: transparent; border: 0; font-size: 14px; font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--ink); }
.table .num-col { text-align: right; white-space: nowrap; }
.cell-sub { display: block; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.show-mobile { display: none; }

/* ---- settings ---- */
.settings { display: grid; gap: 20px; max-width: 780px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-item { display: flex; align-items: center; gap: 12px; padding: 8px 2px 8px 4px; border-top: 1px solid var(--line); }
.cat-swatch { width: 14px; height: 14px; flex-shrink: 0; border-radius: 5px; background: var(--c); }
.cat-name { flex: 1; min-width: 0; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item.is-archived .cat-name, .cat-item.is-archived .cat-swatch { opacity: 0.55; }
.cat-actions { display: flex; gap: 2px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 14px; }
.facts dt { font-size: 12.5px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch-dot { display: block; width: 32px; height: 32px; border-radius: 10px; background: var(--c); transition: box-shadow 0.15s, transform 0.15s; }
.swatch:hover .swatch-dot { transform: scale(1.06); }
.swatch input:checked + .swatch-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--focus); outline-offset: 5px; }

/* ---- forms ---- */
.form { display: grid; gap: 18px; }
.form-inline { margin-top: 4px; }
.form-inline > .btn { justify-self: start; }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field { display: block; }
fieldset.field > legend { padding: 0; margin-bottom: 8px; }
fieldset.field > .field-error { margin-top: 6px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-optional { margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.field-hint { font-size: 12.5px; color: var(--ink-3); }
.field-error { font-size: 13px; color: var(--danger); font-weight: 500; }
.field-error:empty { display: none; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.form-error { padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"],
input:not([type]), select, textarea {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft) !important; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 0.8; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
input[list]::-webkit-calendar-picker-indicator { display: none !important; } /* suggestions still appear while typing */

.input-group { position: relative; }
.input-group input { padding-right: 46px; }
.input-addon { position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--ink-3); cursor: pointer; }
.input-addon:hover { background: var(--sunken); color: var(--ink); }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; pointer-events: none; }
.input-prefix input { padding-left: 32px; font-weight: 600; }

.amount-field {
  display: flex; align-items: center; gap: 8px; height: 68px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.amount-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
.field.has-error .amount-field { border-color: var(--danger); }
.amount-currency { font-size: 24px; font-weight: 600; color: var(--ink-3); }
.amount-field .amount-input {
  flex: 1; min-width: 0; height: 100%; padding: 0;
  border: 0; background: transparent; box-shadow: none !important;
  font-family: var(--font-display); font-size: 32px; font-weight: 650; letter-spacing: -0.02em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 550; color: var(--ink-2); cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip:active { transform: scale(0.97); }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip:has(input:checked) { background: var(--c-soft); border-color: var(--c); color: var(--c-ink); }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--c, var(--ink-3)); }
.chip-plain { height: 32px; padding: 0 12px; font-size: 13px; }
.quick-dates { display: flex; gap: 8px; padding-top: 25px; }

.receipt-box { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.receipt-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.receipt-text { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); }
.receipt-text strong { color: var(--ink); }
.attach-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px;
  border: 1.5px dashed var(--line-strong); border-radius: 12px; background: transparent;
  color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.attach-btn:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.attach-hint { margin-left: auto; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.receipt-img { display: block; max-width: 100%; max-height: 68vh; margin: 0 auto; border-radius: 12px; }
.receipt-pdf { display: grid; justify-items: center; gap: 10px; padding: 28px; color: var(--ink-2); }
.notice { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 13.5px; font-weight: 500; }

/* ---- dialog / sheet ---- */
.dialog { margin: 0; padding: 0; border: 0; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; background: transparent; overflow: hidden; }
.dialog[open] { display: grid; place-items: center; padding: 24px; }
.dialog::backdrop { background: rgba(9, 14, 12, 0.46); backdrop-filter: blur(3px); animation: fade 0.2s ease both; }
.dialog.is-closing::backdrop { animation: fade-out 0.18s ease both; }
.dialog-panel {
  display: flex; flex-direction: column; width: 100%; max-width: 540px; max-height: calc(100dvh - 48px);
  background: var(--surface); color: var(--ink); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  animation: pop 0.24s var(--ease) both;
}
.dialog.is-closing .dialog-panel { animation: pop-out 0.18s ease both; }
.dialog-sm .dialog-panel { max-width: 420px; }
.dialog-lg .dialog-panel { max-width: 780px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 6px 24px; }
.dialog-head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.dialog-body { padding: 12px 24px 24px; overflow-y: auto; overscroll-behavior: contain; }
.dialog-message { color: var(--ink-2); }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.foot-start { margin-right: auto; }

/* ---- feedback ---- */
.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 100; display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 32px); transform: translateX(-50%); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-radius: 12px; background: #15201c; color: #eef3f0;
  box-shadow: var(--shadow-3); font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(10px) scale(0.98);
  transition: opacity 0.2s, transform 0.28s var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast-success svg { color: var(--mint); }
.toast-error svg { color: #ff9a87; }

.empty { display: grid; justify-items: center; gap: 6px; padding: 30px 16px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 6px; border-radius: 16px; background: var(--sunken); color: var(--ink-2); }
.empty-error .empty-icon { background: var(--danger-soft); color: var(--danger); }
.empty-title { font-weight: 650; font-size: 15.5px; }
.empty-text { max-width: 44ch; margin-bottom: 8px; color: var(--ink-3); font-size: 14px; }

.skeleton { display: grid; gap: 14px; padding: 6px 0; }
.skeleton-bar { width: var(--w, 100%); height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--sunken) 25%, var(--surface-2) 50%, var(--sunken) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ---- full-page states ---- */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.boot .logo { animation: breathe 1.4s ease-in-out infinite; }
.solo { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.solo-card { display: grid; justify-items: start; gap: 14px; width: 100%; max-width: 500px; padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-2); }
.solo-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); }
.solo-icon-error { background: var(--danger-soft); color: var(--danger); }
.solo-title { font-family: var(--font-display); font-size: 22px; font-weight: 650; letter-spacing: -0.015em; }
.solo-text { color: var(--ink-2); }
.solo-list { margin: 0; padding-left: 20px; color: var(--danger); display: grid; gap: 4px; }

/* ---- sign in ---- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-aside { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 44px 52px; overflow: hidden; background: var(--hero-bg); color: #e9efec; }
.auth-aside .brand-name { color: #fff; }
.auth-aside .brand-company { color: rgba(233, 239, 236, 0.65); }
.auth-pitch { position: relative; z-index: 1; max-width: 520px; padding-bottom: 150px; }
.auth-pitch-title { font-family: var(--font-display); font-size: clamp(34px, 3.6vw, 50px); font-weight: 650; line-height: 1.05; letter-spacing: -0.035em; color: #fff; margin-bottom: 18px; }
.auth-pitch-text { max-width: 44ch; font-size: 16.5px; color: rgba(233, 239, 236, 0.7); }
.auth-lines { position: absolute; left: -10%; right: -10%; bottom: -24px; display: grid; gap: 20px; transform: rotate(-6deg); opacity: 0.45; }
.auth-lines span { display: block; height: 3px; border-radius: 3px; background: repeating-linear-gradient(90deg, rgba(60, 194, 156, 0.55) 0 46px, transparent 46px 92px); background-size: 92px 3px; animation: drive 3.2s linear infinite; }
.auth-lines span:nth-child(2n) { animation-duration: 4.4s; opacity: 0.6; }
.auth-lines span:nth-child(3n) { animation-duration: 5.6s; opacity: 0.35; }
.auth-main { display: grid; place-items: center; padding: 32px 24px; }
.auth-form { display: grid; gap: 18px; width: 100%; max-width: 380px; }
.auth-mobile-brand { display: none; margin-bottom: 10px; }
.auth-title { font-family: var(--font-display); font-size: 30px; font-weight: 650; letter-spacing: -0.025em; }
.auth-lead { margin-top: -10px; color: var(--ink-3); }
.auth-foot { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }

/* ---- responsive ---- */
@media (max-width: 1080px) {
  .dash-grid > :nth-child(2), .dash-grid > :nth-child(3) { grid-column: 1 / -1; }
  .view { padding: 30px 28px 64px; }
}

@media (max-width: 860px) {
  body { font-size: 15.5px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    min-height: 58px; padding: env(safe-area-inset-top) 12px 0 16px;
    background: var(--bg); background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .topbar-title { flex: 1; font-family: var(--font-display); font-weight: 650; font-size: 17px; }
  .view { padding: 20px 16px calc(104px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, 0.3);
  }
  .tab { display: grid; justify-items: center; gap: 2px; padding: 6px 0 4px; border-radius: 10px; color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 600; }
  .tab[aria-current="page"] { color: var(--brand); }
  .tab-add {
    justify-self: center; display: grid; place-items: center;
    width: 54px; height: 54px; margin-top: -22px;
    border: 0; border-radius: 18px; background: var(--brand); color: var(--brand-ink); cursor: pointer;
    box-shadow: 0 12px 26px -10px rgba(13, 107, 85, 0.7);
    transition: transform 0.15s var(--ease);
  }
  .tab-add:active { transform: scale(0.94); }
  .hide-mobile { display: none !important; }
  .show-mobile { display: block; }
  .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: 18px; }
  .page-title { font-size: 25px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 24px 20px; }
  .hero-chart { min-height: 170px; }
  .dash-grid { gap: 16px; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .stat-lead, .stat-wide { grid-column: 1 / -1; }
  .toolbar-filters { flex-basis: 100%; }
  .search { max-width: none; }
  .select { min-width: 0; width: 44%; }
  .period-nav { flex: 1; justify-content: space-between; }
  .period-label { min-width: 0; }
  .pay-actions { display: none; }
  .pay-row { padding-right: 0; }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: block; }
}

@media (max-width: 640px) {
  input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"],
  input:not([type]), select, textarea { font-size: 16px; } /* stops iOS zooming into fields */
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .table th, .table td, .table tfoot th, .table tfoot td { padding-left: 16px; padding-right: 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .quick-dates { padding-top: 0; }
  .stat-wide { grid-column: 1 / -1; }
  .stat { padding: 16px; }
  .stat-value { font-size: 22px; }
  .stat-lead .stat-value { font-size: 28px; }
  /* icon-only header buttons on phones; the label stays for screen readers */
  .page-head .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .page-head .btn { width: 42px; padding: 0; }

  .dialog[open] { place-items: end stretch; padding: 0; }
  .dialog-panel { max-width: none !important; max-height: calc(100dvh - 20px); border-radius: var(--r-xl) var(--r-xl) 0 0; animation: sheet-in 0.3s var(--ease) both; }
  .dialog.is-closing .dialog-panel { animation: sheet-out 0.18s ease both; }
  .dialog-body { padding: 8px 18px 20px; }
  .dialog-head { padding: 16px 12px 4px 18px; }
  .dialog-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
  .dialog-foot .btn { flex: 1; }
  .dialog-foot .foot-start { flex: 0 0 auto; }
}

/* ---- motion ---- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes breathe { 50% { transform: scale(0.94); opacity: 0.7; } }
@keyframes drive { to { background-position: -92px 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
