/* ELEVATE33 design system (shared with the search audit tool): DM Sans/Mono, indigo-to-orange accents, slate neutrals.
   Layout: blurred white header, sticky filter bar under it, numbered section cards. */
:root {
  --p1: #3730a3; --p2: #4f46e5; --p3: #7c3aed; --p4: #9333ea; --o2: #ea580c; --o3: #f97316;
  --grad: linear-gradient(135deg, var(--p2), var(--o3));
  --bg: #f8f9fb; --bg-grad: linear-gradient(150deg, #f0f3ff 0%, #f8f9fb 50%, #fff8f3 100%);
  --panel: #ffffff; --fg: #0f172a; --fg2: #1e293b; --body: #475569; --muted: #64748b; --faint: #94a3b8;
  --line: #e8ecf0; --line2: #e2e8f0; --grid: #f1f5f9; --stripe: #fafbfc;
  --tint: linear-gradient(135deg, rgba(79,70,229,0.06), rgba(249,115,22,0.04)); --tint-line: rgba(79,70,229,0.14);
  --head-bg: rgba(255,255,255,0.93);
  --c1: #4f46e5; --c2: #f97316; --c3: #a855f7; --c4: #cbd5e1;
  --ok: #15803d; --warn: #c2410c; --bad: #be123c;
  --shadow: 0 2px 8px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 20px; --gap: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --bg-grad: linear-gradient(150deg, #11142b 0%, #0b1020 50%, #1a120d 100%);
    --panel: #121830; --fg: #f1f5f9; --fg2: #e2e8f0; --body: #cbd5e1; --muted: #94a3b8; --faint: #7c8aa3;
    --line: #232b45; --line2: #2b3452; --grid: #1a2140; --stripe: #141b35;
    --tint: linear-gradient(135deg, rgba(129,140,248,0.10), rgba(251,146,60,0.06)); --tint-line: rgba(129,140,248,0.22);
    --head-bg: rgba(14,19,38,0.88);
    --c1: #818cf8; --c2: #fb923c; --c3: #c084fc; --c4: #475569;
    --ok: #4ade80; --warn: #fb923c; --bad: #fb7185;
    --shadow: 0 2px 10px rgba(0,0,0,0.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --bg-grad: linear-gradient(150deg, #11142b 0%, #0b1020 50%, #1a120d 100%);
  --panel: #121830; --fg: #f1f5f9; --fg2: #e2e8f0; --body: #cbd5e1; --muted: #94a3b8; --faint: #7c8aa3;
  --line: #232b45; --line2: #2b3452; --grid: #1a2140; --stripe: #141b35;
  --tint: linear-gradient(135deg, rgba(129,140,248,0.10), rgba(251,146,60,0.06)); --tint-line: rgba(129,140,248,0.22);
  --head-bg: rgba(14,19,38,0.88);
  --c1: #818cf8; --c2: #fb923c; --c3: #c084fc; --c4: #475569;
  --ok: #4ade80; --warn: #fb923c; --bad: #fb7185;
  --shadow: 0 2px 10px rgba(0,0,0,0.35); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); background-image: var(--bg-grad); min-height: 100vh;
  color: var(--fg); font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

/* header */
.bar { position: sticky; top: 0; z-index: 10; background: var(--head-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.bar-in { max-width: 1240px; margin: 0 auto; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { display: inline-flex; align-items: center; background: linear-gradient(135deg, #3730a3, #1e1b4b); border-radius: 10px; padding: 5px 14px;
  box-shadow: 0 2px 10px rgba(79,70,229,0.25); flex-shrink: 0; }
.logo img { height: 22px; width: auto; display: block; }
.sep { width: 1px; height: 28px; background: var(--line2); flex-shrink: 0; }
.titles { min-width: 0; line-height: 1.25; }
.product { display: block; font-size: 14px; font-weight: 800; color: var(--fg2); letter-spacing: -0.02em; white-space: nowrap; }
.client { display: block; font-size: 10px; font-weight: 500; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--o3);
  background: rgba(249,115,22,0.1); border: 1px solid rgba(249,115,22,0.22); padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
@media (max-width: 520px) { .sep, .titles .client { display: none; } .logo img { height: 18px; } }

.wrap { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap);
  padding-block: 28px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* intro */
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.intro > div { min-width: 0; max-width: 80ch; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--p2); }
:root[data-theme="dark"] .eyebrow { color: var(--c1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .eyebrow { color: var(--c1); } }
h1 { font-weight: 900; font-size: clamp(24px, 3vw, 30px); letter-spacing: -0.03em; line-height: 1.15; margin: 0 0 8px; color: var(--fg); text-wrap: balance; }
.lede { margin: 0; font-size: 15px; color: var(--body); max-width: 74ch; }
.fresh { margin: 0; font-size: 11px; color: var(--faint); font-family: var(--font-mono); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 4px 12px; }

/* filters */
.controls { position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); z-index: 5; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); }
.control { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.control.dates { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; }
.control label, .control .label { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.control.dates label { margin-left: 4px; }
input[type=date], select, .search { font: inherit; font-size: 13px; font-weight: 500; color: var(--fg2); background: var(--panel); border: 1px solid var(--line2);
  border-radius: 10px; padding: 6px 10px; min-height: 34px; }
input[type=date] { font-family: var(--font-mono); font-size: 12px; }
select { max-width: min(100%, 22rem); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--grid); flex-wrap: wrap; }
.seg button { font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); background: transparent; border: 0; padding: 5px 12px; border-radius: 9px;
  cursor: pointer; min-height: 28px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--fg2); }
.seg button[aria-pressed="true"] { background: linear-gradient(135deg, var(--p2), var(--p3)); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,0.3); }
.seg.small button { font-size: 11px; padding: 4px 10px; min-height: 26px; }
.reset { font: inherit; font-size: 12px; font-weight: 700; color: var(--p2); background: transparent; border: 1px solid var(--tint-line); border-radius: 10px;
  padding: 6px 14px; cursor: pointer; min-height: 34px; }
.reset:hover { background: var(--tint); }
button:focus-visible, input:focus-visible, select:focus-visible, tr[tabindex]:focus-visible { outline: 2px solid var(--p2); outline-offset: 2px; }

/* headline figures */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--panel); background-image: var(--tint); border: 1px solid var(--tint-line); border-radius: 14px; padding: 14px 18px;
  display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile .k { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.tile .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; color: var(--fg2); font-variant-numeric: tabular-nums; }
.tile .s { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile .s .up, .tile .s .down { font-family: var(--font-mono); font-weight: 600; }
.tile .s .up { color: var(--ok); } .tile .s .down { color: var(--bad); }

/* section cards */
.card { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); }
@media (max-width: 640px) { .card { padding: 22px 16px 18px; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; }
.card-head > div { min-width: 0; }
.title { display: flex; align-items: flex-start; gap: 14px; flex: 1 1 22rem; }
.num { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center;
  font: 800 14px var(--font-mono); flex-shrink: 0; box-shadow: 0 4px 14px rgba(79,70,229,0.3); }
h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; margin: 0 0 3px; color: var(--fg); }
.note { margin: 0; font-size: 12px; font-weight: 500; color: var(--faint); max-width: 80ch; }
.insight { margin: 0; font-size: 14px; color: var(--body); padding: 12px 16px; background: var(--tint); border: 1px solid var(--tint-line); border-radius: 12px; }
.insight b, .insight strong { color: var(--fg); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; font-weight: 500; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.chart { position: relative; min-height: 260px; }
.chart svg { display: block; }
.chart text { font-family: var(--font-mono); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.tablewrap.tall { max-height: 480px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 700; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 11px 14px;
  border-bottom: 1.5px solid var(--line2); white-space: nowrap; position: sticky; top: 0; z-index: 1;
  background: linear-gradient(90deg, rgba(79,70,229,0.05), rgba(249,115,22,0.04)), var(--panel); }
td { padding: 10px 14px; border-bottom: 1px solid var(--grid); vertical-align: middle; color: var(--fg2); }
tbody tr:nth-child(even) td { background: var(--stripe); }
tbody tr:last-child td { border-bottom: 0; }
th.n, td.n { text-align: right; }
td.n { font-family: var(--font-mono); font-size: 12px; }
.sortable th { cursor: pointer; user-select: none; }
.sortable th:hover { color: var(--p2); }
.sortable th[aria-sort="ascending"]::after { content: " ↑"; color: var(--o3); } .sortable th[aria-sort="descending"]::after { content: " ↓"; color: var(--o3); }
tr.click { cursor: pointer; } tbody tr.click:hover td { background: color-mix(in srgb, var(--c1) 6%, var(--panel)); }
tbody tr.sel td { background: color-mix(in srgb, var(--c1) 11%, var(--panel)); }
tr.sel td.name { box-shadow: inset 3px 0 0 var(--p2); }
.name { min-width: 14rem; font-weight: 600; }
.sub { display: block; font-size: 11px; font-weight: 500; color: var(--faint); }
.mono { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  background: color-mix(in srgb, currentColor 11%, transparent); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.pace { position: relative; height: 8px; min-width: 120px; background: var(--grid); border-radius: 4px; margin-bottom: 4px; }
.pace .f { position: absolute; inset: 0 auto 0 0; background: var(--grad); border-radius: 4px; }
.pace .f.behind { background: var(--bad); }
.pace .m { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--fg2); }
.cellbar { position: relative; min-width: 90px; }
.cellbar .b { position: absolute; right: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--c1); opacity: .18; }
.cellbar span { position: relative; }
.search { width: min(100%, 16rem); }
.inv-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.inv-summary div { background: var(--tint); border: 1px solid var(--tint-line); border-radius: 12px; padding: 12px 16px; }
.inv-summary b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--fg2); }
.inv-summary span { font-size: 11px; font-weight: 500; color: var(--muted); }
.freq-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .freq-grid { grid-template-columns: 1fr; } }

.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  padding: 10px 14px; font-size: 12px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fg2); }
.tip .d { font-family: var(--font-sans); font-weight: 700; color: var(--fg); margin-bottom: 4px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.foot { font-size: 12px; color: var(--faint); display: flex; flex-direction: column; gap: 6px; max-width: 90ch; padding-top: 8px; }
.foot p { margin: 0; }
.foot .brandline { font-weight: 700; color: var(--muted); }
.foot .brandline b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (prefers-reduced-motion: no-preference) { .tile, .card { animation: rise .4s cubic-bezier(.2,.7,.2,1) both; } }
@keyframes rise { from { opacity: .001; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* order multi-select */
.ms { position: relative; }
.ms-btn { font: inherit; font-size: 13px; font-weight: 600; color: var(--fg2); background: var(--panel); border: 1px solid var(--line2); border-radius: 10px;
  padding: 6px 32px 6px 12px; min-height: 34px; min-width: 13rem; max-width: min(100%, 22rem); text-align: left; cursor: pointer; position: relative;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-btn::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -5px; border: solid var(--faint); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.ms-btn[aria-expanded="true"] { border-color: var(--p2); }
.ms-btn.on { color: var(--p2); border-color: var(--tint-line); background: var(--tint), var(--panel); }
.ms-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(26rem, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line2);
  border-radius: 14px; box-shadow: 0 12px 36px rgba(15,23,42,0.16); padding: 8px; }
.ms-actions { display: flex; justify-content: space-between; padding: 2px 4px 8px; border-bottom: 1px solid var(--grid); margin-bottom: 4px; }
.ms-actions button, .ms-only { font: inherit; font-size: 11px; font-weight: 700; color: var(--p2); background: none; border: 0; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.ms-actions button:hover, .ms-only:hover { background: var(--tint); }
.ms-list { max-height: 320px; overflow-y: auto; }
.control .ms-item { text-transform: none; letter-spacing: normal; font-weight: 500; }
.ms-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.ms-item:hover { background: var(--grid); }
.ms-item input { accent-color: var(--p2); width: 16px; height: 16px; flex-shrink: 0; margin: 0; }
.ms-item .t { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--fg2); line-height: 1.3; }
.ms-only { opacity: 0; }
.ms-item:hover .ms-only, .ms-only:focus-visible { opacity: 1; }
@media (hover: none) { .ms-only { opacity: 1; } }

/* table tools */
.tools { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.export { font: inherit; font-size: 12px; font-weight: 700; color: #fff; background: var(--grad); border: 0; border-radius: 10px; padding: 7px 14px; min-height: 34px;
  cursor: pointer; box-shadow: 0 3px 12px rgba(79,70,229,0.25); white-space: nowrap; }
.export::before { content: "↓ "; }
.export:hover { filter: brightness(1.06); }
.conv-note { font-size: 11px; color: var(--faint); margin: -6px 0 0; }
