:root {
  --ink: #1a2230; --ink2: #3a4556; --muted: #556070; --faint: #8792a2;
  --canvas: #f3f5f8; --panel: #ffffff; --line: #d6dce4; --input: #c5cdd8;
  --primary: #1f5fae; --primary-lo: #174a88; --nav-active: #eaf1fb;
  --danger: #9a4a06; --danger-soft: #fff4e5; --success: #1e7a4c; --success-soft: #e6f4ec;
  --error: #b42318; --error-soft: #fdecea; --info-soft: #eef4fc;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6eaf0; --ink2: #c9d1dc; --muted: #9aa5b4; --faint: #6f7a89;
    --canvas: #12161c; --panel: #1b2129; --line: #2c3540; --input: #3a4552;
    --primary: #4a8be0; --primary-lo: #3a78c9; --nav-active: #1f2b3b;
    --danger: #f0a660; --danger-soft: #2e2216; --success: #5cc48f; --success-soft: #16291f;
    --error: #ff8a7a; --error-soft: #331b18; --info-soft: #1a2636;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink); background: var(--canvas); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }
[hidden] { display: none !important; }

.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; color: var(--ink); padding: 0 6px; }
.brand:hover { text-decoration: none; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--ink2); padding: 9px 12px; border-radius: 8px; }
nav a:hover { background: var(--canvas); text-decoration: none; }
nav a.active { background: var(--nav-active); color: var(--primary); font-weight: 600; }
.account { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.content { padding: 28px 32px 48px; max-width: 1100px; width: 100%; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.page-head { margin-bottom: 18px; }
.page-head p { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px; min-width: 0; }
fieldset.card { margin: 0 0 16px; }
.login { width: 100%; max-width: 400px; text-align: center; padding: 32px; }
.login p { margin: 8px 0 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2.tight { gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.quick-card { display: flex; flex-direction: column; gap: 4px; color: var(--ink); margin: 0; }
.quick-card:hover { border-color: var(--primary); text-decoration: none; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.label { display: block; font-weight: 600; font-size: .88rem; color: var(--ink2); margin: 10px 0 5px; }
.label:first-child, h2 + .label { margin-top: 0; }
select, input[type=text], input[type=email], input[type=password], input[type=date], input:not([type]) {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--input); border-radius: 8px; padding: 8px 10px; min-height: 38px;
}
select:focus, input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[type=date] { max-width: 220px; }
.radio, .check { display: flex; align-items: center; gap: 8px; margin: 4px 0; cursor: pointer; }
.hint { color: var(--muted); font-size: .84rem; margin: 6px 0 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--input); background: var(--panel); color: var(--ink); cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--canvas); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-lo); }
.btn-stop { color: var(--danger); border-color: var(--danger); }
.btn-stop:hover { background: var(--danger-soft); }
.btn-link { border: 0; background: none; padding: 0; min-height: 0; color: var(--primary); font-weight: 400; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.actions form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.alert { border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.alert-error { background: var(--error-soft); color: var(--error); }
.alert-info { background: var(--info-soft); }

progress { width: 100%; height: 12px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 6px; background: var(--canvas); overflow: hidden; margin: 10px 0 6px; }
progress::-webkit-progress-bar { background: var(--canvas); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 6px; transition: width .4s; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 6px; }
.stat-big { font-size: 1.5rem; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-top: 12px; }
.stats div { display: flex; flex-direction: column; }
.stats strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.active-job { display: block; color: var(--ink); padding: 12px 0; border-bottom: 1px solid var(--line); }
.active-job:last-child { border-bottom: 0; }
.active-job:hover { text-decoration: none; }

.status { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; background: var(--canvas); color: var(--ink2); }
.status-running, .status-queued { background: var(--info-soft); color: var(--primary); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-completed_errors, .status-stopped, .status-interrupted { background: var(--danger-soft); color: var(--danger); }
.status-failed { background: var(--error-soft); color: var(--error); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; color: var(--ink2); font-size: .82rem; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; }
td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.log { background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; height: 420px; overflow: auto; font: 12.5px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .lvl-WARN { color: var(--danger); }
.log .lvl-ERROR { color: var(--error); font-weight: 600; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .account { margin: 0; border: 0; padding: 0; display: flex; gap: 8px; align-items: center; }
  .account .muted:first-child { display: none; }
  .content { padding: 20px 16px 40px; }
  .grid-2, .grid-3, .quick { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

.setup { width: 100%; max-width: 560px; padding: 32px; }
.setup h1 { margin-top: 8px; }
.setup ol { padding-left: 20px; }
.setup li { margin: 6px 0; }
.checklist { list-style: none; padding: 0; margin: 16px 0; }
.checklist.card { padding: 12px 20px; }
.checklist li { padding: 6px 0 6px 28px; position: relative; }
.checklist li::before { position: absolute; left: 0; font-weight: 700; }
.checklist li.ok::before { content: "✓"; color: var(--success); }
.checklist li.todo::before { content: "•"; color: var(--danger); font-size: 1.3em; line-height: 1; top: 5px; }

.setup-wrap { width: 100%; max-width: 1000px; }
.setup-head { display: flex; gap: 16px; align-items: center; }
.setup-head h1 { margin: 0; }
.setup-head p { margin: 4px 0 0; }
.setup-options .card h2 { margin-top: 10px; }
.setup-options ol { padding-left: 18px; }
.steps { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.step { border-top: 1px solid var(--line); padding-top: 12px; }
.step h3, .card h3 { font-size: .98rem; margin: 0 0 6px; }
.ok-line { color: var(--success); font-weight: 600; margin: 6px 0; }
.row-input { display: flex; gap: 8px; align-items: center; }
.row-input input { flex: 1; }
.add-user { margin-top: 12px; max-width: 480px; }
.device { margin-top: 8px; }
.device-box { background: var(--info-soft); border-radius: 8px; padding: 12px 14px; margin-top: 10px; text-align: left; }
.device-box ol { margin: 0; padding-left: 18px; }
.device-box li { margin: 4px 0; }
.device-code { font-size: 1.25rem; font-weight: 700; letter-spacing: .08em; padding: 2px 6px; background: var(--panel); border-radius: 6px; }
.msg-ok { color: var(--success); font-weight: 600; }
.msg-error { color: var(--error); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.login .device { text-align: left; }

/* ---- Site sign-in screen ------------------------------------------------- */
.gate-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%),
    var(--canvas);
}
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 36px 32px 28px;
  box-shadow: 0 24px 60px -24px rgba(16, 24, 40, .35), 0 2px 6px rgba(16, 24, 40, .06);
}
.gate-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.gate-brand img { border-radius: 12px; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 60%, transparent); }
.gate-brand h1 { margin: 0; font-size: 1.45rem; }
.gate-brand p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.gate-lock {
  display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--ink2);
  background: var(--canvas); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; margin-bottom: 18px; width: fit-content;
}
.gate-lock svg { color: var(--primary); flex: none; }
.gate-form .label { margin-top: 0; }
.pw-field { position: relative; }
.pw-field input { padding-right: 46px; min-height: 46px; font-size: 1rem; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 6px; line-height: 0;
}
.pw-toggle:hover { color: var(--ink); background: var(--canvas); }
.pw-toggle[aria-pressed="true"] { color: var(--primary); }
.gate-remember { margin: 14px 0 18px; font-size: .9rem; color: var(--ink2); }
.gate-submit { min-height: 46px; font-size: 1rem; }
.gate-foot { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: .84rem; }
.gate-title { font-size: 1.15rem; margin: 0 0 6px; }
.gate-text { margin: 0 0 14px; color: var(--ink2); }
.gate-gap { margin-top: 18px; }
.gate-form .label { margin-top: 14px; }
.gate-form .label:first-of-type { margin-top: 0; }
.label-row { margin-top: 14px; margin-bottom: 5px; }
.label-row .label { margin: 0; }
.gate-form input[type=email] { min-height: 46px; font-size: 1rem; }
.gate-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--info-soft); color: var(--primary); margin-bottom: 14px; }
.banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-color: var(--primary); background: var(--info-soft); }
.banner p { margin: 4px 0 0; }
.code-input { font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; min-height: 52px; }
.mfa-steps { padding-left: 20px; margin: 0 0 8px; color: var(--ink2); }
.mfa-steps li { margin: 8px 0; }
.qr { margin: 10px 0 6px; }
.qr img { display: block; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.secret { display: inline-block; margin-top: 6px; font-size: .95rem; letter-spacing: .05em; overflow-wrap: anywhere; }
.recovery-codes { list-style: none; padding: 12px; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px;
  background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; }
.recovery-codes code { font-size: 1rem; }
.ok-icon { color: var(--success); background: var(--success-soft); font-size: 1.5rem; font-weight: 700; }
