/* Daftar 3: tokens, base, components and app.
   Colour primitives: Radix Colors 3.0.0 (MIT, (c) 2021 Radix): Sage, Amber, Red.
   Accent: custom Viridian on Radix step roles (OKLCH hue 168).
   Type: IBM Plex Sans Variable (OFL 1.1, fonts/OFL-IBM-Plex-Sans.txt).
   Rules and evidence: DESIGN.md, design/references.md. */

/* ---------- fonts ---------- */

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 100 700;
  src: url(/fonts/ibm-plex-sans-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 100 700;
  src: url(/fonts/ibm-plex-sans-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */

:root {
  /* primitives, light */
  --sage-1: #fbfdfc; --sage-2: #f7f9f8; --sage-3: #eef1f0; --sage-4: #e6e9e8; --sage-5: #dfe2e0; --sage-6: #d7dad9;
  --sage-7: #cbcfcd; --sage-8: #b8bcba; --sage-9: #868e8b; --sage-10: #7c8481; --sage-11: #5f6563; --sage-12: #1a211e;
  --viridian-3: #e0f8ed; --viridian-4: #d1f3e4; --viridian-6: #ace0cb; --viridian-8: #68b79a;
  --viridian-9: #1e7359; --viridian-10: #14654d; --viridian-11: #156a51; --viridian-12: #0e3629;
  --amber-3: #fff7c2; --amber-6: #f3d673; --amber-9: #ffc53d; --amber-11: #ab6400; --amber-12: #4f3422;
  --red-3: #feebec; --red-6: #fdbdbe; --red-9: #e5484d; --red-11: #ce2c31;

  /* functional layer: components use only these */
  --bg: var(--sage-2);
  --surface: #ffffff;
  --surface-sunken: var(--sage-1);
  --surface-hover: var(--sage-3);
  --surface-active: var(--sage-4);
  --surface-selected: var(--viridian-3);
  --divider: var(--sage-4);
  --border: var(--sage-6);
  --border-strong: var(--sage-8);
  --fg: var(--sage-12);
  --fg-muted: var(--sage-11);
  --fg-subtle: var(--sage-9);
  --accent: var(--viridian-9);
  --accent-hover: var(--viridian-10);
  --accent-fg: #ffffff;
  --accent-text: var(--viridian-11);
  --accent-subtle: var(--viridian-3);
  --accent-border: var(--viridian-6);
  --soon: var(--amber-11);
  --soon-dot: var(--amber-9);
  --soon-subtle: var(--amber-3);
  --soon-strong: var(--amber-12);
  --soon-border: var(--amber-6);
  --due: var(--red-11);
  --due-dot: var(--red-9);
  --due-subtle: var(--red-3);
  --due-border: var(--red-6);
  --focus: color-mix(in srgb, var(--viridian-9) 55%, transparent);
  --scrim: rgb(16 18 17 / 0.32);
  --shadow-float: 0 1px 2px rgb(26 33 30 / 0.06), 0 12px 32px -8px rgb(26 33 30 / 0.18);
  --shadow-press: inset 0 1px 0 rgb(255 255 255 / 0.12);

  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 240ms;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --sage-1: #101211; --sage-2: #171918; --sage-3: #202221; --sage-4: #272a29; --sage-5: #2e3130; --sage-6: #373b39;
  --sage-7: #444947; --sage-8: #5b625f; --sage-9: #63706b; --sage-10: #717d79; --sage-11: #adb5b2; --sage-12: #eceeed;
  --viridian-3: #0d261d; --viridian-4: #0e3025; --viridian-6: #144636; --viridian-8: #206e56;
  --viridian-9: #369375; --viridian-10: #47a383; --viridian-11: #7dd2b2; --viridian-12: #caf0e0;
  --amber-3: #302008; --amber-6: #5c3d05; --amber-9: #ffc53d; --amber-11: #ffca16; --amber-12: #ffe7b3;
  --red-3: #3b1219; --red-6: #72232d; --red-9: #e5484d; --red-11: #ff9592;
  --bg: var(--sage-1);
  --surface: var(--sage-2);
  --surface-sunken: var(--sage-1);
  --accent-fg: #101211;
  --scrim: rgb(0 0 0 / 0.5);
  --shadow-float: 0 0 0 1px var(--sage-6), 0 16px 40px -12px rgb(0 0 0 / 0.6);
  --shadow-press: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --sage-1: #101211; --sage-2: #171918; --sage-3: #202221; --sage-4: #272a29; --sage-5: #2e3130; --sage-6: #373b39;
    --sage-7: #444947; --sage-8: #5b625f; --sage-9: #63706b; --sage-10: #717d79; --sage-11: #adb5b2; --sage-12: #eceeed;
    --viridian-3: #0d261d; --viridian-4: #0e3025; --viridian-6: #144636; --viridian-8: #206e56;
    --viridian-9: #369375; --viridian-10: #47a383; --viridian-11: #7dd2b2; --viridian-12: #caf0e0;
    --amber-3: #302008; --amber-6: #5c3d05; --amber-9: #ffc53d; --amber-11: #ffca16; --amber-12: #ffe7b3;
    --red-3: #3b1219; --red-6: #72232d; --red-9: #e5484d; --red-11: #ff9592;
    --bg: var(--sage-1);
    --surface: var(--sage-2);
    --surface-sunken: var(--sage-1);
    --accent-fg: #101211;
    --scrim: rgb(0 0 0 / 0.5);
    --shadow-float: 0 0 0 1px var(--sage-6), 0 16px 40px -12px rgb(0 0 0 / 0.6);
    --shadow-press: none;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.45;
  font-weight: 400;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-weight: 540; letter-spacing: -0.01em; text-wrap: balance; }
p { text-wrap: pretty; }

a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

::selection { background: color-mix(in srgb, var(--viridian-9) 22%, transparent); color: inherit; }
input, textarea { caret-color: var(--accent); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

html { scrollbar-color: var(--sage-7) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--sage-7); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

[hidden] { display: none !important; }

.num, .money, time, .figure { font-variant-numeric: tabular-nums lining-nums; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

kbd {
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 500;
  min-width: 1.5em;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--fg-muted);
  background: var(--surface);
  text-align: center;
  display: inline-block;
  line-height: 1.4;
}

.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons ---------- */

.btn {
  --btn-h: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--btn-h);
  padding: 0 16px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-press); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-quiet { background: transparent; color: var(--fg-muted); padding: 0 10px; }
.btn-quiet:hover:not(:disabled) { background: var(--surface-hover); color: var(--fg); }

.btn-danger { background: transparent; color: var(--due); padding: 0 12px; }
.btn-danger:hover:not(:disabled) { background: var(--due-subtle); }
.btn-danger.is-armed { background: var(--due-dot); color: #fff; }

.btn-sm { --btn-h: 30px; padding: 0 12px; font-size: 0.8125rem; }
.btn-lg { --btn-h: 44px; padding: 0 22px; font-size: 0.9375rem; }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-icon:hover:not(:disabled) { background: var(--surface-hover); color: var(--fg); }
.btn-icon:disabled { opacity: 0.35; cursor: default; }

@media (pointer: coarse) {
  .btn { --btn-h: 44px; }
  .btn-sm { --btn-h: 38px; }
  .btn-icon { width: 44px; height: 44px; }
}

/* ---------- form controls ---------- */

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 0.8125rem; font-weight: 500; color: var(--fg); }
.field-hint { font-size: 0.8125rem; color: var(--fg-muted); }
.field-label .optional { color: var(--fg-subtle); font-weight: 400; }

.input, .select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--fg-subtle); }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input[type='number'] { font-variant-numeric: tabular-nums; }
.input[type='date'] { font-variant-numeric: tabular-nums; }
.input[readonly] { background: var(--surface-sunken); color: var(--fg-muted); }

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868e8b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

@media (pointer: coarse) {
  .input, .select { height: 44px; font-size: 1rem; }
}

.input-group { display: flex; }
.input-group .select { width: auto; flex: none; border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -1px; }
.input-group .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .select:focus, .input-group .input:focus { position: relative; z-index: 1; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
}
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  flex: none;
  width: 34px; height: 20px;
  margin-top: 1px;
  border-radius: var(--radius-full);
  background: var(--sage-7);
  position: relative;
  transition: background-color var(--dur) var(--ease);
}
.switch-track::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-text { display: grid; gap: 2px; }
.switch-text strong { font-weight: 500; }
.switch-text span { color: var(--fg-muted); font-size: 0.8125rem; }

/* segmented control */
.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-full);
  background: var(--surface-active);
}
.seg button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(26 33 30 / 0.12); }
.field > .seg { justify-self: start; }
.seg-wide { display: flex; }
.field > .seg-wide { justify-self: stretch; }
.seg-wide button { flex: 1; }
@media (pointer: coarse) { .seg button { height: 36px; } }

/* chips (filters) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--fg); }
.chip[aria-pressed='true'] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.chip .count { color: inherit; opacity: 0.6; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--surface-active);
  color: var(--fg-muted);
}
.badge-soon { background: var(--soon-subtle); color: var(--soon-strong); }
.badge-due { background: var(--due-subtle); color: var(--due); }
.badge-accent { background: var(--accent-subtle); color: var(--accent-text); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
:root[data-theme='dark'] .dot { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .dot { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14); } }

/* ---------- money ---------- */

.money { white-space: nowrap; }
.money-hero {
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
}
.money-hero .cents { font-size: 0.55em; vertical-align: 0.62em; letter-spacing: 0; margin-left: 1px; color: var(--fg-muted); font-weight: 500; }
.money-hero .cur { font-size: 0.62em; vertical-align: 0.46em; color: var(--fg-muted); margin-right: 2px; letter-spacing: 0; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease);
}
.topbar.is-scrolled { border-bottom-color: var(--divider); }
.topbar-inner {
  max-width: 1168px;
  margin: 0 auto;
  height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-spacer { flex: 1; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.015em;
}
.wordmark:hover { text-decoration: none; }
.mark { width: 22px; height: 22px; flex: none; }
.mark-fill { fill: var(--accent); }

/* menu (popover) */
.menu-wrap { position: relative; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  text-transform: uppercase;
}
.avatar:hover { border-color: var(--border-strong); }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border);
  z-index: 40;
  transform-origin: top right;
  animation: menu-in var(--dur) var(--ease);
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--divider); margin-bottom: 6px; }
.menu-head strong { display: block; font-weight: 500; }
.menu-head span { color: var(--fg-muted); font-size: 0.8125rem; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); outline: none; text-decoration: none; }
.menu-item .icon { color: var(--fg-muted); }
.menu-item .trail { margin-left: auto; color: var(--fg-subtle); font-size: 0.8125rem; }
.menu-sep { height: 1px; background: var(--divider); margin: 6px 0; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.97) translateY(-4px); } }

/* ---------- page ---------- */

.page { max-width: 1168px; margin: 0 auto; padding: 24px 24px 96px; }

.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 1rem; font-weight: 560; letter-spacing: -0.005em; }
.section-meta { color: var(--fg-muted); font-size: 0.8125rem; }

/* demo banner */
.demo-banner {
  background: var(--accent-subtle);
  color: var(--viridian-12);
  border-bottom: 1px solid var(--accent-border);
  font-size: 0.8125rem;
}
.demo-banner-inner { max-width: 1168px; margin: 0 auto; padding: 8px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.demo-banner a { color: inherit; font-weight: 500; }
.demo-banner .spacer { flex: 1; }

/* operator announcement (set in the console) */
.announce { background: var(--surface-sunken); border-bottom: 1px solid var(--divider); color: var(--fg); font-size: 0.875rem; }
.announce.is-warning { background: var(--soon-subtle); border-bottom-color: var(--soon-border); color: var(--soon-strong); }
.announce-inner { max-width: 1168px; margin: 0 auto; padding: 9px 24px; }

/* ---------- summary ---------- */

.summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 24px;
  align-items: end;
  padding: 28px 0 32px;
}
.summary-label { color: var(--fg-muted); font-weight: 500; margin-bottom: 10px; }
.summary-line { margin-top: 12px; color: var(--fg-muted); font-size: 0.9375rem; max-width: 62ch; }
.summary-line .money { color: var(--fg); font-weight: 500; }

.next-charge {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.next-charge:hover { border-color: var(--border-strong); }
.next-charge-label { color: var(--fg-muted); font-size: 0.8125rem; }
.next-charge-row { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 0.9375rem; }
.next-charge-row .money { margin-left: auto; }
.next-charge-when { font-size: 0.8125rem; color: var(--fg-muted); }

/* ---------- attention ---------- */

.attention {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: 32px;
  overflow: hidden;
}
.attention-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}
.attention-counts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.attention-item:first-child { border-top: 0; }
.attention-item:hover { background: var(--surface-hover); }
.attention-main { display: grid; gap: 2px; min-width: 0; }
.attention-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attention-why { font-size: 0.8125rem; color: var(--fg-muted); }
.attention-why.is-soon { color: var(--soon); }
.attention-why.is-due { color: var(--due); }
.attention-item .money { font-weight: 500; }

/* ---------- horizon (signature) ---------- */

.horizon { margin-bottom: 40px; }
.horizon .section-head { flex-wrap: wrap; row-gap: 2px; }
.horizon-total { color: var(--fg-muted); font-size: 0.8125rem; margin-left: auto; }
.horizon-total .money { color: var(--fg); font-weight: 500; }
.horizon-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 20px 20px 12px;
}
.horizon-track { position: relative; height: 116px; margin: 0 6px; }
.horizon-axis { position: absolute; left: 0; right: 0; bottom: 24px; height: 1px; background: var(--border); }
.horizon-stem { position: absolute; bottom: 24px; width: 1px; margin-left: -0.5px; background: var(--border-strong); pointer-events: none; }
.horizon-tick { position: absolute; bottom: 0; transform: translateX(-50%); font-size: 0.75rem; color: var(--fg-subtle); white-space: nowrap; font-variant-numeric: tabular-nums; }
.horizon-tick::before { content: ''; position: absolute; left: 50%; bottom: 20px; width: 1px; height: 5px; background: var(--border-strong); }
.horizon-tick.is-today { color: var(--accent-text); font-weight: 500; }
.horizon-tick.is-today::before { background: var(--accent); height: 96px; width: 1px; opacity: 0.6; }
.horizon-tick:first-of-type { transform: none; }
.horizon-tick:first-of-type::before { left: 0; }
.horizon-tick:last-of-type { transform: translateX(-100%); }
.horizon-tick:last-of-type::before { left: auto; right: 0; }

.horizon-marker {
  position: absolute;
  width: 14px; height: 14px;
  margin-left: -7px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.horizon-marker:hover, .horizon-marker:focus-visible { transform: scale(1.25); z-index: 2; outline: none; box-shadow: 0 0 0 2px var(--fg); }
.horizon-marker.is-soon { box-shadow: 0 0 0 1.5px var(--soon-dot); }
.horizon-marker.is-due { box-shadow: 0 0 0 1.5px var(--due-dot); }
.horizon-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: var(--bg);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  font-variant-numeric: tabular-nums;
}
.horizon-tip strong { font-weight: 600; }
.horizon-marker:hover .horizon-tip, .horizon-marker:focus-visible .horizon-tip { opacity: 1; }
.horizon-empty { position: absolute; left: 0; right: 0; top: 30px; text-align: center; color: var(--fg-muted); }

/* ---------- toolbar + table ---------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .section-title { margin-right: 4px; }
.toolbar-spacer { flex: 1; }
.search {
  position: relative;
  width: 220px;
}
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--fg-subtle); pointer-events: none; }
.search .input { padding-left: 32px; padding-right: 32px; }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.search .input:focus ~ kbd, .search .input:not(:placeholder-shown) ~ kbd { display: none; }
.toolbar .select { width: auto; }
.filters { margin-bottom: 12px; }

.table-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table th {
  height: 36px;
  padding: 0 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
.ledger-table td {
  height: 56px;
  padding: 8px 16px;
  border-top: 1px solid var(--divider);
  vertical-align: middle;
}
.ledger-table tbody tr:first-child td { border-top: 0; }
.ledger-table tbody tr.row { cursor: pointer; transition: background-color var(--dur-fast) var(--ease); }
.ledger-table tbody tr.row:hover { background: var(--surface-hover); }
.ledger-table tbody tr.row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ledger-table .col-amount { text-align: right; }
.ledger-table td:not(.col-service), .ledger-table th { white-space: nowrap; }
@media (min-width: 721px) {
  .ledger-table { table-layout: auto; }
  .ledger-table td.col-service { max-width: 0; width: 42%; }
  .ledger-table td.col-category { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
}
.ledger-table th.col-amount { text-align: right; }

.svc { display: flex; align-items: center; gap: 10px; min-width: 0; }
.svc-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc .badge { margin-left: 2px; }
.cell-stack { display: grid; gap: 2px; }
.cell-sub { font-size: 0.8125rem; color: var(--fg-muted); }
.cell-muted { color: var(--fg-muted); }
.when.is-soon { color: var(--soon); font-weight: 500; }
.when.is-due { color: var(--due); font-weight: 500; }
.row.is-paused .svc-name, .row.is-paused .money, .row.is-paused .when { color: var(--fg-subtle); }
.row-none td { color: var(--fg-muted); text-align: center; height: 72px; }
.amount { font-weight: 500; }

/* phone layout: two-line rows keep the next date and amount visible */
@media (max-width: 720px) {
  .ledger-table thead { display: none; }
  .ledger-table, .ledger-table tbody { display: block; }
  .ledger-table tr.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'svc amount' 'next cycle';
    gap: 2px 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--divider);
  }
  .ledger-table tbody tr.row:first-child { border-top: 0; }
  .ledger-table tr.row td { display: block; height: auto; padding: 0; border: 0; }
  .ledger-table td.col-service { grid-area: svc; }
  .ledger-table td.col-amount { grid-area: amount; }
  .ledger-table td.col-next { grid-area: next; padding-left: 20px; }
  .ledger-table td.col-cycle { grid-area: cycle; text-align: right; }
  .ledger-table tr.row td.col-category { display: none; }
  .ledger-table td.col-next .cell-stack { display: flex; gap: 6px; }
  .ledger-table td.col-next .when::after { content: ','; }
  .ledger-table td.col-next .cell-stack { gap: 4px; }
  .ledger-table td.col-amount .cell-sub { display: none; }
  .ledger-table .row-none { display: block; padding: 24px 16px; }
  .ledger-table .row-none td { display: block; height: auto; }
}

/* calendar */
.cal { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: 16px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-title { font-weight: 560; font-size: 1rem; margin-right: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { font-size: 0.75rem; color: var(--fg-subtle); text-align: center; padding-bottom: 4px; }
.cal-cell {
  min-height: 72px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 6px;
  text-align: left;
  font: inherit;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}
.cal-cell:disabled { cursor: default; color: var(--fg-subtle); }
.cal-cell:not(:disabled):hover { border-color: var(--border-strong); }
.cal-cell.is-today .cal-num { background: var(--accent); color: var(--accent-fg); }
.cal-cell.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-num { font-size: 0.75rem; font-weight: 500; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; font-variant-numeric: tabular-nums; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin-top: auto; }
.cal-dots .dot { width: 8px; height: 8px; }
.cal-dots em { font-style: normal; font-size: 0.6875rem; color: var(--fg-muted); }
.cal-sum { font-size: 0.75rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.cal-blank { min-height: 72px; }
.cal-day { margin-top: 16px; border-top: 1px solid var(--divider); padding-top: 12px; }
.cal-day-title { font-weight: 500; margin-bottom: 6px; }
.cal-day-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 6px; border: 0; border-radius: var(--radius-sm); background: transparent;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.cal-day-row:hover { background: var(--surface-hover); }
.cal-day-row .money { margin-left: auto; font-weight: 500; }
@media (max-width: 720px) {
  .cal { padding: 10px; }
  .cal-cell, .cal-blank { min-height: 48px; padding: 4px; }
  .cal-sum { display: none; }
}

/* empty states */
.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 8px;
}
.empty-title { font-weight: 560; font-size: 1rem; }
.empty-hint { color: var(--fg-muted); max-width: 44ch; margin-bottom: 8px; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- sheet (add / edit) ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 50;
  animation: fade-in var(--dur) var(--ease);
}
.sheet {
  position: fixed;
  top: 8px;
  right: 8px;
  bottom: 8px;
  width: min(480px, calc(100vw - 16px));
  z-index: 51;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border);
  animation: sheet-in var(--dur-slow) var(--ease);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--divider); }
.sheet-head h2 { font-size: 1.0625rem; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 20px; align-content: start; overscroll-behavior: contain; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--divider); }
.sheet-foot .spacer { flex: 1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.date-preview { font-size: 0.8125rem; color: var(--fg-muted); }
.date-preview strong { color: var(--fg); font-weight: 500; }
.more { border-top: 1px solid var(--divider); padding-top: 16px; }
.more summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--fg-muted);
  width: fit-content;
}
.more summary::-webkit-details-marker { display: none; }
.more summary .icon { transition: transform var(--dur) var(--ease); }
.more[open] summary .icon { transform: rotate(90deg); }
.more summary:hover { color: var(--fg); }
.more-body { display: grid; gap: 16px; padding-top: 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  padding: 0;
}
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--fg); }
.swatch-custom { position: relative; overflow: hidden; background: conic-gradient(#e5484d, #ffc53d, #30a46c, #0090ff, #8e4ec6, #e5484d); }
.swatch-custom input { position: absolute; inset: -4px; opacity: 0; cursor: pointer; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row .input { flex: 1; }

@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 720px) {
  .sheet { top: 0; right: 0; bottom: 0; left: 0; width: 100%; border-radius: 0; border: 0; animation-name: sheet-up; }
  .form-row { grid-template-columns: 1fr; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }

/* ---------- settings page ---------- */

.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; padding-top: 24px; }
.settings-nav { position: sticky; top: 84px; align-self: start; display: grid; gap: 2px; }
.settings-nav a {
  display: block; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--fg-muted); text-decoration: none; font-weight: 500;
}
.settings-nav a:hover { background: var(--surface-hover); color: var(--fg); }
.settings-nav a[aria-current='true'] { background: var(--surface-active); color: var(--fg); }
.settings-main { display: grid; gap: 24px; max-width: 680px; }
.settings-title { font-size: 1.5rem; margin-bottom: 4px; }
.settings-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  scroll-margin-top: 84px;
}
.settings-card-head { padding: 16px 20px 0; }
.settings-card-head h2 { font-size: 1rem; }
.settings-card-head p { color: var(--fg-muted); margin-top: 4px; }
.settings-card-body { padding: 16px 20px 20px; display: grid; gap: 16px; }
.settings-card-foot { padding: 12px 20px; border-top: 1px solid var(--divider); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface-sunken); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.settings-card-foot .spacer { flex: 1; }
.lead-options { display: flex; flex-wrap: wrap; gap: 6px; }
.lead-options label { position: relative; }
.lead-options input { position: absolute; opacity: 0; pointer-events: none; }
.lead-options span {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  border-radius: var(--radius-full); border: 1px solid var(--border); color: var(--fg-muted);
  font-weight: 500; font-size: 0.8125rem; cursor: pointer; background: var(--surface);
}
.lead-options input:checked + span { background: var(--accent-subtle); border-color: var(--accent-border); color: var(--accent-text); }
.lead-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.cat-rows { display: grid; gap: 8px; }
.cat-row { display: flex; gap: 8px; align-items: center; }
.cat-row .input { flex: 1; }
.cal-row { display: flex; gap: 8px; }
.cal-row .input { flex: 1; font-size: 0.8125rem; }
.save-bar {
  position: sticky; bottom: 16px; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius-full);
  background: var(--fg); color: var(--bg);
  box-shadow: var(--shadow-float);
  width: fit-content; margin-left: auto;
  animation: menu-in var(--dur) var(--ease);
}
.save-bar .btn-quiet { color: var(--bg); opacity: 0.75; }
.save-bar .btn-quiet:hover { background: transparent; opacity: 1; color: var(--bg); }

@media (max-width: 860px) {
  .settings { grid-template-columns: 1fr; gap: 16px; }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .settings-nav a { white-space: nowrap; }
}

/* ---------- auth ---------- */

.auth-screen { min-height: calc(100dvh - 60px); display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(380px, 100%); display: grid; gap: 16px; }
.auth-card h1 { font-size: 1.5rem; letter-spacing: -0.015em; }
.auth-card .lede { color: var(--fg-muted); margin-top: -8px; }
.auth-error { color: var(--due); font-size: 0.8125rem; }
.auth-foot { color: var(--fg-muted); font-size: 0.8125rem; border-top: 1px solid var(--divider); padding-top: 16px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 10px 10px 16px;
  border-radius: var(--radius-full);
  background: var(--fg);
  color: var(--bg);
  font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast:not(:has(.toast-action)) { padding-right: 16px; }
.toast.is-error { background: var(--due-dot); color: #fff; }
.toast-action {
  border: 0; background: color-mix(in srgb, var(--bg) 16%, transparent); color: inherit;
  font: inherit; font-weight: 600; height: 28px; padding: 0 12px; border-radius: var(--radius-full); cursor: pointer;
}
.toast-action:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- responsive app ---------- */

@media (max-width: 860px) {
  .summary { grid-template-columns: 1fr; align-items: start; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; height: 56px; }
  .page { padding: 16px 16px 96px; }
  .money-hero { font-size: 2.125rem; }
  .summary { padding: 16px 0 24px; }
  .toolbar .search { width: 100%; order: 5; }
  .toolbar .select { margin-left: auto; }
  .attention-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .attention-item .btn { grid-column: 2 / 4; justify-self: start; }
  .horizon-frame { padding: 16px 12px 10px; }
  .hide-sm { display: none !important; }
}

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