:root {
    --bg: #0b0d12; --bg2: #0f1117; --panel: #151820; --elev: #1b1f29;
    --border: #262b36; --border2: #313845;
    --text: #e7e9ee; --muted: #8a93a3; --faint: #5b6472;
    --accent: #5b8cff; --accent-dim: rgba(91,140,255,.15);
    --ok: #34d399; --fail: #f87171; --partial: #fbbf24; --run: #5b8cff;
    --ok-dim: rgba(52,211,153,.15); --fail-dim: rgba(248,113,113,.15);
    --warn-dim: rgba(251,191,36,.15); --sched-dim: rgba(91,140,255,.13);
}
* { box-sizing: border-box; }
body { margin: 0; background:
        radial-gradient(900px 500px at 80% -10%, #11151f 0%, transparent 60%),
        var(--bg);
    color: var(--text); font: 15px/1.55 -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #0a0c11; padding: 1px 6px; border-radius: 5px; font-size: 13px; color: #b9c2d0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 23px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; letter-spacing: .01em; }

/* Header */
header { display: flex; align-items: center; gap: 28px; padding: 14px 26px;
    border-bottom: 1px solid var(--border); background: rgba(11,13,18,.7);
    backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.brand { color: var(--text); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.logo { filter: drop-shadow(0 0 6px rgba(91,140,255,.5)); }
nav { display: flex; gap: 18px; }
nav a { color: var(--muted); font-size: 14px; }
nav a:hover { color: var(--text); text-decoration: none; }
main { max-width: 1040px; margin: 0 auto; padding: 26px; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.logout { color: var(--muted); font-size: 13px; }
.logout:hover { color: var(--text); text-decoration: none; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: linear-gradient(180deg, var(--elev), var(--panel));
    border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px;
    width: 320px; display: flex; flex-direction: column; gap: 4px; }
.login-brand { font-size: 19px; font-weight: 700; margin-bottom: 2px; }
.login-card .field { margin-top: 12px; }
.login-card .btn { margin-top: 18px; }
.login-error { background: var(--fail-dim); color: var(--fail); font-size: 13px;
    padding: 8px 12px; border-radius: 8px; margin-top: 8px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }

/* Summary chips */
.summary { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-chip { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 18px; min-width: 96px; display: flex; flex-direction: column; gap: 2px; }
.stat-chip .num { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-chip .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat-chip.is-run { border-color: var(--run); box-shadow: 0 0 0 1px var(--accent-dim) inset; }
.stat-chip.is-run .num { color: var(--run); }
.stat-chip.is-sched .num { color: var(--accent); }
.stat-chip.is-fail { border-color: var(--fail); }
.stat-chip.is-fail .num { color: var(--fail); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: linear-gradient(180deg, var(--elev), var(--panel));
    border: 1px solid var(--border); border-radius: 14px; padding: 18px;
    display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--border2); transform: translateY(-2px); }
.card-running { border-color: var(--run); box-shadow: 0 0 0 1px var(--accent-dim) inset; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.card-title { font-size: 17px; font-weight: 650; color: var(--text); }
.card-title:hover { color: var(--accent); text-decoration: none; }
.card-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.desc { margin: 0; color: var(--muted); font-size: 13.5px; min-height: 2.6em; }

/* Health dot */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-failed { background: var(--fail); box-shadow: 0 0 8px var(--fail); }
.dot-partial { background: var(--partial); box-shadow: 0 0 8px var(--partial); }
.dot-stopped { background: var(--muted); box-shadow: 0 0 8px var(--muted); }
.dot-none { background: var(--faint); }

/* Pills */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 20px; display: inline-flex;
    align-items: center; gap: 6px; font-weight: 500; }
.pill-run { background: var(--accent-dim); color: var(--run); }
.pill-sched { background: var(--sched-dim); color: var(--accent); }
.pill-idle { background: #20242e; color: var(--muted); }
.pill-ok { background: var(--ok-dim); color: var(--ok); }
.pill-warn { background: var(--warn-dim); color: var(--partial); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor;
    animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    70% { box-shadow: 0 0 0 6px transparent; opacity: .6; } 100% { opacity: 1; } }

/* 3-up stats */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats3 > div { display: flex; flex-direction: column; gap: 2px; }
.stats3 .k, .sb-item .k, .fires .k { font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--faint); }
.stats3 .v { font-size: 13.5px; font-weight: 600; }

/* Sparkline */
.spark { width: 100%; height: 30px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6;
    stroke-linejoin: round; stroke-linecap: round; }
.spark-empty { height: 30px; display: flex; align-items: center; }

/* Buttons */
.actions, .head-actions, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { margin-top: auto; }
.actions form, .head-actions form, .row-actions form { display: inline; }
.btn { border: 1px solid transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer;
    font-size: 13.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none; background: var(--elev); color: var(--text); }
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; border-color: var(--fail); color: var(--fail); }
.btn[disabled] { opacity: .65; cursor: default; }

/* Detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.statusbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px 18px; margin-bottom: 18px; }
.sb-item { display: flex; flex-direction: column; gap: 6px; }
.sb-item .v { font-size: 14px; font-weight: 600; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field span { font-size: 13px; }
.field input { background: #0a0c11; border: 1px solid var(--border2); color: var(--text);
    padding: 9px 11px; border-radius: 7px; font-size: 14px; }
.field input:focus { outline: none; border-color: var(--accent); }
.req { color: var(--fail); }
.checkbox { display: flex; gap: 8px; align-items: center; margin-bottom: 13px; font-size: 14px; }

.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { background: #20242e; border: 1px solid var(--border2); color: var(--muted);
    padding: 5px 11px; border-radius: 20px; font-size: 12.5px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--accent); }
.fires { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.fires ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* Status text */
.status { font-weight: 600; }
.status-ok { color: var(--ok); } .status-failed { color: var(--fail); }
.status-partial { color: var(--partial); } .status-running { color: var(--run); }
.status-stopped { color: var(--muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

/* Log */
.logbox { background: #07090d; border: 1px solid var(--border); border-radius: 8px;
    padding: 13px; max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
    font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; margin: 0; }

@media (max-width: 720px) {
    .grid, .statusbar { grid-template-columns: 1fr; }
    .statusbar { gap: 14px; }
}
