/* ХОГВАРТС-ПУЛЬТ — дизайн-токены и компоненты.
   Тёмный замок при свечах: камень, пергамент, золото. Данные — прежде всего. */

@import url("/static/fonts/fonts.css");

:root {
  --bg: #0b0912;
  --bg-deep: #070609;
  --surface: #14101f;
  --surface-2: #1b1629;
  --surface-3: #221c33;
  --border: #282139;
  --border-gold: rgba(212, 175, 55, 0.28);
  --text: #ece4d3;
  --muted: #a89d87;
  --faint: #6e6656;
  --gold: #d4af37;
  --gold-bright: #e9cd6f;
  --pos: #6fbe8b;
  --neg: #e0616f;
  --warn: #dfa640;
  --info: #7fa8e0;
  /* серии (категориальная палитра, порядок фиксирован; проверена
     validate_palette.js: dark #14101f — все 5 проверок зелёные) */
  --s1: #a28b2b; --s2: #be525f; --s3: #4e78c7; --s4: #4a9a5e;
  --s5: #8766bb; --s6: #009d9e; --s7: #bd7138; --s8: #5e7ec5;
  --font-display: "Cormorant SC", "EB Garamond", serif;
  --font-body: "EB Garamond", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(212, 175, 55, 0.05), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(111, 157, 232, 0.04), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
}
::selection { background: rgba(212, 175, 55, 0.3); }

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

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.02em; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 22px; color: var(--gold-bright); margin-bottom: 12px; }
h2 .rune { color: var(--gold); margin-right: 8px; }
h3 { font-size: 18px; color: var(--text); }

.num, td.num, .mono { font-family: var(--font-mono); font-size: 13px; }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: linear-gradient(180deg, var(--bg-deep), #0d0a15 60%);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 700; color: var(--gold-bright);
  letter-spacing: 0.06em;
  padding: 4px 10px 14px;
  border-bottom: 1px solid var(--border-gold);
  margin-bottom: 12px;
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.35);
}
.brand small { display: block; font-family: var(--font-body); font-size: 12px; color: var(--faint); letter-spacing: 0.1em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--muted); cursor: pointer; user-select: none;
  border: 1px solid transparent;
  font-size: 16px;
  transition: all 0.15s ease;
}
.nav-item:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-item.active {
  color: var(--gold-bright);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-color: var(--border-gold);
}
.nav-item .ic { width: 18px; text-align: center; color: var(--gold); font-size: 15px; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 12px; color: var(--faint); padding: 0 12px 4px; }

.main { flex: 1; min-width: 0; padding: 22px 28px 60px; max-width: 1420px; }

/* ---------- топбар ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.beacon-box { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.beacon-box b { color: var(--text); font-weight: 500; }
.beacon { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.beacon.ok { background: var(--pos); box-shadow: 0 0 8px rgba(111, 190, 139, 0.7); }
.beacon.bad { background: var(--neg); box-shadow: 0 0 8px rgba(224, 97, 111, 0.8); }
.beacon.armed {
  background: var(--neg);
  animation: flicker 1.6s infinite alternate ease-in-out;
}
@keyframes flicker {
  0% { box-shadow: 0 0 6px rgba(224, 97, 111, 0.9), 0 0 18px rgba(224, 97, 111, 0.4); }
  100% { box-shadow: 0 0 10px rgba(224, 97, 111, 1), 0 0 30px rgba(224, 97, 111, 0.6); }
}
.topbar .sep { width: 1px; height: 22px; background: var(--border); }
.topbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ---------- карточки/сетки ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: 1fr; } .grid.cols-2 { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card.gold { border-color: var(--border-gold); }
.card .k { font-size: 13px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--font-body); }
.card .v { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin-top: 4px; }
.card .v small { font-size: 14px; color: var(--muted); font-weight: 400; }
.card .sub { font-size: 13px; color: var(--faint); margin-top: 4px; }

section.block { margin-bottom: 26px; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-family: var(--font-body); font-weight: 500;
  font-size: 12.5px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer;
}
.tbl th.sorted { color: var(--gold); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid rgba(40, 33, 57, 0.6); font-size: 14.5px; vertical-align: middle; }
.tbl td.num { font-size: 13px; white-space: nowrap; }
.tbl tr:hover td { background: rgba(212, 175, 55, 0.04); }
.tbl .pos { color: var(--pos); }
.tbl .neg { color: var(--neg); }
.scroll-x { overflow-x: auto; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-family: var(--font-mono);
  border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.chip.cand { color: var(--gold-bright); border-color: var(--border-gold); }
.chip.live { color: #fff; background: rgba(224, 97, 111, 0.25); border-color: var(--neg); }
.chip.data { color: var(--info); border-color: rgba(127, 168, 224, 0.4); }
.chip.broken { color: var(--neg); border-color: rgba(224, 97, 111, 0.4); }
.chip.won { color: var(--pos); border-color: rgba(111, 190, 139, 0.5); }
.chip.lost { color: var(--neg); border-color: rgba(224, 97, 111, 0.5); }
.chip.open { color: var(--warn); border-color: rgba(223, 166, 64, 0.5); }

/* ---------- кнопки/формы ---------- */
.btn {
  font-family: var(--font-body); font-size: 15px;
  padding: 9px 18px; border-radius: var(--radius);
  border: 1px solid var(--border-gold);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  color: var(--gold-bright); cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--gold); box-shadow: 0 0 14px rgba(212, 175, 55, 0.25); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.danger { border-color: rgba(224, 97, 111, 0.5); color: #f0a9b1; }
.btn.danger:hover { border-color: var(--neg); box-shadow: 0 0 14px rgba(224, 97, 111, 0.3); }
.btn.ghost { border-color: var(--border); color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn.small { padding: 5px 12px; font-size: 13.5px; }

input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-family: var(--font-mono); font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--border-gold); }

.toggle-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 20px; cursor: pointer; user-select: none;
  border: 1px solid var(--border); color: var(--muted); font-size: 14px;
  transition: all 0.12s ease;
}
.toggle-chip.on { color: var(--gold-bright); border-color: var(--gold); background: rgba(212, 175, 55, 0.08); }
.toggle-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.7; }

/* ---------- график ---------- */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(11, 9, 18, 0.95); border: 1px solid var(--border-gold);
  border-radius: 8px; padding: 8px 11px; font-family: var(--font-mono); font-size: 12px;
  display: none; min-width: 150px; box-shadow: var(--shadow);
}
.chart-tip .t { color: var(--faint); margin-bottom: 4px; }
.chart-tip .row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chart-tip .dot { width: 8px; height: 8px; border-radius: 50%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 10px; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- журнал ---------- */
.logbox {
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.65;
  max-height: 68vh; overflow: auto; white-space: pre-wrap; word-break: break-all;
  color: #b9b0a0;
}
.logbox .warn { color: var(--warn); }
.logbox .err { color: var(--neg); }

/* ---------- модалка подтверждения ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(4, 3, 8, 0.75);
  display: none; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-back.open { display: flex; }
.modal {
  width: min(480px, 92vw);
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
  border: 1px solid var(--border-gold); border-radius: 14px;
  padding: 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.modal h3 { font-family: var(--font-display); color: var(--gold-bright); font-size: 22px; margin-bottom: 10px; }
.modal p { color: var(--muted); font-size: 15px; margin-bottom: 14px; }
.modal .row { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.modal input { width: 100%; }

/* ---------- алерты ---------- */
.alert {
  border: 1px solid rgba(224, 97, 111, 0.4); border-left: 3px solid var(--neg);
  background: rgba(224, 97, 111, 0.06);
  padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 10px;
}
.alert.warn { border-color: rgba(223, 166, 64, 0.4); border-left-color: var(--warn); background: rgba(223, 166, 64, 0.05); }
.alert.ok { border-color: rgba(111, 190, 139, 0.35); border-left-color: var(--pos); background: rgba(111, 190, 139, 0.05); }

.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.gold-t { color: var(--gold-bright); }

/* прогресс-свиток */
.progress { height: 10px; border-radius: 6px; background: var(--bg-deep); border: 1px solid var(--border); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); border-radius: 6px; }

/* ---------- логин ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-card {
  width: min(400px, 92vw); text-align: center;
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
  border: 1px solid var(--border-gold); border-radius: 16px;
  padding: 44px 36px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8);
  position: relative; z-index: 2;
}
.login-card .sigil { margin: 0 auto 18px; width: 74px; height: 74px; filter: drop-shadow(0 0 16px rgba(212, 175, 55, 0.45)); }
.login-card h1 { color: var(--gold-bright); font-size: 26px; letter-spacing: 0.08em; }
.login-card .sub { color: var(--faint); font-size: 13.5px; margin: 6px 0 24px; letter-spacing: 0.12em; }
.login-card input { width: 100%; text-align: center; font-size: 16px; padding: 12px; }
.login-card .btn { width: 100%; margin-top: 14px; font-size: 16px; padding: 12px; }
.login-card .err { color: var(--neg); font-size: 14px; margin-top: 12px; min-height: 20px; }
.dust {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: var(--gold-bright); opacity: 0; z-index: 1;
  animation: float 9s infinite linear;
}
@keyframes float {
  0% { transform: translateY(30px); opacity: 0; }
  15% { opacity: 0.55; }
  85% { opacity: 0.25; }
  100% { transform: translateY(-92vh); opacity: 0; }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; height: auto; position: static; padding: 10px; align-items: center; }
  .brand { border: none; padding: 0 12px; margin: 0; white-space: nowrap; }
  .brand small { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .sidebar .spacer, .sidebar .foot { display: none; }
  .main { padding: 14px 12px 40px; }
}
