/* ==========================================================================
   Jomart Plus - budget planner
   1. Tokens      5. Auth screen      9.  Category sheets
   2. Base        6. Page header      10. Tables
   3. Buttons     7. Stat cards       11. Tooltip + toast
   4. Forms       8. Charts           12. Responsive
   ========================================================================== */

/* 1. Tokens ----------------------------------------------------------------
   Light values live on :root. Dark mode overrides the same names, so nothing
   further down the file needs to know which theme is active.
   -------------------------------------------------------------------------- */
:root {
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface-muted: #f8fafc;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --text:    #0f172a;
  --text-2:  #334155;
  --muted:   #64748b;
  --muted-2: #94a3b8;

  --navy:      #16306b;
  --navy-deep: #102253;
  --navy-soft: #e8edf8;
  --brand-red: #e01b2d;

  --green:  #16a34a;
  --red:    #dc2626;
  --blue:   #2563eb;
  --purple: #7c3aed;
  --amber:  #c2610c;

  --ok-bg:   #f0fdf4;  --ok-border:   #86efac;  --ok-text:   #14532d;
  --bad-bg:  #fef2f2;  --bad-border:  #fca5a5;  --bad-text:  #991b1b;
  --warn-bg: #fffbeb;  --warn-border: #fcd34d;  --warn-text: #92400e;

  --tip-bg:     #0f172a;
  --tip-text:   #e2e8f0;
  --tip-strong: #ffffff;   /* headings and figures inside a tooltip */
  --tip-rule:   rgba(255, 255, 255, .16);

  --footer-bg:     #1c1f26;
  --footer-text:   #cbd2dc;
  --footer-heading:#ffffff;
  --footer-border: rgba(255, 255, 255, .12);

  --radius:    12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .14);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 40px;

  color-scheme: light;
}

/* Dark theme.
   Not an inversion: surfaces are lifted greys rather than pure black, the
   accent colours are brightened so they still read on a dark ground, and the
   navy brand colour becomes a lighter blue because the original disappears
   against a dark background. */
:root[data-theme="dark"] {
  --bg:            #0f1319;
  --surface:       #171c24;
  --surface-muted: #1e242e;
  --border:        #2a313d;
  --border-strong: #3a434f;

  --text:    #e8ecf2;
  --text-2:  #bcc6d4;
  --muted:   #8c98a8;
  --muted-2: #6b7686;

  --navy:      #5b8def;
  --navy-deep: #4478e0;
  --navy-soft: #1d2740;
  --brand-red: #ff4757;

  --green:  #34d399;
  --red:    #f87171;
  --blue:   #60a5fa;
  --purple: #a78bfa;
  --amber:  #fbbf24;

  --ok-bg:   #0f2a1d;  --ok-border:   #1f6b45;  --ok-text:   #86efac;
  --bad-bg:  #2c1416;  --bad-border:  #7f2b30;  --bad-text:  #fca5a5;
  --warn-bg: #2a2010;  --warn-border: #7c5a15;  --warn-text: #fcd34d;

  --tip-bg:     #303947;
  --tip-text:   #e8ecf2;
  --tip-strong: #ffffff;
  --tip-rule:   rgba(255, 255, 255, .14);

  --footer-bg:     #12161c;
  --footer-text:   #a8b3c1;
  --footer-heading:#f1f5f9;
  --footer-border: rgba(255, 255, 255, .09);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .55);

  color-scheme: dark;
}

/* Category accents, tuned per theme so the tinted row backgrounds stay subtle. */
[data-cat="income"]    { --cat: var(--green);  --cat-soft: #eefaf1; --cat-line: #b7e3c5; }
[data-cat="utilities"] { --cat: var(--red);    --cat-soft: #fdeeee; --cat-line: #f4c2c2; }
[data-cat="family"]    { --cat: var(--blue);   --cat-soft: #eef2fd; --cat-line: #c1d1f8; }
[data-cat="financial"] { --cat: var(--purple); --cat-soft: #f4eefd; --cat-line: #d7c6f7; }

:root[data-theme="dark"] [data-cat="income"]    { --cat-soft: #10241a; --cat-line: #245c3c; }
:root[data-theme="dark"] [data-cat="utilities"] { --cat-soft: #2a1518; --cat-line: #6d2f34; }
:root[data-theme="dark"] [data-cat="family"]    { --cat-soft: #141d30; --cat-line: #2f4a7a; }
:root[data-theme="dark"] [data-cat="financial"] { --cat-soft: #1e1731; --cat-line: #4c3a7a; }

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  border-radius: 4px;
}

.page { flex: 1 0 auto; }
.shell { width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 22px 46px; }
.shell--narrow { max-width: 640px; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-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;
}

/* Wordmark: JOMART in red, PLUS in ink, both italic and tight. */
.logo {
  display: inline-flex;
  align-items: baseline;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.04em;
  line-height: 1;
  font-size: 22px;
  white-space: nowrap;
}
.logo__jomart { color: var(--brand-red); }
.logo__plus   { color: var(--text); }
.logo--sm { font-size: 19px; }
.logo--lg { font-size: 40px; }
/* Image logos.
   Both dimensions are capped and object-fit sorts out the rest, so a tall
   square mark and a very wide wordmark both sit correctly without distortion. */
.logo--image { max-height: 30px; max-width: 210px; width: auto; height: auto; object-fit: contain; }
.logo--image.logo--sm { max-height: 26px; max-width: 176px; }
.logo--image.logo--lg { max-height: 54px; max-width: 300px; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar__brand { margin-right: auto; }
.topbar__brand:hover { text-decoration: none; }
.topbar__nav { display: flex; flex-wrap: wrap; gap: 6px; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.tab.is-active { background: var(--navy-soft); color: var(--navy); border-color: #cfd9ef; }
.tab svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.topbar__account { display: flex; align-items: center; gap: 12px; }
.topbar__user {
  color: var(--muted);
  font-size: 12.5px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__signout { margin: 0; }

.sitefoot {
  flex-shrink: 0;
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 13px;
  padding: 34px 22px 0;
  margin-top: 30px;
}
.sitefoot__inner {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.3fr;
  gap: 34px;
  padding-bottom: 28px;
}
.sitefoot__col--brand .logo--foot { max-height: 30px; max-width: 190px; margin-bottom: 12px; }
.sitefoot__col--brand .logo { font-size: 21px; }
.sitefoot__col--brand .logo__plus { color: var(--footer-heading); }
.sitefoot__about { line-height: 1.65; color: var(--footer-text); max-width: 34ch; }

.sitefoot__heading {
  position: relative;
  color: var(--footer-heading);
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 11px;
}
.sitefoot__heading::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: 0;
  width: 74px;
  height: 2px;
  background: linear-gradient(90deg, var(--footer-border) 0 46%, transparent 46% 56%, var(--footer-border) 56% 100%);
}
[dir="rtl"] .sitefoot__heading::after { background: linear-gradient(270deg, var(--footer-border) 0 46%, transparent 46% 56%, var(--footer-border) 56% 100%); }

.sitefoot__links { list-style: none; margin: 0; padding: 0; }
.sitefoot__links li { margin-bottom: 10px; }
.sitefoot__links a { color: var(--footer-text); }
.sitefoot__links a:hover { color: var(--footer-heading); text-decoration: none; }

.sitefoot__contact { line-height: 1.7; margin-bottom: 12px; }
.sitefoot__phone a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--footer-text);
}
.sitefoot__phone a:hover { color: var(--footer-heading); text-decoration: none; }
.sitefoot__phone svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.sitefoot__bar {
  max-width: 1180px;
  margin: 0 auto;
  border-top: 1px solid var(--footer-border);
  padding: 17px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.sitefoot__company { font-size: 12.5px; }
.sitefoot__social { display: flex; gap: 14px; }
.sitefoot__social a {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  color: var(--footer-text);
  transition: color .14s, background .14s;
}
.sitefoot__social a:hover { color: var(--footer-heading); background: var(--footer-border); }
.sitefoot__social svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.sitefoot__social svg path[d^="M14 9h3V6"] { fill: currentColor; stroke: none; }

@media (max-width: 820px) {
  .sitefoot__inner { grid-template-columns: 1fr 1fr; gap: 26px; }
  .sitefoot__col--brand { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .sitefoot { padding: 26px 14px 0; }
  .sitefoot__inner { grid-template-columns: 1fr; gap: 24px; padding-bottom: 22px; }
  .sitefoot__bar { flex-direction: column; align-items: flex-start; gap: 14px; }
  .sitefoot__about { max-width: none; }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: 20px; margin-bottom: 18px; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px 0;
}
.card__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-2);
}
.card--pad .card__title { font-size: 13px; letter-spacing: .04em; margin-bottom: 14px; }
.card__note { font-size: 12px; color: var(--muted); }

/* 3. Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn__glyph { stroke: none; }

.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-deep); }
.btn--ghost { border-color: var(--border-strong); color: var(--text-2); background: var(--surface); }
.btn--ghost:hover { background: var(--surface-muted); }
.btn--google { width: 100%; border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.btn--google:hover { background: var(--surface-muted); }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* 4. Forms ----------------------------------------------------------------- */
.form { display: block; }
.field { margin-bottom: 14px; }
.field label,
.filters__group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field input,
.field select {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--muted-2); }
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 48, 107, .12);
}
.field input:disabled { background: var(--surface-muted); color: var(--muted); }
.field__hint { margin-top: 5px; font-size: 12px; color: var(--muted); }
.form--rows .btn { margin-top: 4px; }

.select { position: relative; display: inline-block; }
.select::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5px;
  border-right: 1.8px solid var(--muted);
  border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}
.select select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.select select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 48, 107, .12);
}
.select--sm select { min-height: 32px; font-size: 13px; padding: 0 28px 0 10px; }
.select--sm::after { right: 10px; }

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid;
}
.alert--error { background: var(--bad-bg); border-color: var(--bad-border); color: var(--bad-text); }
.alert--ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12.5px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* 5. Auth screen ----------------------------------------------------------- */
.body--auth .page { display: flex; align-items: center; justify-content: center; }
.auth { width: 100%; max-width: 380px; padding: 40px 20px 60px; text-align: center; }
.auth__brand { display: inline-block; margin-bottom: 26px; }
.auth__brand:hover { text-decoration: none; }
.auth__card { padding: 24px; text-align: left; }
.auth__title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.auth__subtitle { color: var(--muted); font-size: 13px; margin: 4px 0 18px; }
.auth__switch { margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.auth__switch a { font-weight: 600; }
.backlink { margin-top: 6px; font-size: 13px; }

/* 6. Page header + filters ------------------------------------------------- */
.pagehead { margin-bottom: 16px; }
.pagehead--split { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.pagehead__title { font-size: 25px; font-weight: 700; letter-spacing: -.02em; }
.pagehead__sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.filters__group { min-width: 116px; }
.filters__group--inline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.filters__group--inline label { margin: 0; font-size: 12px; color: var(--muted); }
.filters .select { width: 100%; }

.savestate {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
  opacity: 0;
  transition: opacity .2s;
}
.savestate.is-on { opacity: 1; }
.savestate::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
}
.savestate.is-saved::before { background: var(--green); }
.savestate.is-error { color: var(--red); }
.savestate.is-error::before { background: var(--red); }

/* Money saved banner */
.saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.saved__label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #c7d3ec;
}
.saved__icon { width: 22px; height: 22px; fill: none; stroke: #c7d3ec; stroke-width: 1.5; }
.saved__value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.saved.is-negative { background: #7f1d1d; }
.saved.is-negative .saved__label, .saved.is-negative .saved__icon { color: #fecaca; stroke: #fecaca; }

/* 7. Stat cards ------------------------------------------------------------ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px 16px;
  text-align: center;
  cursor: default;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--border-strong); }
.stat__icon { width: 17px; height: 17px; margin: 0 auto 7px; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stat__label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat__value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat--green  .stat__value, .stat--green  .stat__icon { color: var(--green);  stroke: var(--green); }
.stat--red    .stat__value, .stat--red    .stat__icon { color: var(--red);    stroke: var(--red); }
.stat--blue   .stat__value, .stat--blue   .stat__icon { color: var(--blue);   stroke: var(--blue); }
.stat--purple .stat__value, .stat--purple .stat__icon { color: var(--purple); stroke: var(--purple); }
.stat--navy   .stat__value, .stat--navy   .stat__icon { color: var(--navy);   stroke: var(--navy); }
.stat--amber  .stat__value, .stat--amber  .stat__icon { color: var(--amber);  stroke: var(--amber); }
.stats--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* 8. Charts ---------------------------------------------------------------- */
.chartcard { margin-bottom: 16px; }
.chart { padding: 6px 12px 12px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart__empty {
  padding: 42px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.legend { display: flex; gap: 16px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend__dot--budget { background: var(--border-strong); }
.legend__dot--actual { background: var(--navy); }

.axis-line { stroke: var(--border); stroke-width: 1; }
.axis-text { fill: var(--muted-2); font-size: 10px; font-family: var(--font); }
.axis-text--x { fill: var(--muted); font-size: 11px; }
.hover-band { fill: currentColor; color: var(--text); opacity: 0; transition: opacity .12s; }
.hover-band.is-on { opacity: .05; }
.bar { transition: opacity .12s; }
.bar--budget { opacity: .42; }
.area-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area-dot { stroke: var(--surface); stroke-width: 2; opacity: 0; transition: opacity .12s; }
.area-dot.is-on { opacity: 1; }

/* 9. Category sheets ------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.sheet__head {
  background: var(--cat);
  color: #fff;
  padding: 9px 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sheet__count { font-weight: 600; letter-spacing: .02em; opacity: .85; text-transform: none; font-size: 11px; }

.sheet table { width: 100%; border-collapse: collapse; }
.sheet thead th {
  padding: 7px 8px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.sheet thead th.num { text-align: center; }
.sheet tbody td { padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sheet tbody td:first-child { padding-left: 10px; }
.sheet tbody tr:hover { background: var(--cat-soft); }

.cell-label, .cell-amount {
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.cell-label:hover, .cell-amount:hover { border-color: var(--cat-line); }
.cell-label:focus, .cell-amount:focus {
  outline: none;
  background: #fff;
  border-color: var(--cat);
  box-shadow: 0 0 0 3px var(--cat-soft);
}
.cell-amount {
  border-color: var(--cat-line);
  background: #fff;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.cell-amount::-webkit-outer-spin-button,
.cell-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cell-label::placeholder, .cell-amount::placeholder { color: var(--muted-2); }
.col-amount { width: 84px; }
.col-remove { width: 26px; }

.rowdel {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--muted-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.sheet tbody tr:hover .rowdel, .rowdel:focus-visible { opacity: 1; }
.rowdel:hover { background: var(--bad-bg); color: var(--red); }
.rowdel svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }

.sheet__total td {
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  border-bottom: 0;
  font-weight: 700;
  font-size: 12.5px;
  padding: 9px 8px;
}
.sheet__total .num { padding-right: 14px; font-variant-numeric: tabular-nums; }
.sheet__total td:first-child { color: var(--text-2); }

.sheet__foot { padding: 8px 10px 10px; }
.addrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: none;
  padding: 4px 6px;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cat);
  cursor: pointer;
}
.addrow:hover { background: var(--cat-soft); }
.sheet__empty { padding: 14px 12px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* 10. Tables --------------------------------------------------------------- */
.tablecard { margin-bottom: 16px; padding-bottom: 4px; }
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  position: sticky;
  top: 0;
  padding: 10px 14px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}
.table tbody td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .is-empty { color: var(--muted-2); }
.table tbody tr.is-untracked td { color: var(--muted-2); }
.table tfoot td {
  padding: 11px 14px;
  border-top: 2px solid var(--border);
  font-weight: 700;
  background: var(--surface-muted);
}
.table--months tbody td:first-child { font-weight: 600; }
.money-in { color: var(--green); }
.money-out { color: var(--red); }
.money-save { color: var(--navy); }
.diff-up { color: var(--red); font-weight: 600; }
.diff-down { color: var(--green); font-weight: 600; }
.diff-flat { color: var(--muted); }
.diff__arrow { display: inline-block; margin-right: 3px; }
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--cat-soft);
  color: var(--cat);
}
.tablenote { padding: 12px 14px 14px; color: var(--muted-2); font-size: 11.5px; }
.emptystate { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.emptystate a { font-weight: 600; }

/* 11. Tooltip -------------------------------------------------------------- */
.tooltip {
  position: fixed;
  z-index: 200;
  max-width: 260px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .13s ease, transform .13s ease;
  visibility: hidden;
}
.tooltip.is-on { opacity: 1; transform: translateY(0); visibility: visible; }
.tooltip__title { color: var(--tip-strong); font-weight: 700; margin-bottom: 4px; }
.tooltip__row { display: flex; justify-content: space-between; gap: 18px; }
.tooltip__row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--tip-strong); }
.tooltip__hr { height: 1px; background: var(--tip-rule); margin: 5px 0; }
.tooltip__note { color: var(--tip-text); opacity: .75; font-size: 11px; margin-top: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  z-index: 210;
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: var(--red); color: #fff; }

/* 12. Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- tablets */
@media (max-width: 820px) {
  .shell { padding: 18px 14px 40px; }
  .pagehead__title { font-size: 22px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
}

/* ----------------------------------------------------------------- phones */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .shell { padding: 14px 12px 40px; }

  /* Top bar: brand and account on one line, navigation scrolling beneath it. */
  .topbar__inner {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "brand account" "nav nav";
    align-items: center;
    gap: 10px 8px;
    padding: 10px 12px;
  }
  .topbar__brand { grid-area: brand; margin: 0; }
  .topbar__account { grid-area: account; justify-self: end; gap: 6px; }
  /* Wraps onto a second line rather than scrolling sideways.
     A horizontal scroller hid whatever did not fit - and since the Admin tab
     only exists for admins, the cut-off point moved depending on who was
     looking. Wrapping lays the same tabs out cleanly either way. */
  .topbar__nav {
    grid-area: nav;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 2px;
  }
  .tab { flex: 0 0 auto; padding: 8px 14px; font-size: 13.5px; }
  .topbar__user { display: none; }          /* the email is in Account anyway */
  .langswitch { padding: 6px 10px; font-size: 12px; }
  .btn--sm { padding: 0 10px; }

  .pagehead__title { font-size: 20px; }
  .pagehead__sub { font-size: 12.5px; }
  .pagehead--split { flex-direction: column; align-items: stretch; gap: 12px; }

  /* Filters as a two-up grid rather than a cramped row. */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 10px;
    padding: 12px;
  }
  .filters__group { min-width: 0; }
  .savestate { grid-column: 1 / -1; margin: 0; }

  .saved { padding: 14px 16px; }
  .saved__value { font-size: 21px; }
  .saved__label { font-size: 10.5px; letter-spacing: .08em; }

  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 10px 13px; }
  .stat__value { font-size: 17px; }
  .stat__label { font-size: 9.5px; letter-spacing: .06em; }
  .stats--six { grid-template-columns: 1fr 1fr; }

  /* Bigger tap targets in the sheets. */
  .sheet tbody td { padding: 6px 4px; }
  .sheet tbody td:first-child { padding-inline-start: 8px; }
  .cell-label, .cell-amount { min-height: 38px; font-size: 15px; }
  .col-amount { width: 76px; }
  .sheet thead th { font-size: 9px; padding: 7px 5px; }
  .rowdel { opacity: 1; }                   /* no hover on a phone */
  .sheet__head { padding: 10px 12px; }
  .addrow { padding: 8px 6px; font-size: 13.5px; }

  .chart { padding: 4px 2px 8px; }
  .card__head { padding: 12px 12px 0; }
  .legend { gap: 12px; }

  .table thead th { padding: 9px 10px; font-size: 9.5px; }
  .table tbody td { padding: 10px 10px; }
  .tablewrap { -webkit-overflow-scrolling: touch; }

  /* Dialogs behave like sheets that rise from the bottom. */
  .modal { align-items: end; padding: 0; }
  .modal__box {
    max-width: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 88vh;
    animation: sheetUp .22s ease;
  }
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }

  .rowactions { white-space: normal; }
  .linkbtn { padding: 6px 8px; }
  .createform { grid-template-columns: 1fr; }
  .searchbar { width: 100%; }
  .searchbar input[type="search"] { flex: 1; min-width: 0; }
  .pagefoot { justify-content: stretch; }
  .pagefoot .btn { width: 100%; }
  .auth { padding: 26px 14px 50px; }
  .auth__card { padding: 20px 16px; }
  .codeinput { font-size: 26px !important; letter-spacing: .38em; }
}

@media (max-width: 380px) {
  .stats, .stats--six { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .col-amount { width: 68px; }
}

/* Phones and tablets: no hover states to get stuck on. */
@media (hover: none) {
  .tooltip { display: none !important; }
  .rowdel { opacity: 1; }
  .stat:hover { transform: none; box-shadow: var(--shadow-sm); }
}

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

@media print {
  .topbar, .filters, .rowdel, .sheet__foot, .savestate { display: none !important; }
  body { background: #fff; }
  .card, .sheet { box-shadow: none; }
}

/* ==========================================================================
   Language switcher + right-to-left support
   ========================================================================== */
.langswitch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.langswitch:hover { background: var(--surface-muted); text-decoration: none; }
.langswitch svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
}
.langswitch--auth {
  position: absolute;
  top: 18px;
  inset-inline-end: 18px;
}
.body--auth { position: relative; }

/* Arabic reads better a touch larger and with more line spacing. */
[lang="ar"] body,
body[dir="rtl"] { font-size: 14.5px; line-height: 1.65; }

/* --- mirrored layout ---------------------------------------------------- */
[dir="rtl"] .topbar__brand { margin-right: 0; margin-left: auto; }
[dir="rtl"] .savestate { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sheet thead th,
[dir="rtl"] .table thead th,
[dir="rtl"] .sheet tbody td:first-child { text-align: right; }
[dir="rtl"] .sheet thead th.num,
[dir="rtl"] .table .num,
[dir="rtl"] .sheet__total .num { text-align: left; }
[dir="rtl"] .sheet tbody td:first-child { padding-left: 6px; padding-right: 10px; }
[dir="rtl"] .sheet__total .num { padding-right: 8px; padding-left: 14px; }
[dir="rtl"] .cell-amount { text-align: left; }
[dir="rtl"] .select::after { right: auto; left: 12px; }
[dir="rtl"] .select select { padding: 0 12px 0 32px; }
[dir="rtl"] .select--sm select { padding: 0 10px 0 28px; }
[dir="rtl"] .field input,
[dir="rtl"] .field select { text-align: right; }
[dir="rtl"] .diff__arrow { margin-right: 0; margin-left: 3px; }
[dir="rtl"] .backlink a::before { content: "→ "; }
[dir="ltr"] .backlink a::before { content: "← "; }

/* Amounts stay left-to-right so "SAR 1,250.50" never reorders. */
[dir="rtl"] .saved__value,
[dir="rtl"] .stat__value,
[dir="rtl"] .cell-amount,
[dir="rtl"] .sheet__total .num,
[dir="rtl"] .table .num,
[dir="rtl"] .tooltip__row span:last-child,
[dir="rtl"] .axis-text {
  direction: ltr;
  unicode-bidi: embed;
}
[dir="rtl"] .tooltip__row { flex-direction: row-reverse; }

/* Charts are drawn in SVG coordinates, so they must not be mirrored. */
[dir="rtl"] .chart svg { direction: ltr; }

@media (max-width: 720px) {
  .langswitch { padding: 5px 9px; font-size: 12px; }
  .langswitch--auth { top: 12px; inset-inline-end: 12px; }
}

/* ==========================================================================
   Admin panel
   ========================================================================== */
.shell--wide { max-width: 1320px; }
.stats--six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats--six .stat__value { font-size: 20px; }
.stats--six .stat__label { font-size: 10px; }

.subtabs { display: flex; gap: 4px; flex-wrap: wrap; }
.subtab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.subtab:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.subtab.is-active { background: var(--navy-soft); color: var(--navy); border-color: #cfd9ef; }

.createform {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 16px;
  align-items: start;
}
.createform .btn { grid-column: 1 / -1; justify-self: start; }
.field--check { display: flex; align-items: center; padding-top: 22px; }
.field--check label {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0; font-weight: 500; cursor: pointer;
}
.field--check input { width: auto; min-height: 0; }

.searchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.searchbar input[type="search"] {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  min-width: 190px;
}
.searchbar input[type="search"]:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 48, 107, .12);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge--ok    { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); }
.badge--info  { background: var(--navy-soft); color: var(--navy); border: 1px solid var(--border); }
.badge--warn  { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.badge--bad   { background: var(--bad-bg); color: var(--bad-text); border: 1px solid var(--bad-border); }
.badge--muted { background: var(--surface-muted); color: var(--muted); border: 1px solid var(--border); }

.tag {
  display: inline-block;
  margin-inline-start: 5px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
}
.tag--admin { background: var(--navy); color: #fff; }
.tag--free  { background: var(--warn-bg); color: var(--amber); border: 1px solid var(--warn-border); }

.table--users td { vertical-align: top; }
.table--users .muted { font-size: 12px; }
.rowactions { white-space: nowrap; }
.inlineform { display: inline; margin: 0; }
.linkbtn {
  border: 0;
  background: none;
  padding: 3px 6px;
  border-radius: 5px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}
.linkbtn:hover { background: var(--navy-soft); }
.linkbtn--danger { color: var(--red); }
.linkbtn--danger:hover { background: var(--bad-bg); }

.ratesgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.ratefield { display: block; }
.ratefield span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.ratefield em { color: var(--muted); font-weight: 400; font-style: normal; }
.ratefield input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.ratefield input:read-only { background: var(--surface-muted); color: var(--muted); }
.ratefield input:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 48, 107, .12);
}

.pager { display: flex; gap: 5px; padding: 12px 14px; flex-wrap: wrap; }
.pager__link {
  min-width: 30px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.pager__link:hover { background: var(--surface-muted); text-decoration: none; }
.pager__link.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Read-only notice for expired accounts */
.readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.readonly-banner strong { display: block; margin-bottom: 2px; }
.is-readonly .cell-label,
.is-readonly .cell-amount { background: var(--surface-muted); cursor: not-allowed; }
.is-readonly .addrow,
.is-readonly .rowdel { display: none; }

@media (max-width: 1100px) { .stats--six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .stats--six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Subscribe / renew page */
.auth--wide { max-width: 430px; }
.pricebox {
  text-align: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 4px 0 16px;
}
.pricebox__amount { font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.pricebox__period { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ticklist { list-style: none; margin: 0 0 18px; padding: 0; }
.ticklist li {
  position: relative;
  padding-inline-start: 24px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.ticklist li::before {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  top: 5px;
  width: 5px; height: 9px;
  border: solid var(--green);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Price conversion on the subscribe page */
.pricebox__converted { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); margin-top: 4px; }
.pricecurrency {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.pricecurrency label { margin: 0; }
.pricenote {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* Admin settings previews */
.previewrow {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  min-height: 54px;
}
.imgpreview { max-height: 34px; max-width: 210px; width: auto; object-fit: contain; }
.imgpreview--icon { max-height: 34px; max-width: 34px; border-radius: 6px; }
.field input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
}

/* Verification code + password reset */
.codeinput {
  text-align: center;
  font-size: 30px !important;
  font-weight: 700;
  letter-spacing: .5em;
  text-indent: .5em;
  font-variant-numeric: tabular-nums;
  min-height: 62px !important;
}
.spamnote {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 14px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.forgotlink { text-align: end; margin: -6px 0 14px; font-size: 12.5px; }

/* ==========================================================================
   Dialogs (export, quick add) + page footer actions
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, .45);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal[hidden] { display: none; }
.modal__box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal__title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal__sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
body.modal-open { overflow: hidden; }

.choice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.choice input { width: auto; margin: 0; }
.choice__body {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px 26px;
  flex-wrap: wrap;
}
[dir="rtl"] .choice__body { padding: 0 26px 10px 0; }
.choice__body[hidden] { display: none; }
.choice__and { color: var(--muted); font-size: 12.5px; }

.tab--quick {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
.tab--quick:hover { background: var(--surface-muted); }

.pagefoot { display: flex; justify-content: flex-end; margin-top: 4px; }
.pagefoot .btn svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ==========================================================================
   Motion
   Small, quick and purposeful. Every one of these is disabled outright for
   anyone who has asked their system to reduce motion.
   ========================================================================== */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp  { from { transform: translateY(100%); } to { transform: none; } }
@keyframes popIn    { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes flash    { 0% { background: var(--cat-soft); } 100% { background: transparent; } }
@keyframes countUp  { from { opacity: .35; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes barGrow  { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes drawLine { from { stroke-dashoffset: var(--len, 1200); } to { stroke-dashoffset: 0; } }

/* Cards arrive in sequence rather than all at once. */
.saved      { animation: fadeUp .32s ease both; }
.stats .stat{ animation: fadeUp .3s ease both; }
.stats .stat:nth-child(2) { animation-delay: .04s; }
.stats .stat:nth-child(3) { animation-delay: .08s; }
.stats .stat:nth-child(4) { animation-delay: .12s; }
.stats .stat:nth-child(5) { animation-delay: .16s; }
.stats .stat:nth-child(6) { animation-delay: .2s; }
.chartcard  { animation: fadeUp .34s ease .1s both; }
.grid .sheet{ animation: fadeUp .32s ease both; }
.grid .sheet:nth-child(2) { animation-delay: .05s; }
.grid .sheet:nth-child(3) { animation-delay: .1s; }
.grid .sheet:nth-child(4) { animation-delay: .15s; }
.tablecard  { animation: fadeUp .32s ease .06s both; }
.auth__card { animation: popIn .28s ease both; }
.alert      { animation: fadeUp .24s ease both; }

/* A figure that has just changed nudges into place. */
.stat__value.is-changed,
.saved__value.is-changed { animation: countUp .3s ease; }

/* The row you just edited glows briefly in its category colour. */
.sheet tbody tr.is-saved { animation: flash .9s ease; }

/* Charts draw themselves in. */
.chart .bar { transform-origin: bottom; animation: barGrow .45s cubic-bezier(.2,.8,.3,1) both; }
.chart .area-line { animation: drawLine 1s ease both; }
.chart svg { animation: fadeIn .3s ease both; }

.modal__box { animation: popIn .2s ease both; }
.modal      { animation: fadeIn .16s ease both; }

/* Interactive polish */
.btn, .tab, .linkbtn, .subtab, .langswitch { transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s; }
.btn:active, .linkbtn:active { transform: translateY(1px) scale(.99); }
.sheet tbody tr { transition: background .12s; }
.cell-label, .cell-amount { transition: border-color .14s, background .14s, box-shadow .14s; }
.card { transition: box-shadow .18s; }
.toast { transition: opacity .2s, transform .24s cubic-bezier(.2,.8,.3,1); }

/* Anything the browser is told not to animate, is not animated. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   My Account menu
   ========================================================================== */
.accountmenu { position: relative; }
.accountmenu__button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.accountmenu__button:hover { background: var(--surface-muted); }
.accountmenu__button svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.accountmenu__caret { width: 12px !important; height: 12px !important; opacity: .6; transition: transform .16s; }
.accountmenu.is-open .accountmenu__caret { transform: rotate(180deg); }
.accountmenu.is-open .accountmenu__button { background: var(--navy-soft); border-color: #cfd9ef; color: var(--navy); }

.accountmenu__panel {
  position: absolute;
  top: calc(100% + 7px);
  inset-inline-end: 0;
  min-width: 226px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .14s, transform .14s, visibility .14s;
}
.accountmenu.is-open .accountmenu__panel { opacity: 1; visibility: visible; transform: none; }

.accountmenu__who {
  padding: 8px 10px 9px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}
.accountmenu__form { margin: 0; }
.accountmenu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
.accountmenu__item:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.accountmenu__item--danger { color: var(--red); }
.accountmenu__item--danger:hover { background: var(--bad-bg); color: var(--red); }
.accountmenu__item svg { width: 15px; height: 15px; flex-shrink: 0; }

@media (max-width: 640px) {
  .accountmenu__button span { display: none; }        /* icon only, saves room */
  .accountmenu__button { padding: 7px 9px; }
  .accountmenu__panel { min-width: 210px; }
}

/* ==========================================================================
   Subscription box on the account page
   ========================================================================== */
.subbox {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.subbox__status { min-width: 150px; }
.subbox__days {
  display: block;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.subbox__status .muted { font-size: 12.5px; }
.subbox__status .badge { margin-bottom: 5px; }
.subbox__renew { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0; }
.subbox__note { flex: 1 0 100%; margin: 4px 0 0; }

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.stepper__btn {
  width: 38px;
  height: 38px;
  border: 0;
  background: none;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  color: var(--navy);
  cursor: pointer;
  transition: background .12s;
}
.stepper__btn:hover:not(:disabled) { background: var(--navy-soft); }
.stepper__btn:disabled { color: var(--muted-2); cursor: not-allowed; }
.stepper__value {
  min-width: 96px;
  padding: 0 6px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 700;
  border-inline: 1px solid var(--border);
  line-height: 38px;
}
.field__hint--above { margin: -2px 0 6px; }

@media (max-width: 640px) {
  .subbox { gap: 12px; padding: 14px; }
  .subbox__renew { width: 100%; }
  .subbox__renew .btn { flex: 1; }
  .readonly-banner { flex-direction: column; align-items: stretch; }
  .readonly-banner .btn { width: 100%; }
}

/* Revenue period bar on the Reports tab */
.periodbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.periodbar__dates { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.periodbar__dates[hidden] { display: none; }
.periodbar__dates label { margin: 0; font-size: 12.5px; color: var(--muted); }
.periodbar__dates input[type="date"] {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
}
.periodbar__label { color: var(--muted); font-size: 12px; margin-top: 10px; }
.stats--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.periodstats { margin-bottom: 0; }
.periodbar .btn svg { margin-inline-end: 2px; }

@media (max-width: 640px) {
  .periodbar { flex-direction: column; align-items: stretch; }
  .periodbar .select, .periodbar .btn { width: 100%; }
  .stats--three { grid-template-columns: 1fr; }
}

/* Amount field with its currency shown alongside */
.amountfield { position: relative; display: block; }
.amountfield input {
  width: 100%;
  min-height: var(--tap);
  padding-inline: 12px 58px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.amountfield input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 48, 107, .12);
}
.amountfield__code {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
  letter-spacing: .03em;
}
.amountfield__preview {
  margin: 6px 0 0;
  min-height: 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Dark mode extras
   ========================================================================== */
body { transition: background-color .2s ease, color .2s ease; }

/* The theme toggle in the top bar */
.themetoggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.themetoggle:hover { background: var(--surface-muted); color: var(--text); }
.themetoggle svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.themetoggle__sun  { display: none; }
.themetoggle__moon { display: block; }
:root[data-theme="dark"] .themetoggle__sun  { display: block; }
:root[data-theme="dark"] .themetoggle__moon { display: none; }

/* Form controls need explicit colours in dark mode or the browser draws them
   with its own light chrome. */
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
:root[data-theme="dark"] input::placeholder { color: var(--muted-2); }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="file"]::-webkit-file-upload-button { filter: invert(.85); }
:root[data-theme="dark"] .cell-amount { background: var(--surface-muted); }
:root[data-theme="dark"] .cell-label:focus,
:root[data-theme="dark"] .cell-amount:focus { background: var(--surface); }
:root[data-theme="dark"] .field input:disabled { background: var(--surface-muted); color: var(--muted); }

/* The saved banner already sits on navy; in dark mode it needs its own tone. */
:root[data-theme="dark"] .saved { background: #1b2740; }
:root[data-theme="dark"] .saved.is-negative { background: #3a1a1c; }
:root[data-theme="dark"] .saved__label,
:root[data-theme="dark"] .saved__icon { color: #93a7cc; stroke: #93a7cc; }

/* Category headers keep white text but need slightly deeper fills. */
:root[data-theme="dark"] .sheet__head { filter: saturate(.85) brightness(.85); }
:root[data-theme="dark"] .btn--primary { color: #0f1319; font-weight: 700; }
:root[data-theme="dark"] .btn--primary:hover { background: var(--navy-deep); }
:root[data-theme="dark"] .tab.is-active { background: var(--navy-soft); color: var(--navy); border-color: var(--border-strong); }
:root[data-theme="dark"] .pager__link.is-active { color: #0f1319; }
:root[data-theme="dark"] .stepper__btn { color: var(--navy); }
:root[data-theme="dark"] img.logo--image { /* nothing by default; a dark logo can be set in Settings */ }

/* Charts: the gridlines and labels come from tokens, so only the fills that
   were hardcoded need attention. */
:root[data-theme="dark"] .chart__empty { color: var(--muted); }

/* One logo per theme; only the matching one is shown. */
.logo--dark { display: none; }
:root[data-theme="dark"] .logo--light { display: none; }
:root[data-theme="dark"] .logo--dark  { display: inline-block; }
/* With no dark logo uploaded, the light one is still shown rather than nothing. */
:root[data-theme="dark"] .logo--light:only-of-type { display: inline-block; }

/* Currency picker grid in the admin */
.curgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}
.curcard {
  display: block;
  position: relative;
  padding: 11px 12px 11px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
[dir="rtl"] .curcard { padding: 11px 34px 11px 12px; }
.curcard:hover { border-color: var(--border-strong); }
.curcard.is-on { border-color: var(--navy); background: var(--navy-soft); }
.curcard input {
  position: absolute;
  inset-inline-start: 11px;
  top: 13px;
  width: auto;
  min-height: 0;
  margin: 0;
}
.curcard__code { display: block; font-weight: 700; font-size: 13px; }
.curcard__name { display: block; font-size: 11.5px; color: var(--muted); }
.curcard__note {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--amber);
}
.curcard.is-locked { opacity: .95; }
.curactions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ratefield--off { opacity: .5; }
.previewrow--dark { background: #12161c; border-color: #2a313d; }

@media (max-width: 640px) {
  .curgrid { grid-template-columns: 1fr 1fr; }
  .curactions { flex-direction: column; align-items: stretch; }
  .curactions .btn { width: 100%; }
}

/* Content pages (privacy, terms, refund) */
.pagetitle { margin: 8px 0 20px; }
.pagetitle__h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.15;
}
.pagetitle__meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.prose { line-height: 1.75; color: var(--text-2); font-size: 14.5px; }
.prose p { margin-bottom: 14px; }
.prose p:last-child { margin-bottom: 0; }

@media (max-width: 640px) {
  .pagetitle__h1 { font-size: 26px; }
  .prose { font-size: 14px; }
}

/* Textareas, used by the content editor */
.field textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}
.field textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 48, 107, .12);
}
.minihead {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
.minihead:first-of-type { margin-top: 4px; }

/* Payment method badges */
.paygrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 9px;
  margin-bottom: 18px;
}
.paycard {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.paycard:hover { border-color: var(--border-strong); }
.paycard.is-on { border-color: var(--navy); background: var(--navy-soft); }
.paycard input { width: auto; min-height: 0; margin: 0; flex-shrink: 0; }
.paycard__img { max-height: 22px; max-width: 62px; object-fit: contain; }
.paycard__badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 5px;
  background: var(--tone, var(--navy));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
  line-height: 1.35;
}

/* The strip shown to the customer on the subscribe page */
.paystrip {
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  text-align: center;
}
.paystrip__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}
.paystrip__items { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.paystrip__img { max-height: 22px; max-width: 58px; object-fit: contain; }

@media (max-width: 640px) {
  .paygrid { grid-template-columns: 1fr 1fr; }
}

/* A short explanatory line under a table. Distinct from the old tablenote,
   which was removed from Reports at the client's request. */
.tablehint {
  padding: 11px 14px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

/* Gateway cards in the admin */
.gwcard {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-bottom: 10px;
  background: var(--surface);
  transition: border-color .14s, background .14s;
}
.gwcard.is-on { border-color: var(--navy); background: var(--navy-soft); }
.gwcard__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gwcard__pick {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}
.gwcard__pick input { width: auto; min-height: 0; margin: 0; }
.gwcard__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tone, var(--navy)); flex-shrink: 0; }
.gwcard__name { font-weight: 700; font-size: 14px; }
.gwcard__region {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
}
.gwcard__status {
  margin-inline-start: auto;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.gwcard__status--ready      { background: var(--ok-bg);   color: var(--ok-text);   border: 1px solid var(--ok-border); }
.gwcard__status--pending    { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.gwcard__status--manual     { background: var(--navy-soft); color: var(--navy);    border: 1px solid var(--border-strong); }
.gwcard__status--incomplete { background: var(--bad-bg);  color: var(--bad-text);  border: 1px solid var(--bad-border); }
.gwcard__status--off        { background: var(--surface-muted); color: var(--muted); border: 1px solid var(--border); }
.gwcard__note { margin: 9px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
/* The credential fields open as soon as the switch is on.
   Three routes to the same result, because relying on one meant a browser
   without :has() and a script that had not run left the box stuck shut:
     - the server marks the card when it loads
     - :has() reacts to the tick with no script at all
     - the script keeps older browsers in step */
.gwcard__fields { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); display: none; }
.gwcard.is-on .gwcard__fields { display: block; }
.gwcard:has(.switch input:checked) .gwcard__fields { display: block; }
.gwcard:has(.switch input:checked) { border-color: var(--navy); background: var(--navy-soft); }
.gwcard .check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 4px 0 0; cursor: pointer; }
.gwcard .check input { width: auto; min-height: 0; margin: 0; }

@media (max-width: 640px) {
  .gwcard__status { margin-inline-start: 0; }
}

/* "this is your account currency" tag beside the picker */
.deftag {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--navy-soft);
  border: 1px solid var(--border);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  white-space: nowrap;
}
.deftag[hidden] { display: none; }

/* Trend charts with their comparison toggle */
.trendfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 16px 16px;
}
.trendfoot .legend { margin: 0; }
.trendfoot .legend[hidden] { display: none; }
.trendfoot .btn.is-active {
  background: var(--navy-soft);
  border-color: var(--navy);
  color: var(--navy);
}
.trend-line { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 640px) {
  .trendfoot { flex-direction: column; align-items: stretch; padding: 0 12px 14px; }
  .trendfoot .btn { width: 100%; }
  .trendfoot .legend { justify-content: center; }
}

/* On/off switch */
.switch { position: relative; display: inline-flex; flex-shrink: 0; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.switch__track {
  display: block;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background .18s;
}
.switch__knob {
  display: block;
  width: 16px;
  height: 16px;
  margin: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .35);
  transition: transform .18s;
}
.switch input:checked + .switch__track { background: var(--green); }
.switch input:checked + .switch__track .switch__knob { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .switch__track .switch__knob { transform: translateX(-16px); }
.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* Editable payment method / gateway logo cards */
.paygrid--edit { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); }
.paycard--edit { flex-direction: column; align-items: stretch; gap: 10px; cursor: default; }
.paycard__head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  margin: 0;
  cursor: pointer;
}
.paycard__edit { display: grid; grid-template-columns: 1fr 38px; gap: 6px; }
.paycard__edit input[type="text"] {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  min-width: 0;
}
.paycard__edit input[type="color"] {
  width: 38px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.paycard__edit input[type="file"] {
  grid-column: 1 / -1;
  padding: 5px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
}
.paycard__drop {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 11.5px;
  color: var(--red);
  cursor: pointer;
}
.paycard__drop input { width: auto; min-height: 0; margin: 0; }
.gwcard__logo { max-height: 20px; max-width: 74px; object-fit: contain; flex-shrink: 0; }

/* Choosing a gateway at checkout */
.paychoice__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 9px;
}
.paychoice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.paychoice__option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px;
  margin: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .14s, background .14s, transform .08s;
}
.paychoice__option:hover { border-color: var(--border-strong); }
.paychoice__option:active { transform: scale(.99); }
.paychoice__option input { position: absolute; opacity: 0; width: 0; height: 0; }
.paychoice__option:has(input:checked),
.paychoice__option.is-picked { border-color: var(--navy); background: var(--navy-soft); }
.paychoice__option img { max-height: 26px; max-width: 100%; object-fit: contain; }
.paychoice__name { font-weight: 700; font-size: 13.5px; color: var(--tone, var(--navy)); }
.paychoice__option:focus-within { outline: 2px solid var(--navy); outline-offset: 2px; }

/* Live rates controls */
.ratesbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 11px 13px;
  margin-bottom: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ratesbar__when { color: var(--muted); font-size: 12px; margin-inline-start: auto; }
.switchline { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 13px; cursor: pointer; }
.ratesbar__auto { display: inline-flex; }

@media (max-width: 640px) {
  .ratesbar { flex-direction: column; align-items: stretch; }
  .ratesbar__when { margin-inline-start: 0; }
  .ratesbar .btn { width: 100%; }
}

/* ==========================================================================
   Planner activity log
   ========================================================================== */
.plannerwrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}
.plannerwrap .grid { margin: 0; }

.logpanel {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeUp .32s ease .12s both;
}
.logpanel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 14px 0;
}
.logpanel__title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.logpanel__sub { padding: 2px 14px 11px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.logpanel__toggle {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.logpanel__toggle:hover { background: var(--surface-muted); color: var(--text); }
.logpanel__toggle svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform .18s;
}
.logpanel.is-closed .logpanel__toggle svg { transform: rotate(-90deg); }
.logpanel.is-closed .logpanel__body,
.logpanel.is-closed .logpanel__sub { display: none; }

.logpanel__body { max-height: 60vh; overflow-y: auto; border-top: 1px solid var(--border); }
.logpanel__empty { padding: 18px 14px; color: var(--muted); font-size: 12.5px; text-align: center; }

.loglist { list-style: none; margin: 0; padding: 0; }
.logitem {
  display: grid;
  grid-template-columns: 3px 1fr auto;
  gap: 0 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  animation: fadeUp .22s ease both;
}
.logitem:last-child { border-bottom: 0; }
.logitem__bar { border-radius: 2px; background: var(--tone, var(--border-strong)); }
.logitem__name { font-weight: 600; color: var(--text); word-break: break-word; }
.logitem__meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.logitem__amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
  align-self: center;
}
.logitem__amount--up   { color: var(--green); }
.logitem__amount--down { color: var(--red); }
.logitem__amount--flat { color: var(--muted); }
.logitem__tag {
  display: inline-block;
  margin-inline-start: 5px;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

@media (max-width: 1180px) {
  .plannerwrap { grid-template-columns: minmax(0, 1fr); }
  .logpanel { position: static; }
  .logpanel__body { max-height: 340px; }
}

/* Quick Add: money out or money in */
.quickhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.quickhead label { margin: 0; }
.kindswitch {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-muted);
  padding: 2px;
  gap: 2px;
}
.kindswitch__btn {
  border: 0;
  border-radius: 999px;
  background: none;
  padding: 5px 13px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background .14s, color .14s;
}
.kindswitch__btn--expense.is-on { background: var(--red); color: #fff; }
.kindswitch__btn--income.is-on { background: var(--green); color: #fff; }
.kindswitch__btn:not(.is-on):hover { color: var(--text); }

/* The dialog takes on the colour of whichever side is chosen. */
.modal.is-income .btn--primary { background: var(--green); border-color: var(--green); }
.modal.is-income .btn--primary:hover { background: #12833c; }
.modal.is-income .amountfield input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
}
.modal.is-income .amountfield__preview { color: var(--green); }

/* Page-head controls kept together at the end of the row */
.pagehead__tools {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.filters__group--edit { display: flex; align-items: flex-end; gap: 8px; }
.editicon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#edit-toggle.is-editing { background: var(--navy); border-color: var(--navy); color: #fff; }
#edit-toggle svg, #undo-last svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Read-only name and total in the sheet */
.cell-name { display: block; padding: 8px 10px; font-size: 14px; color: var(--text); word-break: break-word; }
.cell-name em { color: var(--muted-2); font-style: italic; }
.cell-actual {
  display: block;
  padding: 8px 10px;
  text-align: end;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.col-add { width: 66px; }
.addtx {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--cat, var(--border-strong));
  border-radius: 999px;
  background: var(--surface);
  color: var(--cat, var(--navy));
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, transform .08s;
}
.addtx:hover { background: var(--cat-soft); }
.addtx:active { transform: scale(.97); }
.addtx svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

/* ==========================================================================
   Expense tracker
   ========================================================================== */
.trackertools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tracker__scope { color: var(--muted); font-size: 12.5px; margin: -6px 0 12px; }

.statement { padding: 4px 0; }
.statement__day {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 16px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.txrow {
  display: grid;
  grid-template-columns: 4px 1fr auto auto auto;
  align-items: center;
  gap: 0 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp .2s ease both;
}
.txrow:last-child { border-bottom: 0; }
.txrow__mark { align-self: stretch; border-radius: 2px; }
.txrow__mark--income { background: var(--green); }
.txrow__mark--expense { background: var(--red); }
.txrow__main { min-width: 0; }
.txrow__title { display: block; font-weight: 600; font-size: 14px; word-break: break-word; }
.txrow__sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.txrow__time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txrow__amount { font-weight: 800; font-size: 14.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txrow__amount--income { color: var(--green); }
.txrow__amount--expense { color: var(--red); }
.txrow__revoke {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--muted-2);
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.txrow__revoke:hover { background: var(--bad-bg); color: var(--red); border-color: var(--bad-border); }
.txrow__revoke svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.monthpick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
}
.monthpick__item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.monthpick__item:hover { background: var(--surface-muted); }
.monthpick__item input { width: auto; min-height: 0; margin: 0; }
.choice__body--months { display: block; padding-inline-start: 26px; }

@media (max-width: 640px) {
  .trackertools { width: 100%; }
  .trackertools .searchbar { flex: 1 1 100%; }
  .trackertools .searchbar input { width: 100%; }
  .trackertools .btn { flex: 1; }
  .txrow { grid-template-columns: 4px 1fr auto; row-gap: 6px; padding: 12px 12px; }
  .txrow__time { grid-column: 2; font-size: 11px; }
  .txrow__amount { grid-column: 3; grid-row: 1; }
  .txrow__revoke { grid-column: 3; grid-row: 2; justify-self: end; }
  .col-add { width: 44px; }
  .addtx__text { display: none; }
  .addtx { padding: 7px 9px; }
  .monthpick { grid-template-columns: 1fr 1fr; }
}

/* The account's own currency, called out in the picker */
.select optgroup {
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-muted);
}
.select optgroup option { font-weight: 500; color: var(--text); background: var(--surface); }

/* Locked month plus editable day and time in the Add dialog */
.whenrow {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 74px minmax(0, 1fr);
  gap: 8px;
}
.whenrow input {
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  min-width: 0;
}
#tx-period {
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 600;
  cursor: not-allowed;
}
.whenrow input:focus-visible {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-ring);
}

/* Net total under the ledger */
.statement__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-top: 2px solid var(--border-strong);
  background: var(--surface-muted);
}
.statement__foot[hidden] { display: none; }
.statement__foot-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.statement__foot-value {
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.statement__foot-value.is-up { color: var(--green); }
.statement__foot-value.is-down { color: var(--red); }

/* From / to date range */
.rangerow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.rangerow__cell { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.rangerow__cell span { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.rangerow__cell input {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  min-width: 0;
}

/* The date and time controls read left-to-right even in Arabic, because that
   is how the browser's own pickers lay them out. */
[dir="rtl"] .whenrow input[type="time"],
[dir="rtl"] .whenrow input[type="number"],
[dir="rtl"] .rangerow__cell input[type="date"] { direction: ltr; text-align: start; }

@media (max-width: 560px) {
  .whenrow { grid-template-columns: 1fr; }
  .rangerow { grid-template-columns: 1fr; }
  .statement__foot { padding: 12px; }
}

/* A tapped tooltip needs to sit clear of the finger holding the button. */
@media (hover: none) {
  .tooltip { max-width: min(88vw, 320px); font-size: 13px; padding: 10px 12px; }
}

/* Sort direction toggle on the ledger */
#sort-toggle.is-active {
  background: var(--navy-soft);
  border-color: var(--navy);
  color: var(--navy);
}
#sort-toggle svg { flex-shrink: 0; }

/* ==========================================================================
   Admin settings, grouped
   ========================================================================== */
.jumpbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.jumpbar a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background .14s, color .14s, border-color .14s;
}
.jumpbar a:hover { background: var(--navy-soft); color: var(--navy); border-color: var(--navy); }

.group { padding: 0 !important; overflow: hidden; }
.group__box { width: 100%; }
.group__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .14s;
}
.group__head::-webkit-details-marker { display: none; }
.group__head:hover { background: var(--surface-muted); }
.group__title { font-size: 14px; font-weight: 700; color: var(--text); }
.group__note { font-size: 12.5px; color: var(--muted); }
/* A caret that turns, so open and closed are obvious at a glance. */
.group__head::after {
  content: "";
  margin-inline-start: auto;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .18s;
  flex-shrink: 0;
}
.group__box[open] > .group__head::after { transform: rotate(-135deg); }
.group__box[open] > .group__head { border-bottom: 1px solid var(--border); }
.group__body { padding: 18px; }

.savebar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 18px;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -3px 12px rgba(15, 23, 42, .07);
}
.savebar__note { color: var(--muted); font-size: 12.5px; }

/* Test mode banner */
.testbanner { border-inline-start: 4px solid var(--warn-border); }
.testbanner--live { border-inline-start-color: var(--red); background: var(--bad-bg); }
.testmode__state { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.testbanner--live .testmode__state { color: var(--red); font-weight: 600; }

/* Read-only figures in the planner */
.cell-locked {
  display: block;
  padding: 8px 10px;
  text-align: end;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--muted-2);
}
.editnote {
  margin: -4px 0 14px;
  padding: 9px 13px;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
}
.editnote[hidden] { display: none; }

/* Destructive actions */
.card--danger { border-color: var(--bad-border); }
.card--danger .card__title { color: var(--red); }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }

@media (max-width: 640px) {
  .jumpbar { gap: 5px; }
  .jumpbar a { font-size: 12px; padding: 5px 10px; }
  .group__body { padding: 14px; }
  .group__head { padding: 13px 14px; }
  .savebar { padding: 11px 14px; }
  .savebar .btn { width: 100%; }
}

/* What a gateway will charge, when it differs from the price currency */
.paychoice__option { flex-direction: column; gap: 4px; }
.paychoice__amount {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Settings fields keep a readable measure instead of stretching the card.
   The subscription inputs were full-width while everything above them was
   capped, which made the page look like two different forms. */
.group__body .field input[type="text"],
.group__body .field input[type="email"],
.group__body .field input[type="number"],
.group__body .field input[type="file"],
.group__body .field textarea,
.group__body .field .select,
.group__body .field select { max-width: 420px; }
.group__body .field .select select { width: 100%; }
.savebar { max-width: 420px; }

@media (max-width: 560px) {
  .group__body .field input,
  .group__body .field textarea,
  .group__body .field .select,
  .group__body .field select,
  .savebar { max-width: none; }
}

/* Very narrow phones: the tabs share the width in pairs instead of leaving a
   single orphan on its own line. Works whether or not the Admin tab is there,
   since nothing here assumes a fixed number of them. */
@media (max-width: 420px) {
  .topbar__nav { gap: 5px; }
  .topbar__nav .tab {
    flex: 1 1 calc(50% - 3px);
    justify-content: center;
    padding: 8px 10px;
    font-size: 13px;
    min-width: 0;
  }
  .topbar__nav .tab svg { flex-shrink: 0; }
}
