:root {
  --ink: #101410;
  --rail: #0c0f0c;
  --panel: #171c18;
  --panel-2: #212922;
  --line: #314038;
  --text: #e8f2e6;
  --muted: #93a396;
  --lamp: #dff56a;
  --lamp-ink: #1a2208;
  --amber: #ffc14d;
  --red: #ff6b4a;
  --violet: #c9a6ff;
  --sea: #8fd0c6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
  font-family: "Segoe UI Variable Text", "Segoe UI", "Avenir Next", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.hidden { display: none !important; }
code, .mono { font-family: "Cascadia Code", Consolas, monospace; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 50% 0%, rgba(223, 245, 106, 0.16), transparent 32%),
    var(--ink);
}
.gate form {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.gate h1 { margin: 12px 0 8px; font-size: 42px; letter-spacing: -0.04em; }
.gate p { margin: 0 0 22px; color: var(--muted); }
.lamp-hero {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 0 18px var(--lamp);
}

.shell { min-height: 100vh; display: grid; grid-template-columns: 112px 1fr; }
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 18px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.mark { display: grid; justify-items: center; gap: 6px; margin-bottom: 18px; }
.mark strong { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; }
.mark-lamp { width: 14px; height: 14px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 12px var(--lamp); }
.rail nav { display: grid; gap: 4px; }
.rail button {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 14px; padding: 9px 6px; text-align: center; font-size: 12px;
}
.rail button.active, .rail button:hover { background: var(--panel); color: var(--text); }

.workspace { min-width: 0; padding: 22px 28px 48px; }
.top { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.company { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.office { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.pill {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--lamp); box-shadow: 0 0 8px var(--lamp); }
.dot.off { background: var(--red); }

.banner {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: #2a2414; border: 1px solid #6d5a28; color: var(--amber);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 16px;
}
.banner .row, .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat, .card, .ticket, .editor, .dialer {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
}
.stat { padding: 14px 16px; }
button.stat { font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer; }
.stat.open { border-color: var(--lamp); }
.stat b { display: block; font-size: 28px; letter-spacing: -0.04em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat-detail { margin-bottom: 16px; }
.stat-list { display: grid; gap: 8px; margin-top: 12px; }
.stat-row { display: grid; gap: 2px; text-align: left; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); color: inherit; font: inherit; }
.stat-row span { color: var(--muted); font-size: 13px; }

.layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.board-kicker { margin: 16px 0 8px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.lamp {
  text-align: left; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 18px; padding: 12px; min-height: 108px; position: relative;
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
}
.lamp-open {
  display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 0; color: inherit;
}
.lamp-end { padding: 6px 10px; font-size: 13px; flex: none; }
.lamp .call-status { font-size: 12px; line-height: 1.35; color: var(--amber); font-weight: 650; }
.lamp-call { flex-direction: column; align-items: stretch; gap: 6px; }
.lamp-call .lamp-end { width: 100%; }
.lamp.selected { outline: 2px solid var(--lamp); }
.lamp.open { border-color: var(--lamp); }
.lamp.in-call { border-color: var(--red); }
.call-rows { display: grid; gap: 8px; margin-top: 8px; }
.call-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.card-detail { margin-top: 12px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.card-detail h2 { margin: 0; font-size: 20px; }
.card-detail h3 { margin: 14px 0 6px; font-size: 15px; }
.facts { display: grid; gap: 8px; margin-top: 12px; }
.facts div { display: grid; grid-template-columns: 140px 1fr; gap: 8px; }
.facts span { color: var(--muted); }
.facts strong { font-weight: 550; overflow-wrap: anywhere; }
.bulb {
  width: 12px; height: 12px; border-radius: 50%; background: #445246; display: inline-block;
}
.lamp .num { font-family: "Cascadia Code", Consolas, monospace; font-size: 18px; display: block; margin-top: 10px; }
.lamp .name, .muted { color: var(--muted); }
.lamp .meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.lamp .phone { display: block; margin-top: 4px; font-size: 12px; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.presence-phone .bulb, .presence-both .bulb { background: var(--lamp); box-shadow: 0 0 10px var(--lamp); }
.presence-console .bulb { background: var(--sea); }
.presence-ringing .bulb { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.presence-busy .bulb { background: var(--red); }
.presence-dnd .bulb { background: var(--violet); }
.presence-ringing { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { border-color: var(--amber); } }

.dialer { padding: 16px; position: sticky; top: 16px; }
.dialer h2, .section-title { margin: 0 0 8px; font-size: 18px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  width: 100%; background: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; outline: none;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--lamp); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 12px; }
.pad button, .solid, .ghost {
  border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); background: var(--panel-2);
}
.solid { background: var(--lamp); color: var(--lamp-ink); border-color: transparent; font-weight: 650; }
.ghost.danger { color: var(--red); }
.full { width: 100%; }

.tickets { display: grid; gap: 10px; margin-top: 16px; }
.ticket { padding: 14px 16px; display: grid; gap: 8px; }
.ticket header, .spread { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.phase { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.trace { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.menu-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 14px; }
.try-call form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.try-call label { display: grid; gap: 4px; min-width: 140px; font-size: 13px; color: var(--muted); }
.try-call input, .try-call select { color: var(--text); min-width: 160px; }
.workspace section + section { margin-top: 28px; }
.help, .journal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
.sheet-tools { justify-content: flex-end; }
.sheet-preview { margin-bottom: 16px; }
.sheet-preview .table-wrap { max-height: 420px; overflow: auto; margin: 10px 0; }
.sheet-preview tr.sheet-problem td { color: var(--red); }
.journal { font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; white-space: pre-wrap; max-height: 360px; overflow: auto; }
.help-layout { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.help-layout > * { min-width: 0; }
.help-index { display: grid; gap: 10px; position: sticky; top: 12px; }
.help-index h2 { margin: 0; font-size: 18px; }
.help-link {
  display: grid; gap: 4px; text-align: left; padding: 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-decoration: none;
}
.help-link span { color: var(--muted); font-size: 13px; }
.help-link.active { border-color: var(--lamp); }
.guide { max-width: 900px; padding: 20px 26px; }
.guide h2 { margin: 4px 0 12px; font-size: 26px; }
.guide h3 { margin: 26px 0 8px; font-size: 19px; color: var(--lamp); }
.guide h4 { margin: 18px 0 6px; font-size: 16px; }
.guide p, .guide li { color: var(--text); }
.guide li + li { margin-top: 6px; }
.guide code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: 0.9em; overflow-wrap: anywhere; }
.guide pre { background: var(--rail); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; overflow-x: auto; }
.guide pre code { background: none; border: 0; padding: 0; }
.guide .table-wrap { margin: 10px 0 14px; }
.guide a { color: var(--sea); }
@media (max-width: 760px) { .help-layout { grid-template-columns: 1fr; } .help-index { position: static; } }
.report-filters { margin-bottom: 16px; }
.report-filters .toolbar { margin-bottom: 4px; }
.report-filters .ghost.active { border-color: var(--lamp); color: var(--text); }
.report-sheet { transition: opacity 0.15s; }
.report-sheet.loading { opacity: 0.5; }
.report-head h2 { margin: 0 0 4px; font-size: 22px; }
.report-head p { margin: 0 0 4px; }
.report-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-top: 12px; }
.report-stats .stat b { font-size: 22px; }
.report-table th.num, .report-table td.num, .report-table td:first-child { text-align: right; white-space: nowrap; }
.report-table td:first-child { text-align: left; }
.report-table tfoot th { border-top: 2px solid var(--line); text-align: right; }
.report-table tfoot th:first-child { text-align: left; }
.report-bar { display: inline-block; height: 10px; min-width: 2px; border-radius: 4px; background: var(--lamp); vertical-align: middle; }
@media print {
  body:has(.print-area, .guide) * { visibility: hidden; }
  body .guide, body .guide *, body .print-area, body .print-area * { visibility: visible; color: #000 !important; }
  .guide, .print-area { position: absolute; left: 0; top: 0; width: 100%; max-width: none; background: #fff; border: 0; }
  .guide #print-guide, .print-area button { display: none; }
  .guide code, .guide pre { background: #f3f3f3; border-color: #ccc; }
  .print-area .stat { background: #fff; border-color: #bbb; }
  .print-area .table-wrap { overflow: visible; border-color: #bbb; }
  .print-area th, .print-area td { border-color: #ccc !important; font-size: 11px; padding: 4px 6px; }
  .print-area .report-bar { background: #555; }
  .print-area .banner { background: #fff; border-color: #999; }
}
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.route-card { margin: 16px 0 22px; }
.route-card h2 { margin: 18px 0 8px; font-size: 18px; }
.route-card h2:first-child { margin-top: 0; }
.trunk-slot { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.trunk-slot span { color: var(--text); font-size: 14px; }
.trunk-slot select { margin: 0; }
.days { display: flex; gap: 8px; flex-wrap: wrap; }
.days label { display: flex; gap: 6px; align-items: center; margin: 0; }

dialog {
  border: 0; padding: 0; background: transparent; width: min(560px, calc(100% - 24px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog form { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 18px; }
dialog header h2 { margin: 0; }
dialog header p { margin: 6px 0 12px; color: var(--muted); }
dialog footer { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
#editor-fields { max-height: min(60vh, 520px); overflow: auto; display: grid; gap: 12px; padding-right: 4px; }
.field { display: grid; gap: 4px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; font-weight: 400; }
label .hint { display: block; }
.stack { display: grid; gap: 16px; }
.spacer { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.check input { width: auto; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 5; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; max-width: 320px; box-shadow: var(--shadow);
}

.empty { color: var(--muted); padding: 28px 8px; }
.phone-grid, .video-grid { display: grid; gap: 16px; }
.phone-grid { grid-template-columns: minmax(260px, 340px) 1fr; }
.stage {
  position: relative; background: #000; border-radius: 18px; min-height: 420px; overflow: hidden;
}
.video-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); min-height: 420px; }
.video-grid figure { margin: 0; position: relative; }
.video-grid video, .local-pip { width: 100%; background: #000; border-radius: 16px; min-height: 180px; object-fit: cover; }
.video-grid figcaption, .stage-caption {
  position: absolute; left: 10px; bottom: 10px; margin: 0; padding: 4px 8px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.55); font-size: 13px;
}
.local-pip {
  position: absolute; right: 12px; bottom: 12px; width: 168px; min-height: 96px; border: 1px solid var(--line); z-index: 1;
}
.stage-caption { position: absolute; left: 12px; top: 12px; bottom: auto; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; margin: 8px 0 24px; }
.meter { height: 10px; border-radius: 99px; background: var(--ink); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--lamp); border-radius: 99px; }
.meter.warn i { background: var(--amber); }
.meter.hot i { background: var(--red); }
.watch-note { border-color: var(--amber); }
.bars i { display: block; flex: 1; background: var(--lamp); border-radius: 6px 6px 0 0; opacity: 0.85; }
audio { width: min(420px, 100%); margin-top: 8px; }
a { color: var(--sea); }
a.ghost { text-decoration: none; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; height: auto; z-index: 2; }
  .rail nav { grid-auto-flow: column; overflow: auto; }
  .mark { display: none; }
  .layout, .stats, .split, .phone-grid, .facts div { grid-template-columns: 1fr; }
  .stats.report-stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .workspace { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .presence-ringing { animation: none; }
}
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0 12px; }
.key-secret { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--lamp); border-radius: 8px; background: #101410; word-break: break-all; }
.msg-log { display: grid; gap: 8px; max-height: 220px; overflow: auto; margin-bottom: 8px; }
.msg-log p { margin: 0; }
.book { display: grid; gap: 6px; max-height: 240px; overflow: auto; margin: 8px 0; }
.book-row { display: flex; gap: 6px; align-items: stretch; }
.book-row > button:first-child {
  flex: 1; display: flex; justify-content: space-between; gap: 8px; align-items: center;
  text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px;
}
.book-row > button:first-child:hover { border-color: var(--lamp); }
.book-row .who { display: grid; min-width: 0; }
.book-row .who span { color: var(--muted); font-size: 12px; }
.book-row .mono { color: var(--sea); font-size: 13px; white-space: nowrap; }
body.embed .rail, body.embed #sign-out, body.embed .banner { display: none; }
body.embed .shell { grid-template-columns: 1fr; }
.doc { max-width: 820px; margin: 0 auto; padding: 36px 24px 80px; }
.doc h1 { margin: 8px 0 12px; letter-spacing: -0.04em; font-size: 40px; }
.doc h2 { margin: 36px 0 8px; font-size: 22px; }
.doc p, .doc li { color: var(--text); }
.doc .lead { color: var(--muted); font-size: 18px; }
.doc pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; overflow: auto; line-height: 1.4;
}
.doc table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; }
.doc th, .doc td { text-align: left; border-bottom: 1px solid var(--line); padding: 8px 10px 8px 0; vertical-align: top; }
.doc th { color: var(--muted); font-weight: 600; }
.doc nav { margin-top: 28px; }
