/* Панель hh: светлая и тёмная тема. Тема по умолчанию — как в системе; кнопка «Тема» переключает вручную. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d8dce2;
  --text: #1c2230;
  --muted: #5d6878;
  --accent: #2f5bd3;
  --accent-hover: #244bb5;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #e5f3e9;
  --warn: #946200;
  --warn-bg: #fdf2d3;
  --bad: #c42b2b;
  --bad-bg: #fce6e6;
  --none: #8a94a3;
  --none-bg: #eceff3;
  --info: #5d6878;
  --head: #2a63b8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --backdrop: rgba(15, 20, 30, .45);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1318;
    --surface: #171c23;
    --surface-2: #1f262f;
    --border: #2d3641;
    --text: #e2e7ee;
    --muted: #96a2b3;
    --accent: #5c82f0;
    --accent-hover: #7596f4;
    --accent-text: #0b1020;
    --ok: #46c25b;
    --ok-bg: rgba(70, 194, 91, .14);
    --warn: #e0a83a;
    --warn-bg: rgba(224, 168, 58, .14);
    --bad: #f2645a;
    --bad-bg: rgba(242, 100, 90, .15);
    --none: #6f7a88;
    --none-bg: rgba(111, 122, 136, .16);
    --info: #96a2b3;
    --head: #6fa6ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --backdrop: rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1318;
  --surface: #171c23;
  --surface-2: #1f262f;
  --border: #2d3641;
  --text: #e2e7ee;
  --muted: #96a2b3;
  --accent: #5c82f0;
  --accent-hover: #7596f4;
  --accent-text: #0b1020;
  --ok: #46c25b;
  --ok-bg: rgba(70, 194, 91, .14);
  --warn: #e0a83a;
  --warn-bg: rgba(224, 168, 58, .14);
  --bad: #f2645a;
  --bad-bg: rgba(242, 100, 90, .15);
  --none: #6f7a88;
  --none-bg: rgba(111, 122, 136, .16);
  --info: #96a2b3;
  --head: #6fa6ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --backdrop: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

code { font-family: var(--mono); font-size: 12.5px; }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.spacer { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

main { padding: 16px 20px 32px; max-width: 1600px; margin: 0 auto; }

/* ---------- кнопки и поля ---------- */
button, input, select {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.small { padding: 3px 8px; font-size: 12.5px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input, select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 9px;
  min-width: 0;
}

.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.toolbar input[type="search"] { width: 260px; }

/* ---------- сообщения ---------- */
.banner {
  border: 1px solid var(--bad);
  background: var(--bad-bg);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.toast.error { border-left-color: var(--bad); }

/* ---------- пульт: вход и версия ---------- */
.login-screen { display: flex; justify-content: center; padding-top: 6vh; }
.login-box {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.login-box input { color: var(--text); font-size: 16px; padding: 8px 10px; }
.login-box p { margin: 0; }
.login-box .form-error { margin: 0; }

.release {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.release .release-text { flex: 1 1 320px; min-width: 0; }
.release .release-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.release .release-last { font-size: 12.5px; margin-top: 4px; }
.release pre.output { margin-top: 6px; max-height: 160px; }
.release .release-actions { display: flex; gap: 8px; }

/* ---------- фоновые проверки ---------- */
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; margin-bottom: 12px; }
.jobs:empty { display: none; }

.job {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.job-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.job-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.job.done .job-title { color: var(--muted); font-weight: 500; }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s; }
.job.done .bar > span { background: var(--ok); }

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -1px;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .bar > span { transition: none; } }

/* ---------- сводка ---------- */
.counts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; color: var(--muted); }
.counts button { border-radius: 999px; padding: 2px 10px; font-size: 12.5px; color: var(--text); }
.counts button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); }
.counts .last { margin-left: 6px; }

/* ---------- таблица ---------- */
.table-wrap {
  position: relative;   /* иначе скрытые подписи (.sr) вылезают за край и страница едет вбок на телефоне */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tr.retired td { color: var(--muted); }

td.ip, td.mono { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td.domains { font-size: 12.5px; }
td.domains div { white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: 4px; }
td.actions .login { margin-top: 4px; }
td.when { white-space: nowrap; font-size: 12.5px; }

.name-link {
  border: none;
  background: none;
  padding: 0;
  font-weight: 600;
  color: var(--accent);
}
.name-link:hover { background: none; text-decoration: underline; }

.state { min-width: 170px; max-width: 280px; }
.state-label { display: flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; }
.state-reason { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--none); flex: none; vertical-align: 0; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.none { background: transparent; border: 2px solid var(--none); }

.c-green, .c-ok { color: var(--ok); }
.c-yellow, .c-warn { color: var(--warn); }
.c-red, .c-bad { color: var(--bad); }
.c-gray { color: var(--none); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--none-bg);
  color: var(--text);
  white-space: nowrap;
}
.chip.new { background: var(--warn-bg); }
.chip.active { background: var(--ok-bg); }
.chip.green { background: var(--ok-bg); color: var(--ok); }
.chip.yellow { background: var(--warn-bg); color: var(--warn); }
.chip.red { background: var(--bad-bg); color: var(--bad); }

.paid-bad { color: var(--bad); font-weight: 600; }
.paid-warn { color: var(--warn); font-weight: 600; }

.empty { padding: 24px; text-align: center; color: var(--muted); margin: 0; }

.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.hint .dot { margin: 0 2px; }

/* ---------- окна ---------- */
dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: var(--backdrop); }

.dialog-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
#card-body, #add-form { padding: 4px 18px 18px; }

.summary-box {
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  background: var(--none-bg);
}
.summary-box.ok { background: var(--ok-bg); }
.summary-box.warn { background: var(--warn-bg); }
.summary-box.bad { background: var(--bad-bg); }
.summary-box ul { margin: 6px 0 0; padding-left: 20px; }

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 16px;
  margin: 0;
}
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; gap: 8px; padding: 2px 0; }
.items .tag { font-family: var(--mono); font-size: 12px; flex: none; width: 52px; }

.section-meta { color: var(--muted); font-size: 12.5px; margin: -4px 0 8px; }

pre.output {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.output .l-ok { color: var(--ok); }
pre.output .l-fail { color: var(--bad); }
pre.output .l-warn { color: var(--warn); }
pre.output .l-info { color: var(--info); }
pre.output .l-head { color: var(--head); font-weight: 600; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px 14px;
  margin: 12px 0;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form-grid label input, .form-grid label select { color: var(--text); font-size: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.req { color: var(--bad); }
.form-error { color: var(--bad); margin: 4px 0 10px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#add-result { margin-top: 12px; }

@media (max-width: 720px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .toolbar input[type="search"] { width: 100%; }
  .top h1 { font-size: 17px; }
}
