/* Product usage dashboard. Meridian tokens for chrome; validated categorical palette for series. */
:root {
  --surface-1: #ffffff;
  --line: var(--sand);
  --series-1: #4a3aa7; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #2a78d6; --series-8: #e34948;
  --series-other: #9a9083;
  --radius: 10px;
}
body { background: var(--cream); color: var(--tx); }
[hidden] { display: none !important; }

.gate { min-height: 100vh; display: grid; place-items: center; background: var(--deep); }
.gate-card { background: var(--surface-1); padding: 40px 44px; border-radius: 16px; max-width: 420px; width: calc(100% - 32px); }
.gate-card h1 { font-family: var(--font-display); font-weight: 500; font-size: 34px; margin: 6px 0 10px; }
.gate-card p { margin: 0 0 20px; }

.btn { background: var(--primary-indigo); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font: 600 15px var(--font-structural); cursor: pointer; }
.btn:hover { background: var(--primary-light); }
.link { background: none; border: 0; color: var(--text-indigo); font: 500 14px var(--font-body); cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
.error { color: var(--error); }

/* ── header ── */
.top { background: var(--deep); color: rgba(250,247,242,.66); padding: 16px 24px 0; }
.top-row { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand h1 { color: #faf7f2; font-family: var(--font-display); font-weight: 500; font-size: 26px; line-height: 1; }
.brand .overline { color: var(--copper-light); }
.view-toggle { display: inline-flex; background: rgba(255,255,255,.08); border-radius: 999px; padding: 3px; }
.view-toggle button { border: 0; background: transparent; color: rgba(250,247,242,.7); padding: 7px 18px; border-radius: 999px; font: 600 14px var(--font-structural); cursor: pointer; }
.view-toggle button[aria-selected="true"] { background: var(--primary-indigo); color: #fff; }
.who { margin-left: auto; font-size: 13px; }
.who .link { color: var(--copper-light); margin-left: 8px; }

.filters { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.filters label { display: inline-flex; align-items: center; gap: 8px; }
.filters select { background: rgba(255,255,255,.08); color: #faf7f2; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 5px 8px; font: 500 13px var(--font-body); color-scheme: dark; }
.filters select option { color: var(--charcoal); background: #fff; }
.filters .link { color: var(--copper-light); }
.filters label.off { opacity: .45; }
.companies { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 4px 10px 4px 7px; background: transparent; color: rgba(250,247,242,.8); font: 500 12px var(--font-body); cursor: pointer; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip[aria-pressed="true"] { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.4); }
.chip.all[aria-pressed="true"] { background: var(--primary-indigo); border-color: var(--primary-indigo); }
.more-companies { background: transparent; color: rgba(250,247,242,.8); border: 1px dashed rgba(255,255,255,.3); border-radius: 999px; padding: 4px 10px; font: 500 12px var(--font-body); color-scheme: dark; max-width: 160px; }
.more-companies option { color: var(--charcoal); background: #fff; }

/* scope sentence: what the page is showing right now */
.scope { margin-top: 12px; padding: 10px 0 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13.5px; color: rgba(250,247,242,.8); display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; }
.scope b { color: #faf7f2; font-weight: 600; }
.scope .fresh { margin-left: auto; color: rgba(250,247,242,.45); font-size: 12px; }

/* loading overlay: shown while a view, range or company change is fetching and rendering */
.loading { position: fixed; inset: 0; z-index: 20; background: rgba(250,247,242,.82); backdrop-filter: blur(2px); display: grid; place-items: center; }
.loading .box { display: flex; align-items: center; gap: 14px; background: var(--surface-1); border: 1px solid var(--line); border-radius: 12px; padding: 16px 22px; font: 500 15px var(--font-structural); color: var(--tx-strong); box-shadow: 0 8px 30px rgba(21,16,32,.12); }
.loading .spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--primary-pale); border-top-color: var(--primary-indigo); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
main[aria-busy="true"] { opacity: .5; pointer-events: none; }

/* ── main ── */
main { max-width: 1320px; margin: 0 auto; padding: 24px 24px 80px; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px; }
.tile { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 12px; min-width: 0; }
.tile .label { font: 600 11px var(--font-body); letter-spacing: 1.5px; text-transform: uppercase; color: var(--tx-mute); }
.tile .value { font: 500 32px/1.1 var(--font-display); color: var(--tx-strong); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.tile .base { font-size: 12.5px; color: var(--tx); }
.tile .delta { font-size: 12px; color: var(--tx-mute); margin-top: 2px; }
.tile .delta.up { color: var(--success); } .tile .delta.down { color: var(--error); }
.tile .spark { height: 26px; margin-top: 8px; }
.tile .spark canvas { width: 100% !important; height: 26px !important; }

section.block { margin-bottom: 40px; }
section.block > header { padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
section.block > header h2 { font-size: 20px; }
section.block > header .q { color: var(--tx); font-size: 14px; margin-top: 4px; max-width: 80ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 12px; min-width: 0; display: flex; flex-direction: column; }
.card.wide { grid-column: 1 / -1; }
.card.key { border-color: var(--primary-light); box-shadow: 0 0 0 1px var(--primary-pale) inset; }
.card.key::before { content: "Key chart"; font: 600 10px var(--font-body); letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-indigo); margin-bottom: 4px; }
.card h3 { font-size: 15px; font-weight: 600; }
.card.key h3 { font-size: 17px; }
.card .sub { font-size: 12.5px; color: var(--tx-mute); margin: 3px 0 10px; max-width: 90ch; }
.card .plot { position: relative; height: 240px; }
.card.key .plot { height: 300px; }
.card .plot.auto { height: auto; }
.card .plot canvas { width: 100% !important; height: 100% !important; }
.card .foot { display: flex; gap: 10px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--tx-mute); }
.card .empty { color: var(--tx-mute); font-size: 13px; padding: 30px 0; text-align: center; }
.card table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.card th, .card td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--stone); white-space: nowrap; }
.card th { font-weight: 600; color: var(--tx-mute); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
.card td.num, .card th.num { text-align: right; font-variant-numeric: tabular-nums; }
.card .tablewrap { overflow: auto; max-height: 340px; }

.more { margin-top: 14px; }
.more > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; font: 600 13px var(--font-structural); color: var(--text-indigo); padding: 6px 0; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "▸"; font-size: 12px; transition: transform var(--dur-state) var(--ease-out); }
.more[open] > summary::before { transform: rotate(90deg); }
.more .cards { margin-top: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.bold { height: 4px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; }
.heat { display: grid; grid-template-columns: 44px repeat(24, 1fr); gap: 2px; font-size: 11px; }
.heat .h { color: var(--tx-mute); text-align: left; white-space: nowrap; }
.heat .axis-title { grid-column: 1 / -1; font-size: 11px; color: var(--tx-mute); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 2px; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--tx-mute); margin-top: 8px; }
.heat-legend i { width: 120px; height: 10px; border-radius: 3px; display: inline-block; }
.heat .cell { aspect-ratio: 1.6; border-radius: 3px; background: var(--primary-pale); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 13px; margin-top: 8px; }
.kv b { font-variant-numeric: tabular-nums; color: var(--tx-strong); font-weight: 600; }
.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: 170px 1fr 120px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar .track { height: 12px; background: var(--stone); border-radius: 4px; position: relative; }
.bar .fill { display: block; height: 100%; border-radius: 4px; background: var(--primary-indigo); min-width: 2px; }
.bar .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--charcoal); }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--tx-strong); font-weight: 600; line-height: 1.2; }
.bar .n small { display: block; font-weight: 400; color: var(--tx-mute); font-size: 11px; }
.note { font-size: 12px; color: var(--tx-mute); }

dialog { border: 0; border-radius: 14px; padding: 24px 28px; max-width: 560px; }
dialog::backdrop { background: rgba(21,16,32,.6); }
dialog dt { font-weight: 600; color: var(--tx-strong); margin-top: 10px; }
dialog dd { margin: 2px 0 0; font-size: 14px; }

@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .top { padding: 14px 16px 0; }
  main { padding: 16px 16px 60px; }
  .cards { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 110px 1fr 90px; }
}
