@font-face { font-family: "Golos"; src: url(fonts/golos-text-cyrillic.woff2) format("woff2"); font-weight: 400 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos"; src: url(fonts/golos-text-latin.woff2) format("woff2"); font-weight: 400 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JBMono"; src: url(fonts/jetbrains-mono-cyrillic.woff2) format("woff2"); font-weight: 100 800; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "JBMono"; src: url(fonts/jetbrains-mono-latin.woff2) format("woff2"); font-weight: 100 800; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e4e7ec;
  --line-strong: #cfd4dc;
  --text: #111418;
  --text-2: #4a5260;
  --muted: #7a828f;
  --accent: #1f4fd1;
  --accent-hover: #173fb0;
  --accent-soft: #eaf0fd;
  --ok: #117a4a;
  --ok-soft: #e7f5ee;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --err: #c0322b;
  --err-soft: #fcebea;
  --run: #1f4fd1;
  --radius: 6px;
  --mono: "JBMono", ui-monospace, Consolas, monospace;
  --sans: "Golos", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); font-feature-settings: "tnum"; }
[hidden] { display: none !important; }
h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 15px; margin-bottom: 14px; }
h4 { font-size: 13px; margin: 20px 0 10px; color: var(--text-2); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
td .mono { white-space: nowrap; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- controls ---------- */
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 7px 10px; min-height: 34px; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
.input-sm { min-height: 30px; padding: 4px 8px; width: auto; }
.invalid { border-color: var(--err) !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer;
  height: 34px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #b9c0ca; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eceef2; border-color: transparent; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-soft); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #a3271f; border-color: #a3271f; }
.btn-block { width: 100%; }
/* Square icon-only button; the label lives in title/aria-label. */
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-sm svg { width: 15px; height: 15px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; display: grid; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-lg { font-size: 18px; margin-bottom: 4px; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--text); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; height: 100%; }
.tab {
  font: inherit; font-weight: 500; color: var(--text-2); background: none; border: 0; cursor: pointer;
  padding: 0 12px; height: 100%; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.view { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 20px; align-items: start; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head .btn, .panel-tools { margin-left: auto; }
.panel-body { padding: 18px; display: grid; gap: 14px; }
.prose p { margin: 0; color: var(--text-2); }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 2px; letter-spacing: -0.02em; }
.stat-sub { color: var(--muted); font-size: 12.5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td.actions-cell { text-align: right; white-space: nowrap; }
.job-name { font-weight: 600; }
.sub { color: var(--muted); font-size: 12.5px; }
.clickable { cursor: pointer; }

/* ---------- status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: #eef0f3; color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.run { background: var(--accent-soft); color: var(--run); }
.badge.run::before { animation: pulse 1.2s ease-in-out infinite; }
.badge.plain::before { display: none; }
@keyframes pulse { 50% { opacity: .25; } }

.progress { height: 6px; background: #eceef2; border-radius: 3px; overflow: hidden; min-width: 90px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .4s ease; }
.progress.ok > div { background: var(--ok); }
.progress.err > div { background: var(--err); }
/* Unknown total (pg_dump): a band sweeps across the track. */
.progress.indeterminate { position: relative; }
.progress.indeterminate > div {
  position: absolute; top: 0; left: 0; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent) 70%, transparent);
  animation: indeterminate 1.6s cubic-bezier(.45, .05, .55, .95) infinite;
}
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) {
  .progress.indeterminate > div { width: 100%; background: var(--accent); animation: pulse 2s ease-in-out infinite; }
}

/* ---------- status icons ---------- */
.st { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.st-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.st-icon svg { width: 14px; height: 14px; }
.st-icon.ok { background: var(--ok-soft); color: var(--ok); }
.st-icon.err { background: var(--err-soft); color: var(--err); }
.st-icon.run { background: var(--accent-soft); color: var(--run); }
.st-icon.run svg { animation: spin 1.2s linear infinite; }
.st-text { font-size: 13px; color: var(--text-2); }
.cell-actions { display: inline-flex; align-items: center; gap: 4px; }
td.actions-cell .cell-actions { justify-content: flex-end; }

.progress-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-family: var(--mono); }

/* queue */
.q-item { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(200px, 2fr) auto; gap: 18px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.q-item:last-child { border-bottom: 0; }
.q-steps { display: grid; gap: 8px; }
.q-waiting { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.q-waiting:last-child { border-bottom: 0; }
.q-waiting .btn { margin-left: auto; }

/* ---------- sheet (editor) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(17, 20, 24, .28); z-index: 40; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(820px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  display: grid; grid-template-rows: auto 1fr auto; box-shadow: -12px 0 32px rgba(17, 20, 24, .08);
}
.sheet-narrow { width: min(680px, 100vw); grid-template-rows: auto 1fr; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 0 22px 32px; scroll-behavior: smooth; }
.sheet-nav { position: sticky; top: 0; z-index: 2; display: flex; gap: 4px; flex-wrap: wrap; padding: 10px 0; background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.sheet-nav a { color: var(--text-2); font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.sheet-nav a:hover { background: #eceef2; color: var(--text); }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface); }
.sheet-foot .form-error { margin-left: auto; text-align: right; }
.sheet-foot #delete-job + .form-error { margin-left: auto; }

.section { padding: 22px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 52px; }
.section:last-child { border-bottom: 0; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 2; }
.field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }
p.hint { margin: 10px 0 0; }
.field-error { font-size: 12px; color: var(--err); }
.field-error:empty { display: none; }
.form-error { color: var(--err); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; align-self: center; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.toggle-body { margin-top: 14px; }
.toggle-body.off { display: none; }

.result { font-size: 12.5px; }
.result:empty { display: none; }
.result.ok { color: var(--ok); }
.result.err { color: var(--err); }
.result.block { display: block; margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.result.block.ok { border-color: #bfe3cf; background: var(--ok-soft); }
.result.block.err { border-color: #f1c4c1; background: var(--err-soft); }
.result ul { margin: 6px 0 0; padding-left: 18px; color: var(--warn); }

.secret { position: relative; }
.secret-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.secret-state .link { color: var(--err); cursor: pointer; background: none; border: 0; padding: 0; font: inherit; }

.detect-list { display: grid; gap: 4px; }
.detect-list:empty { display: none; }
.detect-item { display: flex; justify-content: space-between; gap: 10px; text-align: left; font: inherit; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; cursor: pointer; }
.detect-item:hover { border-color: var(--accent); }
.detect-item span { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.details { margin-top: 10px; font-size: 13px; }
.details summary { cursor: pointer; color: var(--text-2); }
.details pre { margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }

/* schedule rules */
.rule { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface-2); }
.rule-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.rule-row select { width: 210px; }
.rule-row input[type=time] { width: 120px; }
.rule-row input.w-num { width: 100px; }
.rule-row input.w-cron { width: 220px; font-family: var(--mono); }
.rule-row .btn-ghost { margin-left: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font: inherit; font-size: 12.5px; min-width: 34px; height: 28px; padding: 0 8px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.chip.wide { padding: 0 12px; }
.days-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; max-width: 420px; }
.preview { margin-top: 12px; font-size: 12.5px; color: var(--text-2); }
.preview:empty { display: none; }
.preview ol { margin: 6px 0 0; padding-left: 20px; font-family: var(--mono); font-size: 12px; }

/* run details */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.log { margin: 16px 0 0; padding: 12px 14px; background: #fbfbfc; border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto; }
.log .t { color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-size: 13px; max-width: calc(100vw - 32px); }
.toast.err { background: var(--err); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .q-item { grid-template-columns: 1fr; gap: 10px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .meta { display: none; }
  .container { padding: 16px; }
}
@media (max-width: 640px) {
  .grid-form, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .brand { display: none; }
  .sheet-foot { flex-wrap: wrap; }
}

/* ---------- host load ---------- */
.load { padding: 14px 18px 18px; }
.load-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; }
.load-h { margin: 18px 0 10px; }
.meter .progress-label { font-family: var(--sans); color: var(--text-2); }
.meter-name { font-weight: 500; color: var(--text); }
.meter .progress { margin-bottom: 4px; }
.progress.warn > div { background: var(--warn); }
.master-status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.master-status .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- confirmation panel (confirm.js) ---------- */
.confirm-root { position: fixed; inset: 0; z-index: 100; }
.confirm-backdrop {
  position: absolute; inset: 0; background: rgba(17, 20, 24, .32);
  opacity: 0; transition: opacity .28s ease;
  backdrop-filter: blur(1.5px);
}
.confirm-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(17, 20, 24, .16);
  display: flex; flex-direction: column; gap: 14px; padding: 32px 28px 24px;
  transform: translateX(104%); opacity: .6;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), opacity .34s ease;
}
.confirm-root.open .confirm-backdrop { opacity: 1; }
.confirm-root.open .confirm-panel { transform: none; opacity: 1; }
.confirm-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  transform: scale(.7); opacity: 0; transition: transform .4s cubic-bezier(.34, 1.56, .64, 1) .12s, opacity .25s ease .12s;
}
.confirm-icon::before { content: "?"; font-weight: 700; font-size: 22px; }
.confirm-panel.danger .confirm-icon { background: var(--err-soft); color: var(--err); }
.confirm-panel.danger .confirm-icon::before { content: "!"; }
.confirm-root.open .confirm-icon { transform: none; opacity: 1; }
.confirm-panel h2 { font-size: 18px; margin: 0; }
.confirm-text { color: var(--text-2); font-size: 14px; line-height: 1.5; overflow-y: auto; }
.confirm-text p { margin: 0 0 10px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) {
  .confirm-backdrop, .confirm-panel, .confirm-icon { transition: none; }
}
@media (max-width: 640px) {
  .confirm-panel { top: auto; width: 100vw; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
    transform: translateY(104%); padding: 24px 20px 20px; max-height: 80vh; }
  .confirm-actions .btn { flex: 1; }
}
