:root {
  --space: #050B1F; --night: #0A1433; --deep: #101C45; --accent: #2F6BFF; --electric: #4C8DFF; --signal: #3FA9FF; --neuro: #7B6CFF;
  --paper: #F5F7FC; --ink: #0B1B4D; --muted: #4A5A85; --line: #DCE3F2; --ok: #22C55E; --warn: #F5B33F; --bad: #F05252;
  --r: 12px; font-family: Inter, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
a { color: var(--accent); }
h1 { font: 800 24px Manrope, Inter, sans-serif; letter-spacing: -0.02em; margin: 0; }
h2 { font: 800 17px Manrope, Inter, sans-serif; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--night); color: #C9D3F0; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand b { font: 800 15px Manrope, sans-serif; line-height: 1.15; }
.brand small { display: block; font: 600 10px Inter, sans-serif; letter-spacing: .16em; text-transform: uppercase; color: var(--signal); }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: #C9D3F0; text-decoration: none; font-weight: 500; }
.nav:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav.on { background: var(--accent); color: #fff; }
.nav .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.side .sep { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #6F7FAE; padding: 14px 10px 4px; }
.side .foot { margin-top: auto; padding: 14px 10px 0; font-size: 11px; color: #6F7FAE; display: flex; align-items: center; gap: 8px; }
.side .foot img { width: 18px; height: 18px; }
.side .foot b { color: #fff; } .side .foot b i { color: var(--accent); font-style: normal; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top .grow { flex: 1; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.cards { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.kpi .v { font: 800 30px Manrope, sans-serif; letter-spacing: -0.02em; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.alert .v { color: var(--bad); }
.cols-2 { grid-template-columns: 1.4fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: 600 13px Inter, sans-serif; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #1F5BEF; }
.btn.sec { background: #fff; color: var(--accent); border-color: #C9DAFF; }
.btn.sec:hover { background: #EEF3FF; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--bad); border-color: #F6B9B9; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: 14px Inter, sans-serif; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #EDF1F9; vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #F7F9FE; }
tr.sel td { background: #EEF3FF; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #EEF1F8; color: var(--muted); white-space: nowrap; }
.chip.new { background: #EAF1FF; color: var(--accent); } .chip.sent { background: #E5F4FF; color: #0B6FB8; }
.chip.in_work { background: #FFF6E5; color: #A86A00; } .chip.done { background: #E9F9EF; color: #15803D; }
.chip.em, .chip.emergency, .chip.toxic, .chip.error { background: #FDECEC; color: var(--bad); }
.chip.request { background: #EAF1FF; color: var(--accent); } .chip.complaint { background: #FFF6E5; color: #A86A00; }
.chip.question { background: #F0EDFF; color: var(--neuro); } .chip.running { background: #E9F9EF; color: #15803D; }
.chip.house { background: #E9F9EF; color: #15803D; } .chip.dispatcher, .chip.admin { background: #EAF1FF; color: var(--accent); }
.chip.contractor { background: #FFF6E5; color: #A86A00; } .chip.unknown { background: #FDECEC; color: var(--bad); }
.chip.mass { background: #FFE8D6; color: #C2410C; }
.drawer-bg { position: fixed; inset: 0; background: rgba(5,11,31,.35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: #fff; z-index: 21; overflow-y: auto; padding: 22px; box-shadow: -10px 0 40px rgba(5,11,31,.15); }
.modal { position: fixed; top: 8vh; left: 50%; transform: translateX(-50%); width: min(620px, 94vw); max-height: 84vh; overflow-y: auto; background: #fff; z-index: 21; border-radius: 16px; padding: 22px; }
.close { float: right; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 10px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { border-left: 2px solid var(--line); padding-left: 14px; margin-left: 4px; }
.timeline > div { position: relative; padding-bottom: 10px; }
.timeline > div::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline > div.pub::before { background: var(--ok); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bars > div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars > div .em { position: absolute; bottom: 0; left: 0; right: 0; background: var(--bad); border-radius: 4px 4px 0 0; }
.bars > div:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 6px; border-radius: 6px; white-space: nowrap; margin-bottom: 4px; }
.hbar { display: grid; grid-template-columns: 160px 1fr 48px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.hbar .track { background: #EEF1F8; border-radius: 6px; height: 10px; overflow: hidden; }
.hbar .fill { background: var(--accent); height: 100%; border-radius: 6px; }
.hbar .n { text-align: right; font-family: 'JetBrains Mono', monospace; }
.heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; }
.heat div { height: 34px; border-radius: 5px; background: var(--accent); position: relative; }
.heat div span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.msg { border-bottom: 1px solid #EDF1F9; padding: 12px 0; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.msg .text { white-space: pre-wrap; margin: 4px 0; }
.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.banner.warn { background: #FFF6E5; border: 1px solid #F5D9A0; } .banner.info { background: #EAF1FF; border: 1px solid #C9DAFF; }
.banner.bad { background: #FDECEC; border: 1px solid #F6B9B9; } .banner.ok { background: #E9F9EF; border: 1px solid #B5E8C7; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 50; max-width: 420px; }
.toast.err { background: var(--bad); }
.login { min-height: 100vh; display: grid; place-items: center; background: var(--space); background-image: radial-gradient(rgba(120,150,255,.12) 1px, transparent 1px); background-size: 22px 22px; }
.login .card { width: 360px; background: var(--night); border-color: rgba(120,150,255,.16); color: #fff; }
.login .card input { background: var(--deep); border-color: rgba(120,150,255,.2); color: #fff; }
.login .card .field > span { color: #A9B6D9; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: 600 14px Inter, sans-serif; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
code, pre { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
pre { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.running { background: var(--ok); } .dot.error { background: var(--bad); } .dot.stopped { background: #B0BAD4; }
.steps-list { margin: 0; padding-left: 18px; } .steps-list li { margin: 4px 0; }

/* обучалка */
.tour-block { position: fixed; inset: 0; z-index: 90; }
.tour-dim { position: fixed; inset: 0; background: rgba(5,11,31,.55); z-index: 91; pointer-events: none; }
.tour-shade { position: fixed; z-index: 91; background: rgba(5,11,31,.55); pointer-events: none; }
.tour-spot { position: fixed; z-index: 91; border-radius: 12px; box-shadow: 0 0 0 3px var(--accent), 0 0 24px rgba(47,107,255,.5); pointer-events: none; }
.tour-pop { position: fixed; z-index: 92; background: #fff; border-radius: 16px; padding: 18px; box-shadow: 0 20px 50px rgba(5,11,31,.35); animation: pop .2s ease; }
.tour-pop h3 { font: 800 17px Manrope, Inter, sans-serif; margin: 2px 0 8px; }
.tour-text { white-space: pre-line; line-height: 1.5; color: var(--ink); }
.tour-count { font: 600 11px 'JetBrains Mono', monospace; color: var(--accent); letter-spacing: .1em; }
.tour-btns { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.help-fab { position: fixed; right: 22px; bottom: 22px; z-index: 30; height: 44px; padding: 0 18px; border-radius: 22px; border: 0; background: var(--ink); color: #fff;
  font: 600 14px Inter, sans-serif; display: flex; align-items: center; gap: 8px; cursor: pointer; box-shadow: 0 8px 24px rgba(5,11,31,.25); }
.help-fab:hover { background: var(--accent); }
.hint { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #E6EEFF; color: var(--accent);
  font: 700 11px Inter, sans-serif; cursor: help; position: relative; margin-left: 4px; vertical-align: middle; flex: none; }
.hint-pop { display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 260px; max-width: min(260px, calc(100vw - 24px));
  background: var(--ink); color: #fff; font: 400 12px/1.45 Inter, sans-serif; padding: 10px 12px; border-radius: 10px; z-index: 40;
  text-align: left; white-space: normal; box-shadow: 0 8px 24px rgba(5,11,31,.25); pointer-events: none; }
.hint-pop::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--ink); }
.hint:hover .hint-pop, .hint:focus .hint-pop, .hint:focus-within .hint-pop { display: block; }
/* у правого края экрана — выравниваем всплывашку влево, чтобы не уезжала за viewport */
.hint.hint-end .hint-pop { left: auto; right: 0; transform: none; }
.hint.hint-end .hint-pop::after { left: auto; right: 8px; transform: none; }
.hint.hint-below .hint-pop { bottom: auto; top: calc(100% + 8px); }
.hint.hint-below .hint-pop::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ink); }
.demo-bar { background: linear-gradient(135deg, #2F6BFF, #7B6CFF); color: #fff; border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; }
.demo-bar .btn { background: #fff; color: var(--accent); border-color: #fff; }

/* инструкция */
.help-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.help-toc { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 2px; }
.help-toc a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.help-toc a:hover { background: #fff; color: var(--accent); }
.help-sec { scroll-margin-top: 20px; margin-bottom: 16px; }
.help-sec p, .help-sec li { line-height: 1.6; }
.help-sec h2 { display: flex; align-items: center; gap: 10px; }
.help-sec h2 .btn { margin-left: auto; }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #EDF1F9; }
.check-row .box { width: 22px; height: 22px; border-radius: 6px; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; background: #DCE3F2; }
.check-row.done .box { background: var(--ok); }
.flow { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; margin: 12px 0; }
.flow > div { flex: 1; min-width: 150px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.flow > div b { display: block; margin-bottom: 4px; color: var(--accent); }
.flow > i { align-self: center; color: var(--muted); font-style: normal; }
.cmd { display: grid; grid-template-columns: 260px 1fr; gap: 6px 14px; }
.cmd code { background: var(--paper); padding: 2px 6px; border-radius: 6px; }
.score-bar { height: 10px; background: #EEF1F8; border-radius: 6px; overflow: hidden; margin: 6px 0; position: relative; }
.score-bar div { height: 100%; background: var(--accent); }
.score-bar::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .4; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.examples button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 10px; font: 12px Inter, sans-serif; cursor: pointer; color: var(--muted); }
.examples button:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 1000px) { .help-grid { grid-template-columns: 1fr; } .help-toc { position: static; } }
