/* ============================================================
   TALLY — bold, expressive, light + dark.

   Colour rules that keep it legible rather than just loud:
   · Per-issuer accents are used as ACCENTS — a left bar, a gradient, a dot —
     never as a text or fill colour behind small copy, because a Chase navy
     and an Amex gold have wildly different contrast against the surface.
   · Semantic colour (urgency, success) always wins over issuer colour, so a
     credit dying tomorrow reads the same on every card.
   · Every token is defined for both themes; nothing is hardcoded per theme
     below the token block.
   ============================================================ */

:root {
  color-scheme: light dark;

  /* ---- light (default) ---- */
  --bg:        #f4f6f9;
  --bg-soft:   #eaeef4;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;
  --sunken:    #eef2f7;
  --line:      rgba(12, 20, 36, .09);
  --line-2:    rgba(12, 20, 36, .16);

  --text:  #0c1424;
  --muted: #55637a;
  --faint: #8593a8;
  --invert-text: #ffffff;

  --accent:      #00875a;
  --accent-soft: rgba(0, 135, 90, .12);
  --accent-ink:  #ffffff;
  --warn:        #a35b00;
  --warn-soft:   rgba(200, 120, 0, .14);
  --crit:        #c3123c;
  --crit-soft:   rgba(195, 18, 60, .10);
  --info:        #4c4ddc;
  --info-soft:   rgba(76, 77, 220, .12);

  --shadow-sm: 0 1px 2px rgba(12, 20, 36, .07), 0 1px 1px rgba(12, 20, 36, .04);
  --shadow:    0 4px 16px rgba(12, 20, 36, .09), 0 1px 3px rgba(12, 20, 36, .05);
  --shadow-lg: 0 24px 60px rgba(12, 20, 36, .22);
  --tile-ink:  #ffffff;

  /* ---- type: bigger jumps than a default scale, for the expressive look ---- */
  --fs-display: clamp(40px, 12vw, 60px);
  --fs-xl: 27px;
  --fs-lg: 19px;
  --fs-md: 15.5px;
  --fs-sm: 13.5px;
  --fs-xs: 11.5px;

  --r-sm: 12px;
  --r:    18px;
  --r-lg: 26px;

  --pad: 16px;
  --maxw: 780px;
  --tabh: 64px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #080b11;
    --bg-soft:   #0d1219;
    --surface:   #141b25;
    --surface-2: #1b2431;
    --sunken:    #0b0f16;
    --line:      rgba(255, 255, 255, .09);
    --line-2:    rgba(255, 255, 255, .17);

    --text:  #eef4fb;
    --muted: #97a7ba;
    --faint: #6a7c92;
    --invert-text: #0c1424;

    --accent:      #2ee5a0;
    --accent-soft: rgba(46, 229, 160, .14);
    --accent-ink:  #04150f;
    --warn:        #ffc447;
    --warn-soft:   rgba(255, 196, 71, .14);
    --crit:        #ff6b87;
    --crit-soft:   rgba(255, 107, 135, .13);
    --info:        #9aa5ff;
    --info-soft:   rgba(154, 165, 255, .14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow:    0 6px 22px rgba(0, 0, 0, .5);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, .68);
  }
}

/* Manual override — must beat the media query in both directions. */
:root[data-theme="dark"] {
  --bg:#080b11; --bg-soft:#0d1219; --surface:#141b25; --surface-2:#1b2431; --sunken:#0b0f16;
  --line:rgba(255,255,255,.09); --line-2:rgba(255,255,255,.17);
  --text:#eef4fb; --muted:#97a7ba; --faint:#6a7c92; --invert-text:#0c1424;
  --accent:#2ee5a0; --accent-soft:rgba(46,229,160,.14); --accent-ink:#04150f;
  --warn:#ffc447; --warn-soft:rgba(255,196,71,.14);
  --crit:#ff6b87; --crit-soft:rgba(255,107,135,.13);
  --info:#9aa5ff; --info-soft:rgba(154,165,255,.14);
  --shadow-sm:0 1px 2px rgba(0,0,0,.5); --shadow:0 6px 22px rgba(0,0,0,.5); --shadow-lg:0 28px 70px rgba(0,0,0,.68);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
  transition: background .25s ease, color .25s ease;
}

h1, h2, h3 { margin: 0; font-weight: 780; letter-spacing: -.025em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.hint  { color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.opt   { color: var(--faint); font-weight: 500; font-size: var(--fs-xs); }
.good  { color: var(--accent); }
.bad   { color: var(--crit); }
.mute  { color: var(--faint); }
.pad   { padding: 4px 2px 2px; }
.warn  {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  color: var(--warn); font-size: var(--fs-sm); line-height: 1.55; font-weight: 500;
}
.warn b { font-weight: 750; }

/* ---------------------------------------------------------- buttons */
.btn {
  appearance: none; cursor: pointer;
  background: var(--surface-2);
  border: 1.5px solid var(--line-2);
  color: var(--text);
  padding: 11px 18px; border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 680; letter-spacing: -.005em;
  transition: transform .12s var(--ease), background .16s, border-color .16s, box-shadow .16s;
}
.btn:hover  { background: var(--surface); border-color: var(--text); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 780;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--text)); border-color: transparent; }
.btn-danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); background: var(--crit-soft); }
.btn-danger:hover { background: color-mix(in srgb, var(--crit) 20%, transparent); border-color: var(--crit); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: var(--fs-xs); }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.icon-btn {
  appearance: none; cursor: pointer;
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; place-items: center;
  border-radius: 50%; border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--text);
  font-size: 21px; line-height: 1; padding: 0;
  transition: transform .12s var(--ease), background .16s, border-color .16s;
}
.icon-btn:hover  { background: var(--surface-2); border-color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.linkbtn {
  appearance: none; background: none; border: 0; padding: 4px 6px;
  color: var(--faint); font-size: var(--fs-xs); cursor: pointer;
  text-decoration: underline; font-weight: 600;
}
.linkbtn:hover { color: var(--crit); }

/* ---------------------------------------------------------- fields */
.field { margin-bottom: 16px; }
.field.nomargin { margin-bottom: 0; }
.field label {
  display: block; font-size: var(--fs-xs); font-weight: 750;
  color: var(--muted); margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: .06em;
}
.field input, .field textarea, .sel {
  width: 100%; padding: 12px 14px;
  background: var(--sunken); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); outline: none; color: var(--text);
  font-weight: 550;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.field input:focus, .field textarea:focus, .sel:focus {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft); outline: none;
}
.field textarea { resize: vertical; }
.sel {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 51%, calc(100% - 13px) 51%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prefixed { position: relative; display: flex; align-items: center; }
.prefixed .prefix { position: absolute; left: 14px; color: var(--muted); pointer-events: none; font-weight: 650; }
.prefixed .prefix:not(.hidden) + input { padding-left: 28px; }

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; padding: 0;
  transition: transform .12s var(--ease);
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg); }

/* ---------------------------------------------------------- login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px; box-shadow: var(--shadow-lg);
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 28px; }
.brand img { border-radius: 13px; box-shadow: var(--shadow-sm); }
.brand h1 { font-size: var(--fs-xl); }
.brand-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 3px; }
.or { display: flex; align-items: center; gap: 14px; color: var(--faint); font-size: var(--fs-xs); margin: 20px 0 18px; font-weight: 650; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.auth-msg { margin-top: 16px; font-size: var(--fs-sm); color: var(--muted); min-height: 18px; text-align: center; }
.auth-msg.is-err { color: var(--crit); }

/* ---------------------------------------------------------- shell */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.7); -webkit-backdrop-filter: blur(18px) saturate(1.7);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: var(--maxw); margin: 0 auto;
  padding: 12px var(--pad);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar-title { display: flex; align-items: center; gap: 11px; font-size: var(--fs-lg); font-weight: 800; letter-spacing: -.03em; }
.topbar-title img { border-radius: 8px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

#views {
  max-width: var(--maxw); margin: 0 auto;
  padding: 18px var(--pad) calc(var(--tabh) + 40px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------- tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px) saturate(1.8); -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  height: var(--tabh); position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--faint); font-size: 10.5px; font-weight: 750; letter-spacing: .015em;
  transition: color .18s;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .22s var(--ease); }
.tab.is-active { color: var(--accent); }
.tab.is-active svg { transform: translateY(-1px) scale(1.1); }
.tab.is-active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}

/* ---------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 24px; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.hero::after {                       /* expressive wash, kept well behind text */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(90% 130% at 100% 0%, var(--accent-soft), transparent 60%);
}
.hero-ring { flex: 0 0 96px; position: relative; z-index: 1; }
.ring { width: 96px; height: 96px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line-2); stroke-width: 8; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset .8s var(--ease);
}
.ring-t {
  transform: rotate(90deg); transform-origin: 40px 40px;
  fill: var(--text); font-size: 17px; font-weight: 800; text-anchor: middle;
}
.hero-text { position: relative; z-index: 1; min-width: 0; }
.hero-num {
  font-size: var(--fs-display); font-weight: 830; letter-spacing: -.045em; line-height: .95;
  font-variant-numeric: tabular-nums;
}
.hero-label { color: var(--muted); font-size: var(--fs-sm); margin-top: 6px; font-weight: 650; }
.hero-sub { color: var(--faint); font-size: var(--fs-xs); margin-top: 10px; line-height: 1.5; }

/* ---------------------------------------------------------- filter bar */
.filterbar { margin-bottom: 18px; display: flex; flex-direction: column; gap: 11px; }
.searchwrap { position: relative; display: flex; align-items: center; }
.searchwrap svg {
  position: absolute; left: 14px; width: 17px; height: 17px;
  fill: none; stroke: var(--faint); stroke-width: 2; pointer-events: none;
}
.searchwrap input {
  width: 100%; padding: 12px 40px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line);
  outline: none; font-weight: 550; color: var(--text);
  transition: border-color .16s, box-shadow .16s;
}
.searchwrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.searchwrap input::-webkit-search-cancel-button { -webkit-appearance: none; }
.searchclear {
  position: absolute; right: 8px; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: var(--line); color: var(--muted);
  cursor: pointer; display: grid; place-items: center; font-size: 15px; line-height: 1;
}
.searchclear:hover { background: var(--line-2); color: var(--text); }

.chiprow {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chiprow::-webkit-scrollbar { display: none; }
.fchip {
  flex: 0 0 auto; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line);
  color: var(--muted); font-size: var(--fs-xs); font-weight: 700;
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform .12s var(--ease), background .16s, color .16s, border-color .16s;
}
.fchip:hover  { border-color: var(--line-2); color: var(--text); }
.fchip:active { transform: scale(.95); }
.fchip.on {
  background: var(--text); border-color: var(--text); color: var(--bg);
}
.fchip .fdot { width: 8px; height: 8px; border-radius: 50%; background: var(--fdot, var(--faint)); }
.fchip .fcount {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--line); color: inherit; font-weight: 800;
}
.fchip.on .fcount { background: color-mix(in srgb, var(--bg) 30%, transparent); }
.resultline { color: var(--faint); font-size: var(--fs-xs); font-weight: 600; padding: 0 2px; }

/* ---------------------------------------------------------- sections */
.sec { margin-bottom: 26px; }
.sec-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 0 2px 11px; text-align: left; background: none; border: 0;
}
.sec-head h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; }
.sec-sub { color: var(--faint); font-size: var(--fs-xs); margin-top: 4px; font-weight: 550; }
.sec.urgent .sec-head h3 { color: var(--crit); }
.sec-toggle { cursor: pointer; }
.caret { color: var(--faint); font-size: 12px; }
.sec-body { display: flex; flex-direction: column; gap: 9px; }
.sec-body.pad { padding: 2px; gap: 16px; }
.grouphead {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); padding: 18px 2px 8px; font-weight: 800;
}

/* ---------------------------------------------------------- perk row */
.prow {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 13px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 16px 15px 19px;
  box-shadow: var(--shadow-sm);
  transition: transform .13s var(--ease), box-shadow .18s, border-color .18s;
  animation: rowIn .32s var(--ease) both;
}
/* Issuer colour as a spine — expressive, but never behind text. */
.prow::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--rowaccent, var(--line-2));
}
.prow:hover  { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-2); }
.prow:active { transform: scale(.99); }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.prow-main { flex: 1; min-width: 0; }
.prow-top { display: flex; align-items: center; gap: 9px; }
.prow-name {
  font-weight: 720; font-size: var(--fs-md); letter-spacing: -.015em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prow-sub { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.prow-card { color: var(--faint); font-size: var(--fs-xs); font-weight: 600; }
.prow-meter {
  height: 6px; border-radius: 4px; background: var(--sunken);
  overflow: hidden; margin-top: 12px;
}
.prow-meter.lg { height: 10px; border-radius: 5px; margin-top: 10px; }
.prow-meter i {
  display: block; height: 100%; border-radius: 4px;
  background: var(--accent); transition: width .5s var(--ease);
}
.prow-vals { margin-top: 7px; font-size: var(--fs-sm); }
.prow-vals b { font-weight: 780; font-variant-numeric: tabular-nums; }
.prow-of { color: var(--faint); margin-left: 5px; font-weight: 550; }
.prow-act { flex: 0 0 auto; }

.prow-done, .prow-waiting { opacity: .55; }
.prow-done .prow-meter i, .prow-waiting .prow-meter i { background: var(--accent); opacity: .6; }
.prow.is-off { opacity: .38; }
.prow.u-critical { border-color: color-mix(in srgb, var(--crit) 45%, transparent); }
.prow.u-critical .prow-meter i { background: var(--crit); }
.prow.u-soon .prow-meter i { background: var(--warn); }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--faint)); flex: 0 0 10px; }
.tick {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 800;
}

.chip {
  font-size: 10.5px; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  letter-spacing: .015em; white-space: nowrap; text-transform: uppercase;
}
.chip-mute { background: var(--sunken); color: var(--muted); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-crit { background: var(--crit-soft); color: var(--crit); }
.chip-done { background: var(--accent-soft); color: var(--accent); }
.chip-auto { background: var(--info-soft); color: var(--info); }
.chip-unver { background: var(--warn-soft); color: var(--warn); cursor: help; padding: 4px 8px; }

/* ---------------------------------------------------------- empty states */
.empty, .allclear {
  text-align: center; padding: 52px 24px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.empty img { border-radius: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.empty h2 { font-size: var(--fs-xl); margin-bottom: 10px; }
.empty .hint { max-width: 400px; margin: 0 auto 22px; }
.allclear { padding: 40px 24px; }
.allclear-tick {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 27px; font-weight: 800;
}
.allclear h3 { font-size: var(--fs-lg); margin-bottom: 8px; }

/* ---------------------------------------------------------- card tiles */
.cardgrid { display: grid; gap: 16px; }
.ctile {
  cursor: pointer; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), box-shadow .2s;
}
.ctile:hover  { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.ctile:active { transform: scale(.99); }

/* Expressive per-issuer artwork. Text on it is always --tile-ink (white) and
   the gradient is forced dark enough to carry it in either theme. */
.ctile-face, .cardhero {
  position: relative; overflow: hidden;
  padding: 22px; color: var(--tile-ink);
  background:
    radial-gradient(120% 150% at 8% -10%, color-mix(in srgb, var(--accent) 78%, transparent), transparent 58%),
    radial-gradient(100% 120% at 100% 110%, color-mix(in srgb, var(--accent) 45%, transparent), transparent 55%),
    linear-gradient(125deg, color-mix(in srgb, var(--accent) 62%, #0a1017), #0a1017 82%);
}
/* Scrim + texture, sitting above the artwork and below the text.
   Without the scrim, pale issuer accents (Amex Gold, Platinum) push the
   gradient's brightest region to ~3.7:1 against white — under the 4.5:1 needed
   for the small issuer/footer labels. The scrim makes contrast a property of
   the tile rather than of whichever colour the card happens to use. */
.ctile-face::after, .cardhero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.05) 0 2px, transparent 2px 26px),
    linear-gradient(175deg, rgba(5,9,15,.38) 0%, rgba(5,9,15,.16) 42%, rgba(5,9,15,.52) 100%);
}
.ctile-issuer {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  opacity: .8; font-weight: 800; position: relative; z-index: 1;
}
.ctile-name {
  font-size: 22px; font-weight: 800; letter-spacing: -.03em;
  margin-top: 6px; position: relative; z-index: 1;
}
.ctile-foot {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 34px; font-size: var(--fs-xs); opacity: .88; font-weight: 650;
  font-variant-numeric: tabular-nums; position: relative; z-index: 1;
}
.ctile-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.cstat { padding: 15px 10px; text-align: center; border-right: 1px solid var(--line); }
.cstat:last-child { border-right: 0; }
.cstat-n { display: block; font-size: var(--fs-lg); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.cstat-l { display: block; color: var(--faint); font-size: 10.5px; margin-top: 3px; font-weight: 650; }
.feebar { padding: 14px 16px 16px; border-top: 1px solid var(--line); }
.feebar-top { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 9px; font-weight: 650; }
.preview, .cardhero { border-radius: var(--r); margin-bottom: 18px; }

/* ---------------------------------------------------------- card sheet */
.econ { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 12px; }
.econ-c {
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 13px 8px; text-align: center;
}
.econ-c b { display: block; font-size: var(--fs-lg); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.econ-c span { display: block; color: var(--faint); font-size: 10.5px; margin-top: 3px; font-weight: 650; }
.econ-note { margin-bottom: 8px; }
.perklist { display: flex; flex-direction: column; gap: 9px; }

/* ---------------------------------------------------------- timeline */
.tl-head { margin-bottom: 20px; display: flex; flex-direction: column; gap: 13px; align-items: flex-start; }
.tlrow {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow-sm);
  transition: transform .13s var(--ease), box-shadow .18s;
  animation: rowIn .32s var(--ease) both;
}
.tlrow:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.tlrow-date {
  flex: 0 0 44px; text-align: center; line-height: 1.05;
  border-right: 1px solid var(--line); padding-right: 13px;
}
.tlrow-date b { display: block; font-size: 21px; font-weight: 800; letter-spacing: -.03em; }
.tlrow-date span { display: block; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .09em; font-weight: 750; }
.tlrow-main { flex: 1; min-width: 0; }
.tlrow-amt { font-weight: 800; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- settings */
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setrow > div:first-child { min-width: 0; }
.setrow b { font-size: var(--fs-md); font-weight: 700; }
.setrow .hint { margin-top: 4px; }
.setrow .sel { width: auto; min-width: 120px; flex: 0 0 auto; }
.switch { position: relative; flex: 0 0 50px; width: 50px; height: 29px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 23px; height: 23px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: transform .2s var(--ease);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(21px); }
.switch input:disabled + span { opacity: .4; }
.autorow { margin: 6px 0 18px; padding: 14px 16px; background: var(--sunken); border-radius: var(--r-sm); }
.foot { text-align: center; color: var(--faint); font-size: var(--fs-xs); padding: 10px 0 4px; font-weight: 600; }

/* segmented control (theme picker) */
.seg { display: inline-flex; background: var(--sunken); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 7px 15px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 750; color: var(--muted);
  transition: background .18s, color .18s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------------------------------------------------------- sheets */
.sheet-back {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, #05080d 62%, transparent);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .22s var(--ease);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.sheet-back.in { opacity: 1; }
.sheet {
  width: 100%; max-width: 580px;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(26px); transition: transform .34s var(--ease);
}
.sheet-back.in .sheet { transform: translateY(0); }
.sheet-wide { max-width: 640px; }
.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 20px 14px; border-bottom: 1px solid var(--line);
}
.sheet-titles { min-width: 0; }
.sheet-head h2 { font-size: var(--fs-lg); }
.sheet-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.sheet-body { padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-actions {
  display: flex; gap: 10px; padding: 15px 20px;
  padding-bottom: calc(15px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg-soft);
}
.sheet-actions .btn { flex: 1; }

/* ---------------------------------------------------------- catalog picker */
.catlist { max-height: 46dvh; overflow-y: auto; margin: 0 -4px 16px; padding: 0 4px; }
.catrow {
  display: flex; align-items: center; gap: 12px; width: 100%; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 14px 6px; text-align: left; color: inherit; border-radius: var(--r-sm);
  transition: background .16s;
}
.catrow:hover { background: var(--sunken); }
.catrow-main { flex: 1; min-width: 0; }
.catrow-name { display: block; font-weight: 720; font-size: var(--fs-md); }
.catrow-sub { display: block; color: var(--faint); font-size: var(--fs-xs); margin-top: 3px; font-weight: 550; }
.catrow-go { color: var(--faint); font-size: 19px; }

/* ---------------------------------------------------------- perk detail */
.pdetail { margin-bottom: 18px; }
.pdetail-head { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: var(--fs-sm); flex-wrap: wrap; font-weight: 600; }
.pdetail-window { color: var(--faint); font-size: var(--fs-xs); margin-top: 7px; font-weight: 550; }
.pnote {
  margin-top: 14px; padding: 13px 15px; border-radius: var(--r-sm);
  background: var(--sunken); border-left: 3px solid var(--accent);
  color: var(--muted); font-size: var(--fs-sm); line-height: 1.55;
}
.bigmeter { margin-top: 20px; }
.bigmeter-row { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.bigmeter-row b { font-size: 30px; font-weight: 830; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.bigmeter-row span { color: var(--faint); font-size: var(--fs-sm); font-weight: 600; }
.annualline { margin-top: 9px; }
.annualline b { color: var(--text); font-weight: 780; }
.verifyrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 600;
}
.verifyrow > span { min-width: 0; }
.linkout { display: inline-block; margin-top: 14px; color: var(--accent); text-decoration: none; font-size: var(--fs-sm); font-weight: 750; }
.linkout:hover { text-decoration: underline; }
.logbox { border-top: 1px solid var(--line); padding-top: 18px; }
.logrow { display: grid; grid-template-columns: 1fr 155px; gap: 12px; margin-bottom: 16px; }
.donebar {
  text-align: center; padding: 14px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent); font-size: var(--fs-sm); font-weight: 750;
}
.history { margin-top: 8px; }
.hrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.hrow-main b { font-size: var(--fs-sm); font-weight: 780; font-variant-numeric: tabular-nums; }
.hrow-main span { color: var(--faint); font-size: var(--fs-xs); margin-left: 8px; }
.hrow-main em { display: block; color: var(--muted); font-size: var(--fs-xs); font-style: normal; margin-top: 3px; }

/* ---------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabh) + 20px + env(safe-area-inset-bottom));
  z-index: 200; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg);
  padding: 13px 20px; border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 720;
  box-shadow: var(--shadow-lg);
  animation: pop .3s var(--ease);
}
.toast.is-err { background: var(--crit); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 14px) scale(.94); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ---------------------------------------------------------- desktop */
@media (min-width: 760px) {
  .cardgrid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 30px; gap: 26px; }
  .tabbar {
    left: 50%; right: auto; bottom: 22px; transform: translateX(-50%);
    width: min(460px, calc(100vw - 40px));
    border: 1px solid var(--line-2); border-radius: 999px;
    overflow: hidden; box-shadow: var(--shadow-lg);
  }
  .tab { height: 60px; }
  .tab.is-active::before { display: none; }
  #views { padding-bottom: 120px; }
  .sheet-back { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-lg); border-bottom: 1px solid var(--line-2); max-height: 86dvh; }
  .toast { bottom: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
