/* Copied from claude-sessions (public/style.css: tokens, header, buttons and
   the Usage tab) so this server stays self-contained; only server/ is
   deployed. Keep the two in step by hand when the look changes. */

/* Self-hosted: the CSP allows fonts from this origin only, and a private
   dashboard shouldn't tell Google who opened it. */
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/barlow-semi-condensed-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/barlow-semi-condensed-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/barlow-semi-condensed-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2"); }

:root {
  --bg: #E7EBEF;
  --surface: #FFFFFF;
  --surface-2: #F3F5F8;
  --ink: #17202A;
  --muted: #5A6571;
  --faint: #8792A0;
  --line: #D1D8E0;
  --lamp: #E59A00;
  --lamp-glow: rgba(229, 154, 0, 0.45);
  --alert: #D2460C;
  --danger: #B42318;
  --focus: #2B59C3;
  --select: #17202A;

  --m-opus-new: #4F46E5;
  --m-opus-mid: #8C86EE;
  --m-opus-old: #BEBBF3;
  --m-fable: #0E8A8C;
  --m-sonnet-new: #C93A6B;
  --m-sonnet-old: #E492AD;
  --m-haiku: #6B9122;
  --m-other: #8A94A0;

  /* Devices in the usage chart: a separate set from the model colours, since
     a bar segment here is a machine, not a model. Validated for CVD separation. */
  --d1: #2A78D6;
  --d2: #EB6834;
  --d3: #1BAF7A;
  --d4: #EDA100;

  --sans: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1317;
    --surface: #182027;
    --surface-2: #202932;
    --ink: #E4E8ED;
    --muted: #98A3AF;
    --faint: #6B7682;
    --line: #2A333D;
    --lamp: #F5B640;
    --lamp-glow: rgba(245, 182, 64, 0.5);
    --alert: #F27B4B;
    --danger: #F97066;
    --focus: #7EA2FF;
    --select: #E4E8ED;

    --m-opus-new: #7D75FF;
    --m-opus-mid: #A49FF6;
    --m-opus-old: #5E5A9E;
    --m-fable: #2BB8BA;
    --m-sonnet-new: #EC6A95;
    --m-sonnet-old: #A65873;
    --m-haiku: #93C043;
    --m-other: #6E7884;

    --d1: #3987E5;
    --d2: #D95926;
    --d3: #199E70;
    --d4: #C98500;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.4 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

a { color: var(--focus); }

code, .mono { font-family: var(--mono); font-size: 0.82em; }

/* Header */

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  padding: 22px 24px 14px;
}

.brand { min-width: 0; }

.brand h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

.host { margin: 6px 0 0; color: var(--muted); }

.logout { margin: 0; }

/* Buttons and small text */

.btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
}

.btn:hover:not(:disabled) { background: var(--surface-2); }

.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.btn-primary:hover:not(:disabled) { background: var(--ink); opacity: 0.88; }

.hint { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.stale { color: var(--alert); }

.swatch { width: 14px; height: 14px; border-radius: 2px; display: inline-block; flex: none; }

/* Colour by class, not style="": the CSP has no 'unsafe-inline', so the
   page can't set a colour inline. c- paints a swatch, f- an SVG mark. */

.c-m-opus-new { background: var(--m-opus-new); }
.c-m-opus-mid { background: var(--m-opus-mid); }
.c-m-opus-old { background: var(--m-opus-old); }
.c-m-fable { background: var(--m-fable); }
.c-m-sonnet-new { background: var(--m-sonnet-new); }
.c-m-sonnet-old { background: var(--m-sonnet-old); }
.c-m-haiku { background: var(--m-haiku); }
.c-m-other { background: var(--m-other); }
.c-d1 { background: var(--d1); }
.c-d2 { background: var(--d2); }
.c-d3 { background: var(--d3); }
.c-d4 { background: var(--d4); }
.f-m-opus-new { fill: var(--m-opus-new); }
.f-m-opus-mid { fill: var(--m-opus-mid); }
.f-m-opus-old { fill: var(--m-opus-old); }
.f-m-fable { fill: var(--m-fable); }
.f-m-sonnet-new { fill: var(--m-sonnet-new); }
.f-m-sonnet-old { fill: var(--m-sonnet-old); }
.f-m-haiku { fill: var(--m-haiku); }
.f-m-other { fill: var(--m-other); }
.f-d1 { fill: var(--d1); }
.f-d2 { fill: var(--d2); }
.f-d3 { fill: var(--d3); }
.f-d4 { fill: var(--d4); }

/* Usage */

.usage { flex: 1; border-top: 1px solid var(--line); padding: 18px 24px 48px; min-width: 0; }

.u-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--surface); }

.seg button {
  padding: 5px 12px;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  cursor: pointer;
  font-weight: 500;
}

.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.u-source { margin: 0; color: var(--muted); }

.u-source.is-fallback {
  padding: 6px 10px;
  border-left: 4px solid var(--alert);
  background: var(--surface);
  color: var(--ink);
}

.u-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 18px 0 0;
}

.stat { padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.stat dt { color: var(--muted); font-size: 15px; }
.stat dd { margin: 2px 0 0; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .sub { display: block; color: var(--muted); font-size: 14px; font-weight: 400; }
.stat.is-lead dd { font-size: 30px; }

.usage section { margin-top: 28px; }
.usage h3 { margin: 0 0 10px; font-size: 20px; font-weight: 600; }
.usage h3 .n { color: var(--muted); font-weight: 400; }

.table-wrap { overflow-x: auto; }

.u-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.u-table th, .u-table td { padding: 5px 10px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.u-table th { color: var(--muted); font-weight: 500; font-size: 15px; border-top: 0; }
.u-table th:first-child, .u-table td:first-child { text-align: left; padding-left: 0; }
.u-table td:first-child { white-space: normal; overflow-wrap: anywhere; min-width: 9em; }
.u-table .swatch { flex: none; }
.u-table .lead { font-weight: 600; }
.u-table tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
.u-table .name { display: inline-flex; align-items: center; gap: 8px; }
.u-table .sync { color: var(--muted); text-align: left; }
.u-table .path { font-family: var(--mono); font-size: 13px; }

.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.chart-head select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; padding: 0; list-style: none; color: var(--muted); font-size: 15px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }

.chart { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px 4px; }
.chart svg { display: block; width: 100%; height: 260px; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 400 12px var(--sans); }
.chart .hit { fill: transparent; }
.chart .hit:hover, .chart .hit.is-hot { fill: var(--surface-2); }
.chart .empty { fill: var(--muted); font: 400 15px var(--sans); }

.tip {
  position: absolute;
  z-index: 2;
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(10, 14, 18, 0.14);
  pointer-events: none;
  font-size: 15px;
}
.tip[hidden] { display: none; }
.tip .tip-day { margin: 0 0 4px; font-weight: 600; }
.tip .tip-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.tip .tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }

.u-loading { color: var(--muted); }

/* Sign-in */

.login-body { justify-content: center; align-items: center; padding: 24px 16px; }

.login {
  width: min(380px, 100%);
  padding: 24px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login h1 { margin: 0; font-size: 30px; font-weight: 700; line-height: 1.1; }

.login-form { display: grid; gap: 8px; margin-top: 20px; }

.login-form label { font-weight: 600; }

.login-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.login-form .btn { margin-top: 6px; padding: 8px 12px; }

.login-error { margin: 0; color: var(--danger); }

@media (max-width: 860px) {
  .top { padding: 16px 16px 12px; }
  .usage { padding: 14px 16px 40px; }
  .chart svg { height: 220px; }
}

/* Custom range. Native date inputs: a calendar on desktop and phone with no
   library, and nothing the CSP has to allow. Their popup follows the
   color-scheme set on :root, which flips with the dark palette above. */

.u-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.u-custom[hidden] { display: none; }
.u-custom label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.u-custom input {
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.u-custom input::-webkit-calendar-picker-indicator { cursor: pointer; }

/* Five range buttons are wider than a phone once Custom joins them; tighten
   them, and let the group wrap rather than push the page sideways. */
.seg { max-width: 100%; flex-wrap: wrap; }

@media (max-width: 480px) {
  .seg button { padding: 5px 9px; }
  .u-custom input { width: 9.5em; }
}

/* The note now sits under the controls instead of beside them. */
.u-head + .u-source { margin-top: 10px; }
