/* ЭнергоКонтроль 74 — оформление интерфейса.
   Стиль инженерный и сдержанный: плотные таблицы, спокойные цвета, никаких
   декоративных анимаций. Статус всегда обозначается значком И текстом —
   цвет не является единственным признаком (ТЗ №2, п.95). */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #d8dee5;
  --border-strong: #b9c3cd;
  --text: #16212c;
  --text-dim: #5b6b7b;
  --text-faint: #8a97a4;
  --accent: #0b5d9c;
  --accent-dark: #084a7d;
  --accent-soft: #e8f1f9;
  --ok: #1b7a41;
  --ok-soft: #e6f4ec;
  --warn: #9a6206;
  --warn-soft: #fdf3e0;
  --bad: #b3261e;
  --bad-soft: #fbeae9;
  --idle: #6b7885;
  --idle-soft: #eef1f4;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 33, 48, .08), 0 1px 8px rgba(16, 33, 48, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181e;
    --surface: #1a222b;
    --surface-2: #202a34;
    --border: #2e3a46;
    --border-strong: #3d4c5a;
    --text: #e6edf3;
    --text-dim: #a6b3c0;
    --text-faint: #7d8b99;
    --accent: #4c9fe0;
    --accent-dark: #6cb4ec;
    --accent-soft: #14293c;
    --ok: #56c07f;
    --ok-soft: #142a1d;
    --warn: #e0a94a;
    --warn-soft: #2c2413;
    --bad: #ef6f66;
    --bad-soft: #2e1917;
    --idle: #93a1af;
    --idle-soft: #222c36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .6rem; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }

code, .mono, kbd { font-family: var(--mono); font-size: .92em; }

/* ------------------------------------------------------------ публичный сайт */

.public-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.public-header .inner,
.public-main,
.public-footer .inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}
.public-header .inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}
.public-main { padding-top: 56px; padding-bottom: 56px; }
.hero h1 { font-size: 2.1rem; letter-spacing: -.4px; }
.hero .subtitle { font-size: 1.15rem; color: var(--text-dim); margin-bottom: 1.2rem; }
.hero .lead { max-width: 44rem; color: var(--text); margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 48px;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.feature h3 { font-size: .98rem; }
.feature p { color: var(--text-dim); font-size: .93rem; margin: 0; }

.public-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: .9rem;
}
.public-footer .inner { padding-top: 22px; padding-bottom: 22px; }

/* ------------------------------------------------------------ вход */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card .brand { justify-content: center; margin-bottom: 4px; }
.login-card .hint { text-align: center; color: var(--text-dim); margin-bottom: 20px; font-size: .9rem; }

/* ------------------------------------------------------------ каркас кабинета */

.layout { display: flex; min-height: 100vh; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -.2px;
  color: var(--text);
}
.brand .mark {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-dim); font-size: .88rem; text-align: right; line-height: 1.25; }
.topbar .who b { color: var(--text); font-weight: 600; display: block; }

.body-row { display: flex; flex: 1; align-items: stretch; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 0;
}
.sidebar nav { display: flex; flex-direction: column; }
.sidebar .group {
  padding: 14px 18px 6px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
}
.sidebar a {
  padding: 7px 18px;
  color: var(--text-dim);
  font-size: .93rem;
  border-left: 3px solid transparent;
}
.sidebar a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.sidebar a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 550;
}
.sidebar .count {
  float: right;
  background: var(--idle-soft);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 0 7px;
  font-size: .78rem;
}

.content { flex: 1; padding: 22px 24px 48px; min-width: 0; }
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-dim); font-size: .92rem; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ элементы */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.card > h2, .card > h3 {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .98rem;
}
.card .body { padding: 16px; }
.card .body > :last-child { margin-bottom: 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.tile .label { font-size: .8rem; color: var(--text-dim); margin-bottom: 4px; }
.tile .value { font-size: 1.7rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .note { font-size: .78rem; color: var(--text-faint); margin-top: 3px; }
.tile.ok .value { color: var(--ok); }
.tile.warn .value { color: var(--warn); }
.tile.bad .value { color: var(--bad); }
a.tile:hover { border-color: var(--border-strong); text-decoration: none; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.kv { width: 100%; font-size: .92rem; }
.kv td { padding: 5px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv tr:last-child td { border-bottom: none; }
.kv td:first-child { color: var(--text-dim); width: 44%; padding-right: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 11px;
  font-size: .81rem;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.badge.idle { background: var(--idle-soft); color: var(--idle); border-color: var(--border); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .91rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.small { padding: 3px 9px; font-size: .84rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

form .field { margin-bottom: 13px; }
form label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: 4px; }
form label .req { color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .93rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
  border-color: var(--accent);
}
textarea { min-height: 76px; resize: vertical; }
.hint-text { font-size: .81rem; color: var(--text-faint); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 16px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.checkline { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .92rem; }
.checkline input { width: auto; }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: .92rem;
}
.alert.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.alert.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.alert.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: .95rem;
}
.empty .big { font-size: 1.02rem; color: var(--text); margin-bottom: 6px; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tabs a {
  padding: 8px 14px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-size: .93rem;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 550; }

.steps { display: flex; gap: 4px; margin-bottom: 22px; flex-wrap: wrap; }
.steps .step {
  flex: 1;
  min-width: 118px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-faint);
}
.steps .step b { display: block; color: var(--text-dim); font-size: .74rem; font-weight: 600; }
.steps .step.done { border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); }
.steps .step.done b { color: var(--ok); }
.steps .step.current { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.steps .step.current b { color: var(--accent); }

.progress-list { list-style: none; margin: 0; padding: 0; font-size: .94rem; }
.progress-list li { padding: 5px 0; display: flex; gap: 9px; align-items: baseline; }
.progress-list .sym { width: 1.1em; text-align: center; flex: 0 0 auto; }
.progress-list li.ok .sym { color: var(--ok); }
.progress-list li.warn .sym { color: var(--warn); }
.progress-list li.bad .sym { color: var(--bad); }
.progress-list li.idle { color: var(--text-faint); }

.compare td.same { color: var(--ok); }
.compare td.diff { color: var(--warn); font-weight: 550; }
.compare td.unchecked { color: var(--text-faint); }

.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--text-dim); margin-top: 8px; }
.chart-legend .swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters .field { margin-bottom: 0; min-width: 140px; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pill {
  padding: 4px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  font-size: .86rem;
  color: var(--text-dim);
  background: var(--surface);
}
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill:hover { text-decoration: none; }

.print-block { font-family: var(--mono); font-size: .88rem; white-space: pre-wrap; }
.muted { color: var(--text-faint); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.spinner-inline.htmx-request { opacity: .55; }

/* ------------------------------------------------------------ мобильные */

@media (max-width: 860px) {
  .body-row { flex-direction: column; }
  .sidebar {
    width: auto;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
  }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar .group { display: none; }
  .sidebar a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 8px 13px; }
  .sidebar a.active { border-left: none; border-bottom-color: var(--accent); }
  .sidebar .count { float: none; margin-left: 5px; }
  .content { padding: 16px 14px 40px; }
  .topbar .who span { display: none; }
  table { font-size: .88rem; }
}

@media print {
  .topbar, .sidebar, .page-head .actions, .no-print { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #999; break-inside: avoid; }
}
