:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #f9faf7; --border: #dfe2da; --text: #1d211b;
  --muted: #687064; --accent: #2f5d50; --accent-ink: #ffffff; --accent-soft: #e3ece8;
  --ok: #2e7d4f; --warn: #b7791f; --err: #b3392f; --info: #3a6ea5;
  --ok-soft: #e4f2e9; --warn-soft: #fbf0dc; --err-soft: #f8e4e1; --info-soft: #e3edf7;
  --radius: 8px; --shadow: 0 1px 2px rgba(20, 30, 20, .06);
  --font: "IBM Plex Sans", system-ui, sans-serif; --mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141714; --surface: #1c201c; --surface-2: #222722; --border: #313831; --text: #e6e9e3;
    --muted: #9aa396; --accent: #7fb9a6; --accent-ink: #0f1a16; --accent-soft: #233a33;
    --ok: #6fc28f; --warn: #e2b153; --err: #e8796e; --info: #7ea9dc;
    --ok-soft: #1f3327; --warn-soft: #3a2f19; --err-soft: #3d2220; --info-soft: #1d2b3b;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
a { color: var(--accent); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); 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: 15px; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent);
  box-shadow: 6px 6px 0 -2px var(--accent-soft); }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
#nav a:hover { background: var(--surface-2); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.view { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }

/* cards & tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok, .badge.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warning, .badge.failed, .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.error, .badge.dead { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.running, .badge.info, .badge.pending { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warning { background: var(--warn); } .dot.error { background: var(--err); }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { font-family: var(--mono); font-size: 12px; min-height: 70px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.btn { font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; padding-left: 0; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { font: inherit; background: none; border: none; padding: 8px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tabs .count { font-size: 11px; margin-left: 6px; }

.copy-box { display: flex; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; }
.copy-box code { flex: 1; overflow-x: auto; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow: auto;
  font-family: var(--mono); font-size: 12px; max-height: 320px; margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.error-text { color: var(--err); min-height: 1em; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar span.fill { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar span.lbl { font-size: 10px; color: var(--muted); }
.bar span.val { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card p { margin: -6px 0 6px; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  padding: 22px; width: min(720px, calc(100vw - 32px)); max-height: 86vh; }
dialog::backdrop { background: rgba(10, 15, 10, .45); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px;
  border-radius: 8px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; z-index: 10; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--err); color: #fff; }

@media (max-width: 820px) {
  .shell { 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; }
  .sidebar-foot { margin-top: 0; flex-direction: row; }
  .view { padding: 18px 16px 40px; }
  .grid.two { grid-template-columns: 1fr; }
}
