/* ─────────────────────────────────────────────────────────────────────────
   KURSOR · Процессы — дизайн-система админки
   Светлая и тёмная темы: авто (prefers-color-scheme) + ручной переключатель
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --ink: #17181c;
  --ink-2: #5b6070;
  --ink-3: #9aa0b0;
  --line: #e4e6ec;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-ink: #3730a3;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --info: #0284c7;
  --info-soft: #e6f4fb;
  --shadow: 0 1px 2px rgb(16 18 26 / 5%), 0 4px 16px rgb(16 18 26 / 6%);
  --radius: 12px;
  --radius-s: 8px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101116;
    --surface: #181a21;
    --surface-2: #1f222b;
    --ink: #e8eaf0;
    --ink-2: #a6abbd;
    --ink-3: #6b7182;
    --line: #262a35;
    --accent: #818cf8;
    --accent-soft: #232645;
    --accent-ink: #c0c6ff;
    --ok: #4ade80;
    --ok-soft: #14291c;
    --warn: #fbbf24;
    --warn-soft: #2e2410;
    --danger: #f87171;
    --danger-soft: #321616;
    --info: #38bdf8;
    --info-soft: #0e2433;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}
:root[data-theme="dark"] {
  --bg: #101116;
  --surface: #181a21;
  --surface-2: #1f222b;
  --ink: #e8eaf0;
  --ink-2: #a6abbd;
  --ink-3: #6b7182;
  --line: #262a35;
  --accent: #818cf8;
  --accent-soft: #232645;
  --accent-ink: #c0c6ff;
  --ok: #4ade80;
  --ok-soft: #14291c;
  --warn: #fbbf24;
  --warn-soft: #2e2410;
  --danger: #f87171;
  --danger-soft: #321616;
  --info: #38bdf8;
  --info-soft: #0e2433;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Каркас ── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex: 0 0 224px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.logo { font-weight: 700; font-size: 15px; letter-spacing: .2px; padding: 4px 10px 14px; }
.logo small { display: block; color: var(--ink-3); font-weight: 500; font-size: 11px; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--ink-2); font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }

.main { flex: 1; min-width: 0; padding: 24px 32px 64px; }
.container { max-width: 1080px; margin: 0 auto; }

.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.topbar .grow { flex: 1; }

/* ── Компоненты ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
.card .sub { color: var(--ink-2); font-size: 13px; margin: -6px 0 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.tile .num { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.tile .lbl { color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.tile.t-ok .num { color: var(--ok); }
.tile.t-warn .num { color: var(--warn); }
.tile.t-danger .num { color: var(--danger); }
.tile.t-info .num { color: var(--info); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-s);
  font: inherit; font-weight: 600; font-size: 13px;
  transition: filter .12s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .2px;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.badge.b-running { background: var(--info-soft); color: var(--info); }
.badge.b-waiting { background: var(--warn-soft); color: var(--warn); }
.badge.b-done { background: var(--ok-soft); color: var(--ok); }
.badge.b-error { background: var(--danger-soft); color: var(--danger); }
.badge.b-stopped { background: var(--surface-2); color: var(--ink-2); }
.badge.b-mode-mock { background: var(--warn-soft); color: var(--warn); }
.badge.b-mode-real { background: var(--ok-soft); color: var(--ok); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.b-running .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-3); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.field { display: block; margin-bottom: 12px; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: var(--ink-2); }
.field input[type="text"], .field input[type="password"], .field input[type="number"],
.field input[type="date"], .field input[type="datetime-local"], .field select, .field textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}
.field .err { color: var(--danger); font-size: 12px; margin-top: 3px; }
textarea.yaml { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; min-height: 320px; white-space: pre; }

.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }

.alert { border-radius: var(--radius-s); padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; }
.alert.a-ok { background: var(--ok-soft); color: var(--ok); }
.alert.a-warn { background: var(--warn-soft); color: var(--warn); }
.alert.a-danger { background: var(--danger-soft); color: var(--danger); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-all; }

pre.code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 12px 14px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  margin: 0;
}

.mermaid-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; overflow: auto; }
.mermaid-box svg { max-width: 100%; }

.steps-line { display: flex; flex-direction: column; gap: 0; }
.step-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.step-row:last-child { border-bottom: none; }
.step-row .t { color: var(--ink-3); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-row .body { flex: 1; min-width: 0; }

.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 360px; }
.login-card .logo { text-align: center; padding-bottom: 6px; }

.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 99px; padding: 5px 10px; cursor: pointer; color: var(--ink-2); font: inherit; font-size: 12px; }
.theme-toggle:hover { background: var(--surface-2); }

.empty { text-align: center; color: var(--ink-3); padding: 28px 0; }
.empty .big { font-size: 32px; margin-bottom: 6px; }

/* Песочница */
.sandbox-lead { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; background: var(--surface); }
.sandbox-lead .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-block { background: var(--info-soft); border-radius: var(--radius-s); padding: 12px 14px; margin-top: 10px; }
.task-block .q { font-weight: 600; margin-bottom: 8px; }
.form-block { background: var(--accent-soft); border-radius: var(--radius-s); padding: 12px 14px; margin-top: 10px; }
.timer-block { background: var(--warn-soft); border-radius: var(--radius-s); padding: 10px 14px; margin-top: 10px; color: var(--warn); font-weight: 600; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 6px;
    overflow-x: auto; padding: 10px 14px;
  }
  .sidebar .spacer, .logo small { display: none; }
  .logo { padding: 0 10px 0 0; white-space: nowrap; }
  .nav-item { white-space: nowrap; padding: 6px 10px; }
  .sidebar form { margin: 0 !important; }
  .main { padding: 16px; }
  .kv { grid-template-columns: 1fr; }
}
