:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --fg-2: #52514e;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --card: #fafafa;
  --card-2: #ffffff;
  --fg-invert: #ffffff;
  --danger: #b00020;
  --radius: 12px;
  --max: 1140px;

  /* Brand stays monochrome; one accent carries data + primary emphasis. */
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.1);

  /* Status. Reserved — never reused as a chart series. Always shipped with a label. */
  --st-good: #0ca30c;
  --st-warn: #fab219;
  --st-serious: #ec835a;
  --st-critical: #d03b3b;
  --st-neutral: #898781;

  /* Chart tokens — read by charts.js at render time. Validated against --card. */
  --viz-accent: #2a78d6;
  --viz-series-2: #199e70;
  --viz-surface: #fafafa;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-muted: #898781;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #f2f2f2;
    --fg-2: #c3c2b7;
    --muted: #9a9a9a;
    --line: #1f1f1f;
    --card: #0d0d0d;
    --card-2: #141414;
    --fg-invert: #000000;

    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.14);

    --viz-accent: #3987e5;
    --viz-series-2: #199e70;
    --viz-surface: #0d0d0d;
    --viz-grid: #2c2c2a;
    --viz-axis: #383835;
    --viz-muted: #898781;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 20px 16px 80px; }
.topbar {
  border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--max); margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.3px; }
.brand-logo { width: 22px; height: 22px; display: block; color: var(--fg); flex: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-sub { color: var(--muted); font-size: 14px; margin: 2px 0 0; }

/* marketing lander (index) */
.lander { max-width: 640px; margin: 0 auto; padding: 12vh 22px 80px; text-align: center; }
.lander-mark { width: 56px; height: 56px; color: var(--fg); display: block; margin: 0 auto 22px; }
.lander h1 { font-size: clamp(30px, 6vw, 46px); letter-spacing: -0.5px; margin: 0 0 16px; }
.lander .lead { font-size: 17px; max-width: 30em; margin: 0 auto 28px; }
.cta {
  display: inline-block; background: var(--fg); color: var(--fg-invert); text-decoration: none;
  font-weight: 700; font-size: 16px; padding: 14px 28px; border-radius: 12px;
}
.cta:hover { opacity: 0.9; }
.ul { text-decoration: underline; }
.lander-features {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 72px; text-align: left;
}
.lander-feature {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  padding: 18px;
}
.lander-feature svg { width: 22px; height: 22px; color: var(--fg); display: block; margin-bottom: 10px; }
.lander-feature h3 { margin: 0 0 5px; font-size: 15px; letter-spacing: -0.2px; }
.lander-feature p { margin: 0; font-size: 14px; color: var(--muted); }
@media (max-width: 560px) { .lander-features { grid-template-columns: 1fr; } }

/* site footer (mirrors apprechaun.com) */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 40px; padding: 34px 22px 40px;
  text-align: center; color: var(--muted); font-size: 13px;
}
.site-footer .footer-mark { width: 36px; height: 36px; color: var(--fg); display: block; margin: 0 auto 10px; }
.site-footer .flogo { font-weight: 800; letter-spacing: .3em; padding-left: .3em; color: var(--fg); font-size: 15px; }
.site-footer .company { margin: 12px auto 0; max-width: 30em; line-height: 1.6; }
.site-footer nav { margin-top: 14px; }
.site-footer nav a { color: var(--muted); text-decoration: none; padding: 0 4px; }
.site-footer nav a:hover { color: var(--fg); }
.site-footer .sep { opacity: .4; }
.site-footer .copy { margin-top: 16px; opacity: .7; }

/* ad type picker */
.typepick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.typebtn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: auto;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-weight: 600; text-align: left;
}
.typebtn.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.typebtn:disabled { opacity: 0.5; }
.typebtn .small { font-weight: 500; }

/* image drop-pad + thumbnails */
.droppad {
  border: 1.5px dashed var(--line); border-radius: 12px; background: var(--card);
  padding: 26px 16px; text-align: center; color: var(--muted); cursor: pointer; margin-top: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.droppad:hover, .droppad:focus-visible { border-color: var(--muted); outline: none; }
.droppad.drag { border-color: var(--accent); background: var(--accent-wash); color: var(--fg); }
.thumbrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumbitem {
  position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--card); flex: none;
}
.thumbitem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbx {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 999px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; font-size: 13px; line-height: 1;
  cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
}
.coverbadge {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 10px; text-align: center; padding: 2px 0; letter-spacing: 0.3px;
}
.thumbspin { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.thumbspin::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#videoPreview { width: 100%; max-height: 42vh; border-radius: 10px; background: #000; margin-top: 8px; display: block; }

/* live daily rate on the create form */
.ratebox {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 14px 16px; margin-top: 6px;
}
.ratebox .big { line-height: 1.1; }

/* mobile ad preview — ads only run in the phone app, so preview in a phone frame */
.phone-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 14px; }
.phone {
  width: min(100%, 360px); border: 1px solid var(--line); border-radius: 46px;
  padding: 11px; background: var(--card); box-shadow: 0 20px 48px rgba(0, 0, 0, 0.14);
}
.phone-screen {
  position: relative; border: 1px solid var(--line); border-radius: 36px;
  background: var(--bg); aspect-ratio: 9 / 18.5;
  overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
}
.phone-screen::-webkit-scrollbar { display: none; }
.phone-status {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 6px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pnotch { width: 78px; height: 20px; border-radius: 999px; background: #000; border: 1px solid var(--line); }
.pbatt { width: 21px; height: 10px; border: 1px solid var(--muted); border-radius: 3px; padding: 1.5px; display: block; }
.pbatt > span { display: block; width: 70%; height: 100%; border-radius: 1px; background: var(--muted); }

/* feed placement (image ads) — mirrors the app's PostCard ad layout:
   avatar left, header, body text ABOVE the media, domain CTA at the bottom */
.pvpost { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 16px 8px; }
.pvavatar { border-radius: 999px; object-fit: cover; flex: none; }
.pvavatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line); font-weight: 700;
}
.pvcontent { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pvhead { display: flex; align-items: center; gap: 6px; }
.pvbrand { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvtime { color: var(--muted); font-size: 12px; flex: none; }
.pvadtag { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; flex: none; }
.pvmeg { width: 12px; height: 12px; display: block; }
.pvmenu { color: var(--muted); flex: none; }
.pvbody { margin: 0; font-size: 14px; line-height: 1.4; }
.pvcta {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 13px;
}
.pvcta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvarrow { flex: none; }

.pvmedia { position: relative; }
.pvcarousel { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 12px; scrollbar-width: none; }
.pvcarousel::-webkit-scrollbar { display: none; }
.pvcarousel img {
  width: 100%; aspect-ratio: 1; flex: none; scroll-snap-align: start;
  object-fit: cover; display: block; border-radius: 12px; background: #000;
}
/* the next image peeks 30px at the right edge — the app's swipe hint */
.pvcarousel.peek img { width: calc(100% - 30px); }
.pvcount {
  position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.pvnav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px;
  border-radius: 999px; border: none; background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 20px; line-height: 1; padding: 0 0 2px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pvnav.prev { left: 8px; }
.pvnav.next { right: 8px; }
.pvnav.off { opacity: 0.25; pointer-events: none; }
.pvdots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
.pvdots span { width: 6px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.45); }
.pvdots span.on { background: #fff; }

/* clips placement (video ads) — mirrors the app's clips overlay:
   channel row + caption + black AD pill over a bottom gradient */
.phone-screen.clip { overflow: hidden; }
.phone-screen.clip .phone-status { position: relative; z-index: 2; color: #fff; }
.phone-screen.clip .pbatt { border-color: rgba(255, 255, 255, 0.7); }
.phone-screen.clip .pbatt > span { background: rgba(255, 255, 255, 0.7); }
.pvclip { position: absolute; inset: 0; }
.pvclip video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.pvclip-shade { position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, 0.32) 45%, rgba(0, 0, 0, 0.78)); }
.pvclip-meta { position: absolute; left: 14px; right: 64px; bottom: 18px; color: #fff; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.pvchannel { display: flex; align-items: center; gap: 8px; }
.pvchannel .pvavatar-fallback { background: rgba(0, 0, 0, 0.45); border-color: rgba(255, 255, 255, 0.4); }
.pvchname { font-size: 15px; font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.pvcaption {
  margin: 0; font-size: 14px; line-height: 1.36; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.pvadpill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.45);
  font-size: 11px; font-weight: 600;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--fg); color: var(--fg-invert); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; max-width: 90vw; text-align: center; z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.nav { display: flex; gap: 4px; }
.navlink {
  background: none; color: var(--muted); border: none; width: auto;
  font-weight: 600; font-size: 14px; padding: 6px 12px; border-radius: 999px;
}
.navlink.active { color: var(--fg); background: var(--card); }

.banner {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 12px 16px; margin: 14px 0 0; display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap; font-size: 14px;
}
.banner .actions { margin: 0 0 0 auto; }
.banner-warn { border-left: 3px solid var(--st-warn); }
.banner-crit { border-left: 3px solid var(--st-critical); }
.banner-info { border-left: 3px solid var(--accent); }

h1 { font-size: 26px; letter-spacing: -0.5px; margin: 4px 0 2px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 16px 0;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select, button {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
input[type="file"] { padding: 8px; }
button {
  cursor: pointer; background: var(--fg); color: var(--fg-invert); border: none;
  font-weight: 600; width: auto; padding: 10px 18px;
}
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button.link { background: none; color: var(--muted); border: none; padding: 4px; width: auto; text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: default; }
button.sm { padding: 6px 12px; font-size: 13px; }
button.accent { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.big { font-size: 34px; font-weight: 700; letter-spacing: -1px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.stat { text-align: center; }
.stat .n { font-size: 20px; font-weight: 700; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.pill.active { color: var(--fg-invert); background: var(--fg); border-color: var(--fg); }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.ok { color: var(--muted); font-size: 13px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.counter { color: var(--muted); font-size: 12px; text-align: right; margin-top: 4px; }
.counter.near { color: var(--st-serious); }
.hidden { display: none !important; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input[type="checkbox"] { width: auto; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.checkrow { display: flex; gap: 24px; } .checkrow .check { margin-top: 8px; }
.center { max-width: 380px; margin: 8vh auto 0; }
.slider-out { display: flex; justify-content: space-between; font-size: 13px; }
.campaign { display: flex; gap: 12px; align-items: flex-start; border-top: 1px solid var(--line); padding: 14px 0; }
.campaign:first-child { border-top: none; }
.campaign .body { flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.small { font-size: 13px; }

/* multi-select picker */
.ms { position: relative; }
.ms-drop {
  position: absolute; left: 0; right: 0; top: 46px; z-index: 20;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; }
.ms-opt:hover, .ms-opt.hl { background: var(--card); }
.ms-opt img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; background: var(--line); }
.ms-opt .sub { color: var(--muted); font-size: 12px; margin-left: auto; }
.ms-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ms-note { color: var(--st-serious); font-size: 12px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 10px;
}
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 15px; width: auto; }
.ms-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* ============================================================
   Dashboard
   ============================================================ */

/* One filter row, above everything it scopes. */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 18px 0 4px; }
.toolbar .spacer { flex: 1; }
.rangebar { display: inline-flex; gap: 4px; }
.rangebtn {
  width: auto; background: var(--bg); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600;
}
.rangebtn[aria-pressed="true"] { background: var(--fg); color: var(--fg-invert); border-color: var(--fg); }

/* Refetch holds the previous render — no skeleton flash, no layout jump. */
.is-loading { opacity: 0.55; transition: opacity 0.15s; pointer-events: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 12px; margin: 12px 0; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 12px; min-width: 0;
}
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 30px; font-weight: 650; letter-spacing: -0.8px; margin-top: 4px; line-height: 1.1; }
.kpi .v.na { color: var(--muted); font-weight: 500; letter-spacing: -0.2px; }
.kpi .d { font-size: 12px; margin-top: 3px; display: flex; align-items: center; gap: 5px; color: var(--muted); }
.kpi .d b { font-weight: 600; }
.delta-up b { color: var(--st-good); }
.delta-down b { color: var(--st-critical); }
.kpi .spark { height: 28px; margin-top: 10px; }
.kpi .note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Exactly one hero figure per view — the balance. */
.hero-num { font-size: 48px; font-weight: 650; letter-spacing: -1.6px; line-height: 1; }

/* Auto recharge — a settings row at the foot of the wallet card. */
.recharge {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px;
}
.recharge .body { min-width: 0; }
.recharge .title { font-size: 14px; font-weight: 600; }
.recharge .desc { font-size: 13px; color: var(--muted); margin-top: 2px; }

.switch { position: relative; width: 42px; height: 25px; flex: none; cursor: pointer; }
.switch input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
}
.switch .track {
  display: block; height: 100%; border-radius: 999px; background: var(--line);
  transition: background 0.15s; pointer-events: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px;
  border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:disabled { cursor: default; }
.switch input:disabled + .track { opacity: 0.45; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.warn > span { background: var(--st-warn); }
.meter.crit > span { background: var(--st-critical); }
.meter-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.chart-head h2 { margin: 0; }
.chart-head .sub { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.chart-toggle { width: auto; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; flex: none; }
.chart-toggle[aria-pressed="true"] { color: var(--fg); border-color: var(--fg); }

.viz { height: 260px; margin-top: 12px; position: relative; }
.viz-short { height: 150px; }
.viz-svg { display: block; overflow: visible; }
.viz-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.viz-tick { font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  margin: 0; color: var(--muted); font-size: 13px; text-align: center; padding: 0 24px;
}

.viz-tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0;
  background: var(--card-2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; min-width: 120px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); transition: opacity 0.1s;
}
.viz-tip.show { opacity: 1; }
.viz-tip-date { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 7px; }
.viz-tip-key { width: 10px; height: 2px; border-radius: 2px; flex: none; }
.viz-tip-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.viz-tip-name { color: var(--muted); }

.viz-segbar { display: flex; gap: 2px; height: 10px; margin-top: 6px; }
.viz-seg { border-radius: 3px; min-width: 3px; }
.viz-legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.viz-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.viz-legend li b { margin-left: auto; font-weight: 600; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Table view — the WCAG-clean twin of every chart. */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.data th button {
  width: auto; background: none; border: none; padding: 0; color: inherit; font: inherit;
  text-transform: inherit; letter-spacing: inherit; cursor: pointer;
}
table.data th button[aria-sort]::after { content: ''; }
table.data th .arrow { color: var(--fg); margin-left: 3px; }
.ad-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.ad-cell .body { min-width: 0; }
.ad-cell .name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ad-cell .copy {
  color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 260px;
}
.brandmark { width: 16px; height: 16px; border-radius: 4px; object-fit: cover; flex: none; }

/* Click-to-copy campaign id — a quiet caption, not a control. Short label; full id
   lands on the clipboard. */
.cid-pill {
  display: inline-flex; align-items: center; width: auto; margin-top: 4px;
  padding: 0; font-size: 10px; line-height: 1.4; letter-spacing: 0.2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 400; color: var(--muted); background: none;
  border: none; border-radius: 0; white-space: nowrap;
}
.cid-pill:hover { color: var(--fg); }
.cid-pill.copied { color: var(--st-good); }
/* On the ledger, the campaign name + id sit under the transaction type. */
.tx-campaign { display: flex; align-items: center; gap: 8px; margin-top: 2px; color: var(--muted); font-size: 13px; }
.tx-campaign .cid-pill { margin-top: 0; }

/* Status never rides on colour alone — dot + written label. */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 999px; background: var(--st-neutral); flex: none; }
.status-active::before { background: var(--st-good); }
.status-pending::before { background: var(--st-warn); }
.status-paused::before { background: var(--st-serious); }
.status-rejected::before { background: var(--st-critical); }
.status-ended::before { background: var(--st-neutral); }

.spark-cell { width: 90px; height: 26px; }
.rowactions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.rowactions button { padding: 5px 10px; font-size: 12px; }

.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;
}

/* Compact campaign row: five data columns + an actions cell, no horizontal scroll. */
table.campaigns th.th-actions { width: 1%; }
table.campaigns td { vertical-align: top; padding-top: 14px; }
table.campaigns .status { margin-bottom: 5px; }
.days-line { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-sm { height: 4px; width: 84px; margin-top: 5px; }

/* The summary row keeps its rule only while its detail panel is closed; rows come in
   crow/detail pairs, so the last closed crow drops it too. */
tr.crow.open > td { border-bottom: none; }
#campaignsBody tr.crow:nth-last-child(2):not(.open) > td { border-bottom: none; }

.crow-toggle {
  width: 28px; height: 28px; flex: none; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line); color: var(--muted);
}
.crow-toggle:hover { color: var(--fg); border-color: var(--fg); }
.chev { transition: transform 0.15s ease; }
.crow-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }

tr.detail-row > td { padding: 0 12px 14px; border-bottom: 1px solid var(--line); }
.detail { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.detail-metrics { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.detail-metrics .l {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); font-weight: 600;
}
.detail-metrics b { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.detail-meta { color: var(--muted); font-size: 13px; margin-top: 12px; }
.detail .actions { margin-top: 12px; }
.detail .actions button { font-size: 12px; padding: 5px 10px; }

@media (max-width: 720px) {
  table.campaigns .col-trend { display: none; }
  .ad-cell .copy { max-width: 140px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: 20px; }
}

.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty h3 { color: var(--fg); margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 auto 16px; max-width: 34em; font-size: 14px; }

.tx-pos { color: var(--st-good); font-weight: 600; }

/* mobile portal nav — hamburger + dropdown under the topbar */
.menu-btn { display: none; }

@media (max-width: 720px) {
  .menu-btn {
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--fg); width: auto; padding: 6px; margin: -6px;
  }
  .menu-btn svg { width: 24px; height: 24px; display: block; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 8px 16px 14px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  }
  .nav.open { display: flex; }
  .navlink { text-align: left; font-size: 15px; padding: 12px; border-radius: 10px; }
  .navlink.logout { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 6px; padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Brand mark is monochrome black-on-transparent; invert it on dark so it reads
   the same way the old inline SVG did via currentColor. */
@media (prefers-color-scheme: dark) {
  .brand-logo, .lander-mark, .footer-mark { filter: invert(1); }
}
