* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f5f7;
  color: #1c1e21;
  margin: 0;
}
header.topbar {
  background: #1c1e21;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.topbar a { color: #fff; text-decoration: none; margin-right: 18px; font-size: 14px; white-space: nowrap; }
header.topbar a:hover { text-decoration: underline; }
header.topbar .brand { font-weight: 700; margin-right: 24px; }
header.topbar .nav { display: flex; align-items: center; flex-wrap: wrap; row-gap: 6px; }
header.topbar .nav a { padding: 4px 0; border-bottom: 2px solid transparent; }
header.topbar .nav a.on { border-bottom-color: #60a5fa; }
header.topbar .nav a.minor { color: #b8bec6; font-size: 13px; }
header.topbar .nav-sep { width: 1px; height: 16px; background: #4b5058; margin: 0 18px 0 0; }
main { padding: 24px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.card {
  background: #fff;
  border: 1px solid #e1e3e6;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eceef0; font-size: 14px; }
th { background: #fafafa; font-weight: 600; color: #555; }
tr:hover td { background: #fafcff; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; background: #eee; color: #444;
}
.badge.done, .badge.success, .badge.active { background: #d9f2e3; color: #157347; }
.badge.pending, .badge.running { background: #fff3cd; color: #997404; }
.badge.failed, .badge.error { background: #f8d7da; color: #b02a37; }
.badge.captcha_paused { background: #ffe1cc; color: #b45c09; }
.badge.paused, .badge.stopped { background: #e2e3e5; color: #555; }
/* 2026-09-18, /workers -- статусы приставок по факту systemd, отдельная
   спокойная палитра: "активен" не должен выглядеть так же тревожно-ярко,
   как "работает"/"ошибка", а "выключен" -- нейтрально, не как сбой. */
.badge.status-active { background: #eef1f4; color: #4a5a68; }
.badge.status-working { background: #dcebfa; color: #1a5a96; }
.badge.status-error { background: #f8d7da; color: #b02a37; }
.badge.status-off { background: #ececec; color: #777; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-tile {
  background: #fff; border: 1px solid #e1e3e6; border-radius: 8px;
  padding: 14px 20px; min-width: 140px;
}
.stat-tile .value { font-size: 26px; font-weight: 700; }
.stat-tile .label { font-size: 13px; color: #666; }
form.inline { display: inline; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 6px; border: none;
  background: #2563eb; color: #fff; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #e5e7eb; color: #1c1e21; }
.btn.secondary:hover { background: #d1d5db; }
.hint { color: #777; font-size: 13px; margin-top: 4px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  background: #eef2ff; color: #3730a3; border-radius: 14px; padding: 3px 10px;
  font-size: 13px; display: flex; align-items: center; gap: 6px;
}
.chip button { border: none; background: none; cursor: pointer; color: #3730a3; font-weight: 700; }
.autocomplete-results {
  border: 1px solid #ddd; border-radius: 6px; max-height: 180px; overflow-y: auto;
  background: #fff; margin-top: 2px;
}
.autocomplete-results div { padding: 6px 10px; cursor: pointer; font-size: 14px; }
.autocomplete-results div:hover { background: #f0f4ff; }
.error { color: #b02a37; margin-bottom: 10px; }
.pagination { margin-top: 12px; }
.pagination a { margin-right: 10px; }

/* ===== 08.10: дашборд и приставки ===== */
:root {
  --ok: #157347; --ok-bg: #e3f4ea;
  --busy: #1a5a96; --busy-bg: #e0edfb;
  --warn: #9a6200; --warn-bg: #fff3d6;
  --bad: #b02a37; --bad-bg: #fbe3e5;
  --off: #6b7280; --off-bg: #eef0f2;
  --line: #e4e7eb;
}
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.dot.ok { background: #22a35a; } .dot.warn { background: #e0a100; } .dot.bad { background: #d63545; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
        background: var(--off-bg); color: var(--off); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.busy { background: var(--busy-bg); color: var(--busy); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.warn-text { color: var(--warn); }
.empty { color: var(--off); margin: 6px 0; }

/* Состояние сервиса */
.health { border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; border: 1px solid var(--line); }
.health.ok { background: var(--ok-bg); color: var(--ok); display: flex; align-items: center; gap: 10px; }
.health.warn { background: var(--warn-bg); color: #5c3d00; }
.health.bad { background: var(--bad-bg); color: #6b1720; }
.health-title { display: flex; align-items: center; gap: 10px; }
.health ul { margin: 8px 0 0 20px; padding: 0; }
.health li { margin: 3px 0; font-size: 14px; }
.health li.bad { font-weight: 600; }

/* Плитки */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; border-top: 3px solid #cfd6de; }
.tile.warn { border-top-color: #e0a100; } .tile.bad { border-top-color: #d63545; }
.tile-label { font-size: 12px; color: var(--off); text-transform: uppercase; letter-spacing: .03em; }
.tile-value { font-size: 28px; font-weight: 700; margin: 2px 0; }
.tile-value small { font-size: 14px; font-weight: 500; color: var(--off); }
.tile-sub { font-size: 12px; color: var(--off); }

/* Блоки дашборда */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 6px; }
.panel table { margin-top: 8px; }
tr.row-warn td { background: #fffaeb; }
tr.row-bad td { background: #fdf0f1; }
.progress { height: 8px; background: var(--off-bg); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: #2563eb; }

/* Приставки */
.machines { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 16px; }
.machine { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.machine.offline { opacity: .75; }
.machine-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
                padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.machine-title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.machine-title .hint { margin: 0; }
.machine-note { margin: 10px 16px; font-size: 13px; color: var(--warn); }
.meters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.meter { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--off); }
.meter b { color: #1c1e21; font-weight: 600; min-width: 30px; }
.meter .bar { width: 54px; height: 6px; background: var(--off-bg); border-radius: 3px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: #22a35a; }
.meter .bar i.warn { background: #e0a100; } .meter .bar i.bad { background: #d63545; }
.meter.temp { font-weight: 600; color: #1c1e21; } .meter.temp.warn { color: var(--warn); } .meter.temp.bad { color: var(--bad); }
.units { padding: 4px 0; }
.unit { display: grid; grid-template-columns: 1.1fr 1.6fr auto; grid-template-areas: "name state actions" "name meta actions";
        gap: 2px 12px; align-items: center; padding: 9px 16px; border-bottom: 1px solid #f0f2f4; border-left: 3px solid transparent; }
.unit:last-child { border-bottom: none; }
.unit.bad { border-left-color: #d63545; background: #fffafa; }
.unit.warn { border-left-color: #e0a100; }
.unit-name { grid-area: name; display: flex; flex-direction: column; }
.unit-id { font-size: 11px; color: #9aa1a9; font-family: Consolas, monospace; }
.unit-state { grid-area: state; display: flex; gap: 8px; align-items: center; min-width: 0; }
.unit-note { font-size: 13px; color: #4b5563; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-meta { grid-area: meta; display: flex; gap: 12px; font-size: 12px; color: #9aa1a9; }
.unit-actions { grid-area: actions; display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.disabled-units { border-top: 1px solid var(--line); }
.disabled-units summary { padding: 8px 16px; cursor: pointer; font-size: 13px; color: var(--off); }
.disabled-units summary .hint { margin: 0; font-size: 12px; }
.disabled-units .unit { opacity: .8; }
.service-line { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 16px; border-top: 1px solid var(--line);
                font-size: 12px; color: var(--off); background: #fafbfc; }
.service-line > span { display: flex; align-items: center; gap: 5px; }
.service-line .dot { width: 7px; height: 7px; }
.cmd { font-size: 11px; color: var(--off); }
.cmd.failed { color: var(--bad); } .cmd.done { color: var(--ok); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #cfd6de; background: #fff; cursor: pointer; }
.btn-sm:hover { background: #f3f4f6; }
.btn-sm.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-sm.danger { color: var(--bad); border-color: #f0c2c7; }
.btn-sm.danger:hover { background: var(--bad-bg); }
@media (max-width: 700px) {
  .machines { grid-template-columns: 1fr; }
  .unit { grid-template-columns: 1fr; grid-template-areas: "name" "state" "meta" "actions"; }
  .unit-actions { justify-content: flex-start; }
}
