/* ============================================================
   LLM Token Usage & Cost Monitoring
   A meter/ledger aesthetic: hairlines, tabular figures, one
   instrument (the token strip), one accent colour.
   ============================================================ */

:root {
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --faint: #98A2B3;
  --hair: #E4E7EC;
  --hair-soft: #F0F2F5;
  --paper: #F7F8FA;
  --panel: #FFFFFF;
  --blue: #1B3FA0;
  --blue-deep: #12275E;
  --blue-soft: #EEF1FB;
  --jade: #0E7C66;
  --amber: #B4690E;
  --amber-soft: #FDF6EC;
  --danger: #B42318;

  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --radius: 4px;
  --page: 1280px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, dt, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--paper); border-color: #D0D5DD; color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }

.btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn--primary:hover { background: #16337F; border-color: #16337F; color: #fff; }

.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn--quiet:hover { background: var(--blue-soft); border-color: transparent; color: var(--blue); }

.btn--wide { width: 100%; padding: 10px 14px; }

/* ---------------------------------------------------------- fields */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .01em;
}
.field input,
.field select {
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  font-size: 13px;
  min-height: 34px;
}
.field input:hover, .field select:hover { border-color: #D0D5DD; }
.field input:focus, .field select:focus { border-color: var(--blue); }

/* stacked fields fill their column; inline filter fields keep a natural width */
.field:not(.field--inline) input,
.field:not(.field--inline) select { width: 100%; min-width: 0; }
.field-row .field { min-width: 0; }

.field--inline { flex-direction: row; align-items: center; gap: 8px; }
.field--inline > span { white-space: nowrap; }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.field-row--pair { grid-template-columns: repeat(2, 1fr); }

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 12.5px;
}

/* ---------------------------------------------------------- login */
.login {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--panel);
}

.login__brand {
  background: var(--blue-deep);
  color: #EAEEF9;
  padding: 64px clamp(32px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
}
.login__brand h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 3.1vw, 40px);
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: -.01em;
  color: #fff;
}
.login__copy {
  max-width: 34ch;
  color: #B9C4E0;
  font-size: 14px;
  line-height: 1.6;
}
.login__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 12px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.login__facts dt {
  font-size: 11px;
  color: #8C9CC6;
  margin-bottom: 3px;
}
.login__facts dd { font-size: 13.5px; color: #EAEEF9; }

.mark {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .55);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 16px;
  color: #fff;
  position: relative;
}
.mark::before {
  content: "";
  position: absolute;
  top: 13px;
  left: 8px; right: 8px;
  height: 1px;
  background: rgba(255, 255, 255, .45);
}

.login__form {
  padding: 64px clamp(28px, 6vw, 88px);
  display: flex;
  align-items: center;
}
.login__form form {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login__form h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -.01em;
}
.login__hint { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------- app chrome */
.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 58px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hair);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand__text { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }

.mark--sm {
  width: 28px; height: 28px;
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
}
.mark--sm::before { top: 8px; left: 5px; right: 5px; background: rgba(27, 63, 160, .35); }

.topbar__actions { display: flex; align-items: center; gap: 4px; }
.who { font-size: 12px; color: var(--faint); margin-right: 8px; }

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 26px 24px 56px;
}

/* ---------------------------------------------------------- lede + filters */
.notice {
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--amber-soft);
  border: 1px solid #F3DDBF;
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  color: #6E4208;
  font-size: 13px;
}

.lede {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
}
.lede h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: 1.15;
}
.lede__range { margin-top: 6px; color: var(--muted); font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------------------------------------------------------- meter */
.meter {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.15fr) minmax(240px, 1fr);
  gap: 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--hair);
  padding: 22px 0 24px;
}
.meter > * + * {
  border-left: 1px solid var(--hair);
  padding-left: clamp(16px, 2.4vw, 32px);
}
.meter > * { padding-right: 12px; }

.meter__key {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .01em;
}
.meter__value {
  margin-top: 6px;
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.meter__secondary {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.meter__note { margin-top: 10px; color: var(--faint); font-size: 12px; }

.meter__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  align-content: start;
}
.meter__stats dt { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.meter__stats dd {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.strip {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-top: 10px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--hair-soft);
}
.strip span { display: block; height: 100%; min-width: 0; }
.strip .seg-hit { background: var(--jade); }
.strip .seg-input { background: var(--blue); }
.strip .seg-output { background: var(--amber); }

.strip-legend {
  margin-top: 12px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}
.strip-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.strip-legend .dot { flex: none; }
.strip-legend .val {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------------------------------------------------------- panels */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 40px);
  margin-top: 30px;
}

.panel { padding-top: 14px; border-top: 1px solid var(--hair); }
.split .panel { border-top-color: var(--ink); }

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.panel__head h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.panel__meta { color: var(--faint); font-size: 12px; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--hit { background: var(--jade); }
.dot--input { background: var(--blue); }
.dot--output { background: var(--amber); }
.dot--line { background: var(--ink); border-radius: 1px; height: 2px; width: 12px; }

.chart { min-height: 200px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ---------------------------------------------------------- tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}
.table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--hair-soft);
  vertical-align: middle;
}
.table tbody tr:hover { background: #FBFCFD; }
.table tbody tr:last-child td { border-bottom: 0; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table--dense tbody td { padding: 7px 10px; }

.share-col { width: 130px; }
.share-bar {
  display: block;
  height: 5px;
  background: var(--blue-soft);
  border-radius: 3px;
  overflow: hidden;
}
.share-bar > i { display: block; height: 100%; background: var(--blue); }

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

.empty {
  padding: 22px 10px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--hair-soft);
}

.pager { display: flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------- footer */
.foot {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 11.5px;
}

/* ---------------------------------------------------------- drawer */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .34);
  z-index: 39;
}

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: min(440px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--hair);
  padding: 22px 24px 40px;
  overflow-y: auto;
  z-index: 40;
}
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 14px;
}
.drawer__head h2 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 400;
}
.drawer__hint { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; line-height: 1.55; }
.drawer__hint--tight { margin-bottom: 0; font-size: 12px; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--hair);
}
.stack h3 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.stack .btn { align-self: flex-start; }

/* three prices per token type: standard, peak, off-peak */
.price-grid {
  display: grid;
  grid-template-columns: 58px repeat(3, minmax(0, 1fr));
  gap: 6px 8px;
  align-items: center;
}
.price-grid__head {
  font-size: 10.5px;
  color: var(--faint);
  text-align: right;
}
.price-grid__label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.price-input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.price-input:hover { border-color: #D0D5DD; }
.price-input:focus { border-color: var(--blue); }
.price-input::placeholder { color: var(--faint); font-size: 11px; }

/* one card per model: five prices do not fit a drawer-width table */
.price-list { display: grid; gap: 10px; }
.price-card {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--hair-soft);
}
.price-card:first-child { border-top: 1px solid var(--hair-soft); }
.price-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.price-card__head h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.price-card__head .btn { padding: 4px 8px; font-size: 12px; }

/* ---------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  max-width: min(520px, 92vw);
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .meter { grid-template-columns: 1fr 1fr; row-gap: 22px; }
  .meter__strip { grid-column: 1 / -1; border-left: 0; padding-left: 0; }
}

@media (max-width: 920px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login__brand { padding: 44px 28px; }
  .login__facts { gap: 20px; }
  .login__form { padding: 40px 28px 64px; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .who { display: none; }
  .page { padding: 20px 16px 48px; }
  .meter { grid-template-columns: 1fr; row-gap: 20px; }
  .meter > * + * { border-left: 0; padding-left: 0; border-top: 1px solid var(--hair); padding-top: 18px; }
  .meter__strip { border-top: 1px solid var(--hair); padding-top: 18px; }
  .lede h1 { font-size: 25px; }
  .filters { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
