/*
 * DMED-шлюз — единственный файл стилей. Без сборки: сайт заливается по SFTP.
 *
 * Палитра: холодная бумага и тёмные чернила, кобальт изразца для действий,
 * бирюза — «подключено / успешно», кирпич — ошибки. Шрифты: Unbounded для
 * заголовков (кириллица в нём родная), Golos Text для текста, JetBrains Mono
 * для ключей, масок и чисел — всё, что программист копирует или сверяет.
 */

:root {
  --paper: #eef2f1;
  --surface: #ffffff;
  --ink: #14232b;
  --muted: #5f7179;
  --line: #d3dcdb;
  --cobalt: #1f4fa8;
  --cobalt-soft: #e4ebf8;
  --teal: #1e9c8f;
  --teal-soft: #dff2ef;
  --brick: #b5432f;
  --brick-soft: #f8e6e2;
  --amber: #a86a12;
  --amber-soft: #f7eddc;

  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --radius: 6px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--body);
}

a { color: var(--cobalt); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; }

p { margin: 0 0 0.75em; }

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

/* ---------- Каркас ---------- */

.topbar {
  background: var(--ink);
  color: #dfe8e7;
}
.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.brand span { color: #7fd3c9; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: #c4d1d0;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav a[aria-current="page"] { background: rgba(127, 211, 201, 0.16); color: #fff; }
.who { display: flex; align-items: center; gap: 12px; font-size: 0.86rem; color: #9fb0ae; }
.who button { color: #dfe8e7; border-color: rgba(255, 255, 255, 0.25); background: transparent; }

.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page__head p { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card > h2 { margin-bottom: 14px; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush > h2 { padding: 18px 22px 0; }

.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* ---------- Сообщения ---------- */

.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; border: 1px solid; }
.flash--ok { background: var(--teal-soft); border-color: #b5e0da; }
.flash--error { background: var(--brick-soft); border-color: #ecc5bd; }

/* ---------- Формы ---------- */

label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.92rem; }
.field { margin-bottom: 16px; }
.field .hint { color: var(--muted); font-size: 0.84rem; margin-top: 4px; }
.field .err { color: var(--brick); font-size: 0.86rem; margin-top: 4px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fbfcfc;
  border: 1px solid #b9c6c5;
  border-radius: var(--radius);
  padding: 9px 12px;
}
input:focus, select:focus { border-color: var(--cobalt); outline: none; box-shadow: 0 0 0 3px var(--cobalt-soft); }
input.is-invalid { border-color: var(--brick); }
input.mono-input { font-family: var(--mono); letter-spacing: 0.06em; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; }
.check input { margin-top: 4px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 0.92rem var(--body);
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--cobalt);
  background: var(--cobalt);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--cobalt); }
.btn--danger { background: transparent; color: var(--brick); border-color: #d9a59a; }
.btn--small { padding: 5px 10px; font-size: 0.84rem; }
.inline { display: inline; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Метки состояния ---------- */

.tag {
  display: inline-block;
  font: 500 0.76rem var(--mono);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag--ok { background: var(--teal-soft); color: #11695f; }
.tag--off { background: #e8eded; color: var(--muted); }
.tag--warn { background: var(--amber-soft); color: var(--amber); }
.tag--error { background: var(--brick-soft); color: var(--brick); }

/* ---------- Цифры обзора ---------- */

.figure { display: flex; flex-direction: column; gap: 2px; }
.figure b { font: 600 2rem/1.1 var(--mono); letter-spacing: -0.02em; }
.figure span { color: var(--muted); font-size: 0.86rem; }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 150px; margin-top: 8px; }
.bars__col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars__bar { width: 100%; max-width: 46px; background: var(--cobalt); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars__col small { font: 0.74rem var(--mono); color: var(--muted); }
.bars__col b { font: 600 0.8rem var(--mono); }

/* ---------- Таблицы ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  text-align: left;
  font: 500 0.74rem var(--body);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid #e7eded; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); text-align: right; white-space: nowrap; }
td.mono, td .mono { white-space: nowrap; }
.empty { padding: 28px 22px; color: var(--muted); }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; margin-bottom: 20px; }
.filters .field { margin: 0; }

.pager { display: flex; gap: 12px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); font-size: 0.88rem; }

/* ---------- Трасса подключения DMED ----------
 * Главный элемент кабинета: три станции входа. Пройденные — бирюзовые,
 * текущая — кобальт, впереди — пустые. Порядок здесь настоящий, поэтому
 * станции пронумерованы.
 */

.track { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); position: relative; }
.track::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 16.6%;
  right: 16.6%;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 14px);
}
.track li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 8px; }
.track__dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: 600 0.9rem var(--mono);
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--muted);
  position: relative;
}
.track__name { font-weight: 500; font-size: 0.92rem; }
.track__note { font-size: 0.8rem; color: var(--muted); }
.track li.is-done .track__dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.track li.is-current .track__dot { border-color: var(--cobalt); color: var(--cobalt); box-shadow: 0 0 0 5px var(--cobalt-soft); }
.track li.is-current .track__name { color: var(--cobalt); }

.status-line {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  margin-bottom: 22px;
  background: var(--teal-soft);
  border: 1px solid #b5e0da;
}
.status-line--off { background: #f3f6f6; border-color: var(--line); }
.status-line__pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--teal); flex: none; box-shadow: 0 0 0 0 rgba(30, 156, 143, 0.5); animation: pulse 2.4s infinite; }
.status-line--off .status-line__pulse { background: #a9b6b5; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(30, 156, 143, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(30, 156, 143, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 156, 143, 0); }
}

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 0.92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.roles { display: grid; gap: 10px; margin-bottom: 16px; }
.role {
  display: flex; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; font-weight: 400; margin: 0;
}
.role:has(input:checked) { border-color: var(--cobalt); background: var(--cobalt-soft); }
.role b { font-family: var(--mono); font-size: 0.86rem; }

/* ---------- Новый ключ: показать один раз ---------- */

.secret {
  border: 2px dashed var(--cobalt);
  background: var(--cobalt-soft);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 22px;
}
.secret__value {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 10px;
}
.secret__value code {
  font-size: 0.95rem;
  background: #fff;
  border: 1px solid #c3d0ea;
  border-radius: 4px;
  padding: 8px 12px;
  word-break: break-all;
  flex: 1;
  min-width: 240px;
}

/* ---------- Вход ---------- */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.login__aside {
  background: var(--ink);
  color: #c4d1d0;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login__aside h1 { color: #fff; font-size: 2.3rem; line-height: 1.12; max-width: 14ch; }
.login__aside h1 span { color: #7fd3c9; }
.login__aside p { max-width: 42ch; margin-top: 18px; }
.login__route { font: 0.82rem/1.9 var(--mono); color: #8fa3a1; }
.login__route b { color: #7fd3c9; font-weight: 500; }
.login__form { display: grid; place-items: center; padding: 40px 24px; }
.login__form form { width: 100%; max-width: 360px; }
.login__form h2 { margin-bottom: 22px; font-size: 1.25rem; }

@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login__aside { padding: 32px 24px; }
  .login__aside h1 { font-size: 1.7rem; }
  .page { padding: 24px 16px 48px; }
  .topbar__inner { padding: 10px 16px; gap: 12px; }
  .track__note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .status-line__pulse { animation: none; }
}
