@font-face { font-family: "Montserrat"; src: url("/montserrat.woff") format("woff"); font-weight: 100 900; font-style: normal; font-display: swap; }
/* Фирменные цвета «Алгоритм энергий»: синий #04316a, серый #7a858b, чёрный #000 */
:root {
  --brand: #04316a; --brand-grey: #7a858b;
  --bg: #eef0f1; --card: #fff; --text: #0d1622; --muted: #5f6a70; --line: #dde1e4;
  --accent: #04316a; --accent-bg: #e1e8f2; --accent-text: #04316a;
  --side-bg: #04316a; --side-text: #ffffff; --side-muted: #a9b8cc; --side-on: rgba(255,255,255,.14);
  --ok: #2f6b1c; --ok-bg: #e6f1de; --warn: #8a5100; --warn-bg: #fbeed8;
  --alarm: #b3261e; --alarm-bg: #fbe5e3; --off: #5f6a70; --off-bg: #eceff1;
  --radius: 10px; --nav-h: 62px;
  font-family: "Montserrat", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a111a; --card: #121b26; --text: #e7ebef; --muted: #9aa5ab; --line: #26313d;
    --accent: #7fa6db; --accent-bg: #132a4a; --accent-text: #c3d5ef;
    --side-bg: #061c3d; --side-text: #e7ebef; --side-muted: #8fa1b8; --side-on: rgba(255,255,255,.10);
    --ok: #9ccc6f; --ok-bg: #1d2c12; --warn: #f0a63c; --warn-bg: #36260b;
    --alarm: #f08f89; --alarm-bg: #3b1715; --off: #a7b0b5; --off-bg: #222a31;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
body { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.center { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* каркас */
.shell { display: flex; min-height: 100vh; }
.side { width: 236px; background: var(--side-bg); color: var(--side-text); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 6px 10px 18px; }
.brand img { width: 120px; display: block; }
.brand .bn { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--side-muted); margin-top: 8px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; margin-bottom: 2px; }
.side a.nav.on { background: var(--side-on); font-weight: 600; box-shadow: inset 3px 0 0 #fff; }
.side a.nav:hover { background: var(--side-on); }
.side select { background: rgba(255,255,255,.1); color: var(--side-text); border-color: rgba(255,255,255,.25); }
.side select option { color: #000; }
.side .sec { font-size: 11px; color: var(--side-muted); padding: 16px 10px 6px; letter-spacing: .12em; text-transform: uppercase; }
.main { flex: 1; min-width: 0; padding: 20px 24px 40px; max-width: 1200px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.top h1 { font-size: 21px; margin: 0; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.bottom { display: none; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--alarm); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.ico { width: 20px; height: 20px; flex: none; }

@media (max-width: 760px) {
  .side { display: none; }
  .main { padding: 14px 12px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); padding-top: calc(14px + env(safe-area-inset-top)); }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); z-index: 10; }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; position: relative; }
  .bottom a.on { color: var(--accent); font-weight: 600; }
  .bottom a .badge { position: absolute; top: 6px; left: 52%; }
  .top h1 { font-size: 18px; }
}

/* элементы */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.card h2 { font-size: 13px; margin: 0 0 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.grid .card { margin: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .l { flex: 1; min-width: 0; }
.row .l .sub { font-size: 12px; color: var(--muted); }
.row .v { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .v small { font-weight: 400; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.st-ok .pill { background: var(--ok-bg); color: var(--ok); }
.st-warn .pill { background: var(--warn-bg); color: var(--warn); }
.st-alarm .pill { background: var(--alarm-bg); color: var(--alarm); }
.st-off .pill, .st-na .pill { background: var(--off-bg); color: var(--off); }
.st-alarm .v { color: var(--alarm); }
.st-warn .v { color: var(--warn); }
.st-na .v { color: var(--muted); font-weight: 400; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ok); }
.dot.bad { background: var(--alarm); }
.ctrls { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--muted); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--alarm); }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.err { color: var(--alarm); font-size: 13px; min-height: 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: flex; gap: 6px; align-items: center; }

/* вход */
.login-bg { min-height: 100vh; background: var(--brand) repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 1px, transparent 1px 22px); display: flex; align-items: flex-start; justify-content: center; }
@media (prefers-color-scheme: dark) { .login-bg { background-color: #061c3d; } }
.login { width: 100%; max-width: 380px; margin: 10vh auto 0; padding: 0 16px 40px; }
.login .logo { text-align: center; margin-bottom: 14px; }
.login .logo img { width: 190px; }
.login .wm { text-align: center; color: #fff; font-size: 15px; letter-spacing: .22em; text-transform: uppercase; font-weight: 500; }
.login .sub { text-align: center; color: #a9b8cc; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; margin: 6px 0 22px; }

/* события */
.ev { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; }
.ev .t { width: 92px; flex: none; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev pre, .report pre { margin: 0; white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.ev.k-alarm pre { color: var(--alarm); }
.ev .k { font-size: 11px; color: var(--muted); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 13px; background: var(--card); }
.chip.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-text); }

/* графики */
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: 340px; display: block; touch-action: pan-y; }
.chart-wrap .tip { position: absolute; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.08); white-space: nowrap; display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.tagpick { columns: 2 220px; font-size: 14px; }
.tagpick .g { break-inside: avoid; margin-bottom: 8px; }
.tagpick .g b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.tagpick label { display: flex; gap: 6px; align-items: center; padding: 2px 0; }

/* чат */
.chat { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 360px; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 78%; margin: 6px 0; padding: 8px 11px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.msg.me { margin-left: auto; background: var(--accent-bg); border-color: transparent; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .who b { color: var(--text); font-weight: 600; }
.msg .tx { white-space: pre-wrap; word-wrap: break-word; }
.chat form { display: flex; gap: 8px; padding-top: 8px; }
.chat textarea { resize: none; height: 44px; }
.daysep { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0; }
@media (max-width: 760px) { .chat { height: calc(100vh - 150px - var(--nav-h) - env(safe-area-inset-bottom)); } .msg { max-width: 88%; } }

/* окна */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; padding: 18px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 12px; font-size: 17px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 60; font-size: 14px; }
.hint { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
table.users { width: 100%; border-collapse: collapse; }
table.users td, table.users th { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); font-size: 14px; vertical-align: top; }
table.users th { font-weight: 500; color: var(--muted); font-size: 12.5px; border-top: 0; }
@media (max-width: 760px) { table.users .hide-m { display: none; } }

.mlogo { display: none; height: 30px; width: auto; }
@media (max-width: 760px) {
  .mlogo.lt { display: block; }
  .bottom a.on { color: var(--accent); }
}
@media (max-width: 760px) and (prefers-color-scheme: dark) { .mlogo.lt { display: none; } .mlogo.dk { display: block; } }
