:root {
  --brand: #0b5cad;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ok: #12805c;
  --warn: #b54708;
  --bad: #b42318;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 15px; color: var(--ink);
  background: var(--bg); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 12px 0; }
h3 { font-size: 15px; margin: 0 0 8px 0; }
p { margin: 0 0 10px 0; }
small, .muted { color: var(--muted); }
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; }
.side .logo { padding: 4px 10px 18px 10px; }
.side .logo img { max-width: 170px; max-height: 48px; }
.side .logo .name { font-weight: 700; font-size: 17px; color: var(--brand); }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--ink);
  font-weight: 500; margin-bottom: 2px; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 10px; }
.main { flex: 1; padding: 28px 36px 60px 36px; max-width: 1180px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .l { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(0.93); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfc; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg);
  color: var(--muted); white-space: nowrap; }
.pill.draft { background: #f2f4f7; color: #475467; }
.pill.scheduled { background: #eef4ff; color: #3538cd; }
.pill.running { background: #ecfdf3; color: var(--ok); }
.pill.paused { background: #fffaeb; color: var(--warn); }
.pill.finished { background: #f0f9ff; color: #026aa2; }
.pill.cancelled { background: #fef3f2; color: var(--bad); }
.pill.si { background: #ecfdf3; color: var(--ok); }
.pill.no { background: #f2f4f7; color: #667085; }
.flash { background: #ecfdf3; border: 1px solid #abefc6; color: #05603a; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.err { background: #fef3f2; border: 1px solid #fecdca; color: #912018; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.warnbox { background: #fffaeb; border: 1px solid #fedf89; color: #93370d; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px 0; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=datetime-local],
input[type=time], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #d0d5dd; border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .editor:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, white);
  border-color: var(--brand); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 auto !important; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.preset { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; background: #fff; }
.preset input { display: none; }
.preset .t { font-weight: 700; }
.preset small { display: block; margin-top: 4px; }
.preset:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, white); }
.versions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.version { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; display: flex; flex-direction: column; }
.version .angle { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.version .subj { font-weight: 700; margin-bottom: 4px; }
.version .pre { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.version .body { font-size: 14px; flex: 1; }
.version .box { background: var(--bg); border-left: 3px solid var(--brand); padding: 8px 10px; border-radius: 4px; font-size: 13px; margin: 8px 0; }
.version form { margin-top: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.preview { width: 100%; height: 820px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; border: 1px solid #d0d5dd; border-bottom: none; border-radius: 8px 8px 0 0;
  padding: 6px; background: #fafbfc; }
.toolbar button { border: 1px solid transparent; background: none; padding: 4px 8px; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 13px; }
.toolbar button:hover { background: #fff; border-color: var(--line); }
.editor { min-height: 220px; border: 1px solid #d0d5dd; border-radius: 0 0 8px 8px; padding: 12px 14px; background: #fff; }
.editor p { margin: 0 0 12px 0; }
.thumb { max-width: 100%; max-height: 140px; border-radius: 6px; border: 1px solid var(--line); display: block; margin-top: 8px; }
.stack > * + * { margin-top: 8px; }
.note { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 10px; }
.note .meta { font-size: 12px; color: var(--muted); }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); }
.spinner { display: none; }
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
.htmx-request .idle { display: none; }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.login { max-width: 380px; margin: 9vh auto; }
.login .card { padding: 28px; }
.login .logo { text-align: center; margin-bottom: 18px; }
.login .logo img { max-height: 56px; max-width: 220px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #f2f4f7; border-radius: 6px; }
code { padding: 1px 5px; }
pre { padding: 10px 12px; white-space: pre-wrap; word-break: break-all; }
.ok-dot, .bad-dot, .warn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 6px; }
.ok-dot { background: var(--ok); } .bad-dot { background: var(--bad); } .warn-dot { background: #f79009; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
details summary { cursor: pointer; font-weight: 600; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side nav { display: flex; flex-wrap: wrap; }
  .side .foot { display: none; }
  .main { padding: 18px; }
  .g3, .g4, .presets, .versions, .split, .g2 { grid-template-columns: 1fr; }
}
@media print {
  .side, .noprint { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { break-inside: avoid; }
}
.alertrow { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.alertrow .ok-dot, .alertrow .bad-dot, .alertrow .warn-dot { margin-top: 7px; }
