/* ◆ AXIOM FARM console — one shell stylesheet for every console page.
   Self-contained: brand tokens are defined here so no page depends on
   load order; global rules are minimal and never center or restyle the
   shell (the previous auth.css did `body{display:flex;align-items:center}`
   and `button{width:100%}`, which destroyed the dashboard layout). */

:root {
  --bg-0: #07080a;
  --bg-1: #0d0f12;
  --fg-0: #e6e8eb;
  --fg-1: #a3a8b0;
  --fg-2: #6b7280;
  --fg-3: #3d4451;
  --accent: #7ee0c9;
  --accent-dim: #3b7d6a;
  --accent-soft: rgba(126, 224, 201, 0.08);
  --amber: #f0c674;
  --warn: #e06c75;
  --line: #191c22;
  --line-2: #2a2e37;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 5px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.dim { color: var(--fg-2); }

/* ── shell layout ─────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 224px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 16px;
  padding: 18px 14px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(126,224,201,0.03), transparent 40%);
  overflow-y: auto;
}
.side .lockup {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.06em; white-space: nowrap;
}
.side .lockup .mark { color: var(--accent); margin-right: 5px; }
.side .lockup .slash { color: var(--fg-3); margin: 0 5px; }
.side .lockup .sub { color: var(--fg-2); font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav .group {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--fg-3); margin: 14px 8px 4px;
}
.nav a {
  display: block; padding: 8px 10px; border-radius: 3px;
  border: 1px solid transparent; color: var(--fg-1);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.05em;
  text-decoration: none;
}
.nav a:hover { color: var(--fg-0); background: rgba(255,255,255,0.03); text-decoration: none; }
.nav a.active { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-soft); }
.side-foot { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-foot .who { font-family: var(--mono); font-size: 10px; color: var(--fg-2); word-break: break-all; }
.side-foot button {
  width: 100%; text-align: left; background: transparent; border: none;
  color: var(--fg-2); font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; padding: 4px 2px;
}
.side-foot button:hover { color: var(--warn); }

.main { flex: 1; min-width: 0; padding: 22px 26px 64px; }
.main h1 {
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  letter-spacing: 0.06em; margin: 0 0 16px; color: var(--fg-0);
}

/* ── components ───────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card .k { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg-2); }
.card .v { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--fg-0); margin-top: 6px; }

.panel { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.panel-head h2 { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--fg-2); margin: 0; text-transform: uppercase; }
.panel-head .dim { font-size: 10px; }

table.layers, table.invoice-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.layers th, table.invoice-table th {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--fg-2); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.layers td, table.invoice-table td { padding: 8px; border-bottom: 1px solid rgba(25,28,34,0.6); color: var(--fg-0); vertical-align: middle; }
table.layers tr:last-child td, table.invoice-table tr:last-child td { border-bottom: none; }
table.invoice-table tr:hover td { background: rgba(255,255,255,0.015); }
table.invoice-table td:last-child, table.invoice-table th:last-child { text-align: right; }
td.pos { color: var(--accent); }
td.neg { color: var(--warn); }
td.mono, .mono { font-family: var(--mono); }

/* Tables scroll horizontally instead of crushing columns on narrow
   screens; the panel stays responsive while the data stays readable. */
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; -webkit-overflow-scrolling: touch; }
.table-scroll table.invoice-table { min-width: 600px; }

.btn {
  display: inline-block; width: auto; padding: 7px 12px; border-radius: 3px; cursor: pointer;
  background: var(--bg-1); border: 1px solid var(--line-2); color: var(--fg-1);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
}
.btn:hover { color: var(--fg-0); border-color: var(--accent-dim); }
.btn.primary { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-soft); }
.btn.ghost { color: var(--fg-2); border-color: var(--line); }
.btn.danger { color: var(--warn); border-color: rgba(224,108,117,0.4); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* List rows (API keys, projects, sessions): a bordered card per item with
   content left and its action right. One rule so every such list — which
   previously had no styling at all — reads the same. */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; margin-bottom: 8px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 4px;
}
.row:last-child { margin-bottom: 0; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { border-color: var(--accent-dim); }
.row .grow { flex: 1; min-width: 0; }
.row .v { font-size: 13px; color: var(--fg-0); overflow: hidden; text-overflow: ellipsis; }
.row .k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--fg-2); text-transform: uppercase; margin-top: 2px; }
.row .btn { flex-shrink: 0; }

/* The per-key analytics panel that expands under a key row. */
.key-panel { display: none; }
.key-panel.open {
  display: block; margin: -4px 0 10px; padding: 12px 13px;
  background: var(--bg-0); border: 1px solid var(--line); border-top: none; border-radius: 0 0 4px 4px;
}
.key-panel .k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--fg-2); text-transform: uppercase; }
.key-models { width: 100%; border-collapse: collapse; margin-top: 8px; }
.key-models th { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3); text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.key-models td { font-size: 12px; color: var(--fg-1); padding: 5px 6px; border-bottom: 1px solid var(--line); }
.key-models tr:last-child td { border-bottom: none; }

#keys { display: flex; flex-direction: column; }

input, select {
  background: var(--bg-0); border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--fg-0); font-family: var(--mono); font-size: 12px; padding: 8px 10px; outline: none;
  max-width: 100%;
}
input:focus, select:focus { border-color: var(--accent-dim); }
label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-2); }
.rowline { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rowline:last-child { border-bottom: none; }
.rowline .grow { flex: 1; min-width: 0; }
.rowline .k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--fg-2); text-transform: uppercase; }
.rowline .v { font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* Product rows (billing "products" list): a bordered list item with the
   name + detail left, price and action right; wraps on narrow screens. */
.product-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.product-row:last-child { border-bottom: none; }
.product-row .grow { flex: 1 1 220px; min-width: 0; }
.product-row .v { font-size: 13px; color: var(--fg-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-row .k {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  color: var(--fg-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.product-row .mono { font-family: var(--mono); font-size: 12px; color: var(--fg-1); white-space: nowrap; }
.product-row .btn { flex-shrink: 0; }
.product-row .btn:not(.danger) { padding: 5px 9px; font-size: 10px; }

.invoice-dl {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--fg-1); white-space: nowrap;
}
.invoice-dl:hover { color: var(--accent); border-color: var(--accent-dim); text-decoration: none; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 10px;
  font-family: var(--mono); background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-dim);
}
.badge.dim { background: rgba(138,144,153,0.1); color: var(--fg-2); border-color: transparent; }
.badge.warn { background: rgba(224,108,117,0.1); color: var(--warn); border-color: rgba(224,108,117,0.4); }

.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width 200ms; }
.meter { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg-2); margin-top: 5px; }
.meter b { color: var(--fg-0); }

.error {
  color: var(--warn); background: rgba(224,108,117,0.08);
  border: 1px solid rgba(224,108,117,0.3); border-radius: 3px;
  padding: 8px 12px; font-size: 12px; margin-bottom: 12px;
}
.secret {
  font-family: var(--mono); font-size: 12px; word-break: break-all;
  background: var(--bg-0); border: 1px solid var(--accent-dim); border-radius: 3px;
  padding: 10px 12px; margin: 10px 0; user-select: all;
}
canvas.chart { width: 100%; height: 180px; background: var(--bg-0); border: 1px solid var(--line); border-radius: 4px; display: block; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.plan.active { border-color: var(--accent); }
.plan .price { font-family: var(--mono); font-size: 15px; }
.plan .btn { margin-top: auto; }

/* ── login page (standalone, centered — scoped to .login) ─────────── */
body.login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background-image: radial-gradient(ellipse at top, rgba(126,224,201,0.06), transparent 60%);
}
body.login .card-auth {
  width: 420px; max-width: calc(100vw - 32px);
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 10px; padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
body.login label { display: block; margin-bottom: 12px; }
body.login input { width: 100%; padding: 10px 12px; font-size: 14px; font-family: var(--sans); margin-top: 6px; }
body.login .btn, body.login button.primary { width: 100%; padding: 11px 14px; font-size: 13px; text-align: center; }
body.login button.primary { background: var(--accent); color: #06100d; border-color: var(--accent); font-weight: 600; }
body.login .sub { color: var(--fg-2); font-size: 13px; margin: 0 0 8px; }
body.login h1 { font-family: var(--sans); font-size: 20px; font-weight: 600; }
.auth-switch { font-size: 13px; color: var(--fg-2); text-align: center; }
.auth-switch a { color: var(--accent); }

/* operator auth bar (team console sidebar) */
.side-foot input { width: 100%; margin-bottom: 6px; font-size: 11px; padding: 6px 8px; }
.side-foot .auth-row { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 6px; }
.side-foot .auth-row .btn { padding: 5px 8px; font-size: 10px; }

/* ── reusable table states (see ui.js / Ax.table) ─────────────────────
   Every table renders a centered spinner while loading and a centered
   empty/error message — never a bare "—". */
.ax-state {
  text-align: center !important;
  padding: 34px 12px !important;
  color: var(--fg-2);
}
.ax-state-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg-2);
  vertical-align: middle;
}
.ax-state-label.dim { color: var(--fg-3); }
.ax-state-err { color: var(--warn); }
.ax-spin {
  display: inline-block; width: 15px; height: 15px; margin-right: 10px;
  border: 2px solid var(--line-2); border-top-color: var(--accent);
  border-radius: 50%; vertical-align: middle;
  animation: ax-spin 0.7s linear infinite;
}
@keyframes ax-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ax-spin { animation-duration: 1.8s; }
}

/* Reusable table toolbar (see Ax.table.mount): search · count · page size
   · prev/next, injected above the table. */
.ax-table-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ax-search { flex: 1 1 240px; max-width: 360px; }
.ax-count { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; white-space: nowrap; }
.ax-size { width: auto; padding: 5px 8px; font-size: 11px; }
.ax-page { padding: 5px 10px; font-size: 13px; line-height: 1; }
.ax-page:disabled { opacity: 0.4; cursor: default; }

/* ── customize page (runtime look · behavior · pricing) ─────────────── */
.cz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.cz-hint { font-size: 11px; margin: 0 0 8px; }
.cz-num { width: 74px; }
.cz-color { width: 40px; height: 32px; padding: 2px; cursor: pointer; }
.cz-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.cz-actions .cz-hint { margin: 0; }

/* ── guard page (runtime security plane) ────────────────────────────── */
.guard-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.guard-form label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; letter-spacing: 0.08em; color: var(--fg-2); text-transform: uppercase; }
.guard-form input, .guard-form select { min-width: 160px; }
.guard-out { font-family: var(--mono); font-size: 11px; line-height: 1.5; background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0; overflow-x: auto; white-space: pre-wrap; }
