@font-face { font-family: "Golos"; src: url("fonts/GolosText.ttf"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "JBM"; src: url("fonts/JetBrainsMono.ttf"); font-weight: 100 800; font-display: swap; }

:root { --ink: #0f172a; --muted: #475569; --line: #e2e8f0; --ok: #16a34a; --warn: #d97706; --bad: #e5484d; --blue: #2f80ed; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Golos", system-ui, sans-serif; color: var(--ink); background: linear-gradient(160deg, #f8fafc 0%, #eaeff5 100%); min-height: 100vh; line-height: 1.45; }
a { color: inherit; text-decoration: none; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 22px; height: 62px; padding: 0 24px; background: #0f172a; color: #e2e8f0; }
.brand { font-weight: 800; font-size: 19px; color: #fff; white-space: nowrap; }
#tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tab { position: relative; padding: 8px 14px; border-radius: 999px; color: #cbd5e1; white-space: nowrap; font-size: 15px; }
.tab:hover { color: #fff; background: #1e293b; }
.tab.on { color: #fff; background: #1e3a5f; }
.tab .dot { position: absolute; top: 6px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.demo { font-size: 13px; color: #1f2937; background: #fde68a; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
#clock { font-family: "JBM", monospace; font-size: 15px; color: #cbd5e1; min-width: 72px; text-align: right; }

/* раскладка */
.main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; padding: 20px 24px 28px; max-width: 1840px; margin: 0 auto; }
#stage { position: relative; min-width: 0; }
.scene-wrap { border-radius: 18px; background: linear-gradient(160deg, #f8fafc 0%, #eef2f7 100%); box-shadow: inset 0 0 0 1px #e2e8f0; overflow: hidden; }
svg.scene { display: block; width: 100%; height: auto; font-family: "Golos", sans-serif; }
#room-title { position: absolute; left: 22px; bottom: 16px; font-size: 26px; font-weight: 800; line-height: 1.2; pointer-events: none; }
#room-title span { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.offline #room-title span::after { content: " · нет связи с сервером"; color: var(--bad); }

/* сцена */
.mk { cursor: pointer; }
.mk-t { font-size: 11px; font-weight: 700; font-family: "Golos", sans-serif; }
.mk .pulse { transform-box: fill-box; transform-origin: center; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .45; } to { transform: scale(2.6); opacity: 0; } }
.spin { transform-box: fill-box; transform-origin: center; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hot.alarm polygon { animation: glow 1.8s ease-in-out infinite; }
@keyframes glow { 50% { stroke-opacity: .35; } }
.bang { animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.bang-t { font-size: 17px; font-weight: 800; fill: #fff; font-family: "Golos", sans-serif; }
.lead-l { stroke: #334155; stroke-width: 1.3; stroke-dasharray: 4 4; fill: none; }
.card-bg { fill: #fff; filter: url(#cardsh); }
.card-bg.alarm { stroke: var(--bad); stroke-width: 2.5; }
.card-bg.warn { stroke: var(--warn); stroke-width: 2; }
.card-title { font-size: 15.5px; font-weight: 700; fill: var(--ink); }
.chip.ok { fill: #dcfce7; } .chip.warn { fill: #fef3c7; } .chip.alarm { fill: #fee2e2; }
.chip-t { font-size: 12px; font-weight: 700; }
.chip-t.ok { fill: #166534; } .chip-t.warn { fill: #92400e; } .chip-t.alarm { fill: #b91c1c; }
.row { cursor: pointer; }
.row-hit { fill: transparent; } .row:hover .row-hit { fill: #f1f5f9; }
.row-l { font-size: 14px; fill: #334155; } .row-l.calc { font-style: italic; fill: var(--muted); }
.row-v { font-size: 14px; font-family: "JBM", monospace; font-weight: 600; fill: var(--ink); }
.row-l.alarm, .row-v.alarm { fill: #b91c1c; } .row-l.warn, .row-v.warn { fill: #92400e; }
.calc-line { stroke: #cbd5e1; stroke-dasharray: 4 3; }

/* компактный режим: карточки списком под сценой */
#list { display: none; }
.compact .card, .compact .lead { display: none; }
.compact #list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 14px; }
.compact #room-title { position: static; margin: 14px 4px 0; }
.lcard { background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 6px 20px rgba(15, 23, 42, .08); }
.lcard.alarm { box-shadow: 0 0 0 2px var(--bad), 0 6px 20px rgba(15, 23, 42, .08); }
.lcard.warn { box-shadow: 0 0 0 2px var(--warn); }
.lcard header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 15.5px; }
.chip-h { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip-h.ok { background: #dcfce7; color: #166534; } .chip-h.warn { background: #fef3c7; color: #92400e; } .chip-h.alarm { background: #fee2e2; color: #b91c1c; }
.lrow { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 4px; border: 0; background: none; font: inherit; color: #334155; text-align: left; border-radius: 8px; cursor: pointer; }
.lrow:hover, .lrow.sel { background: #f1f5f9; }
.lrow span { flex: 1; } .lrow b { font-family: "JBM", monospace; font-weight: 600; color: var(--ink); white-space: nowrap; }
.lrow.alarm, .lrow.alarm b { color: #b91c1c; }
.sym { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ok); color: var(--ok); font-style: normal; font-weight: 700; font-size: 11px; flex: none; }
.sym.alarm { border-color: var(--bad); color: var(--bad); } .sym.warn { border-color: var(--warn); color: var(--warn); } .sym.calc { border-color: #64748b; color: #64748b; }

/* правая колонка */
.side { background: #fff; border-radius: 18px; padding: 20px 22px; box-shadow: 0 10px 30px rgba(15, 23, 42, .08); align-self: start; position: sticky; top: 82px; }
.side h3 { margin: 0 0 10px; font-size: 16px; }
.side section + section { margin-top: 22px; }
.tiles { display: flex; gap: 10px; }
.tile { flex: 1; border-radius: 12px; padding: 10px 12px; background: #f1f5f9; }
.tile b { display: block; font-family: "JBM", monospace; font-size: 26px; line-height: 1.2; }
.tile span { font-size: 13px; color: var(--muted); }
.tile.ok { background: #ecfdf5; } .tile.ok b { color: #15803d; }
.tile.bad { background: #fef2f2; } .tile.bad b { color: #dc2626; }
.ev { display: flex; gap: 12px; font-size: 14px; line-height: 1.4; padding: 10px 0; border-top: 1px solid #eef2f6; color: var(--muted); }
.ev b { color: var(--ink); } .ev em { font-style: normal; color: #b91c1c; }
.et { font-family: "JBM", monospace; font-weight: 600; color: #64748b; min-width: 50px; }
.ev.now .et { color: #dc2626; }
#trend-title { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 600; color: #334155; }
#trend-title b { font-family: "JBM", monospace; white-space: nowrap; color: var(--ink); }
.spark { width: 100%; height: 96px; display: block; margin-top: 8px; }
.axis { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.blk { display: flex; gap: 16px; font-size: 14px; color: var(--muted); }
.blk b { font-family: "JBM", monospace; font-size: 18px; color: var(--ink); margin-right: 5px; }
.blk .bad b { color: #dc2626; }
.note { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }
#legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; color: var(--muted); }
#legend span { display: flex; align-items: center; gap: 7px; }
.foot { font-size: 12.5px; color: var(--muted); margin-top: 18px; line-height: 1.4; }

@media (max-width: 1180px) {
  .main { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 700px) {
  .top { gap: 10px; padding: 0 12px; height: 56px; }
  .brand { font-size: 17px; }
  #clock { display: none; }
  .demo { font-size: 12px; padding: 3px 8px; }
  .main { padding: 12px; gap: 14px; }
  .top { flex-wrap: wrap; height: auto; padding: 10px 12px 8px; row-gap: 6px; }
  #tabs { order: 3; flex-basis: 100%; margin: 0 -4px; }
  .demo { margin-left: auto; }
  #room-title { font-size: 22px; }
}
