/* The dashboard's only stylesheet. No external fonts or images (CSP). */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7d;
  --line: #dde3ea;
  --accent: #0f6e8c;
  --accent-text: #ffffff;
  --bar: #2a9d8f;
  --warn: #b5541c;
  --error: #b42318;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --panel: #1a2129;
    --text: #e6ebf1;
    --muted: #93a1b2;
    --line: #2c3642;
    --accent: #4fb3cf;
    --accent-text: #0b1218;
    --bar: #4cc3b4;
    --warn: #f0a46c;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }

/* Author rules like `display: block` would otherwise beat the attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

header.top h1 { font-size: 18px; margin: 0; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.narrow { max-width: 440px; margin: 48px auto; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
}

.big { font-size: 24px; font-weight: 650; margin: 4px 0 0; }
.muted { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.error { color: var(--error); }
.warn { color: var(--warn); }
.note { color: var(--muted); font-size: 13px; }

form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
form label { width: 100%; font-weight: 600; }
#login-form input { flex: 1 1 260px; }

input, select, button, textarea {
  font: inherit;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

button.secondary { background: transparent; color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toolbar label { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--bar); }
.chart .axis { fill: var(--muted); font-size: 12px; }

.qr {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px dashed var(--line);
  word-break: break-all;
  font-size: 13px;
}

.qr-image {
  display: block;
  width: 256px;
  max-width: 100%;
  height: auto;
  margin: 8px 0 12px;
  background: #fff;
  border-radius: 7px;
}
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 6px; }

.credits { list-style: none; padding: 0; margin: 0; font-variant-numeric: tabular-nums; }
.credits li { padding: 6px 0; border-bottom: 1px solid var(--line); white-space: pre; }

.subhead { margin: 20px 0 8px; }
fieldset.scopes { border: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; width: 100%; }
fieldset.scopes legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
fieldset.scopes label { width: auto; font-weight: 400; display: flex; align-items: center; gap: 6px; }
#key-name { flex: 1 1 260px; }
.secret { margin-top: 12px; padding: 12px; border: 1px solid var(--warn); border-radius: 8px; }
.secret p { margin: 0 0 8px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
button.danger { background: transparent; color: var(--error); border-color: var(--error); padding: 3px 10px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 16px 40px;
}

/* Receipts and statements (K-075). */
#buyer-form input, #buyer-form textarea { flex: 1 1 100%; }
.statement-bar { margin: 12px 0 0; }
button.link { padding: 3px 10px; }

/* Customer email settings (K-089). */
label.check { width: 100%; font-weight: 400; display: flex; align-items: center; gap: 6px; }
#notify-threshold { flex: 1 1 200px; }
/* Usage analytics (K-088): one colour per series, the rest in grey. */
.seg.s0 { fill: var(--bar); }
.seg.s1 { fill: #3b6fb6; }
.seg.s2 { fill: #c8873a; }
.seg.s3 { fill: #8a5cb8; }
.seg.s4 { fill: #c4566b; }
.seg.s5 { fill: #5b8c3a; }
.seg.s-other { fill: var(--muted); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 8px 0 12px; font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.swatch.s0 { background: var(--bar); }
.swatch.s1 { background: #3b6fb6; }
.swatch.s2 { background: #c8873a; }
.swatch.s3 { background: #8a5cb8; }
.swatch.s4 { background: #c4566b; }
.swatch.s5 { background: #5b8c3a; }
.swatch.s-other { background: var(--muted); }
#runway-card.low { border-color: var(--warn); }
#runway-card.low #runway { color: var(--warn); }
/* Playground (K-099): model output is text; code blocks keep their spacing. */
.pg-models label.check { width: auto; }
.pg-models select { max-width: 100%; }
#pg-model, #pg-model2 { width: min(560px, 100%); }
.pg-system { margin: 0 0 12px; }
.pg-system textarea, #pg-input { width: 100%; resize: vertical; }
.pg-columns { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.pg-columns.compare { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.pg-column { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.pg-column h3 { overflow-wrap: anywhere; }
.pg-log { max-height: 480px; overflow-y: auto; }
.pg-message { padding: 8px 0; border-top: 1px solid var(--line); }
.pg-message.user strong { color: var(--accent); }
.pg-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; }
.pg-message pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; overflow-x: auto; margin: 6px 0 2px; font-size: 13px; }
.pg-meta { font-size: 13px; margin: 4px 0 0; }
.pg-meta.error { color: var(--error); }
#pg-form .actions label.file-button { position: relative; width: auto; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: 7px; padding: 7px 10px; cursor: pointer; }
#pg-form .actions label.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#pg-form .actions label.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.pg-attachment { display: flex; align-items: center; gap: 10px; width: 100%; }
.pg-attachment img { object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
/* Playground tabs (K-119): one tab per kind sold; results are text, images and audio from blob: URLs. */
.pg-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 12px; }
.pg-tabs [role="tab"] { background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none; border-radius: 7px 7px 0 0; margin-bottom: -1px; }
.pg-tabs [role="tab"][aria-selected="true"] { color: var(--accent); border-color: var(--line); background: var(--panel); }
.pg-pane:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#pg-img-model, #pg-tts-model, #pg-stt-model, #pg-rr-model { width: min(560px, 100%); }
#pg-img-prompt, #pg-tts-input, #pg-rr-documents, #pg-rr-query { width: 100%; resize: vertical; }
#pg-stt-file { width: 100%; }
.pg-preview { width: 100%; }
.pg-results { display: grid; gap: 12px; margin-top: 12px; }
.pg-result { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.pg-result h3 { overflow-wrap: anywhere; }
.pg-prompt { color: var(--muted); max-height: 7.5em; overflow-y: auto; }
.pg-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; margin: 8px 0; }
.pg-images figure { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.pg-images img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); }
.pg-result audio, .pg-attachment audio { width: min(420px, 100%); margin: 6px 0; }
td.pg-document { white-space: normal; overflow-wrap: anywhere; min-width: 200px; }
.pg-attachment { flex-wrap: wrap; }
/* A picker's long option labels must not widen the page on a phone. */
.pg-pane form > * { min-width: 0; max-width: 100%; }
.pg-pane .pg-models label { max-width: 100%; min-width: 0; flex-wrap: wrap; }
.pg-pane .pg-models select { min-width: 0; }
#pg-img-variant, #pg-tts-voice, #pg-tts-format { max-width: 100%; }
/* The Batch tab (K-127): ids are long; the table scrolls on a phone. */
.pg-batch-id { font-family: ui-monospace, monospace; font-size: 0.85em; }
.alert-banner { border-color: var(--warn); }
.alert-banner h2 { color: var(--warn); }
