:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2430; --muted: #5d6b7e; --line: #dde3ea;
  --brand: #0b5cad; --brand-dark: #08457f; --ok: #1d7a3e; --warn: #9a6200; --err: #b3261e;
  --ok-bg: #e5f4ea; --warn-bg: #fff4dc; --err-bg: #fde8e6; --info-bg: #e7f0fb;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
pre { background: #0f1720; color: #dbe4ee; padding: 12px; border-radius: 6px; overflow: auto; max-height: 420px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: #12263f; color: #fff; flex-wrap: wrap; }
.topbar a { color: #dce8f7; text-decoration: none; }
.topbar a:hover { color: #fff; }
.brand { font-weight: 600; color: #fff !important; }
.topbar nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.user { display: flex; gap: 12px; align-items: center; }
main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 480px; margin: 40px auto; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 2fr 1fr; }
@media (max-width: 1000px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:hover td { background: #f8fafc; }
td.actions { white-space: nowrap; text-align: right; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #c4cdd8; border-radius: 5px; background: #fff; min-width: 0; }
input[type=checkbox] { width: auto; }
.field { margin-bottom: 10px; }
.field input, .field select, .field textarea { width: 100%; }
.errorlist { color: var(--err); margin: 2px 0; padding-left: 16px; font-size: 12px; }

button, .btn { font: inherit; display: inline-block; padding: 6px 12px; border-radius: 5px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { background: var(--brand-dark); }
.btn.secondary, button.secondary { background: #fff; color: var(--brand); }
.btn.danger, button.danger { background: #fff; color: var(--err); border-color: var(--err); }
button.link { background: none; border: 0; color: #dce8f7; padding: 0; }
.inline { display: inline; }
.big { font-size: 15px; padding: 9px 18px; }

.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 10px; background: var(--info-bg); }
.msg.success { background: var(--ok-bg); color: var(--ok); }
.msg.warning { background: var(--warn-bg); color: var(--warn); }
.msg.error { background: var(--err-bg); color: var(--err); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef2f6; }
.badge.applied, .badge.completed, .badge.on { background: var(--ok-bg); color: var(--ok); }
.badge.would_add, .badge.running, .badge.queued, .badge.preview { background: var(--info-bg); color: var(--brand); }
.badge.failed, .badge.off { background: var(--err-bg); color: var(--err); }
.badge.cancelled, .badge.pending, .badge.up_to_date { background: #eef2f6; color: var(--muted); }
.badge.apply { background: var(--warn-bg); color: var(--warn); }

.progress { height: 10px; background: #e6ebf1; border-radius: 5px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--brand); }
.stats { display: flex; gap: 20px; flex-wrap: wrap; }
.stats div b { display: block; font-size: 20px; }
.checklist { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.checklist label { display: flex; gap: 8px; color: var(--text); font-size: 14px; padding: 2px 0; }
details summary { cursor: pointer; color: var(--brand); }
.auth form p, .auth form div { margin-bottom: 10px; }
.auth input:not([type=checkbox]) { width: 100%; }
.auth img { max-width: 220px; }
