/* app.css — Tally Sync by Swastik Solutions.
   Mobile first: the base styles ARE the phone styles; desktop is added at
   min-width breakpoints, never the other way round. Quiet, professional,
   nothing decorative. Every colour and size comes from tokens.css. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--c-body);
  background: var(--c-bg);
  overflow-x: hidden;              /* a sideways scroll is always a bug */
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--c-primary); text-decoration: none; }
button, a, input, select, textarea { touch-action: manipulation; }

/* One visible focus treatment everywhere; never removed, only styled. */
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }

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

/* ---------- boot ---------- */
.boot-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.boot-card { text-align: center; }
.boot-title { font-size: var(--fs-page); font-weight: var(--fw-page); color: var(--c-heading); }
.boot-note { margin-top: var(--sp-2); color: var(--c-secondary); font-size: var(--fs-body); }

/* ---------- brand ---------- */
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-words { min-width: 0; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--c-heading); line-height: 20px; letter-spacing: -.01em; white-space: nowrap; }
.brand-by { font-size: 10px; font-weight: 500; color: var(--c-secondary); line-height: 12px; white-space: nowrap; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.shell-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.shell-main {
  flex: 1;
  padding: var(--sp-4);
  padding-bottom: calc(var(--safe-bottom) + var(--sp-7));
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ---------- sharpness ----------
   Nothing in this application is frosted, translucent or blurred. Blur and
   half-opacity backgrounds make text render soft on ordinary office screens,
   which reads as "broken", not "modern". Surfaces are solid; separation comes
   from a 1px border and a whisper of shadow. Text is never animated at a
   fractional offset, which is the other thing that smears glyphs. */
.card, .topbar, .nav, .modal, .rt { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ---------- topbar: where am I, what is happening ---------- */
.topbar {
  position: sticky; top: 0; z-index: 35;
  min-height: var(--topbar-h);
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
}
.topbar-brand { flex: 0 1 auto; min-width: 0; }
.topbar-status { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }

/* Search: hidden on the smallest screens, where the space belongs to the
   page itself. */
.topbar-searchwrap { display: none; align-items: center; gap: var(--sp-2); flex: 1 1 auto; max-width: 420px;
  border: 1px solid var(--c-input-border); border-radius: var(--r-control);
  padding: 0 var(--sp-3); height: 36px; background: var(--c-card); color: var(--c-light); }
.topbar-searchwrap:focus-within { border-color: var(--c-primary); outline: 2px solid var(--c-primary); outline-offset: -1px; }
.topbar-searchwrap svg { width: 15px; height: 15px; flex: 0 0 auto; }
.topbar-search { border: 0; outline: 0; background: none; width: 100%; height: 100%;
  font-family: var(--font); font-size: var(--fs-input); color: var(--c-heading); }
@media (min-width: 900px) { .topbar-searchwrap { display: flex; } .topbar-brand { display: none; } }

.topbar-user { display: flex; align-items: center; gap: var(--sp-2); color: var(--c-body); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  background: var(--c-primary-light); color: var(--c-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.topbar-user-name { display: none; font-size: var(--fs-helper); font-weight: 500; }
@media (min-width: 768px) { .topbar-user-name { display: block; } }
.menu-btn { display: inline-flex; }
@media (min-width: 768px) { .menu-btn { display: none; } }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-control);
  border: 1px solid var(--c-input-border); background: var(--c-card);
  color: var(--c-secondary); cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--c-bg); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- status pill ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: var(--fs-helper); font-weight: 600; white-space: nowrap;
  background: var(--c-bg); color: var(--c-secondary);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-light); flex: 0 0 auto; }
.status-pill.ok { background: var(--c-success-bg); color: var(--c-success); }
.status-pill.ok .dot { background: var(--c-success); }
.status-pill.warn { background: var(--c-warning-bg); color: var(--c-warning); }
.status-pill.warn .dot { background: var(--c-warning); }
.status-pill.err { background: var(--c-error-bg); color: var(--c-error); }
.status-pill.err .dot { background: var(--c-error); }
.status-pill.busy .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- navigation ----------
   ONE sidebar everywhere: fixed on desktop, the same markup sliding in as a
   drawer on phones. Groups expand in place — navigation never becomes its own
   page, and no destination is more than two taps away. */
.nav {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(84vw, var(--sidebar-w));
  background: var(--c-card);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  padding: var(--sp-4) var(--sp-3) calc(var(--sp-3) + var(--safe-bottom));
  z-index: 45;
  transform: translateX(-102%);
  transition: transform var(--t-med) var(--ease-out);
  overflow-y: auto;
}
.shell.drawer-open .nav { transform: translateX(0); }
.nav-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  opacity: 0; pointer-events: none; z-index: 44;
  transition: opacity var(--t-med) var(--ease-out);
}
.shell.drawer-open .nav-scrim { opacity: 1; pointer-events: auto; }

.nav-head { display: flex; align-items: center; padding: var(--sp-1) var(--sp-2) var(--sp-5); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding: 0 var(--sp-3);
  border-radius: var(--r-nav);
  font-family: var(--font); font-size: var(--fs-nav); line-height: var(--lh-nav); font-weight: var(--fw-nav);
  color: var(--c-body); text-align: left;
  background: none; border: 0; cursor: pointer; width: 100%;
  white-space: nowrap; overflow: hidden;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.nav-item svg { width: var(--icon); height: var(--icon); flex: 0 0 auto; color: var(--c-secondary); }
.nav-item:hover { background: var(--c-bg); }
.nav-item.active { background: var(--c-primary-light); color: var(--c-primary); font-weight: 600; }
.nav-item.active svg { color: var(--c-primary); }
.nav-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }

/* A group whose page you are on reads as selected even while collapsed. */
.nav-group.holds { color: var(--c-primary); }
.nav-group.holds svg { color: var(--c-primary); }
.nav-chevron { width: 14px !important; height: 14px !important; margin-left: auto;
  transition: transform var(--t-med) var(--ease-out); }
.nav-group.open .nav-chevron { transform: rotate(90deg); }

/* The dropdown under a menu. nav.js sets display/height inline, so this only
   styles the box — no CSS-only collapse that an older browser might ignore.
   The display:none below is the starting state for the split second before
   the script paints, and the fallback if the script never runs. */
.nav-children { display: none; height: 0; overflow: hidden; }
.nav-child {
  display: flex; align-items: center; min-height: 38px;
  padding: 0 var(--sp-3) 0 calc(var(--sp-3) + var(--icon) + var(--sp-3));
  border-radius: var(--r-nav);
  font-size: var(--fs-nav); color: var(--c-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.nav-child:hover { background: var(--c-bg); color: var(--c-body); }
.nav-child.active { color: var(--c-primary); font-weight: 600; background: var(--c-primary-light); }

.nav-foot { margin-top: auto; padding-top: var(--sp-3); }
.nav-collapse { display: none; }

@media (min-width: 768px) {
  .shell { flex-direction: row; }
  .nav {
    position: sticky; top: 0; height: 100vh;
    width: var(--sidebar-w); flex: 0 0 auto;
    transform: none;
    transition: width var(--t-med) var(--ease-out);
    padding-bottom: var(--sp-3);
  }
  .nav-scrim { display: none; }
  .nav-collapse {
    display: flex; align-items: center; gap: var(--sp-3);
    min-height: 36px; padding: 0 var(--sp-3); width: 100%;
    border: 0; background: none; border-radius: var(--r-nav);
    color: var(--c-light); cursor: pointer;
    font-family: var(--font); font-size: var(--fs-helper);
  }
  .nav-collapse:hover { background: var(--c-bg); color: var(--c-secondary); }
  .nav-collapse svg { width: 15px; height: 15px; flex: 0 0 auto; transition: transform var(--t-med) var(--ease-out); }

  /* Collapsed rail: icons only. Groups become flyouts so every destination
     stays reachable without widening the rail. */
  .shell.nav-collapsed .nav { width: var(--sidebar-rail); padding-left: var(--sp-2); padding-right: var(--sp-2); overflow: visible; }
  .shell.nav-collapsed .nav-item { justify-content: center; padding: 0; gap: 0; }
  .shell.nav-collapsed .nav-label,
  .shell.nav-collapsed .nav-chevron,
  .shell.nav-collapsed .brand-words { display: none; }
  .shell.nav-collapsed .nav-head { justify-content: center; padding-left: 0; padding-right: 0; }
  .shell.nav-collapsed .nav-collapse { justify-content: center; padding: 0; }
  .shell.nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
  .shell.nav-collapsed .nav-group-wrap { position: relative; }
  /* Rail flyout: the box only. nav.js shows and hides it on hover and on
     keyboard focus. */
  .shell.nav-collapsed .nav-children {
    position: absolute; left: calc(100% + var(--sp-2)); top: 0;
    min-width: 190px;
    background: var(--c-card); border: 1px solid var(--c-border);
    border-radius: var(--r-card); box-shadow: var(--shadow-lift);
    padding: var(--sp-2); z-index: 50;
  }
  .shell.nav-collapsed .nav-child { padding-left: var(--sp-3); }

  .shell-main { padding: var(--sp-6); padding-bottom: var(--sp-8); }
  .topbar { padding: var(--sp-2) var(--sp-6); }
}

/* ---------- headings & text ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
h1.page-title { font-size: var(--fs-page); line-height: var(--lh-page); font-weight: var(--fw-page); color: var(--c-heading); margin: 0; letter-spacing: -.01em; }
h2.section-title { font-size: var(--fs-section); line-height: var(--lh-section); font-weight: var(--fw-section); color: var(--c-heading); margin: var(--sp-5) 0 var(--sp-3); }
.helper { font-size: var(--fs-helper); line-height: var(--lh-helper); color: var(--c-secondary); }

/* ---------- cards ---------- */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  transition: box-shadow var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
a .card:hover, a.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.card-title { font-size: var(--fs-card); line-height: var(--lh-card); font-weight: var(--fw-card); color: var(--c-heading); margin: 0 0 var(--sp-3); }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.kpi { padding: var(--sp-4); margin-bottom: 0; }
.kpi .kpi-label { font-size: var(--fs-label); line-height: var(--lh-label); font-weight: var(--fw-label); color: var(--c-secondary); }
.kpi .kpi-value { font-size: var(--fs-kpi); line-height: var(--lh-kpi); font-weight: var(--fw-kpi); color: var(--c-heading); margin-top: var(--sp-1); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: var(--fs-helper); color: var(--c-secondary); margin-top: var(--sp-1); }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-grid.cols-3 { grid-template-columns: 1fr 1fr; }
@media (min-width: 768px) { .kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

/* ---------- quick actions ---------- */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (min-width: 768px) { .quick-actions { grid-template-columns: repeat(4, 1fr); } }
.quick-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-4); min-height: var(--tap);
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--r-card);
  color: var(--c-heading); font-weight: 600; font-size: var(--fs-body);
  transition: box-shadow var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.quick-action:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--c-primary-light); }
.quick-action:active { transform: scale(.98); }
.quick-action svg { width: 20px; height: 20px; color: var(--c-primary); }
.quick-action .qa-sub { font-size: var(--fs-helper); font-weight: 400; color: var(--c-secondary); }

/* ---------- greeting ---------- */
.greeting { margin-bottom: var(--sp-4); }
.greeting-line { font-size: var(--fs-section); line-height: var(--lh-section); font-weight: 600; color: var(--c-heading); }

/* ---------- two-up split (one column on phones) ---------- */
.split { display: grid; grid-template-columns: 1fr; gap: var(--sp-3); }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1.4fr; align-items: start; } }

/* ---------- entry stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.stat { display: block; padding: var(--sp-3); border-radius: var(--r-control); background: var(--c-bg); text-align: center; }
.stat:hover { background: var(--c-primary-light); }
.stat-value { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--fs-helper); color: var(--c-secondary); margin-top: 2px; }
.stat.ok .stat-value { color: var(--c-success); }
.stat.warn .stat-value { color: var(--c-warning); }
.stat.err .stat-value { color: var(--c-error); }

/* ---------- alerts ---------- */
.alert { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-control); font-size: var(--fs-body); margin-bottom: var(--sp-3); }
.alert-action {
  flex: 0 0 auto; font-weight: 600; font-size: var(--fs-helper); color: inherit;
  border: 1px solid currentColor; border-radius: 6px; padding: 4px 12px; min-height: 28px;
  display: inline-flex; align-items: center;
}
.alert-action:hover { background: rgba(255, 255, 255, .55); }
.alert .alert-fix { font-size: var(--fs-helper); margin-top: 2px; opacity: .85; }
.alert.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.alert.error { background: var(--c-error-bg); color: var(--c-error); }
.alert.info { background: var(--c-info-bg); color: var(--c-info); }
.alert.success { background: var(--c-success-bg); color: var(--c-success); }

/* ---------- freshness ---------- */
.freshness { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-helper); color: var(--c-secondary); }
.freshness .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-success); }
.freshness.stale .dot { background: var(--c-warning); }
.freshness.never .dot { background: var(--c-light); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border-radius: var(--r-control); border: 0; cursor: pointer;
  background: var(--c-primary); color: #fff;
  font-family: var(--font); font-size: var(--fs-button); font-weight: var(--fw-button);
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { background: var(--c-primary-strong); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.secondary { background: var(--c-card); color: var(--c-body); border: 1px solid var(--c-input-border); }
.btn.secondary:hover:not(:disabled) { background: var(--c-bg); }
.btn.danger { background: var(--c-error); }
.btn.small { min-height: 32px; padding: 0 var(--sp-3); font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

/* Primary actions stick above the safe area on phones. */
.sticky-actions {
  position: sticky; bottom: 0;
  margin: var(--sp-4) calc(-1 * var(--sp-4)) 0;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-bottom));
  background: var(--c-card);
  border-top: 1px solid var(--c-border);
  z-index: 30;
}
.sticky-actions .btn { width: 100%; min-height: var(--tap); }
@media (min-width: 768px) {
  .sticky-actions { position: static; margin: 0; padding: var(--sp-4) 0 0; background: none; border-top: 0; }
  .sticky-actions .btn { width: auto; }
}

/* ---------- forms ---------- */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: var(--fs-label); line-height: var(--lh-label); font-weight: var(--fw-label); color: var(--c-body); margin-bottom: var(--sp-1); }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--control-h);
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font); font-size: var(--fs-input);
  color: var(--c-heading);
  border: 1px solid var(--c-input-border); border-radius: var(--r-control);
  background: var(--c-card);
  transition: border-color var(--t-fast) var(--ease-out);
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--c-primary); outline-offset: 0; border-color: var(--c-primary);
}
.field .hint { font-size: var(--fs-helper); color: var(--c-secondary); margin-top: var(--sp-1); }
.field.error input { border-color: var(--c-error); }
.field .error-text { font-size: var(--fs-helper); color: var(--c-error); margin-top: var(--sp-1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

.switch { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); gap: var(--sp-3); }
.switch input { width: 20px; height: 20px; accent-color: var(--c-primary); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 16px; white-space: nowrap; }
.badge.success { background: var(--c-success-bg); color: var(--c-success); }
.badge.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.error { background: var(--c-error-bg); color: var(--c-error); }
.badge.neutral { background: var(--c-primary-light); color: var(--c-primary); }
.badge.info { background: var(--c-info-bg); color: var(--c-info); }

/* ---------- responsive table: real table on desktop, cards on phones. ---------- */
.rt { width: 100%; }
.rt .rt-row {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-2);
}
.rt .rt-row.clickable { cursor: pointer; }
@media (max-width: 767px) {
  .rt .rt-row.clickable { transition: transform var(--t-fast) var(--ease-out); }
  .rt .rt-row.clickable:active { transform: scale(.985); }
}
.rt .rt-cell { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 2px 0; overflow-wrap: anywhere; }
.rt .rt-cell .rt-label { color: var(--c-secondary); font-size: var(--fs-helper); flex: 0 0 auto; }
.rt .rt-cell .rt-value { font-size: var(--fs-table); text-align: right; }
.rt .rt-cell.rt-main { display: block; }
.rt .rt-cell.rt-main .rt-value { font-size: var(--fs-body); font-weight: 600; color: var(--c-heading); text-align: left; }
.rt .rt-cell[data-low="1"] { display: none; }
.rt .rt-head { display: none; }

@media (min-width: 768px) {
  .rt { display: table; border-collapse: separate; border-spacing: 0; background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; }
  .rt .rt-head { display: table-row; }
  .rt .rt-head .rt-th {
    display: table-cell; text-align: left; padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-thead); line-height: var(--lh-thead); font-weight: var(--fw-thead);
    color: var(--c-secondary); border-bottom: 1px solid var(--c-border);
    text-transform: uppercase; letter-spacing: .03em;
    position: sticky; top: var(--topbar-h); background: var(--c-card); z-index: 5;
  }
  .rt .rt-head .rt-th.num { text-align: right; }
  .rt .rt-head .rt-th.sortable { cursor: pointer; user-select: none; }
  .rt .rt-head .rt-th.sortable:hover { color: var(--c-heading); }
  .rt .rt-head .rt-th .sort-arrow { display: inline-block; margin-left: 4px; opacity: .5; font-size: 10px; }
  .rt .rt-row { display: table-row; border: 0; box-shadow: none; border-radius: 0; padding: 0; }
  .rt .rt-row:hover { background: var(--c-bg); }
  .rt .rt-cell { display: table-cell; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); font-size: var(--fs-table); line-height: var(--lh-table); vertical-align: middle; }
  .rt .rt-row:last-child .rt-cell { border-bottom: 0; }
  .rt .rt-cell .rt-label { display: none; }
  .rt .rt-cell .rt-value { text-align: left; font-size: var(--fs-table); }
  .rt .rt-cell.num .rt-value { text-align: right; font-variant-numeric: tabular-nums; display: block; }
  .rt .rt-cell.rt-main .rt-value { font-size: var(--fs-table); font-weight: 500; }
  .rt .rt-cell[data-low="1"] { display: table-cell; }
}

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; }
.pagination .pg-info { font-size: var(--fs-helper); color: var(--c-secondary); }
.pagination .pg-btns { display: flex; gap: var(--sp-2); }

/* ---------- modal: sheet on phones, dialog on desktop ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal {
  background: var(--c-card); width: 100%; max-height: 85vh; overflow-y: auto;
  border-radius: var(--r-card) var(--r-card) 0 0;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + var(--safe-bottom));
}
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; }
  .modal { width: 480px; border-radius: var(--r-card); padding: var(--sp-6); }
}
.modal h3 { margin: 0 0 var(--sp-3); font-size: var(--fs-section); color: var(--c-heading); }
.modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); }
.modal-actions .btn { min-height: var(--tap); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + var(--sp-5));
  background: var(--c-heading); color: #fff;
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-control);
  font-size: var(--fs-body); z-index: 60; max-width: 90vw;
}
.toast .toast-fix { display: block; font-size: var(--fs-helper); color: var(--c-light); margin-top: 2px; }
@media (min-width: 768px) { .toast { bottom: var(--sp-6); } }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--c-secondary); padding: var(--sp-7) var(--sp-4); }
.empty .empty-title { font-weight: 600; color: var(--c-body); margin-bottom: var(--sp-1); }

.bar-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.bar-row .bar-label { flex: 0 0 88px; font-size: var(--fs-helper); color: var(--c-secondary); }
.bar-row .bar-track { flex: 1; height: 8px; background: var(--c-bg); border-radius: 4px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--c-primary); border-radius: 4px; }
.bar-row .bar-value { flex: 0 0 auto; font-size: var(--fs-helper); font-variant-numeric: tabular-nums; }

.breadcrumbs { font-size: var(--fs-helper); color: var(--c-secondary); margin-bottom: var(--sp-3); overflow-wrap: anywhere; }
.breadcrumbs a { color: var(--c-primary); }
.breadcrumbs .sep { margin: 0 var(--sp-1); color: var(--c-light); }

.list-line { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); min-height: var(--tap); border-bottom: 1px solid var(--c-border); transition: background var(--t-fast) var(--ease-out); }
.list-line:last-child { border-bottom: 0; }
.list-line .ll-title { font-size: var(--fs-body); color: var(--c-heading); overflow-wrap: anywhere; }
.list-line .ll-sub { font-size: var(--fs-helper); color: var(--c-secondary); }
.list-line .ll-right { text-align: right; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
a.list-line:hover { background: var(--c-primary-light); margin: 0 calc(-1 * var(--sp-2)); padding: 0 var(--sp-2); border-radius: var(--r-control); }

.trend { display: flex; align-items: flex-end; gap: var(--sp-2); height: 120px; padding-top: var(--sp-3); }
.trend .trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); height: 100%; justify-content: flex-end; }
.trend .trend-bar { width: 70%; max-width: 40px; background: var(--c-primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.trend .trend-label { font-size: 10px; color: var(--c-secondary); }

.seg { display: flex; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--r-control); padding: 2px; gap: 2px; margin-bottom: var(--sp-4); overflow-x: auto; }
.seg button {
  flex: 1; min-height: 36px; border: 0; border-radius: 6px; background: none;
  font-family: var(--font); font-size: var(--fs-table); font-weight: 500; color: var(--c-secondary); cursor: pointer;
  white-space: nowrap; padding: 0 var(--sp-3);
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.seg button.active { background: var(--c-card); color: var(--c-heading); box-shadow: var(--shadow-card); }

.line-editor { border: 1px solid var(--c-border); border-radius: var(--r-control); padding: var(--sp-3); margin-bottom: var(--sp-3); }
.line-editor .le-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-2); }
.line-editor .le-title { font-size: var(--fs-label); font-weight: 600; color: var(--c-secondary); }

.totals { display: flex; justify-content: space-between; font-size: var(--fs-body); font-weight: 600; color: var(--c-heading); padding: var(--sp-3) 0; }
.totals.err { color: var(--c-error); }

/* ---------- skeleton loading (shimmer, not spinners) ---------- */
.skeleton { border-radius: var(--r-control); background: var(--c-skeleton); position: relative; overflow: hidden; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--c-skeleton-sheen), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }
.skel-kpi { height: 108px; margin-bottom: 0; }
.skel-row { height: 52px; margin-bottom: var(--sp-2); }
.skel-card { height: 160px; margin-bottom: var(--sp-3); }

/* ---------- auth ---------- */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--sp-4); background: var(--c-bg); }
.auth-box { width: 100%; max-width: 380px; }
.auth-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: var(--sp-6); gap: var(--sp-2); }
.auth-head .brand-title { font-size: 24px; font-weight: 700; color: var(--c-heading); letter-spacing: -.01em; }
.auth-head .brand-tag { font-size: var(--fs-helper); color: var(--c-secondary); }
.auth-box .card { padding: var(--sp-6); }

/* ---------- connection page ---------- */
.conn-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); }
.conn-hero .conn-state { font-size: 20px; font-weight: 700; color: var(--c-heading); }
.conn-hero .conn-sub { font-size: var(--fs-body); color: var(--c-secondary); max-width: 420px; }
.conn-ring {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg); border: 2px solid var(--c-border); color: var(--c-light);
  margin-bottom: var(--sp-2);
}
.conn-ring svg { width: 28px; height: 28px; }
.conn-ring.ok { background: var(--c-success-bg); border-color: var(--c-success); color: var(--c-success); }
.conn-ring.warn { background: var(--c-warning-bg); border-color: var(--c-warning); color: var(--c-warning); }
.conn-ring.err { background: var(--c-error-bg); border-color: var(--c-error); color: var(--c-error); }

/* No `will-change` anywhere on text containers. Promoting an element to its
   own compositor layer and leaving it there makes the browser rasterise its
   text once, at one scale — which is exactly how a page ends up looking
   permanently soft. Animations here are short-lived and opacity-based, so
   nothing needs promoting. */
.status-pill.clickable { cursor: pointer; }
