:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #667085;
  --border: #e3e6ea;
  --accent: #ff5a00;
  --accent-ink: #ffffff;
  --ok: #12805c;
  --ok-bg: #e3f5ed;
  --warn: #a15c00;
  --warn-bg: #fff2dc;
  --err: #c52a2a;
  --err-bg: #fde8e8;
  --info: #2457c5;
  --info-bg: #e5edfc;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --panel: #191d22;
    --panel-2: #20252b;
    --text: #e7eaee;
    --muted: #8d96a3;
    --border: #2b3139;
    --ok: #4cc597;
    --ok-bg: #163126;
    --warn: #f0b04f;
    --warn-bg: #362a14;
    --err: #ff7b7b;
    --err-bg: #3a1d1d;
    --info: #7fa6ff;
    --info-bg: #1b2640;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
textarea { min-height: 80px; font-family: var(--mono); font-size: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
label { display: block; font-weight: 500; font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
.check { display: flex; gap: 8px; align-items: center; }
.form-error { color: var(--err); min-height: 18px; font-size: 13px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: grid; gap: 14px; }
.login-card p { margin: 0; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand-lg { font-size: 18px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
nav { display: grid; gap: 2px; }
nav a { padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
nav a:hover { background: var(--panel-2); text-decoration: none; }
nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; margin-bottom: 4px; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel.flush { padding: 0; overflow: hidden; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile.bad .v { color: var(--err); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--panel-2); }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
tr.selected td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
td.num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.success { color: var(--ok); background: var(--ok-bg); }
.badge.failed { color: var(--err); background: var(--err-bg); }
.badge.partial { color: var(--warn); background: var(--warn-bg); }
.badge.running { color: var(--info); background: var(--info-bg); }
.badge.idle, .badge.paused { color: var(--muted); background: var(--panel-2); }
.badge.running::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .25; } }
.counts { display: flex; gap: 8px; font-variant-numeric: tabular-nums; }
.counts .ok { color: var(--ok); }
.counts .bad { color: var(--err); }

/* Toggle */
.switch { position: relative; width: 38px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }

/* Forms */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid2 .full { grid-column: 1 / -1; }
.interval { display: flex; gap: 8px; margin-top: 5px; }
.interval input { width: 110px; margin: 0; }
.interval select { width: 130px; margin: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.form-actions .grow { flex: 1; }
.form-actions input.grow { max-width: 280px; }
details.import summary { cursor: pointer; font-weight: 500; }
details.import[open] summary { margin-bottom: 10px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: none; padding: 9px 14px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* Logs */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label { font-size: 12px; color: var(--muted); }
.filters input, .filters select { width: auto; min-width: 130px; }
.filters .grow { flex: 1; min-width: 180px; }
.filters .grow input { width: 100%; }
.logbox { font-family: var(--mono); font-size: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); max-height: 68vh; overflow: auto; }
.logline { display: grid; grid-template-columns: 150px 52px minmax(120px, 180px) 1fr; gap: 10px; padding: 4px 12px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.logline.nojob { grid-template-columns: 150px 52px 1fr; }
.logline .msg { white-space: pre-wrap; word-break: break-word; }
.logline .ts { color: var(--muted); }
.logline .src { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { font-weight: 700; }
.lvl.debug { color: var(--muted); }
.lvl.info { color: var(--info); }
.lvl.warn { color: var(--warn); }
.logline.warn { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.lvl.error { color: var(--err); }
.logline.error { background: color-mix(in srgb, var(--err-bg) 60%, transparent); }
.log-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; gap: 8px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 16px; align-items: start; }
.split .panel { margin: 0; }
.runs-list { max-height: 68vh; overflow: auto; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 500; z-index: 50; max-width: 420px; }
.toast.err { background: var(--err); color: #fff; }

.logbox { container-type: inline-size; }
@container (max-width: 640px) {
  .logline, .logline.nojob { grid-template-columns: 1fr; gap: 0; padding: 6px 12px; }
  .logline .ts { display: inline; }
}
.filters .check { color: var(--text); padding-bottom: 8px; }
@media (max-width: 1250px) {
  .split { grid-template-columns: 1fr; }
  .runs-list { max-height: 300px; }
}
@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 10px; }
  nav { display: flex; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; align-items: center; }
  .sidebar-foot .muted { display: none; }
  .main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .logline, .logline.nojob { grid-template-columns: 1fr; gap: 0; }
}
