/* Panel chrome. This is an admin tool with its own look; it does NOT consume
   the site's tokens.css. Kept small and dependency-free. */

:root {
  --bg: #0b1322;
  --surface: #111c30;
  --surface-2: #182640;
  --line: #24344f;
  --text: #eef3fb;
  --muted: #9fb0c8;
  --accent: #f7931e;
  --accent-ink: #0a192f;
  --ok: #10b981;
  --err: #ef4444;
  --pending: #f59e0b;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
.muted { color: var(--muted); }

/* Header / nav */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 1rem; }
.nav a { color: var(--muted); font-weight: 600; }
.nav a.active, .nav a:hover { color: var(--text); text-decoration: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; }

/* Layout */
.main { max-width: 76rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
body.auth .main { max-width: 26rem; padding-top: 4rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

h1 { font-size: 1.5rem; margin: 0.25rem 0 0.5rem; }
h3 { margin: 0 0 0.35rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.auth-card { margin-top: 2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.card--module { display: block; transition: border-color 120ms ease; }
.card--module:hover { border-color: var(--accent); text-decoration: none; }

/* Forms */
label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }
input {
  font: inherit; padding: 0.6rem 0.7rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 0.6rem 1rem; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
}
button:hover { filter: brightness(1.05); }
.btn-secondary { display: inline-block; padding: 0.55rem 0.9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 600; }
.link { background: none; border: none; color: var(--muted); padding: 0; text-decoration: underline; }
.link:hover { color: var(--text); }
form.inline { display: inline; }

/* Notices */
.notice { padding: 0.7rem 0.9rem; border-radius: 8px; border: 1px solid var(--line); }
.notice--error { border-color: var(--err); background: color-mix(in srgb, var(--err) 12%, var(--surface)); }
.notice--ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.notice--info { color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.badge--success { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.badge--failed { background: color-mix(in srgb, var(--err) 22%, transparent); color: var(--err); }
.badge--pending { background: color-mix(in srgb, var(--pending) 22%, transparent); color: var(--pending); }
.badge--muted { background: var(--surface-2); color: var(--muted); }
.deploy-line { color: var(--muted); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 700; }

/* Auth extras */
.qr { display: flex; justify-content: center; padding: 0.5rem 0; }
.qr img { background: #fff; padding: 6px; border-radius: 8px; }
.secret { text-align: center; }
.codes { columns: 2; list-style: none; padding: 0; }
.codes li { padding: 0.2rem 0; }

/* Preview harness */
.preview { display: flex; flex-direction: column; height: 100vh; }
.preview-toolbar { display: flex; gap: 1rem; align-items: center; padding: 0.5rem 0.75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.device-toggle button, .preview-theme button { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); padding: 0.35rem 0.7rem; }
.device-toggle button.on, .preview-theme button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.preview-stage { flex: 1; display: flex; justify-content: center; background: #050a12; overflow: auto; }
.preview-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-stage.phone iframe { width: 390px; max-width: 100%; margin: 1rem 0; height: calc(100% - 2rem); border-radius: 12px; }

/* Colors module editor */
.editor { display: grid; grid-template-columns: 22rem 1fr; gap: 1rem; height: calc(100vh - 3.7rem); }
.controls { overflow: auto; padding-right: 0.5rem; display: flex; flex-direction: column; gap: 1rem; }
.controls-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.controls-head h1 { font-size: 1.25rem; margin: 0; }
.small { font-size: 0.85rem; }
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.theme-switch a { padding: 0.3rem 0.7rem; color: var(--muted); }
.theme-switch a.on { background: var(--accent); color: var(--accent-ink); }
.theme-switch a:hover { text-decoration: none; }
.applyall { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.applyall input { width: auto; }
.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.9rem; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.group legend { padding: 0 0.4rem; color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field > label { font-weight: 600; font-size: 0.9rem; }
.color-row { display: flex; gap: 0.5rem; align-items: center; }
.color-row .c-pick { width: 2.6rem; height: 2.2rem; padding: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.color-row .c-hex { flex: 1; text-transform: uppercase; font-family: ui-monospace, Menlo, Consolas, monospace; }
.c-font { width: 100%; font: inherit; padding: 0.5rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.field .raw { color: var(--muted); font-size: 0.78rem; }
.controls-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--bg); padding: 0.5rem 0; }
.editor-preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.editor-preview iframe { width: 100%; height: 100%; border: 0; display: block; }
.check-output { max-height: 16rem; overflow: auto; background: #0a0f1a; color: #e6edf7; padding: 0.6rem; border-radius: 8px; font-size: 0.78rem; white-space: pre-wrap; margin-top: 0.5rem; }

/* Commit modal */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.25rem; max-width: 30rem; width: calc(100% - 2rem); }
dialog::backdrop { background: rgba(0,0,0,0.55); }
dialog h2 { margin: 0 0 0.5rem; }
dialog textarea { font: inherit; padding: 0.5rem 0.6rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.bump { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem; display: flex; flex-direction: column; gap: 0.35rem; }
.bump legend { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.radio { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; }
.radio input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* Text module */
.text-group > summary { cursor: pointer; font-weight: 700; padding: 0.4rem 0; color: var(--text); }
.text-group[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 0.6rem; }
.text-group .count { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.t-input { width: 100%; font: inherit; padding: 0.5rem 0.6rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
textarea.t-input { resize: vertical; }

@media (max-width: 60rem) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor-preview { height: 70vh; }
}
