/* Car Tracker. Mobile-first, system fonts only (the CSP blocks external fonts and inline styles).
   Inputs stay 16px so iOS doesn't zoom on focus.
   Layout: sidebar on desktop (>= 900px), top bar + bottom tab bar on phones. */

:root {
  color-scheme: light dark;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e7ef;
  --primary: #2358d8;
  --primary-hi: #3b72f2;
  --primary-text: #ffffff;
  --ring: rgba(35, 88, 216, 0.28);
  --pos: #0d8a47;
  --neg: #d12f2f;
  --stock-bg: #e6edff;
  --stock-text: #1e46a8;
  --sold-bg: #def5e8;
  --sold-text: #0d6e3a;
  --hero-from: #eaf0ff;
  --hero-to: #f7f9ff;
  --hero-grad: linear-gradient(135deg, #2358d8 0%, #3b4fe0 55%, #5b3fd6 100%);
  --side-bg: #0b1220;
  --side-text: #a9b4c7;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 14px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080c14;
    --surface: #111826;
    --surface-2: #19212e;
    --text: #e7ebf2;
    --muted: #8c97ab;
    --border: #212b3c;
    --primary: #7aa5ff;
    --primary-hi: #9bbcff;
    --primary-text: #08111f;
    --ring: rgba(122, 165, 255, 0.35);
    --pos: #4fd17f;
    --neg: #ff7b7b;
    --stock-bg: #1d2b4a;
    --stock-text: #aac3ff;
    --sold-bg: #15382a;
    --sold-text: #7be0a2;
    --hero-from: #17243d;
    --hero-to: #111826;
    --hero-grad: linear-gradient(135deg, #1f4fc4 0%, #3342c9 55%, #4b36bd 100%);
    --side-bg: #05080e;
    --side-text: #8c97ab;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

h1 { font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.02em; margin: 4px 0 18px; }
h2 { font-size: 1.02rem; letter-spacing: -0.01em; margin: 0 0 14px; }

.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 0.85rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.r { text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; }

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

.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- App shell ---------- */

.page { min-width: 0; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-right))
           max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.is-app main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* Top bar (phones, and the sign-in page) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand::before {
  content: "";
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: url("icons/icon-192.png") center / cover no-repeat, var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}

/* Sidebar (desktop only) */
.sidebar { display: none; }

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: end;
  padding: 6px 12px max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-decoration: none;
}
.tab.active { color: var(--primary); }
.tab-add .ico {
  width: 40px;
  height: 40px;
  padding: 9px;
  margin-top: -20px;
  border-radius: 50%;
  color: var(--primary-text);
  background: linear-gradient(180deg, var(--primary-hi), var(--primary));
  box-shadow: 0 4px 12px rgba(35, 88, 216, 0.4);
  border: 3px solid var(--bg);
  box-sizing: content-box;
}
.tab-add { color: var(--text); }

@media (min-width: 900px) {
  body.is-app {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
  }
  .is-app .topbar, .tabbar { display: none; }

  .sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 22px 14px 18px;
    background: var(--side-bg);
    color: var(--side-text);
  }
  .sidebar .brand { color: #fff; padding: 2px 10px 22px; font-size: 1.12rem; }
  .side-nav { display: grid; gap: 4px; }
  .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    color: var(--side-text);
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
  .nav-link.active {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--primary-hi);
  }
  .side-foot { margin: auto 0 0; }
  .nav-btn {
    width: 100%;
    background: none;
    border: 0;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  main { padding: 34px 40px 56px; }
  .is-app main { padding-bottom: 56px; }
}

/* ---------- Page header and KPI tiles ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; }
.page-sub { margin: 2px 0 0; color: var(--muted); }
.page-head .head-add { display: none; }
@media (min-width: 600px) { .page-head .head-add { display: inline-flex; } }

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.kpi-label { font-size: 0.74rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.kpi-value { margin-top: 4px; font-size: 1.55rem; line-height: 1.2; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-sub { margin-top: 2px; font-size: 0.82rem; color: var(--muted); }

.kpi-hero {
  grid-column: 1 / -1;
  border: 0;
  color: #fff;
  background: radial-gradient(circle at 88% 0%, rgba(255, 255, 255, 0.24), transparent 46%), var(--hero-grad);
  box-shadow: 0 10px 28px rgba(35, 88, 216, 0.3);
}
.kpi-hero .kpi-label { color: rgba(255, 255, 255, 0.78); }
.kpi-hero .kpi-sub { color: rgba(255, 255, 255, 0.78); }
.kpi-hero .kpi-value { font-size: 2.3rem; color: #fff; }
.kpi-hero .kpi-value.neg { color: #ffd2d2; }
.kpi-cars { display: none; }

@media (min-width: 600px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-hero { grid-column: auto; }
  .kpi-cars { display: block; }
  .kpi-hero .kpi-value { font-size: 1.9rem; }
}

/* ---------- Cards, charts ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

.grid-2 { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1.7fr 1fr; } }

.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis { stroke: var(--muted); opacity: 0.45; }
.chart .bar-pos { fill: var(--pos); }
.chart .bar-neg { fill: var(--neg); }
.chart .val { font-size: 11.5px; font-weight: 700; fill: var(--text); }
.chart .val.neg { fill: var(--neg); }
.chart .lbl { font-size: 11.5px; font-weight: 600; fill: var(--muted); }
.chart-empty { margin: 8px 0 0; padding: 28px 0; text-align: center; }
@media (max-width: 599px) {
  .chart .val, .chart .lbl { font-size: 14px; }
}

.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut-track { stroke: var(--surface-2); }
.donut-stock { stroke: var(--primary); }
.donut-sold { stroke: var(--pos); }
.donut-num { font-size: 9px; font-weight: 750; fill: var(--text); }
.donut-cap { font-size: 3.2px; font-weight: 650; letter-spacing: 0.4px; text-transform: uppercase; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; flex: 1; min-width: 150px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-stock { background: var(--primary); }
.dot-sold { background: var(--pos); }
.legend-note { padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); }
.legend-note strong { color: var(--text); }

/* ---------- Cars table ---------- */

.table-card { padding: 0; overflow: hidden; }
.table-card .card-head { padding: 16px 16px 12px; margin: 0; }

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tabs a {
  padding: 6px 13px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14); }
@media (prefers-color-scheme: dark) {
  .tabs a.active { background: var(--border); box-shadow: none; }
}

.car-head { display: none; }
.car-row {
  display: grid;
  grid-template-columns: 76px repeat(3, minmax(0, 1fr));
  column-gap: 12px;
  row-gap: 6px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.12s ease;
}
.car-row:hover { background: var(--surface-2); }
.car-row .thumb { grid-row: 1 / span 2; grid-column: 1; width: 76px; height: 76px; }
.car-name { grid-column: 2 / -1; min-width: 0; }
.car-title { font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.car-title .badge { margin-left: 4px; }
.car-sub { margin-top: 2px; font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.car-status, .cell-roi { display: none; }
.cell { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; }
.cell::before {
  content: attr(data-label);
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.thumb { object-fit: cover; border-radius: 11px; background: var(--surface-2); flex: none; }
.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

@media (min-width: 900px) {
  .table-card .card-head { padding: 18px 20px 14px; }
  .car-head, .car-row {
    grid-template-columns: 56px minmax(0, 2.4fr) 96px minmax(90px, 1fr) minmax(90px, 1fr) 76px 60px;
    column-gap: 16px;
  }
  .car-head {
    display: grid;
    padding: 9px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .car-row { padding: 10px 20px; }
  .car-row .thumb { grid-row: auto; grid-column: auto; width: 56px; height: 56px; }
  .car-name { grid-column: auto; }
  .car-title .badge-inline { display: none; }
  .car-status { display: block; }
  .cell-roi { display: block; }
  .cell { text-align: right; }
  .cell::before { display: none; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  vertical-align: middle;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-stock { background: var(--stock-bg); color: var(--stock-text); }
.badge-sold { background: var(--sold-bg); color: var(--sold-text); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  margin: 0;
  border-top: 1px solid var(--border);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, var(--primary-hi), var(--primary));
  border-color: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 1px 2px rgba(35, 88, 216, 0.35);
}
.btn-primary:hover { filter: brightness(1.06); border-color: var(--primary); }
.btn-danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 55%, var(--border)); background: transparent; box-shadow: none; }
.btn-danger:hover { background: color-mix(in srgb, var(--neg) 8%, transparent); border-color: var(--neg); }
.link-btn {
  background: none;
  border: none;
  padding: 6px 0;
  color: var(--neg);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.back:hover { color: var(--text); }

/* Flash messages */
.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 550; }
.flash-ok { background: var(--sold-bg); color: var(--sold-text); }
.flash-error { background: #fde4e4; color: #8f1d1d; }
@media (prefers-color-scheme: dark) {
  .flash-error { background: #4a1d1d; color: #ffb3b3; }
}

/* ---------- Detail-page stat tiles ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 0.74rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.stat-value { margin-top: 2px; font-size: 1.4rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.82rem; color: var(--muted); }
.stat-hero {
  grid-column: 1 / -1;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
}
.stat-hero .stat-value { font-size: 2.2rem; line-height: 1.15; }

@media (max-width: 599px) {
  .detail-stats .stat:last-child { grid-column: 1 / -1; }
}
@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .detail-stats { grid-template-columns: repeat(3, 1fr); }
  .detail-stats .stat-hero { grid-column: auto; }
}

/* ---------- Forms ---------- */

.form { display: grid; gap: 14px; }
/* The label text and its "optional" hint share one row; the field spans below.
   align-content keeps side-by-side fields aligned even when a neighbour is taller. */
.form label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  column-gap: 6px;
  row-gap: 5px;
  font-size: 0.88rem;
  font-weight: 650;
}
.form label > input, .form label > select, .form label > textarea { grid-column: 1 / -1; }
.opt { font-weight: normal; color: var(--muted); }
.row-2, .row-3 { display: grid; gap: 14px; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: normal;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
textarea { resize: vertical; }
input[type="file"] { padding: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
main > form.card.form { max-width: 780px; }

@media (min-width: 600px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------- Car detail ---------- */

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-head h1 { margin-bottom: 14px; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 0; }
.details dt { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 2px 0 0; font-weight: 550; }
.notes { white-space: pre-wrap; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }

.expense-list { list-style: none; margin: 18px 0 0; padding: 0; }
.expense-list li { padding: 11px 0; border-top: 1px solid var(--border); }
.exp-main { display: flex; justify-content: space-between; font-weight: 650; }
.exp-amt { font-variant-numeric: tabular-nums; }
.exp-sub { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.photo-grid figure { margin: 0; }
.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.photo-grid a:hover img { transform: scale(1.015); }

.danger { margin: 28px 0 8px; text-align: center; }

/* ---------- Sign-in and settings ---------- */

.narrow { max-width: 420px; margin: 32px auto; padding: 22px; }
.narrow h1 { margin-top: 0; }
.check { display: flex !important; align-items: center; gap: 10px; font-weight: normal !important; }
.check input { width: 22px; min-height: 22px; accent-color: var(--primary); }
pre, code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.qr { display: block; background: #fff; padding: 8px; border-radius: 10px; margin: 8px 0; }
.steps { padding-left: 20px; margin: 0 0 8px; }
.muted-btn { color: var(--muted); }

/* Photo upload buttons: the label is the button, the file input is hidden. */
.file-btn { position: relative; overflow: hidden; }
.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload-status { margin: 12px 0 0; font-weight: 650; }
.busy .file-btn { opacity: 0.5; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Capital ---------- */
.kpis-capital { margin-top: -4px; }
.kpi-link { display: block; color: inherit; text-decoration: none; }
.kpi-link:hover { border-color: var(--primary); }
.kpis-capital .kpi-value { font-size: 1.35rem; }
.split { display: block; width: 100%; height: 12px; border-radius: 6px; overflow: hidden; margin: 6px 0 14px; }
.split-cash { fill: #16a34a; }
.split-stock { fill: #2563eb; }
.legend-row { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.legend-row li { display: flex; align-items: center; gap: 8px; }
.formula { margin: 14px 0 0; }
.exp-amt.pos { color: var(--pos, #0f8a3c); }
.exp-amt.neg { color: var(--neg, #d32f2f); }

.kpi-avg { display: none; }
@media (min-width: 600px) { .kpi-avg { display: block; } }
