:root {
  --paper: #fff9ee; --white: #fff; --indigo: #24135f; --indigo-deep: #170b45; --ink-soft: #4a3d7a; --ink-muted: #6e6396;
  --line: rgba(36, 19, 95, .13); --line-strong: rgba(36, 19, 95, .25); --marigold: #ffb01f; --peacock: #0a7d78;
  --leaf: #1f8a4c; --chilli: #c92a1b; --butter: #fff1c7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--indigo); font-size: 15px; line-height: 1.45; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px;
  background: var(--indigo-deep); color: var(--white); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.brand b { color: var(--marigold); font-weight: 800; }
.emblem { width: 22px; height: 22px; border: 2px solid var(--marigold); transform: rotate(45deg); border-radius: 3px; }
#topRight { display: flex; align-items: center; gap: 12px; font-size: 14px; }
main { padding: 20px; max-width: 1100px; margin: 0 auto; outline: none; }
h1 { font-size: 24px; margin: 4px 0 6px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin-bottom: 14px; }
.narrow { max-width: 440px; margin: 40px auto; }
.cols { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 14px; }
.kpi .n { font-size: 26px; font-weight: 800; }
.kpi .l { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.muted { color: var(--ink-muted); font-size: 13px; }
.err { color: var(--chilli); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.spacer { flex: 1; }
button, .btn { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer; background: var(--indigo); color: var(--white); min-height: 42px; }
button.ghost { background: var(--white); color: var(--indigo); border: 1px solid var(--line-strong); }
button.good { background: var(--leaf); }
button.danger { background: var(--chilli); }
button.small { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: 10px; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
input, textarea, select { font: inherit; border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; background: var(--white); color: var(--indigo); width: 100%; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 700; font-size: 13px; margin: 10px 0 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin: 0; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; background: var(--white); }
.checks input { width: auto; margin: 0; }
.checks label.on { background: var(--indigo); color: var(--white); border-color: var(--indigo); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { background: var(--white); color: var(--indigo); border: 1px solid var(--line-strong); min-height: 36px; padding: 6px 14px; }
.tabs button.on { background: var(--indigo); color: var(--white); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #efeaf8; }
.pill.ok { background: #d8f1e3; color: #145c30; } .pill.warn { background: var(--butter); color: #6b4a00; } .pill.bad { background: #ffe0db; color: #8a1d0e; }
.banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; background: var(--butter); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 800; user-select: none; }
.switch .track { width: 54px; height: 30px; border-radius: 999px; background: #cfc8e3; position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--white); transition: left .2s; }
.switch.on .track { background: var(--leaf); }
.switch.on .track::after { left: 27px; }
.switch.disabled { opacity: .5; cursor: default; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #b8b0cf; margin-right: 6px; vertical-align: 1px; }
.dot.online { background: var(--leaf); } .dot.busy { background: var(--marigold); }
.request { border: 2px solid var(--marigold); background: #fffaf0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 176, 31, .25); } }
@media (prefers-reduced-motion: reduce) { .request { animation: none; } }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; min-height: 220px; overflow-y: auto; padding: 4px 2px 8px; }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; }
.bubble.me { align-self: flex-end; background: var(--indigo); color: var(--white); border-bottom-right-radius: 5px; }
.bubble.them { align-self: flex-start; background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.sys { align-self: center; background: transparent; color: var(--ink-muted); font-size: 13px; }
.bubble time { display: block; font-size: 11px; opacity: .65; margin-top: 2px; }
.composer { display: flex; gap: 8px; margin-top: 8px; }
.composer textarea { min-height: 46px; height: 46px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-muted); font-weight: 600; }
.kv dd { margin: 0; }
.video { display: grid; gap: 8px; grid-template-columns: 2fr 1fr; margin-bottom: 10px; }
.video > div { background: #0d0726; border-radius: 12px; aspect-ratio: 4 / 3; overflow: hidden; position: relative; }
.video span { position: absolute; left: 8px; bottom: 6px; color: #fff; font-size: 12px; font-weight: 700; z-index: 2; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); }
.avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 2px solid var(--marigold); background: #efeaf8; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--indigo); color: var(--white);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--chilli); }
ul.rules { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
ul.rules li { margin-bottom: 4px; }
