/* Shared by every dashboard page. Page-specific styles live in each page. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1c2029;
  --border: #2a2e38;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --accent: #5b8cff;
  --ok: #3ecf8e;
  --err: #ff5d5d;
  --warn: #e8b339;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
body.fixed { height: 100vh; min-height: 0; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { margin: 0; }

/* --- header + navigation --- */
header.app {
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  min-height: 48px;
}
header.app .brand { font-size: 16px; font-weight: 600; color: var(--text); }
header.app nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
header.app nav a {
  color: var(--muted);
  padding: 14px 11px 12px;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
header.app nav a:hover { color: var(--text); text-decoration: none; }
header.app nav a.active { color: var(--text); border-bottom-color: var(--accent); }
header.app .header-right { display: flex; align-items: center; gap: 12px; }
header.app .sub { color: var(--muted); font-size: 12px; }

/* --- page body --- */
.page { width: 100%; max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 70ch; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* --- cards --- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card > h2 { font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 0; line-height: 1.5; }
.empty { color: var(--muted); font-size: 13px; padding: 14px 0; text-align: center; }
.err { color: var(--err); font-size: 12.5px; min-height: 16px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

/* --- controls --- */
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
input[type=number] { width: 110px; }
.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.btn.danger { color: var(--err); }
.btn.danger:hover:not(:disabled) { border-color: var(--err); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }
label.check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 999px; transition: 0.15s; }
.switch .slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 2.5px; background: var(--text); border-radius: 50%; transition: 0.15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(15px); }

/* --- badges, chips, bars --- */
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.badge.queued, .badge.starting, .badge.stopped, .badge.neutral { background: #3a3f4d; color: var(--muted); }
.badge.running { background: #23324d; color: var(--accent); }
.badge.success, .badge.merged, .badge.done, .badge.good { background: #163a2c; color: var(--ok); }
.badge.error, .badge.no_backend_available, .badge.blocked, .badge.bad { background: #3a1f1f; color: var(--err); }
.badge.usage_limited, .badge.left, .badge.idle, .badge.paused, .badge.pausing, .badge.needs_resolution, .badge.caution { background: #3a331a; color: var(--warn); }
.badge.awaiting_merge { background: #1a2a3a; color: #6aa9ff; }
.chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--border); border-radius: 10px; font-size: 11px; color: var(--muted); }
.bar { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.warn > i { background: var(--warn); }
.bar.over > i { background: var(--err); }

/* --- tables --- */
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.note { color: var(--muted); }
table.data tr.next td:first-child { border-left: 3px solid var(--accent); }
.scroll-x { overflow-x: auto; }

/* --- readiness checks --- */
.rd-list { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; }
.rd-row { display: flex; gap: 10px; padding: 4px 0; align-items: baseline; }
.rd-tag { flex: 0 0 44px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.rd-tag.pass { color: var(--ok); } .rd-tag.info { color: var(--muted); } .rd-tag.warn { color: var(--warn); } .rd-tag.error { color: var(--err); }
.rd-fix { color: var(--muted); display: block; }
.rd-verdict { font-weight: 600; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }

/* --- event log --- */
.log { font-size: 12px; color: var(--muted); max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.log div { padding: 1px 0; }

/* --- toast --- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 9px 13px; font-size: 13px; max-width: 360px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.toast.ok { border-left-color: var(--ok); color: var(--text); }
.toast.err { border-left-color: var(--err); color: var(--text); }

/* --- modal (sign-in, confirmations) --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: none; align-items: center; justify-content: center; z-index: 40; }
.modal-overlay.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; width: 420px; max-width: 92vw; max-height: 84vh; display: flex; flex-direction: column; }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 15px; }
.modal-body { padding: 14px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-body input { width: 100%; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 720px) {
  header.app { padding: 0 12px; gap: 8px; }
  .page { padding: 14px 12px 50px; }
}
