:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --text: #1b1f24;
  --muted: #6a7380;
  --accent: #2f6fed;
  --accent-hover: #2459c9;
  --accent-soft: #e8efff;
  --ok: #18794e;
  --ok-soft: #e3f5ec;
  --fail: #c92a2a;
  --fail-soft: #fdecec;
  --warn: #a15c07;
  --warn-soft: #fff4e0;
  --s3: #6741d9;
  --s3-soft: #efeafd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2a3039;
    --text: #e6e9ee;
    --muted: #8c95a3;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-soft: #1c2740;
    --ok: #4cc38a;
    --ok-soft: #13271e;
    --fail: #ff6b6b;
    --fail-soft: #2d1719;
    --warn: #f0a33a;
    --warn-soft: #2b2112;
    --s3: #a48bff;
    --s3-soft: #231d3a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 6px 0; }
code {
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }

.muted { color: var(--muted); }
.text-muted { color: var(--muted); }
.text-fail { color: var(--fail); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* ---------- каркас ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner, .container {
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 20px;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  flex-wrap: wrap;
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.container { padding-block: 20px 48px; display: grid; gap: 16px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--s3));
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--surface) 25%, transparent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.card > h2 { margin-bottom: 12px; }
.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 6px;
}
.kpi { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.card form { margin-top: 10px; }
.card form.inline { margin-top: 0; }

.grid-cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; margin-inline: -18px; padding-inline: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
th.right, td.right { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.row-off td { opacity: .6; }

/* ---------- бейджи ---------- */
.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-fail { background: var(--fail-soft); color: var(--fail); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-s3 { background: var(--s3-soft); color: var(--s3); }
.badge-run { background: var(--accent-soft); color: var(--accent); }
.pill { padding: 4px 10px; }
.pill::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.pill-idle { background: var(--ok-soft); color: var(--ok); }
.pill-run { background: var(--accent-soft); color: var(--accent); }
.pill-run::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.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 { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--fail); }
.btn-danger-ghost:hover { background: var(--fail-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=time] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); opacity: .8; }

.stack { display: grid; gap: 12px; }
.cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.pwd-field { display: grid; gap: 4px; }
.row-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row-form label { min-width: 180px; flex: 1 1 180px; }

/* ---------- прогресс диска ---------- */
progress.meter {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}
progress.meter::-webkit-progress-bar { background: var(--surface-2); }
progress.meter::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress.meter::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
progress.meter-warn::-webkit-progress-value { background: var(--warn); }
progress.meter-warn::-moz-progress-bar { background: var(--warn); }

/* ---------- уведомления ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: opacity .4s;
}
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--fail-soft); color: var(--fail); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert.hide { opacity: 0; }

/* ---------- лог и details ---------- */
details.log summary { cursor: pointer; color: var(--accent); font-size: 13px; }
details.log pre {
  margin: 8px 0 0;
  max-width: 520px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: #0f1216;
  color: #d5dae1;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.card > details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}
.card > details > summary::-webkit-details-marker { display: none; }
.card > details > summary::before { content: "▸"; color: var(--muted); }
.card > details[open] > summary::before { content: "▾"; }
.card > details[open] > summary { margin-bottom: 12px; }
.inline-h { display: inline; }

/* ---------- диалоги ---------- */
dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(10, 14, 20, .5); backdrop-filter: blur(2px); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-danger { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px; }

/* ---------- вход ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 18px;
}
.login-card h1 { font-size: 20px; }
.login-card .brand-mark { width: 36px; height: 36px; }

@media (max-width: 640px) {
  .topbar-inner, .container { padding-inline: 16px; }
  .card { padding: 14px; }
  .table-wrap { margin-inline: -14px; padding-inline: 14px; }
}
