/* shop-web styles: dark theme, system fonts, no framework, no CDN. */

/* Palette and shared tokens in one place so the whole portal stays consistent. */
:root {
  --bg: #0b0e14;
  --panel: #121722;
  --panel-2: #0d1119;
  --border: #1f2735;
  --border-2: #2a3446;
  --text: #e6eaf2;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --accent-2: #3a6fd8;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 20px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

/* Layout: centered column, sticky-free nav, quiet footer. */
.container { max-width: 1280px; margin: 0 auto; padding: 26px 0 60px; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1280px; margin: 0 auto; padding: 18px 20px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 17px; }
.nav-links a { color: var(--muted); text-decoration: none; margin-left: 18px; font-size: 14.5px; }
.nav-links a:hover { color: var(--text); }
.footer { max-width: 1280px; margin: 0 auto; padding: 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

h1 { font-size: 26px; margin: 8px 0 6px; }
h2 { font-size: 12.5px; margin: 0 0 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
h3 { font-size: 16px; margin: 0; }
p { margin: .4em 0; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .95em; }
.hidden { display: none; }
.note { font-size: 12.5px; margin: 10px 0 0; }
.note-muted { color: var(--muted); font-size: 14px; }
.linkline { margin: 18px 0; }
.big { font-size: 22px; font-weight: 700; }

/* Cards: the one surface everything sits on. */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 16px 0; }

/* Buttons and inputs. */
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border: 1px solid var(--border-2); color: var(--muted); font-weight: 500; padding: 7px 12px; font-size: 13px; border-radius: 8px; cursor: pointer; }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.key-form { display: flex; gap: 10px; flex-wrap: wrap; }
.key-form input { flex: 1; min-width: 220px; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text); border-radius: 10px; padding: 11px 13px; font-family: var(--mono); font-size: 14px; }
.key-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.search { width: 100%; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 15px; margin: 14px 0; }
.search:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* Key display: masked key row with reveal + copy. */
.keyrow { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; margin-top: 6px; }
.keybox { flex: 1; min-width: 200px; display: flex; align-items: center; font-family: var(--mono); font-size: 13.5px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; overflow-wrap: anywhere; }

/* Status badges. */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.badge.active { background: rgba(63,185,80,.14); color: var(--green); }
.badge.exhausted { background: rgba(248,81,73,.14); color: var(--red); }
.badge.disabled { background: rgba(139,148,167,.15); color: var(--muted); }

/* Quota progress bar: green <70%, amber <90%, red >=90%/exhausted. */
.bar { height: 10px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; margin: 6px 0 12px; }
.bar > div { height: 100%; border-radius: 6px; }
.bar.ok > div { background: var(--green); }
.bar.warn > div { background: var(--amber); }
.bar.bad > div { background: var(--red); }

/* Stat grids and label/value rows. */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.kv .k { color: var(--muted); font-size: 12.5px; }
.kv .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-variant-numeric: tabular-nums; }
.row span:first-child { color: var(--muted); }
.row.total { font-weight: 700; }
.rows { margin-top: 6px; }
.rows .row { border-bottom: 1px solid var(--border); }
.rows .row:last-child { border-bottom: 0; }

/* Recent requests table: scrollable on phones instead of squashed. */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th { color: var(--muted); text-align: left; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-2); white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
td.model { font-family: var(--mono); font-size: 12px; }
.hide-reasoning .col-reasoning { display: none; }

/* Inline alert (never window.alert). */
.alert { border-radius: 10px; padding: 12px 14px; margin: 16px 0; border: 1px solid rgba(248,81,73,.4); background: rgba(248,81,73,.08); color: #ffb4ae; }

/* Landing tiles. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 22px 0; }
.tile { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); }
.tile .t { font-weight: 700; margin-bottom: 4px; }
.tile .d { color: var(--muted); font-size: 14px; }

/* Code blocks with a copy button (docs + landing). */
.codeblock { position: relative; margin: 12px 0; }
.codeblock pre { margin: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 76px 14px 14px; overflow-x: auto; }
.codeblock code { font-family: var(--mono); font-size: 12.8px; color: #c9d4e8; white-space: pre; }
.codeblock .copy { position: absolute; top: 8px; right: 8px; }

/* Toast (copy feedback). */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: #1c2433; border: 1px solid var(--border-2); color: var(--text); padding: 9px 16px; border-radius: 10px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Model catalog (/models) and the collapsible list on /customer. */
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin: 18px 0; }
.model-card .desc { color: var(--muted); font-size: 13.5px; margin: 8px 0; }
.pill { display: inline-block; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 1px 9px; font-size: 11.5px; margin: 8px 6px 0 0; }
.prices { margin-top: 10px; font-size: 13.5px; }
.models-details { padding-top: 14px; padding-bottom: 14px; }
.models-details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.model-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 9px 0; border-bottom: 1px solid var(--border); }
.model-line:last-child { border-bottom: 0; }
.model-line .nm { font-weight: 600; }
.model-line .id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.model-line .ds { color: var(--muted); font-size: 13px; flex: 1; min-width: 160px; }

/* Header rows inside cards (name + badge, name + copy). */
.header-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Phones: tighten paddings, keep the table scrollable. */
@media (max-width: 600px) {
  body { padding: 0 12px; }
  .nav { padding: 14px 12px; }
  .container { padding-top: 16px; }
  .card { padding: 16px; }
  h1 { font-size: 22px; }
  .nav-links a { margin-left: 12px; }
}

/* Authenticated customer view: the entry chrome (heading, intro, key-input
   card) steps aside once stats render — the visitor came for the numbers. */
main.authed > h1,
main.authed > p,
main.authed > section {
  display: none;
}

/* The authenticated stat row: quota · requests & tokens · costs · models
   link side by side, wrapping to one column on narrow screens. */
.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .cards-row { grid-template-columns: 1fr; }
}
.cards-row .card { margin-bottom: 0; }
.card-link { display: flex; align-items: center; justify-content: center; }

/* Header left group: logout button sits leftmost of the brand, shown only
   while a key is remembered in this browser. */
.nav-left { display: flex; align-items: center; gap: 10px; }
#logout-btn { white-space: nowrap; }

/* Long unbroken names (a key named with a 200-char string, a model id)
   must WRAP inside their cell instead of pushing the card or table wider
   than the viewport — overflow-wrap:anywhere breaks anywhere, unlike
   break-word which still refuses mid-"word" runs without spaces. */
.header-row h3 { min-width: 0; overflow-wrap: anywhere; }
.header-row .badge { flex-shrink: 0; }
.table-wrap td, .table-wrap th { overflow-wrap: anywhere; }
.model-line .nm, .model-line .id, .model-line .ds { overflow-wrap: anywhere; }

/* Docs playground: key + model + prompt + result. Same visual family as the
   customer key form, one column, roomy textarea. */
#try-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
#try-form input, #try-form select, #try-form textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
#try-form textarea { resize: vertical; min-height: 44px; }
.try-out { margin-top: 12px; }
.try-out .reply { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.try-out .meta { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* Model availability strip: 24 hourly bars + uptime line. */
.avail { margin-top: 10px; }
.up-strip { display: flex; gap: 2px; height: 14px; align-items: stretch; }
.up-bar { flex: 1; border-radius: 2px; min-width: 2px; }
.up-ok { background: #2f9e6e; }
.up-warn { background: #c9a227; }
.up-bad { background: #d64545; }
.avail-line { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* /models — mock-style cards (structure only; colors inherit the shop's
   dark theme — the light graph-paper background was rejected 2026-10-10). */
/* Recommended badge — terracotta chip overlapping the card's top-left. */
.rec-badge {
  position: absolute; top: -11px; left: 14px;
  background: #B85C38; color: #FFF8F2;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.rec-badge .rec-rank { font-weight: 800; margin-left: 2px; }

/* Header: vendor circle + titles + copy. */
.m-head { display: flex; align-items: center; gap: 12px; }
.m-logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 50%; background: #FFFFFF; border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: var(--accent);
}
.m-titles { min-width: 0; flex: 1; }
.m-titles h3 { font-size: 16.5px; }
.m-id { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.m-copy { flex-shrink: 0; }

/* Tier toggle row. */
.tier-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 10px; }
.tier-lab { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.seg-btn {
  font: inherit; font-size: 12.5px; padding: 5px 12px; cursor: pointer;
  background: transparent; border: 0; color: var(--muted);
}
.seg-btn.sel { background: var(--accent); color: #fff; font-weight: 600; }

/* 2x2 pricing grid: bordered quadrants, bold credits, small-caps labels. */
.price-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.price-grid.single { grid-template-columns: 1fr; }
.price-cell { padding: 12px 14px; background: var(--panel); }
.price-grid .price-cell:nth-child(2n) { border-left: 1px solid var(--border); }
.price-grid .price-cell:nth-child(n+3) { border-top: 1px solid var(--border); }
.price-grid.single .price-cell { border-left: 0 !important; border-top: 0 !important; }
.price-val { font-size: 16px; font-weight: 700; }
.price-lab { font-size: 10.5px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-top: 3px; }
.desc { margin-top: 12px; }

/* Uptime block. */
.avail { margin-top: 14px; }
.avail-head { display: flex; justify-content: space-between; align-items: baseline; }
.avail-lab { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.avail-lat { font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.up-strip { gap: 3px; height: 20px; }
.up-bar { border-radius: 4px; min-width: 3px; }
.up-bar:hover { filter: brightness(1.25); }

/* Docs playground: searchable model picker (input + filtered dropdown). */
.model-picker { position: relative; }
.model-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  max-height: 240px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
}
.model-item { padding: 8px 12px; cursor: pointer; font-size: 13.5px; overflow-wrap: anywhere; }
.model-item:hover { background: var(--panel-2); }
