/* Usage dashboard preview. Tokens first, then layout, then components. */

:root {
  color-scheme: light;
  --plane: #f4f3ee;
  --surface: #fcfcfb;
  --surface-2: #efeee8;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #74726c;
  --grid: #e6e5de;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --wash: rgba(11, 11, 11, 0.055);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px -16px rgba(11, 11, 11, 0.18);

  /* The eight chart hues, light steps. */
  --hue-blue: #2a78d6;
  --hue-orange: #eb6834;
  --hue-aqua: #1baf7a;
  --hue-yellow: #eda100;
  --hue-magenta: #e87ba4;
  --hue-green: #008300;
  --hue-violet: #6250d6;
  --hue-red: #e34948;

  /* Status: always shown with an icon and a label. */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;

  /* Who wears which hue. */
  --m-opus: var(--hue-blue);
  --m-fable: var(--hue-red);
  --m-sonnet: var(--hue-aqua);
  --m-haiku: var(--hue-yellow);
  --m-other: #898781;
  --l-five: var(--hue-violet);
  --l-seven: var(--hue-green);
  --l-fable: var(--m-fable);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #96948d;
    --grid: #2c2c2a;
    --axis: #45453f;
    --border: rgba(255, 255, 255, 0.1);
    --wash: rgba(255, 255, 255, 0.07);
    --shadow: none;
    --hue-blue: #3987e5;
    --hue-orange: #d95926;
    --hue-aqua: #199e70;
    --hue-yellow: #c98500;
    --hue-magenta: #d55181;
    --hue-green: #008300;
    --hue-violet: #9085e9;
    --hue-red: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #96948d;
  --grid: #2c2c2a;
  --axis: #45453f;
  --border: rgba(255, 255, 255, 0.1);
  --wash: rgba(255, 255, 255, 0.07);
  --shadow: none;
  --hue-blue: #3987e5;
  --hue-orange: #d95926;
  --hue-aqua: #199e70;
  --hue-yellow: #c98500;
  --hue-magenta: #d55181;
  --hue-green: #008300;
  --hue-violet: #9085e9;
  --hue-red: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
main { display: grid; gap: 14px; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-mark { align-self: center; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark circle { fill: var(--ink); stroke: none; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: 10px; }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.fresh.live::before { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.btn {
  height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.solid { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* Verdict: the answer to "will I run out?" in one sentence */
.verdict { padding: 6px 2px 4px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 7px;
  border-radius: 13px; font-size: 12.5px; font-weight: 600; color: var(--ink);
  background: color-mix(in srgb, var(--tone) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 38%, transparent);
}
.status svg { color: var(--tone); }
.tone-good { --tone: var(--good); }
.tone-warn { --tone: var(--warn); }
.tone-serious { --tone: var(--serious); }
.tone-crit { --tone: var(--crit); }
.tone-idle { --tone: var(--ink-3); }
.verdict h2 { margin-top: 10px; font-size: 27px; line-height: 1.14; font-weight: 650; letter-spacing: -0.025em; text-wrap: balance; }
.verdict p { margin-top: 6px; font-size: 15px; color: var(--ink-2); max-width: 62ch; text-wrap: pretty; }
.verdict p b { color: var(--ink); font-weight: 600; }

/* Limits: one instrument with three readouts */
.limits {
  display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden;
}
.limit { padding: 14px 16px 14px; min-width: 0; }
.limit + .limit { border-top: 1px solid var(--border); }
.limit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.limit-name { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.limit-reset { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.limit-reset b { color: var(--ink); font-weight: 600; }
.limit-body { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: start; margin-top: 6px; }
.pct { font-size: 46px; line-height: 1; font-weight: 650; letter-spacing: -0.04em; margin-top: 6px; }
.pct small { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); margin-left: 1px; }
.pct.dim { color: var(--ink-3); }
.limit-meta { margin-top: 8px; font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.limit-meta span { display: block; white-space: nowrap; }
.limit-plot { min-width: 0; }
.limit-plot svg, .plot svg { display: block; width: 100%; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.limit-empty {
  height: 96px; display: grid; place-items: center; text-align: center; font-size: 12.5px; color: var(--ink-3);
  border: 1px dashed var(--axis); border-radius: 10px; padding: 0 14px;
}
.forecast { display: flex; gap: 7px; align-items: flex-start; margin-top: 10px; font-size: 13.5px; color: var(--ink-2); line-height: 1.4; }
.forecast svg { flex: none; margin-top: 1.5px; color: var(--tone, var(--ink-3)); }
.forecast b { color: var(--ink); font-weight: 600; }
.forecast + .forecast { margin-top: 4px; }

.key { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--ink-3); padding: 0 4px; margin-top: -4px; }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 18px; height: 0; border-top: 2px solid var(--ink-2); }
.key .key-dash { border-top: 2px dashed var(--ink-2); }
.key .key-diag { border-top: 1px solid var(--axis); transform: rotate(-24deg); }

/* Cards and groups */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 10px; min-height: 32px; }
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 600; }
.row { display: grid; gap: 14px; }
.group { display: grid; gap: 12px; margin-top: 10px; min-width: 0; }
.group-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 0 2px; }
.group-head h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
.group-sub { font-size: 13px; color: var(--ink-3); margin-top: 1px; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 10px; background: var(--surface-2); }
.seg button {
  height: 30px; min-width: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: none;
  font-size: 13px; font-weight: 550; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.06); }
.chip {
  height: 34px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--border); background: none;
  font-size: 13px; font-weight: 550; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip:hover { background: var(--wash); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip.check::before { content: ""; width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid currentColor; flex: none; }
.chip.check[aria-pressed="true"]::before {
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.3l2.4 2.4 4.6-5.2' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.3l2.4 2.4 4.6-5.2' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  border: 0; width: 14px; height: 14px;
}
.chip:disabled { opacity: 0.45; cursor: default; }
.chip:disabled:hover { background: none; }

/* Legends: swatch, name, then the figure in ink */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.legend .note { color: var(--ink-3); margin-left: auto; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.sw.line { height: 3px; width: 14px; border-radius: 2px; }
.sw.hit { width: 0; height: 0; background: none; border-radius: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--crit); }

/* Chart internals */
.plot { position: relative; outline: none; }
.plot:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 8px; }
svg text { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
svg text.lbl { fill: var(--ink-2); font-size: 11.5px; font-weight: 550; }
svg text.lbl-strong { fill: var(--ink); font-size: 12px; font-weight: 650; }
.g-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.g-axis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.g-band { fill: var(--wash); }
.g-cross { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; }
.ring { stroke: var(--surface); stroke-width: 2; }

/* Tooltip: values lead, names follow */
.tip {
  position: fixed; z-index: 30; top: 0; left: 0; pointer-events: none; min-width: 132px; max-width: 260px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 9px 11px; font-size: 12.5px; line-height: 1.35;
}
.tip-title { color: var(--ink-2); font-size: 12px; margin-bottom: 6px; }
.tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; column-gap: 7px; padding: 1.5px 0; }
.tip-row i { width: 12px; height: 3px; border-radius: 2px; background: var(--c); }
.tip-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--ink-2); }
.tip-total { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 5px; }
.tip-note { color: var(--ink-3); font-size: 11.5px; margin-top: 5px; }

/* Right now */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.tile-val { font-size: 27px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; white-space: nowrap; }
.tile-val small { font-size: 13px; font-weight: 550; letter-spacing: 0; color: var(--ink-2); margin-left: 4px; }
.tile-lab { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.rule { border: 0; border-top: 1px solid var(--border); margin: 14px 0 12px; }
.sub-h { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.sub-h span { font-weight: 450; color: var(--ink-3); }
.day { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.day .tile-val { font-size: 22px; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 40px; margin-top: 12px; border-bottom: 1px solid var(--axis); }
.spark i { flex: 1 1 0; background: var(--ink-3); opacity: 0.55; border-radius: 2px 2px 0 0; }
.spark i.cur { background: var(--ink); opacity: 1; }
.spark-ax { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.mixbar { display: flex; gap: 2px; height: 8px; margin: 14px 0 10px; }
.mixbar i { background: var(--c); border-radius: 4px; min-width: 3px; }
.mixbar.empty { background: var(--surface-2); border-radius: 4px; }
.mix { width: 100%; border-collapse: collapse; font-size: 13px; }
.mix td { padding: 3px 0; }
.mix td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); padding-left: 12px; }
.mix td.num.strong { color: var(--ink); font-weight: 600; }
.name { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }

/* Tables */
.table-wrap { overflow: auto; max-height: 340px; margin: 0 -4px; padding: 0 4px; }
.table-wrap.flush { max-height: none; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 7px 0 7px 12px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.data th:first-child, table.data td:first-child { text-align: left; padding-left: 0; position: sticky; left: 0; background: var(--surface); }
table.data thead th { font-size: 12px; font-weight: 550; color: var(--ink-3); position: sticky; top: 0; background: var(--surface); z-index: 1; }
table.data thead th:first-child { z-index: 2; }
table.data td { color: var(--ink-2); }
table.data td:first-child { color: var(--ink); font-weight: 550; }
table.data td.zero { color: var(--axis); }
table.data tfoot td { border-bottom: 0; border-top: 1px solid var(--axis); color: var(--ink); font-weight: 650; }
table.data caption { caption-side: bottom; text-align: left; font-size: 12px; color: var(--ink-3); padding-top: 8px; }

/* Signed-in area */
.locked {
  display: grid; gap: 10px; justify-items: start; padding: 18px 16px; border: 1px dashed var(--axis); border-radius: 18px;
}
.locked h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.locked ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.locked li { font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px; background: var(--surface); }
.locked p { font-size: 13.5px; color: var(--ink-2); max-width: 56ch; }
.badge { font-size: 11px; font-weight: 650; letter-spacing: 0.02em; padding: 2px 7px; border-radius: 6px; border: 1px dashed var(--ink-3); color: var(--ink-2); white-space: nowrap; }
.acct { display: grid; gap: 14px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 13px; }
.rank .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.rank .who span { color: var(--ink-3); font-weight: 450; margin-left: 6px; }
.rank .amt { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.rank .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.rank .bar i { display: block; height: 100%; border-radius: 3px; background: var(--ink-2); }
.jobs { list-style: none; margin: 0 0 4px; padding: 0; display: grid; }
.jobs li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.jobs li:last-child { border-bottom: 0; }
.jobs .job { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs .meta { grid-column: 1 / -1; color: var(--ink-3); font-size: 12px; }
.jobs .when { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.machine { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550; color: var(--ink-2); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; margin-left: 6px; }
.machine::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.pos { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); font-size: 11px; font-weight: 650; color: var(--ink-2); margin-right: 7px; }
.colors { display: grid; gap: 10px; }
.color-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; background: var(--c); cursor: pointer; position: relative; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 10px; }

.foot { margin-top: 22px; padding: 0 2px; font-size: 12.5px; color: var(--ink-3); max-width: 70ch; }

/* Preview controls: for reviewing the design, not part of it */
.proto { margin-top: 28px; padding: 12px 14px; border: 1px dashed var(--axis); border-radius: 14px; display: grid; gap: 10px; }
.proto-title { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.proto-title span { font-weight: 450; color: var(--ink-3); }
.proto-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.proto-row .seg { flex-wrap: wrap; }
.proto-row .seg button { height: 28px; font-size: 12.5px; }

/* Tablet and up */
@media (min-width: 720px) {
  .app { padding: 20px 28px 56px; }
  main { gap: 16px; }
  .verdict h2 { font-size: 34px; }
  .verdict p { font-size: 16px; }
  .card { padding: 16px 20px 20px; }
  .row { gap: 16px; }
  .acct { grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (min-width: 960px) {
  .limits { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .limit { padding: 18px 20px; }
  .limit + .limit { border-top: 0; border-left: 1px solid var(--border); }
  .row-a { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
  .row-b { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .acct { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .acct > .card { grid-column: span 4; }
  .acct > .card.wide { grid-column: span 6; }
}
@media (max-width: 400px) {
  .brand-sub, .fresh-long { display: none; }
  table.data { font-size: 12px; }
  table.data th, table.data td { padding-left: 8px; }
}
@media (max-width: 380px) {
  table.data { font-size: 11.5px; }
  table.data th, table.data td { padding-left: 6px; }
  .swatches button { width: 22px; height: 22px; }
  .color-row { grid-template-columns: 56px 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .seg button, .chip, .btn { transition: background-color 0.12s, color 0.12s; }
}
