/* Dashboard Studio: one stylesheet, no build step. */
:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7975;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e3eefb;
  --good: #0a7a2f;
  --good-soft: #e3f4e8;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf1d6;
  --code-bg: #1a1a19;
  --code-text: #f0efec;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #33322f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #16263a;
    --good: #5cc27a;
    --good-soft: #15291b;
    --bad: #f28b82;
    --bad-soft: #3a1714;
    --warn: #e7b84a;
    --warn-soft: #33270d;
    --code-bg: #0d0d0c;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 600; }
code, pre, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .86em; }
.muted { color: var(--text-3); }
.small { font-size: .85rem; }

/* Header */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--text-2); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: .75rem; text-align: center; margin-left: 4px; }
.user { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: .9rem; white-space: nowrap; }
.user form { margin: 0; }

/* Layout */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip.passed, .chip.published { background: var(--good-soft); color: var(--good); }
.chip.failed, .chip.rejected { background: var(--bad-soft); color: var(--bad); }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.live { background: var(--accent-soft); color: var(--accent-ink); }

/* Forms */
label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { margin-bottom: 12px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1; min-width: 160px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
button:hover, .button:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--accent-ink); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.notice { background: var(--good-soft); color: var(--good); }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.secret { background: var(--warn-soft); color: var(--warn); }

/* Login */
.login { max-width: 380px; margin: 10vh auto; }
.login .card { padding: 28px; }

/* Editor */
.editor-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: calc(100vh - 52px); }
#monaco.editor-full { min-height: 0; }
.validation h3 .spacer { flex: 1; }
.editor-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.editor-bar .title { font-weight: 600; }
.editor-bar input[type=text] { width: 260px; padding: 5px 8px; }
.editor-bar .spacer { flex: 1; }
.editor-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 0; }
#monaco { min-height: 0; border-right: 1px solid var(--border); }
.preview-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border);
  font-size: .85rem; color: var(--text-2); }
.preview-head .spacer { flex: 1; }
.preview-pane iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.validation { max-height: 32vh; overflow: auto; background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 16px; }
.validation h3 { margin: 0 0 6px; font-size: .9rem; display: flex; gap: 8px; align-items: center; }
.finding { display: flex; gap: 10px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: .88rem; }
.finding:hover { background: var(--surface-2); }
.finding .where { color: var(--text-3); min-width: 70px; font-family: ui-monospace, Menlo, monospace; }
.finding .rule { color: var(--text-3); font-family: ui-monospace, Menlo, monospace; }
.finding.error .sev { color: var(--bad); font-weight: 700; }
.finding.warning .sev { color: var(--warn); font-weight: 700; }
pre.traceback { background: var(--code-bg); color: var(--code-text); padding: 12px 14px; border-radius: 8px;
  white-space: pre-wrap; overflow: auto; max-height: 26vh; margin: 6px 0 0; }
.kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px;
  font-size: .78rem; color: var(--text-2); background: var(--surface-2); }
@media (max-width: 900px) {
  .editor-shell { height: auto; }
  #monaco.editor-full { height: 70vh; }
  .editor-main { grid-template-columns: 1fr; }
  #monaco { height: 60vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .preview-pane iframe { height: 70vh; }
}

/* Diff */
.diff { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
.diff pre { margin: 0; padding: 8px 0; }
.diff .line { display: block; padding: 0 12px; white-space: pre; }
.diff .add { background: var(--good-soft); color: var(--good); }
.diff .del { background: var(--bad-soft); color: var(--bad); }
.diff .hunk { color: var(--accent-ink); background: var(--accent-soft); }
.diff .meta { color: var(--text-3); }

.empty { text-align: center; padding: 32px; color: var(--text-3); }
.details-json { font-size: .78rem; color: var(--text-3); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-inline-error { color: var(--bad); font-weight: 600; }

/* Confirmation dialog (delete dashboard) */
.confirm-dialog { border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; max-width: 480px; width: calc(100% - 32px); background: var(--surface); color: var(--text); }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.confirm-dialog h2 { margin-top: 0; }
.confirm-dialog .actions { justify-content: flex-end; margin-top: 14px; }
