:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --border: #e3e6eb; --text: #14171c; --muted: #5d6673;
  --faint: #8a93a0; --accent: #2f5bea; --accent-weak: #e8eefe; --accent-text: #ffffff;
  --good: #1f8a4c; --good-weak: #e3f4ea; --warn: #b26a00; --warn-weak: #fdf1dc; --bad: #c43131; --bad-weak: #fbe7e7;
  --info: #5b6bd6; --violet: #7a4fd0; --slate: #6b7685;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a313b; --text: #e8ebef; --muted: #a3acb8;
    --faint: #7a8491; --accent: #6d8cff; --accent-weak: #1f2945; --accent-text: #0b0e13;
    --good: #48c17a; --good-weak: #15301f; --warn: #e3a33b; --warn-weak: #33260f; --bad: #f07070; --bad-weak: #3a1a1a;
    --info: #8f9cf0; --violet: #a988ee; --slate: #95a0ae; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2a313b; --text: #e8ebef; --muted: #a3acb8;
  --faint: #7a8491; --accent: #6d8cff; --accent-weak: #1f2945; --accent-text: #0b0e13;
  --good: #48c17a; --good-weak: #15301f; --warn: #e3a33b; --warn-weak: #33260f; --bad: #f07070; --bad-weak: #3a1a1a;
  --info: #8f9cf0; --violet: #a988ee; --slate: #95a0ae; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 620; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 54px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; white-space: nowrap; color: var(--text); }
.logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 750; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { padding: 7px 11px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 520; }
nav.tabs a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
nav.tabs a.on { background: var(--accent-weak); color: var(--accent); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; height: 32px; min-width: 32px; cursor: pointer; font-size: 14px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.crumb { color: var(--muted); font-size: 13px; }

/* cards + grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile .s { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { color: var(--warn); border-color: var(--warn); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 550; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 220px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .fields { grid-template-columns: minmax(0, 1fr); } }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 13px; }
.switch { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.switch input { margin-top: 3px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg label { flex-direction: row; padding: 7px 12px; cursor: pointer; color: var(--muted); font-size: 13px; gap: 6px; align-items: center; }
.seg label + label { border-left: 1px solid var(--border); }
.seg input { display: none; }
.seg label.on { background: var(--accent-weak); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); padding: 2px 7px; border-radius: 6px; cursor: pointer; }
.chip:hover { color: var(--accent); border-color: var(--accent); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.running { background: var(--good-weak); color: var(--good); }
.pill.paused, .pill.stopping { background: var(--warn-weak); color: var(--warn); }
.pill.interrupted { background: var(--bad-weak); color: var(--bad); }
.pill.finished { background: var(--accent-weak); color: var(--accent); }
.pill.live { background: var(--bad-weak); color: var(--bad); }
.pill.dry { background: var(--accent-weak); color: var(--accent); }
.pill.q { background: var(--bad-weak); color: var(--bad); }
.pill.ok { background: var(--good-weak); color: var(--good); }

/* progress */
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s; }
.bar.thin { height: 6px; }
.bigprog { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.bigprog .v { font-size: 26px; font-weight: 680; font-variant-numeric: tabular-nums; }
.statusbars .sb { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.statusbars .sb .track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.statusbars .sb .track span { display: block; height: 100%; border-radius: 999px; }
@media (max-width: 600px) { .statusbars .sb { grid-template-columns: 110px 1fr 56px; } }

/* tables */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.empty { padding: 24px; text-align: center; color: var(--faint); }

/* campaign cards */
.camp { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: 16px; align-items: center; padding: 14px 16px; }
.camp + .camp { border-top: 1px solid var(--border); }
.camp:hover { background: var(--surface-2); }
.camp .name { font-weight: 600; color: var(--text); }
.camp .meta { font-size: 12px; color: var(--faint); margin-top: 2px; }
.camp .nums { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.camp .nums b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .camp { grid-template-columns: minmax(0, 1fr); gap: 8px; } }
.list-card { padding: 0; overflow: hidden; }

/* sub tabs */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.subtabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 550; }
.subtabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.subtabs a:hover { text-decoration: none; color: var(--text); }

/* preview */
.preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.preview .subj { font-weight: 600; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.preview .body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; border: 1px solid var(--border); background: var(--surface-2); }
.notice.warn { background: var(--warn-weak); border-color: transparent; color: var(--warn); }
.notice.bad { background: var(--bad-weak); border-color: transparent; color: var(--bad); }
.notice.good { background: var(--good-weak); border-color: transparent; color: var(--good); }
.notice.info { background: var(--accent-weak); border-color: transparent; color: var(--accent); }
pre.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: 11.5px/1.5 var(--mono); max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.drop { border: 2px dashed var(--border); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface-2); }
.drop.over { border-color: var(--accent); color: var(--accent); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal h2 { font-size: 17px; }
.modal.live { border-top: 4px solid var(--bad); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 60; max-width: calc(100% - 32px); }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.login .err { color: var(--bad); margin: 0; font-size: 13px; }
