/* ihm-reports core/v1 theme. The AdsMatrix demo's look (dark first) with a designed light twin.
   Frozen once a brand pins v1: changes that alter an existing brand's look go in core/v2.
   Series colors are the dataviz reference palette, validated (scripts/validate_palette.js) on both surfaces:
   1 blue = this period / the store, 2 orange = Meta, 3 aqua = Google, 4 yellow, 5 magenta, 6 violet; compare = gray. */
:root {
  color-scheme: light;
  --bg: #f4f5f9; --surface: #ffffff; --surface-2: #f3f4f8; --surface-3: #e9ecf3;
  --border: #e1e4ee; --border-strong: #cdd2e0;
  --text: #12141c; --text-2: #4a5068; --text-3: #737a93;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #4a3aa7;
  --compare: #8d93ab; --compare-2: #c3c8d8;
  --good: #11804f; --good-bg: #e2f4ea; --good-line: #a8dcc0;
  --warn: #9a6400; --warn-bg: #fbf0d4; --warn-line: #ecd08a;
  --bad: #c0392f; --bad-bg: #fbe5e3; --bad-line: #f0b5af;
  --accent: #4b5ce0; --accent-bg: #e9ebff; --accent-line: #c4caff;
  --brandmark: linear-gradient(135deg, #2fb4d6, #8f5bf0);
  --shadow: 0 1px 2px rgba(18, 20, 28, .06), 0 4px 16px rgba(18, 20, 28, .05);
  --menu-shadow: 0 24px 60px rgba(18, 20, 28, .18);
  --radius: 12px; --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --top-h: 60px; --side-w: 232px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0a0c14; --surface: #11131d; --surface-2: #171a27; --surface-3: #1e2232;
  --border: #242838; --border-strong: #343a52;
  --text: #f2f3f7; --text-2: #a8adc2; --text-3: #737990;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #9085e9;
  --compare: #6b7190; --compare-2: #3b4058;
  --good: #35c08a; --good-bg: #0f2a22; --good-line: #1d4a3a;
  --warn: #e0a020; --warn-bg: #2e2410; --warn-line: #5a4514;
  --bad: #e66767; --bad-bg: #321a1c; --bad-line: #5c2a2d;
  --accent: #7c8cff; --accent-bg: #1b1f3d; --accent-line: #2f3670;
  --shadow: none; --menu-shadow: 0 32px 80px rgba(0, 0, 0, .6);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c14; --surface: #11131d; --surface-2: #171a27; --surface-3: #1e2232;
  --border: #242838; --border-strong: #343a52;
  --text: #f2f3f7; --text-2: #a8adc2; --text-3: #737990;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #9085e9;
  --compare: #6b7190; --compare-2: #3b4058;
  --good: #35c08a; --good-bg: #0f2a22; --good-line: #1d4a3a;
  --warn: #e0a020; --warn-bg: #2e2410; --warn-line: #5a4514;
  --bad: #e66767; --bad-bg: #321a1c; --bad-line: #5c2a2d;
  --accent: #7c8cff; --accent-bg: #1b1f3d; --accent-line: #2f3670;
  --shadow: none; --menu-shadow: 0 32px 80px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); }
.num, .tnum { font-variant-numeric: tabular-nums; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.ihm-top { position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.ihm-logo { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.ihm-logo i { width: 26px; height: 26px; border-radius: 8px; background: var(--brandmark); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 12px; font-weight: 800; }
.ihm-logo span { font-size: 15px; } .ihm-logo small { color: var(--text-3); font-weight: 500; font-size: 13px; }
.ihm-brand { position: relative; }
.ihm-brand > button { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px 0 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.ihm-brand > button:hover { border-color: var(--border-strong); }
.ihm-av { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--series-1), var(--series-6)); flex: none; }
.ihm-av.all { background: var(--surface-3); color: var(--text-2); }
.ihm-brand b { font-weight: 600; } .ihm-brand small { display: block; font-size: 11px; color: var(--text-3); line-height: 1.1; }
.ihm-brand .car { color: var(--text-3); margin-left: 2px; }
.ihm-menu { position: absolute; top: 44px; left: 0; min-width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--menu-shadow); padding: 6px; display: none; }
.ihm-menu.open { display: block; }
.ihm-menu a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; color: var(--text); text-decoration: none; }
.ihm-menu a:hover, .ihm-menu a.on { background: var(--surface-2); }
.ihm-menu a .st { margin-left: auto; }
.ihm-menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.ihm-grow { flex: 1; }
.ihm-fresh { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); white-space: nowrap; }
.ihm-fresh .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.ihm-fresh.warn .dot { background: var(--warn); } .ihm-fresh.bad .dot { background: var(--bad); }
.ihm-iconbtn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); }
.ihm-iconbtn:hover { color: var(--text); border-color: var(--border-strong); }
.ihm-iconbtn svg { width: 17px; height: 17px; }

.ihm-layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.ihm-side { position: sticky; top: var(--top-h); align-self: start; height: calc(100vh - var(--top-h)); overflow: auto; padding: 18px 12px 30px; border-right: 1px solid var(--border); }
.ihm-side h6 { margin: 18px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.ihm-side h6:first-child { margin-top: 2px; }
.ihm-side a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.ihm-side a:hover { color: var(--text); background: var(--surface-2); }
.ihm-side a.on { color: var(--text); background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent); }
.ihm-side a .k { margin-left: auto; font-size: 10px; color: var(--text-3); }
.ihm-side .note { margin: 20px 10px 0; font-size: 12px; color: var(--text-3); line-height: 1.45; }
.ihm-main { min-width: 0; padding: 24px clamp(16px, 2.2vw, 44px) 64px; }
.ihm-page { max-width: 2400px; margin: 0 auto; display: grid; gap: 22px; }   /* fills wide screens; 2400px keeps ultrawide rows readable */
.ihm-crumbs { font-size: 12px; color: var(--text-3); }
.ihm-crumbs a { color: var(--text-3); text-decoration: none; } .ihm-crumbs a:hover { color: var(--text); }
.ihm-h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 0; line-height: 1.2; }
.ihm-sub { color: var(--text-2); margin: 4px 0 0; max-width: 820px; }
.ihm-pagepick { display: none; width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); padding: 0 10px; }
.ihm-hidden { display: none !important; }

/* ---------- shared components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { background: var(--surface-2); box-shadow: none; }
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--text-3); }
.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.chip, .pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.chip.good, .pill.good { color: var(--good); background: var(--good-bg); border-color: var(--good-line); }
.chip.warn, .pill.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.chip.bad, .pill.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.chip.accent, .pill.accent { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-line); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; color: var(--text-2); cursor: pointer; font-weight: 500; font-size: 13px; }
.seg button[aria-pressed="true"], .seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.t tr:last-child td { border-bottom: 0; } table.t .r { text-align: right; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ihm-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--text); font-size: 13px; }
.ihm-banner.bad { border-color: var(--bad-line); background: var(--bad-bg); } .ihm-banner.good { border-color: var(--good-line); background: var(--good-bg); }
.ihm-tip { position: fixed; pointer-events: none; z-index: 60; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--menu-shadow); display: none; max-width: 280px; }

/* ---------- login ---------- */
.ihm-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.ihm-login form { width: min(380px, 100%); display: grid; gap: 14px; }
.ihm-login input { height: 44px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); padding: 0 12px; }
.ihm-login button { height: 44px; border-radius: 10px; border: 0; background: var(--brandmark); color: #fff; font-weight: 600; cursor: pointer; }

@media (max-width: 1100px) { .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .ihm-layout { grid-template-columns: minmax(0, 1fr); }
  .ihm-side { display: none; }
  .ihm-pagepick { display: block; }
  .ihm-main { padding: 16px 16px 48px; }
  .ihm-fresh .long { display: none; }
  .g3, .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .ihm-top { padding: 0 12px; gap: 8px; }
  .ihm-logo span, .ihm-logo small { display: none; }
  .ihm-brand small { display: none; }
  .ihm-fresh { display: none; }
  .g2, .g3, .g4, .g5 { grid-template-columns: minmax(0, 1fr); }
  .ihm-h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
.ihm-page > *, .ihm-page section { min-width: 0; }

/* source icons on metric cards (core/v1/sources.js) */
.ihm-src { display: inline-flex; gap: 2px; align-items: center; vertical-align: middle; flex: none; }
.ihm-src-i { display: block; width: 14px; height: 14px; }

/* ---------- responsive top bar: drop detail step by step as the window narrows (no sideways scroll at any width) ---------- */
.ihm-top > * { flex-shrink: 0; }
.ihm-top .ihm-grow { flex: 1 1 0; min-width: 0; }
.ihm-fresh { flex-shrink: 1; min-width: 0; overflow: hidden; }
.ihm-fresh > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ihm-fresh .dot { flex: none; }
.ihm-brand { min-width: 0; flex-shrink: 1; }
.ihm-brand > button { max-width: 100%; min-width: 0; }
.ihm-brand b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1280px) { .ihm-fresh .long { display: none; } }
@media (max-width: 1100px) { .ihm-logo small { display: none; } }
@media (max-width: 760px) { .ihm-logo span { display: none; } .ihm-brand small { display: none; } }
@media (max-width: 680px) { .ihm-fresh { display: none; } }
@media (min-width: 1800px) { .ihm-side { padding-left: 16px; padding-right: 16px; } .ihm-layout { grid-template-columns: 252px minmax(0, 1fr); } }
