/* Usage dashboard (MES-223). A two-sided ledger: bills on one side, our own count on the other, with a seam between them that nothing crosses. */
:root {
  color-scheme: light dark;
  --paper: #f5f7f9;
  --sheet: #ffffff;
  --ink: #17212b;
  --muted: #4f5d6b;
  --line: #d3dae1;
  --invoice: #008a7b;   /* identity of "From bills" (validated with estimate: CVD dE 17.2) */
  --estimate: #6a4fc4;  /* identity of "Our own count" */
  --meter: #5d6b79;
  --warn: #b45f06;
  --warn-ink: #8a4700;
  --focus: #1f5fbf;
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11171d;
    --sheet: #18212a;
    --ink: #e4eaf0;
    --muted: #a3b0bc;
    --line: #2d3946;
    --invoice: #2fa89d;
    --estimate: #9580ea;
    --meter: #8796a5;
    --warn: #f0a53a;
    --warn-ink: #f5bd6a;
    --focus: #7fb0ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0 auto;
  max-width: 70rem;
  padding: 1.5rem 1rem 4rem;
  color: var(--ink);
  background: var(--paper);
  font: 1rem/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#main:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 1rem; top: -3rem; padding: 0.5rem 0.75rem; background: var(--sheet); color: var(--ink); border-radius: 0.25rem; }
.skip:focus { top: 0.5rem; }

.top { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; padding-bottom: 1.25rem; border-bottom: 2px solid var(--ink); }
h1 { margin: 0; font: 600 2.25rem/1.1 var(--serif); letter-spacing: -0.01em; }
.range { margin: 0.375rem 0 0; color: var(--muted); }
.actions { display: flex; gap: 0.5rem; }

button {
  min-height: 2.75rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--ink);
  border-radius: 0.375rem;
  background: var(--ink);
  color: var(--paper);
  font: 600 0.9375rem/1 var(--sans);
  cursor: pointer;
}
button.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
button:disabled { opacity: 0.6; cursor: progress; }

.status:empty { display: none; }
.status { margin: 1.25rem 0 0; padding: 0.75rem 1rem; border-left: 4px solid var(--warn); background: var(--sheet); }

section { margin-top: 2.75rem; }
h2 { margin: 0; font: 600 1.375rem/1.25 var(--serif); }
.lede { margin: 0.25rem 0 1rem; max-width: 62ch; color: var(--muted); }

/* Sign in */
.signin { max-width: 22rem; margin: 3rem auto 0; padding: 1.5rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 0.5rem; }
.signin p { margin: 0.25rem 0 1rem; color: var(--muted); }
.signin label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.signin input { width: 100%; min-height: 2.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--muted); border-radius: 0.375rem; background: var(--paper); color: var(--ink); font: inherit; }
.signin .error { min-height: 1.5rem; margin: 0.5rem 0; color: var(--warn-ink); font-weight: 600; }

/* The two ledgers and the seam between them */
.ledgers { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--sheet); border: 1px solid var(--line); border-radius: 0.5rem; }
.ledger { position: relative; padding: 1.25rem 1.5rem 1.5rem; border-top: 6px solid var(--invoice); border-radius: 0.5rem 0 0 0.5rem; }
.ledger-estimate { border-top-color: var(--estimate); border-left: 2px dashed var(--line); border-radius: 0 0.5rem 0.5rem 0; }
.ledger h3 { margin: 0; font-size: 1.0625rem; }
.ledger .note { margin: 0.125rem 0 0.75rem; color: var(--muted); font-size: 0.875rem; }
.figure { margin: 0; font: 600 clamp(2.25rem, 6vw, 3.25rem)/1.05 var(--serif); letter-spacing: -0.015em; }
.figure.none { font-size: 1.5rem; line-height: 1.3; color: var(--muted); }
.tokens { margin: 0.375rem 0 1rem; }
.compare { margin: 0; padding-top: 0.75rem; border-top: 1px solid var(--line); font-size: 0.9375rem; }
.compare dt { color: var(--muted); }
.compare dd { margin: 0; }

/* Limits: the meter with its 80% tick */
.limits { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; }
.limit { padding: 1rem 1.25rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 0.5rem; }
.limit-head { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; justify-content: space-between; align-items: baseline; }
.limit h3 { margin: 0; font-size: 1rem; }
.amount { margin: 0; font-weight: 600; }
.meter { position: relative; height: 0.625rem; margin: 0.875rem 0 0.625rem; border-radius: 0.3125rem; background: color-mix(in srgb, var(--meter) 22%, transparent); }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 0.3125rem; background: var(--meter); }
.meter .tick { position: absolute; top: -0.3125rem; bottom: -0.3125rem; width: 2px; margin-left: -1px; background: var(--ink); box-shadow: 0 0 0 2px var(--sheet); }
.limit.warn { border-color: var(--warn); }
.limit.warn .fill { background: var(--warn); }
.level { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.875rem; }
.limit.warn .level { color: var(--warn-ink); font-weight: 600; }
.warn-icon { display: inline-grid; place-items: center; width: 1.125rem; height: 1.125rem; margin-right: 0.375rem; border-radius: 50%; background: var(--warn); color: var(--sheet); font-size: 0.75rem; font-weight: 800; vertical-align: -0.125rem; }

/* Tables */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--line); border-radius: 0.5rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
caption { padding: 0.75rem 1rem 0.5rem; text-align: left; font-weight: 600; }
.split .table-wrap:first-child caption { box-shadow: inset 4px 0 0 var(--invoice); }
.split .table-wrap:last-child caption { box-shadow: inset 4px 0 0 var(--estimate); }
th, td { padding: 0.5rem 1rem; text-align: left; border-top: 1px solid var(--line); vertical-align: top; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.8125rem; }
tbody th { font-weight: 500; min-width: 8rem; overflow-wrap: break-word; }
.num { text-align: right; white-space: nowrap; }
.empty { margin: 0; padding: 1rem; color: var(--muted); }

@media (max-width: 44rem) {
  body { padding-top: 1rem; }
  h1 { font-size: 1.875rem; }
  .ledgers, .split { grid-template-columns: 1fr; }
  .ledger { border-radius: 0.5rem 0.5rem 0 0; }
  .ledger-estimate { border-left: 0; border-top: 6px solid var(--estimate); border-radius: 0 0 0.5rem 0.5rem; }
  .ledger-estimate::before { content: ""; position: absolute; left: 1.5rem; right: 1.5rem; top: -0.875rem; border-top: 2px dashed var(--line); }
  th, td { padding: 0.5rem 0.625rem; }
}
@media (forced-colors: active) {
  .meter .fill, .meter .tick, .warn-icon { forced-color-adjust: none; background: CanvasText; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
