:root,
html[data-theme="holding"] {
  --navy: #0c2137;
  --navy-2: #1a4a73;
  --gold: #c9a227;
  --gold-2: #e8d48b;
  --cream: #f3efe4;
  --card: #fbf9f4;
  --ink: #102033;
  --muted: #6b6458;
  --line: rgba(201,162,39,.28);
  --ok-bg: #d1fae5; --ok-fg: #065f46;
  --fail-bg: #fee2e2; --fail-fg: #991b1b;
  --unk-bg: #e5e7eb; --unk-fg: #374151;
  --header-on: #f7f1df;
  --grad: linear-gradient(135deg, #071018 0%, #0c2137 42%, #1a4a73 78%, #c9a227 160%);
  --shell: linear-gradient(180deg, rgba(201,162,39,.22), rgba(251,249,244,.98) 46%, var(--card));
}
html[data-theme="gas"] {
  --navy: #0a1628; --navy-2: #1565c0; --gold: #f57c00; --gold-2: #ffb74d;
  --cream: #e8eef6; --card: #f8fbff; --ink: #0a1628; --muted: #5c6b7a;
  --line: rgba(21,101,192,.22);
  --header-on: #f4f8ff;
  --grad: linear-gradient(135deg, #0a1628 0%, #0d2847 40%, #1565c0 78%, #f57c00 155%);
  --shell: linear-gradient(180deg, rgba(245,124,0,.18), rgba(248,251,255,.98) 46%, var(--card));
}
html[data-theme="spa"] {
  --navy: #1a1209; --navy-2: #7a4419; --gold: #c9a227; --gold-2: #e8d48b;
  --cream: #f5ede0; --card: #fffaf3; --ink: #1a1209; --muted: #7a7468;
  --line: rgba(201,162,39,.3);
  --header-on: #f7f1df;
  --grad: linear-gradient(135deg, #1a1209 0%, #4a3728 38%, #7a4419 72%, #c9a227 150%);
  --shell: linear-gradient(180deg, rgba(201,162,39,.24), rgba(255,250,243,.98) 46%, var(--card));
}
html[data-theme="midnight"] {
  --navy: #05070c; --navy-2: #152238; --gold: #d4af37; --gold-2: #f0d78c;
  --cream: #0e141c; --card: #161e2a; --ink: #e8eef6; --muted: #9aa7b5;
  --line: rgba(212,175,55,.28);
  --ok-bg: #064e3b; --ok-fg: #a7f3d0;
  --fail-bg: #7f1d1d; --fail-fg: #fecaca;
  --unk-bg: #1f2937; --unk-fg: #d1d5db;
  --header-on: #f7f1df;
  --grad: linear-gradient(135deg, #05070c 0%, #0b1220 40%, #1b3358 80%, #d4af37 160%);
  --shell: linear-gradient(180deg, rgba(212,175,55,.16), rgba(22,30,42,.98) 50%, var(--card));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Poppins, system-ui, sans-serif;
  background:
    radial-gradient(900px 420px at 110% -8%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 55%),
    var(--cream);
  color: var(--ink);
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  font-size: 13px;
  line-height: 1.4;
}
h1, h2, .serif { font-family: "Playfair Display", Georgia, serif; }

.hero {
  background: var(--grad);
  color: var(--header-on);
  padding: calc(14px + env(safe-area-inset-top)) 16px 28px;
  position: relative;
}
.hero.foldable { padding-bottom: 32px; }
.hero.collapsed {
  padding-bottom: 12px;
}
.hero.collapsed h1 {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 0;
}
.hero.collapsed .sub,
.hero.collapsed .hero-filter { display: none; }
.btn-fold {
  position: absolute; right: 12px; bottom: 8px;
  border: 0; border-radius: 999px; padding: 4px 10px;
  font-size: .72rem; font-weight: 700; font-family: inherit;
  background: rgba(247,241,223,.16); color: var(--gold-2); cursor: pointer;
}
.hero-filter {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.hero-filter label { font-size: .68rem; font-weight: 700; opacity: .9; }
.hero-filter input, .hero-filter select {
  width: auto; margin: 0; padding: 7px 10px; max-width: 220px;
  border-radius: 10px; border: 0; font-family: inherit; font-size: .78rem;
}
.hero::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 22px;
  background: linear-gradient(180deg, transparent, var(--cream));
}
.kicker {
  letter-spacing: 1.6px; font-size: .68rem; font-weight: 700;
  color: var(--gold-2); text-transform: uppercase;
}
.hero h1 { font-size: 1.55rem; margin: 6px 0 4px; font-weight: 700; line-height: 1.2; }
.hero .sub { font-size: .8rem; opacity: .82; }
.hero-actions { display: flex; gap: 8px; margin-top: 12px; }

.shell {
  margin: -22px 12px 0;
  position: relative; z-index: 2;
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px 12px;
  box-shadow: 0 16px 36px rgba(7,16,24,.12);
}
.wrap { padding: 0 12px 16px; }

.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat, .card, .ent, .rpt {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.stat { padding: 12px 10px; }
.stat b { display: block; font-size: 1.22rem; color: var(--navy); font-variant-numeric: tabular-nums; }
html[data-theme="midnight"] .stat b { color: var(--gold-2); }
.stat span { font-size: .7rem; color: var(--muted); }
.ent, .rpt { display: block; padding: 12px; margin-bottom: 8px; text-decoration: none; color: inherit; }
.ent .name, .rpt .name { font-weight: 600; color: var(--navy); font-size: .92rem; }
html[data-theme="midnight"] .ent .name,
html[data-theme="midnight"] .rpt .name { color: var(--ink); }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.grp { font-size: .68rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--gold); margin: 14px 2px 8px; }

.badge { font-size: .62rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.ok { background: var(--ok-bg); color: var(--ok-fg); }
.fail { background: var(--fail-bg); color: var(--fail-fg); }
.unknown { background: var(--unk-bg); color: var(--unk-fg); }

.btn {
  border: 0; border-radius: 11px; padding: 11px 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; font-size: .86rem;
}
.btn-gold { background: linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--navy-2) 35%, var(--gold))); color: #fff; }
.btn-navy { background: var(--navy); color: var(--header-on); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-sm { padding: 7px 10px; font-size: .76rem; width: auto; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }

input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); margin: 4px 0 10px; font-family: inherit; font-size: .88rem;
}
label { font-size: .72rem; font-weight: 600; color: var(--muted); display: block; }
.err { background: var(--fail-bg); color: var(--fail-fg); padding: 8px 10px; border-radius: 8px; font-size: .82rem; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: .78rem; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 10px; }
.table-scroll { overflow: auto; -webkit-overflow-scrolling: touch; max-height: 58vh; border-radius: 12px; border: 1px solid var(--line); }
.table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 10px; }
.table th {
  position: sticky; top: 0;
  text-align: left; color: var(--header-on); padding: 5px 6px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  white-space: nowrap; font-weight: 600; font-size: 9px;
}
.table td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.report-frame {
  width: 100%; height: calc(100vh - 220px); min-height: 280px;
  border: 0; border-radius: 12px; background: #fff; display: block;
}
body.filter-collapsed .report-frame { height: calc(100vh - 168px); }
body.on-report { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.report-shell { margin-bottom: 12px; }
body.filter-collapsed .kpis { display: none; }
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 10px; padding: 8px 10px; border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--navy) 8%, transparent), color-mix(in srgb, var(--gold) 14%, transparent));
  font-size: .78rem; font-weight: 600;
}

html[data-theme="midnight"] .report-frame { background: #0e141c; }

.tabbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom));
  height: 58px; background: color-mix(in srgb, var(--navy) 94%, #000);
  display: flex; justify-content: space-around; align-items: center;
  border-radius: 18px; border: 1px solid var(--line);
  box-shadow: 0 14px 32px rgba(0,0,0,.28); z-index: 20;
}
.tabbar a, .tabbar button {
  background: none; border: 0; color: var(--gold-2); font-size: .68rem;
  text-decoration: none; text-align: center; font-weight: 600; font-family: inherit;
}
.tabbar a.active { color: #fff; }

.login-card {
  max-width: 440px; margin: 0 auto; background: var(--card);
  padding: 20px; border-radius: 16px; border: 1px solid var(--line);
}
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-swatch {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: left;
  background: var(--card); color: inherit; cursor: pointer;
}
.theme-swatch.on { outline: 2px solid var(--gold); }
.swatch-bar { height: 28px; border-radius: 8px; margin-bottom: 8px; }
.err-empty {
  text-align: center; font-weight: 700; font-size: 1.05rem;
  padding: 36px 16px; color: var(--navy);
}
