/* AI Gateway console.
   One loud element: the meter on each account. Everything around it stays quiet. */

:root {
  --ground: #edf1ef;      /* meter faceplate */
  --surface: #ffffff;
  --ink: #14212b;
  --muted: #586771;
  --rule: #cfd8d5;
  --petrol: #0d6b68;      /* credit in use */
  --petrol-deep: #094e4c;
  --amber: #b86e00;       /* close to the cap */
  --brick: #a8301f;       /* stopped */
  --track: #dfe6e3;
  --focus: #1b4dd8;
  --radius: 6px;
  font-family: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.page { max-width: 62rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1.75rem; }
.summary { font-size: 1.75rem; line-height: 1.25; font-weight: 500; letter-spacing: -0.015em; max-width: 34ch; }
.summary .sub { display: block; margin-top: 0.5rem; font-size: 1rem; font-weight: 400; letter-spacing: 0; color: var(--muted); max-width: 60ch; }
.notice { margin-top: 1.25rem; padding: 0.625rem 0.875rem; background: var(--surface); border-left: 4px solid var(--petrol); border-radius: 0 var(--radius) var(--radius) 0; }
.notice.bad { border-left-color: var(--brick); }

section { margin-top: 3rem; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; padding-bottom: 0.875rem; border-bottom: 2px solid var(--ink); }
.hint { color: var(--muted); font-size: 0.875rem; max-width: 70ch; }
.empty { padding: 1.5rem 0; color: var(--muted); max-width: 60ch; }
.optional { color: var(--muted); font-weight: 400; }
.error { color: var(--brick); font-size: 0.875rem; }

/* ---- buttons */
button { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #9aa8a4; border-radius: var(--radius); padding: 0.4375rem 0.875rem; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--ink); }
button:disabled { opacity: 0.45; cursor: default; border-color: #9aa8a4; }
button.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; font-weight: 500; }
button.primary:hover { background: var(--petrol-deep); border-color: var(--petrol-deep); }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--ink); border-color: var(--rule); }
button.danger { color: var(--brick); border-color: var(--brick); }
button.danger.armed { background: var(--brick); color: #fff; }
button.icon { padding: 0.25rem 0.5rem; line-height: 1.2; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- accounts: an ordered list, because the order is the routing rule */
.accounts { list-style: none; margin: 0; padding: 0; }
.account { display: grid; grid-template-columns: 2.25rem minmax(9rem, 1.1fr) minmax(14rem, 2fr) auto; gap: 0.25rem 1.25rem; align-items: center; padding: 1.125rem 0; border-bottom: 1px solid var(--rule); }
.account .pos { font-size: 1.5rem; font-weight: 600; color: var(--muted); align-self: start; }
.account[data-status="in_use"] .pos { color: var(--petrol); }
.account .name { font-weight: 600; overflow-wrap: anywhere; }
.account .sub { font-size: 0.875rem; color: var(--muted); }
.account .state { font-size: 0.875rem; font-weight: 500; margin-top: 0.125rem; }
.account[data-status="in_use"] .state { color: var(--petrol); }
.account[data-status="standby"] .state { color: var(--muted); }
.account[data-status="paused"] .state { color: var(--ink); }
.account[data-status="capped"] .state { color: var(--brick); }

.gauge { position: relative; height: 1.125rem; background: var(--track); border-radius: 3px; }
.gauge .fill { position: absolute; inset: 0 auto 0 0; background: var(--petrol); border-radius: 3px 0 0 3px; min-width: 2px; }
.gauge .cap { position: absolute; top: -0.3125rem; bottom: -0.3125rem; width: 2px; background: var(--ink); }
.account[data-level="near"] .gauge .fill { background: var(--amber); }
.account[data-status="capped"] .gauge .fill { background: var(--brick); }
.account[data-status="paused"] .gauge .fill { background: #8b9995; }
.figures { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.4375rem; font-size: 0.875rem; color: var(--muted); }
.figures strong { color: var(--ink); font-weight: 600; }
.warn { grid-column: 3 / -1; font-size: 0.875rem; color: var(--amber); }

.acts { display: flex; gap: 0.375rem; justify-content: flex-end; }

/* ---- service keys */
.table-wrap { overflow-x: auto; }
.keys { width: 100%; border-collapse: collapse; }
.keys th { text-align: left; font-size: 0.875rem; font-weight: 500; color: var(--muted); padding: 0.75rem 1rem 0.5rem 0; }
.keys td { padding: 0.75rem 1rem 0.75rem 0; border-top: 1px solid var(--rule); vertical-align: middle; }
.keys .num { text-align: right; }
.keys td:last-child, .keys th:last-child { text-align: right; padding-right: 0; }
.keys .svc { font-weight: 600; }
.connect { margin-top: 1rem; }
.connect code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.8125rem; background: var(--surface); padding: 0.125rem 0.375rem; border-radius: 4px; overflow-wrap: anywhere; }

footer { margin-top: 3.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.875rem; max-width: 70ch; }

/* ---- forms and dialogs */
label { display: block; font-size: 0.875rem; font-weight: 500; margin: 0.875rem 0 0.25rem; }
input { font: inherit; color: var(--ink); width: 100%; padding: 0.5rem 0.625rem; background: var(--surface); border: 1px solid #9aa8a4; border-radius: var(--radius); }
input[readonly] { background: var(--ground); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875rem; }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.125rem; }

dialog { width: min(34rem, calc(100vw - 2rem)); padding: 1.5rem; color: var(--ink); background: var(--surface); border: 1px solid var(--ink); border-radius: 10px; }
dialog::backdrop { background: rgba(20, 33, 43, 0.45); }
dialog p { margin-top: 0.5rem; }
dialog h3 { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.danger-zone .actions { justify-content: flex-start; }

.signin { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.signin form { width: min(22rem, 100%); background: var(--surface); padding: 1.75rem; border: 1px solid var(--ink); border-radius: 10px; }
.signin p { margin-top: 0.5rem; color: var(--muted); }
.signin p.error { color: var(--brick); }
.signin button { width: 100%; margin-top: 1.25rem; }

@media (max-width: 46rem) {
  .summary { font-size: 1.375rem; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .account { grid-template-columns: 2rem 1fr; }
  .account .meter, .account .acts, .warn { grid-column: 2; }
  .acts { justify-content: flex-start; flex-wrap: wrap; margin-top: 0.5rem; }
  .fields { grid-template-columns: 1fr; }
}
