/* TankLog design system v2 — warm light theme, vivid orange accent,
   extra-rounded cards & pill chips. Mobile-first app shell. */

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/pjs-3.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/pjs-2.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+20A0-20C0;
}

:root {
  --bg: #F4F1EC;
  --surface: #FFFFFF;
  --surface-2: #F6F4EF;
  --border: #EAE6DF;
  --text: #17181A;
  --muted: #8B8D93;
  --brand: #F04A0C;      /* vivid pump orange */
  --brand-strong: #D63F08;
  --brand-soft: #FDEDE5;
  --on-brand: #FFFFFF;
  --good: #16A34A;
  --bad: #DC2626;
  --info: #0369A1;
  --r-lg: 14px;
  --r-md: 10px;
  --shadow: 0 8px 24px rgba(50, 35, 20, .10);
  --shadow-soft: none;
  --tabbar-h: 68px;
}

/* Dark theme — navy surfaces, same orange brand. Set via <html data-theme="dark">. */
:root[data-theme="dark"] {
  --bg: #0B1020;
  --surface: #131A33;
  --surface-2: #1B2344;
  --border: #26305A;
  --text: #EEF2FA;
  --muted: #8E9AC0;
  --brand-soft: rgba(240, 74, 12, .16);
  --good: #34D399;
  --bad: #F87171;
  --info: #7DD3FC;
  --shadow: 0 10px 30px rgba(2, 6, 23, .5);
  --shadow-soft: 0 4px 14px rgba(2, 6, 23, .4);
}
:root[data-theme="dark"] .tabbar { background: rgba(11, 16, 32, .92); box-shadow: 0 -8px 24px rgba(2, 6, 23, .4); }
:root[data-theme="dark"] .tab { color: #5A669A; }
:root[data-theme="dark"] .seg { background: #0E1430; }
:root[data-theme="dark"] .seg button.active { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .input::placeholder { color: #5A669A; }
:root[data-theme="dark"] .input:focus { background: var(--surface); }
:root[data-theme="dark"] .checkpill, :root[data-theme="dark"] .collapse-toggle { border-color: var(--border); }
:root[data-theme="dark"] .banner-info { background: rgba(125, 211, 252, .12); color: var(--info); }
:root[data-theme="dark"] .banner-bad { background: rgba(248, 113, 113, .14); color: var(--bad); }
:root[data-theme="dark"] .banner-good { background: rgba(52, 211, 153, .12); color: var(--good); }
:root[data-theme="dark"] .banner-warn { background: rgba(240, 74, 12, .16); color: #FDBA8C; }
:root[data-theme="dark"] .chip { color: #FDBA8C; }
:root[data-theme="dark"] .btn-danger { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .35); }
:root[data-theme="dark"] .progress, :root[data-theme="dark"] .sk { background: #1B2344; }
:root[data-theme="dark"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent); }
:root[data-theme="dark"] .sk-stat, :root[data-theme="dark"] .sk-banner,
:root[data-theme="dark"] .sk-card, :root[data-theme="dark"] .sk-row { background: #161D3A; }
:root[data-theme="dark"] .daychip { background: var(--surface); border-color: var(--border); }
:root[data-theme="dark"] .toast { background: var(--surface-2); }
@media (min-width: 720px) {
  :root[data-theme="dark"] body {
    background:
      radial-gradient(900px 500px at 85% -10%, rgba(240, 74, 12, .08), transparent 60%),
      radial-gradient(700px 480px at 0% 100%, rgba(56, 189, 248, .05), transparent 55%),
      var(--bg);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
a { color: var(--brand-strong); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.02em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }

/* ---------- App shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(var(--tabbar-h) + 28px);
}
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 14px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 78%, transparent);
  z-index: 20;
}
.appbar .title { font-size: 1.4rem; font-weight: 700; }
.appbar .sub { color: var(--muted); font-size: .85rem; font-weight: 500; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  max-width: 480px;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #A9ABB0;
  font-size: .68rem;
  font-weight: 600;
  transition: color .18s ease;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--brand); }
.tab-fab { display: flex; align-items: center; justify-content: center; }
.tab-fab .fab {
  width: 52px; height: 52px;
  margin-top: -20px;
  border-radius: 16px;
  background: var(--brand);
  color: var(--on-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(240, 74, 12, .25);
  border: 4px solid var(--bg);
  transition: transform .16s ease, box-shadow .16s ease;
}
.tab-fab .fab:active { transform: scale(.94); }
.tab-fab .fab svg { width: 24px; height: 24px; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}
.card h2 { margin-bottom: .75rem; }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  box-shadow: var(--shadow-soft);
}
.stat .label { color: var(--muted); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .delta { font-size: .8rem; font-weight: 600; }
.up { color: var(--bad); }     /* spending up = bad */
.down { color: var(--good); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: .84rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.input, select.input, textarea.input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 14px;
  min-height: 52px;
}
.input:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.input::placeholder { color: #B9BBC0; font-weight: 500; }

/* Grid rows must be allowed to shrink below input intrinsic widths —
   date/select inputs (iOS especially) otherwise blow the row out of the viewport. */
.field, .input { min-width: 0; }
.inputrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.inputrow-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.inputrow > *, .inputrow-3 > * { min-width: 0; }
input[type="date"].input, input[type="month"].input, input[type="week"].input, input[type="time"].input {
  min-width: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
@media (max-width: 430px) {
  /* three-up rows: two columns, third field takes the full next line */
  .inputrow-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .inputrow-3 > :nth-child(3n) { grid-column: 1 / -1; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border-radius: var(--r-md);
  border: none;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 12px 20px;
  transition: background-color .16s ease, border-color .16s ease, transform .12s ease, opacity .16s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: #D8D2C8; }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid #F0BDBD; }
.btn-danger:hover { background: #FDF1F1; }
.btn-sm { width: auto; min-height: 38px; font-size: .86rem; padding: 8px 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Segmented control */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #ECE9E2;
  border: none;
  border-radius: var(--r-md);
  padding: 3px;
  gap: 3px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.seg button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(50, 35, 20, .1);
}

/* Day-strip chips */
.daystrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.daychip {
  flex: 0 0 auto;
  min-width: 56px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 8px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, transform .12s ease;
}
.daychip:active { transform: scale(.96); }
.daychip .d { font-size: 1.1rem; font-weight: 700; line-height: 1.1; }
.daychip .w { font-size: .72rem; font-weight: 600; color: var(--muted); }
.daychip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.daychip.active .w { color: rgba(255, 255, 255, .8); }

/* Checkbox pill */
.checkpill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 13px 14px;
  font-weight: 700;
  cursor: pointer;
}
.checkpill input { width: 20px; height: 20px; accent-color: var(--brand); }

/* Collapsible optional section */
.collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface-2);
  border: 1.5px dashed #D9D4CB;
  border-radius: var(--r-md);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 13px 14px;
  cursor: pointer;
}
.collapse-body { margin-top: 12px; }
[hidden] { display: none !important; }

/* ---------- Chips, badges, banners ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: none;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  padding: 4px 9px;
}
.badge {
  display: inline-block;
  min-width: 19px;
  text-align: center;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 800;
  padding: 2px 6px;
}
.banner {
  display: block;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: .92rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.banner-warn { background: var(--brand-soft); color: var(--brand-strong); }
.banner-info { background: #E3F1FA; color: var(--info); }
.banner-bad { background: #FDE8E8; color: var(--bad); }
.banner-good { background: #E5F6EC; color: #15803D; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.rowitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  color: var(--text);
  box-shadow: var(--shadow-soft);
}
.rowitem .main { min-width: 0; }
.rowitem .t { font-weight: 600; }
.rowitem .s { color: var(--muted); font-size: .82rem; font-weight: 500; }
a.rowitem { transition: border-color .16s ease, transform .12s ease; }
a.rowitem:active { transform: scale(.99); }
.rowitem .end { text-align: right; flex-shrink: 0; }

/* Comparison rows */
.cmp { display: flex; flex-direction: column; gap: 8px; }
.cmprow {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface-2);
  font-variant-numeric: tabular-nums;
}
.cmprow:last-child { border-bottom: none; }
.cmprow .k { color: var(--muted); font-size: .85rem; font-weight: 700; }
.cmprow .v { font-weight: 800; text-align: right; }

/* ---------- Tables (reports) ---------- */
.tablewrap { overflow-x: auto; }
table.tl {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
table.tl th, table.tl td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--surface-2); white-space: nowrap; }
table.tl th:first-child, table.tl td:first-child { text-align: left; }
table.tl th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Auth / centered screens ---------- */
.authwrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 20px;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; font-weight: 800; margin-bottom: 24px; }
.logo .mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.logo .mark svg { width: 24px; height: 24px; }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; font-weight: 600; }
.empty .big { font-size: 2.2rem; margin-bottom: 8px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Progress bar */
.progress { background: #ECE9E2; border-radius: 999px; height: 9px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-strong)); border-radius: 999px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(440px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: .92rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease;
  pointer-events: auto;
}
.toast-success { border-left-color: var(--good); }
.toast-error { border-left-color: var(--bad); }
.toast-warn { border-left-color: var(--brand); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Dialog (bottom sheet on mobile) ---------- */
.dlg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 14, .45);
  backdrop-filter: blur(3px);
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in .2s;
}
.dlg {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  animation: sheet-up .28s cubic-bezier(.2, .8, .25, 1);
  box-shadow: var(--shadow);
}
.dlg h3 { margin-bottom: 6px; }
.dlg p { color: var(--muted); font-weight: 600; }
.dlg .actions { display: flex; gap: 10px; margin-top: 16px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 720px) {
  .dlg-overlay { align-items: center; }
  .dlg { border-radius: 16px; }
}

/* ---------- Spinner ---------- */
.spin {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(0, 0, 0, .15);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: -3px;
}
.btn-primary .spin { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- First-run tour ---------- */
.tour-hi {
  position: relative;
  z-index: 95;
  box-shadow: 0 0 0 4px var(--brand), 0 0 0 9999px rgba(30, 22, 14, .55) !important;
  border-radius: 16px;
}
.tour-card {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 18px);
  z-index: 96;
  width: min(440px, calc(100vw - 28px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  animation: sheet-up .28s cubic-bezier(.2, .8, .25, 1);
}
.tour-card h3 { margin-bottom: 4px; }
.tour-card p { color: var(--muted); font-size: .92rem; font-weight: 600; margin-bottom: 12px; }
.tour-card .actions { display: flex; gap: 10px; align-items: center; }
.tour-card .steps { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 800; }

/* ---------- Swipeable rows (edit / delete fill-ups) ---------- */
.swipewrap { position: relative; border-radius: var(--r-lg); overflow: hidden; }
.swipe-under {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-radius: var(--r-lg);
  overflow: hidden;
}
.swipe-under button {
  border: none;
  width: 86px;
  font: inherit;
  font-weight: 800;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
}
.swipe-edit { background: var(--info); border-radius: var(--r-lg) 0 0 var(--r-lg); }
.swipe-del { background: var(--bad); border-radius: 0 var(--r-lg) var(--r-lg) 0; margin-left: auto; }
.swipewrap .rowitem {
  position: relative;
  transition: transform .18s ease;
  touch-action: pan-y;
  will-change: transform;
}
.swipewrap.dragging .rowitem { transition: none; }

/* ---------- Onboarding checklist ---------- */
.checklist .step { display: flex; align-items: center; gap: 12px; padding: 9px 0; font-weight: 700; }
.checklist .step .tick {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800;
  background: var(--surface-2);
  color: var(--muted);
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.checklist .step.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.checklist .step.done span { color: var(--muted); text-decoration: line-through; }
.ring { position: relative; width: 62px; height: 62px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 800; }

/* Health score pill */
.score {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 12px;
  font-size: .8rem; font-weight: 800;
}
.score-good { background: #E5F6EC; color: #15803D; }
.score-mid { background: #FEF4E2; color: #B45309; }
.score-bad { background: #FDE8E8; color: var(--bad); }
:root[data-theme="dark"] .score-good { background: rgba(52,211,153,.14); color: var(--good); }
:root[data-theme="dark"] .score-mid { background: rgba(251,191,36,.14); color: #FCD34D; }
:root[data-theme="dark"] .score-bad { background: rgba(248,113,113,.14); color: var(--bad); }

/* ---------- Skeleton loader (page transitions + async waits) ---------- */
.skel-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: flex;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.skel-overlay.on { opacity: 1; pointer-events: auto; }
.skel-inner {
  width: 100%;
  max-width: 480px;
  padding: 18px 16px;
}
.sk {
  position: relative;
  overflow: hidden;
  background: #EAE6DF;
  border-radius: 12px;
}
.sk::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  animation: sk-shimmer 1.3s infinite;
}
@keyframes sk-shimmer { to { transform: translateX(100%); } }
.sk-title { height: 28px; width: 46%; margin: 6px 0 6px; border-radius: 9px; }
.sk-sub { height: 13px; width: 30%; margin-bottom: 20px; border-radius: 7px; }
.sk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.sk-stat { height: 86px; border-radius: var(--r-lg); background: #EFEBE4; }
.sk-stat .sk-line { position: absolute; }
.sk-banner { height: 46px; border-radius: var(--r-md); margin-bottom: 14px; background: #EFEBE4; }
.sk-card { height: 190px; border-radius: var(--r-lg); margin-bottom: 14px; background: #EFEBE4; }
.sk-row { height: 74px; border-radius: var(--r-lg); margin-bottom: 10px; background: #EFEBE4; }
.sk-stat.sk::after, .sk-banner.sk::after, .sk-card.sk::after, .sk-row.sk::after { animation-delay: .12s; }

/* ---------- Print (reports) ---------- */
@media print {
  body { background: #fff; color: #111; }
  .tabbar, .appbar, .no-print { display: none !important; }
  .app { max-width: none; padding: 0; }
  .card, .stat, .rowitem { background: #fff; border-color: #ddd; box-shadow: none; color: #111; }
  table.tl th, table.tl td { border-color: #ccc; }
  table.tl th { color: #555; }
}

/* Wider screens */
@media (min-width: 720px) {
  .statgrid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Super-admin layout ---------- */
.adminbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="dark"] .adminbar { background: rgba(11, 16, 32, .92); }
.adminbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}
.abrand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); font-size: 1.02rem; white-space: nowrap; }
.abrand em { font-style: normal; color: var(--brand-strong); font-weight: 600; }
.abrand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.abrand .mark svg { width: 17px; height: 17px; }
.anav { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.anav a {
  color: var(--muted);
  font-weight: 600;
  font-size: .92rem;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color .16s ease, background-color .16s ease;
}
.anav a:hover { color: var(--text); background: var(--surface-2); }
.anav a.active { color: var(--brand-strong); background: var(--brand-soft); }
.anav a.aout { color: var(--bad); }
.adminwrap { max-width: 960px; margin: 0 auto; padding: 0 20px 48px; }
.adminwrap h1 { font-size: 1.35rem; }
@media (max-width: 620px) {
  .adminbar-inner { flex-wrap: wrap; padding: 8px 14px; }
  .anav { width: 100%; }
  .adminwrap { padding: 0 14px 40px; }
}

/* ---------- Motion ---------- */
/* Cross-document page transitions (Chromium): old page fades, new slides up. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .18s ease both; }
::view-transition-new(root) { animation: vt-in .24s cubic-bezier(.2, .8, .25, 1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* Entrance fallback where view transitions don't exist */
@supports not (view-transition-name: root) {
  .app > .card, .app > .statgrid, .app > .list, .app > .banner, .app > .rowitem, .app > section, .app > form {
    animation: rise-in .3s cubic-bezier(.2, .8, .25, 1) both;
  }
  .app > *:nth-child(2) { animation-delay: .03s; }
  .app > *:nth-child(3) { animation-delay: .06s; }
  .app > *:nth-child(4) { animation-delay: .09s; }
}
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }

.input, select.input, textarea.input { transition: border-color .16s ease, background-color .16s ease; }
.collapse-toggle { transition: color .16s ease, border-color .16s ease; }
.checkpill { transition: border-color .16s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}
