/* CWBMP dashboard */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #16191f;
  --ink-2: #4a5160;
  --ink-3: #7b8292;
  --line: #e3e6eb;
  --line-2: #d3d7de;
  --side: #121821;
  --side-ink: #c9d1dc;
  --side-ink-2: #7f8a99;
  --side-hover: #1c2430;
  --accent: #0d7a6f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f4f1;
  --ok: #18794e; --ok-soft: #e4f5ec;
  --warn: #9a5b00; --warn-soft: #fdf1dc;
  --bad: #c0362c; --bad-soft: #fde9e7;
  --run: #2457c5; --run-soft: #e6eefc;
  --muted-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --panel: #151b23; --panel-2: #1a212b; --ink: #e6e9ee; --ink-2: #aab2bf; --ink-3: #7c8594;
    --line: #262f3b; --line-2: #333d4a; --side: #0a0e13; --side-hover: #161d26;
    --accent: #2bb3a3; --accent-ink: #04201c; --accent-soft: #10302c;
    --ok: #4cc38a; --ok-soft: #0f2a1d; --warn: #e8a948; --warn-soft: #2d2210; --bad: #ff7b72; --bad-soft: #341614;
    --run: #79a6ff; --run-soft: #142140; --muted-soft: #1d242e;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
small, .muted { color: var(--ink-3); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #14a394, #0d6e64); display: grid; place-items: center; }
.brand-mark svg { width: 17px; height: 17px; }
.brand small { display: block; color: var(--side-ink-2); font-weight: 500; font-size: 11px; letter-spacing: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.nav a.on { background: var(--side-hover); color: #fff; box-shadow: inset 2px 0 0 #14a394; }
.nav svg { width: 17px; height: 17px; opacity: .8; flex: none; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #1f2834; font-size: 12px; color: var(--side-ink-2); }
.side-foot form { margin-top: 8px; }
.side-foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; font: inherit; }
.side-foot button:hover { color: #fff; text-decoration: underline; }

.main { min-width: 0; padding: 26px 32px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }
.crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grid ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid > .card + .card, .stats > .card + .card, .grid > div > .card:first-child { margin-top: 0; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3-1 { grid-template-columns: 2fr 1fr; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.stat .s { color: var(--ink-3); font-size: 12.5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
td .t { font-weight: 600; color: var(--ink); }
td .d { color: var(--ink-3); font-size: 12.5px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.empty { padding: 36px 18px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-wait { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-run { background: var(--run-soft); color: var(--run); }
.pill-run::before { animation: pulse 1.2s infinite; }
.pill-muted { background: var(--muted-soft); color: var(--ink-3); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--muted-soft); color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-link { border: 0; background: none; padding: 0; height: auto; color: var(--accent); font-weight: 600; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field { margin-bottom: 16px; }
.help { color: var(--ink-3); font-size: 12.5px; margin-top: 5px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=time], select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit;
}
textarea { height: auto; padding: 9px 11px; min-height: 90px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin-bottom: 12px; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.check span small { display: block; font-weight: 400; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.radio-cards label { border: 1px solid var(--line-2); border-radius: 9px; padding: 11px 12px; cursor: pointer; margin: 0; font-weight: 600; }
.radio-cards label small { display: block; font-weight: 400; color: var(--ink-3); }
.radio-cards input { position: absolute; opacity: 0; }
.radio-cards label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }

/* ---------- alerts ---------- */
.flash { padding: 11px 14px; border-radius: 9px; margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.note { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; color: var(--ink-2); font-size: 13px; }
.note-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.note strong { color: inherit; }

/* ---------- progress ---------- */
.progress { height: 6px; background: var(--muted-soft); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--run); border-radius: 99px; transition: width .6s ease; }
.progress.ok > i { background: var(--ok); }
.progress.bad > i { background: var(--bad); }
.progress.muted > i { background: var(--line-2); }
.job-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.job-line:last-child { border-bottom: 0; }
.job-line .progress { grid-column: 1 / -1; }
.job-stage { color: var(--ink-3); font-size: 12.5px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }

/* ---------- key/value ---------- */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- key box ---------- */
.keybox { position: relative; }
.keybox textarea { font-family: var(--mono); font-size: 12px; min-height: 96px; background: var(--panel-2); word-break: break-all; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 8px; }

/* ---------- logs ---------- */
.log { font-family: var(--mono); font-size: 12.5px; max-height: 520px; overflow: auto; }
.log div { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 6px 18px; border-bottom: 1px solid var(--line); }
.log div:last-child { border-bottom: 0; }
.log time { color: var(--ink-3); }
.log .warn span { color: var(--warn); }
.log .error span { color: var(--bad); }
.log .success span { color: var(--ok); }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 14, 20, .55); }
dialog .card-head { border-bottom: 1px solid var(--line); }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 14px 14px; }
.x { background: none; border: 0; color: var(--ink-3); font-size: 22px; line-height: 1; cursor: pointer; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(420px, 100%); }
.auth .brand { color: var(--ink); padding: 0 0 18px; justify-content: center; }
.auth .brand small { color: var(--ink-3); }

.attention li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.attention li:last-child { border-bottom: 0; }
.attention ul { list-style: none; margin: 0; padding: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 8px; }

@media (max-width: 980px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 4px 8px; }
  .brand small { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; width: 100%; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .nav a span { display: inline; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 48px; }
  .row, .row-3, .radio-cards { grid-template-columns: 1fr; }
  th, td { padding: 10px 12px; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 2px 0; text-align: left; }
  table.stack td.num { text-align: left; }
  table.stack .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; }
  tbody tr:hover td { background: none; }
}
