/* VelocityOS Control Panel — one stylesheet, light + dark via tokens. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #171a21;
  --text-2: #4b5363;
  --muted: #7a8394;
  --border: #e3e6ec;
  --border-strong: #d2d7e0;
  --accent: #5b4be0;
  --accent-2: #7a6cf0;
  --accent-soft: #eeecfd;
  --accent-text: #ffffff;
  --ok: #138a52;      --ok-soft: #e4f6ec;
  --warn: #a8650a;    --warn-soft: #fdf1dc;
  --bad: #c73232;     --bad-soft: #fde8e8;
  --info: #2563c9;    --info-soft: #e6effc;
  --side-bg: #15131f;
  --side-text: #c9c6dc;
  --side-muted: #7f7b96;
  --side-active: #ffffff;
  --side-active-bg: rgba(255, 255, 255, 0.08);
  --term-bg: #12121a;
  --term-text: #d7d9e0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1015;
    --surface: #171920;
    --surface-2: #1c1f27;
    --text: #e8eaf0;
    --text-2: #b4bac6;
    --muted: #868ea0;
    --border: #262a34;
    --border-strong: #323744;
    --accent: #8b7dff;
    --accent-2: #a296ff;
    --accent-soft: #24213d;
    --accent-text: #0f0d1e;
    --ok: #4cc58a;      --ok-soft: #12291e;
    --warn: #e2a640;    --warn-soft: #2d2412;
    --bad: #ff7272;     --bad-soft: #321819;
    --info: #6aa2ff;    --info-soft: #15233b;
    --side-bg: #0b0b10;
    --term-bg: #0b0c10;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ---- shell ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #b264e8); display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 15px; flex: none; }
.brand .name { font-weight: 650; font-size: 14.5px; line-height: 1.15; }
.brand .name small { display: block; font-weight: 500; color: var(--side-muted); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--side-active-bg); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active-bg); color: var(--side-active); }
.nav a.active svg { color: var(--accent-2); }
.nav svg { width: 18px; height: 18px; flex: none; color: var(--side-muted); }
.nav .count { margin-left: auto; font-size: 11.5px; background: rgba(255,255,255,0.1); border-radius: 999px; padding: 0 7px; color: var(--side-text); }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.08); padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.12); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 12px; flex: none; text-transform: uppercase; }
.side-foot .who { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who small { display: block; color: var(--side-muted); font-size: 11px; }
.side-foot button { background: none; border: none; color: var(--side-muted); padding: 4px; cursor: pointer; border-radius: 6px; }
.side-foot button:hover { color: #fff; background: var(--side-active-bg); }
.side-foot svg { width: 18px; height: 18px; display: block; }

.main { min-width: 0; padding: 28px 32px 64px; }
.container { max-width: 1120px; margin: 0 auto; }

/* ---- page header ---------------------------------------------------------- */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.pagehead .title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pagehead .sub { color: var(--text-2); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ---- cards & grids -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.card.danger .card-head h2 { color: var(--bad); }
.card.highlight { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---- buttons -------------------------------------------------------------- */
.btn, button.btn { display: inline-flex; align-items: center; gap: 7px; font: 500 14px/1 var(--font); padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---- status pills --------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); text-transform: capitalize; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.run::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---- alerts --------------------------------------------------------------- */
.alert { border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 16px; border: 1px solid transparent; font-size: 14px; }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* ---- tables & key/value --------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
td .sub { color: var(--muted); font-size: 12.5px; }
.row-link { font-weight: 600; color: var(--text); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 22px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- checks list ---------------------------------------------------------- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: none; }
.checks .icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 1px; font-size: 12px; font-weight: 800; }
.checks .icon.ok { background: var(--ok-soft); color: var(--ok); }
.checks .icon.bad { background: var(--bad-soft); color: var(--bad); }
.checks .icon.warn { background: var(--warn-soft); color: var(--warn); }
.checks .what { flex: 1; min-width: 0; }
.checks .val { color: var(--muted); font-size: 13px; text-align: right; overflow-wrap: anywhere; max-width: 45%; }
.checks .hint { color: var(--muted); font-size: 12.5px; }

/* ---- stepper -------------------------------------------------------------- */
.stepper { display: flex; align-items: center; gap: 0; margin: 0 0 22px; padding: 0; list-style: none; flex-wrap: wrap; row-gap: 10px; }
.stepper li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stepper li + li::before { content: ""; width: 36px; height: 2px; background: var(--border-strong); margin: 0 12px; border-radius: 2px; }
.stepper .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); }
.stepper li.done { color: var(--text-2); }
.stepper li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper li.done + li::before, .stepper li.done + li.done::before { background: var(--ok); }
.stepper li.on { color: var(--text); }
.stepper li.on .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper li.fail .dot { border-color: var(--bad); color: var(--bad); }

/* ---- terminal log --------------------------------------------------------- */
.term { background: var(--term-bg); color: var(--term-text); border-radius: 0 0 var(--radius) var(--radius); padding: 14px 16px; font: 12.5px/1.65 var(--mono); max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.term:empty::after { content: "Waiting for the worker…"; color: #6b7080; }
.term .ln { display: block; }
.term .ts { color: #5d6272; margin-right: 10px; user-select: none; }
.term .start { color: #9db4ff; font-weight: 600; }
.term .okl { color: #6fdc9f; }
.term .warn { color: #f1c46b; }
.term .error { color: #ff8080; }
.term-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--term-bg); color: #9aa0ae; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 12.5px; }
.term-wrap { border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; box-shadow: var(--shadow); }
pre.code { background: var(--term-bg); color: var(--term-text); padding: 14px 16px; border-radius: var(--radius-sm); margin: 0; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }

/* ---- forms ---------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12.5px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 11px; min-width: 0; width: 100%; transition: border-color 0.12s, box-shadow 0.12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 80px; resize: vertical; }
.form-foot { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.preview-line { font-size: 13px; color: var(--muted); margin-top: 6px; }
.preview-line strong { color: var(--text); font-family: var(--mono); font-weight: 600; }

/* ---- misc ----------------------------------------------------------------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-size: 12.5px; font-family: var(--mono); }
.secret { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--mono); font-size: 15px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.tabs a.on { background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input { width: auto; flex: 1 1 180px; }
.link-ext::after { content: " ↗"; font-size: 0.85em; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---- login ---------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #b264e8 14%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px rgba(16, 24, 40, 0.12); padding: 30px 28px; }
.auth-card .brand { color: var(--text); padding: 0 0 22px; }
.auth-card .brand .name small { color: var(--muted); }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 980px) {
  .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; overflow-x: auto; }
  .brand { padding: 0; }
  .brand .name { display: none; }
  .nav { flex-direction: row; }
  .nav .count { display: none; }
  .side-foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .side-foot .who { display: none; }
  .main { padding: 20px 16px 48px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  th, td { padding: 10px 12px; }
  .stepper li + li::before { width: 16px; margin: 0 6px; }
}
