/* Slips design system. Phone-first, light+dark via CSS vars, WCAG AA. */

:root {
  /* series palette — fixed slots; categories & people get permanent slots */
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100;
  --s5:#e87ba4; --s6:#008300; --s7:#4a3aa7; --s8:#e34948;
  --surface:#fcfcfb; --surface2:#f9f9f7; --card:#ffffff;
  --ink:#0b0b0b; --ink2:#52514e; --ink3:#898781;
  --grid:#e1e0d9; --border:#e1e0d9;
  --good:#006300; --bad:#d03b3b; --dim:#c3c2b7;
  --accent:#2a78d6; --accent-ink:#ffffff;
  --shadow:0 1px 3px rgba(0,0,0,.07), 0 4px 14px rgba(0,0,0,.05);
  --radius:14px; --radius-sm:9px;
  --tabbar-h:56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
    --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
    --surface:#1a1a19; --surface2:#0d0d0d; --card:#232322;
    --ink:#ffffff; --ink2:#c3c2b7; --ink3:#898781;
    --grid:#2c2c2a; --border:#2c2c2a;
    --good:#0ca30c; --bad:#d03b3b; --dim:#52514e;
    --accent:#3987e5;
    --shadow:0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over component display rules (e.g. .snackbar sets
   display:flex, which would otherwise keep the empty toast bar visible). */
[hidden] { display: none !important; }
/* Honour the user's OS/browser text-size (iOS Dynamic Type): root font from the system
   body style, ramp expressed in rem so every screen scales. No text-size-adjust:100%,
   which would pin sizes. */
html { font-size: 100%; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
body {
  margin: 0; background: var(--surface2); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem; line-height: 1.45;
  overscroll-behavior-y: none;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3 { margin: 0 0 .4em; }
h1 { font-size: 1.375rem; font-weight: 650; }
h2 { font-size: 0.9375rem; font-weight: 600; }
.muted { color: var(--ink2); } .small { font-size: 0.8125rem; } .faint { color: var(--ink3); }
.tnum { font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* app bar */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--surface2) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.appbar-title { font-size: 20px; font-weight: 650; }
.appbar-actions { display: flex; gap: 10px; align-items: center; }

/* avatar — fixed hue slots */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 650; font-size: 15px; text-transform: uppercase;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.hue-0{background:var(--s1)} .hue-1{background:var(--s2)} .hue-2{background:var(--s3)}
.hue-3{background:var(--s4)} .hue-4{background:var(--s5)} .hue-5{background:var(--s6)}
.hue-6{background:var(--s7)} .hue-7{background:var(--s8)}

/* layout */
.page { padding: 4px 16px 24px; max-width: 720px; margin: 0 auto; }
@media (min-width: 900px) { .page.wide { max-width: 1080px; } }
.stack > * + * { margin-top: 14px; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; border: 1px solid var(--border); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }
.section-title .scope { font-size: 12px; color: var(--ink3); }

/* buttons — 44px tap targets */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink); font-size: 16px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }

/* forms */
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin-bottom: 5px; }
/* Style all text-like inputs — including bare <input> with no type= attribute
   (a plain input[type] selector misses those, leaving them white in dark mode). */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field-row { display: flex; gap: 10px; } .field-row > * { flex: 1; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px;
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font-size: 14px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .x { font-weight: 700; opacity: .7; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-row.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chip-row.scroll::-webkit-scrollbar { display: none; }

/* segmented control (currency scope) */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg a { min-height: 32px; padding: 3px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; color: var(--ink2); }
.seg a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* lists */
.rowlist { display: flex; flex-direction: column; }
.rowitem {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.rowitem:last-child { border-bottom: 0; }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* store logos */
.logo { width: 28px; height: 28px; border-radius: 7px; object-fit: contain; background: #fff; flex: none; }
.logo.lg { width: 44px; height: 44px; border-radius: 10px; }

/* hero + KPI */
.hero-amount { font-size: 2.125rem; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.kpi-row { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 4px 16px; scrollbar-width: none; }
.kpi-row::-webkit-scrollbar { display: none; }
.kpi { scroll-snap-align: start; flex: none; min-width: 128px; }
.kpi .v { font-size: 1.375rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 0.75rem; color: var(--ink2); }
.delta { font-size: 13px; font-weight: 600; }

/* proportional bars in lists */
.minibar { height: 5px; border-radius: 3px; background: var(--surface); overflow: hidden; margin-top: 5px; }
.minibar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }

/* charts */
.chart-box { position: relative; }
.chart-box canvas { max-width: 100%; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; align-items: center; }
.chart-legend .li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .dot { width: 10px; height: 10px; border-radius: 3px; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 20; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 12px; font-size: 13px; opacity: 0; transition: opacity .1s;
}
details.tabletwin summary { font-size: 13px; color: var(--ink2); cursor: pointer; margin-top: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; color: var(--ink2); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }

/* alerts, badges, banners */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 550; }
.alert-error { background: color-mix(in srgb, var(--bad) 12%, var(--card)); color: var(--bad); }
.alert-warn { background: color-mix(in srgb, var(--s4) 14%, var(--card)); }
.alert-info { background: color-mix(in srgb, var(--s1) 10%, var(--card)); }
.badge { display: inline-flex; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; align-items: center; justify-content: center; }
.dot-unreviewed { width: 8px; height: 8px; border-radius: 50%; background: var(--s2); display: inline-block; }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.66rem; font-weight: 600; color: var(--ink3); position: relative; }
.tab svg { width: 24px; height: 24px; fill: currentColor; stroke: currentColor; }
.tab.on { color: var(--accent); }
.tab-badge { position: absolute; top: 4px; right: calc(50% - 20px); z-index: 1;
  min-width: 17px; height: 17px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.tab-add-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; margin-top: -18px;
  box-shadow: var(--shadow);
}
.tab-add-btn svg { width: 22px; height: 22px; stroke: #fff; }

/* snackbar w/ undo */
.snackbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 60; background: var(--ink); color: var(--surface);
  border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); font-size: 14px; font-weight: 550;
}
.snackbar button { background: none; border: 0; color: var(--s1); font-weight: 700; font-size: 14px; cursor: pointer; padding: 6px; }

/* login */
.page-login { display: flex; align-items: center; justify-content: center; min-height: 85dvh; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card .login-logo { font-size: 52px; }
.login-card form { text-align: left; margin-top: 18px; }

/* empty states */
.empty { text-align: center; padding: 42px 20px; color: var(--ink2); }
.empty .glyph { font-size: 44px; margin-bottom: 8px; }
.empty .cta { margin-top: 16px; }

/* utility */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hstack { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt0{margin-top:0}.mt8{margin-top:8px}.mt16{margin-top:16px}.mt24{margin-top:24px}
.cb-inline { width: auto; min-height: auto; }
.print-only { display: none; }
@media print {
  .tabbar, .appbar, .no-print { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; padding: 0; }
  canvas { display: none !important; }
  details.tabletwin { open: true; }
  details.tabletwin summary { display: none; }
}
