:root {
  --bg: #0E141B; --side: #121A23; --panel: #16202B; --panel2: #1A2532; --line: #243142; --line2: #2F3E50;
  --text: #E6EDF3; --soft: #D3DCE5; --muted: #9AA8B6; --link: #8CC0FF;
  --amber: #F2B544; --green: #4CC38A; --greenText: #7EE2B0; --red: #F07167; --redText: #F4A39C;
  --go: #2B7A55; --reg: #8A6A16; --conf: #3B4757; --lic: #8E2F28;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--link); } a:hover { color: #B9D8FF; }
h1, h2 { font-family: "Space Grotesk", Inter, system-ui, sans-serif; font-weight: 600; margin: 0; }
h1 { font-size: 26px; } h2 { font-size: 17px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2); background: transparent; cursor: pointer; }
button:hover { border-color: #4A5868; }
button.primary { background: var(--amber); color: #1A1206; border: 0; font-weight: 600; }
button.ok { background: var(--green); color: #08140E; border: 0; font-weight: 600; }
button.danger { color: var(--redText); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 9px 11px; min-height: 40px; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
nav.side { flex: 1 1 210px; max-width: 230px; background: var(--side); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { padding: 0 8px 20px; } .brand b { font-family: "Space Grotesk", sans-serif; letter-spacing: .08em; font-size: 14px; display: block; } .brand span { font-size: 12px; color: var(--muted); }
nav.side a { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 12px; border-radius: 8px; color: #C3CEDA; text-decoration: none; }
nav.side a.on { background: #1E2A38; color: var(--text); font-weight: 600; }
.pill { border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; display: inline-block; }
.pill.amber { background: var(--amber); color: #1A1206; } .pill.green { background: #13261D; color: var(--greenText); }
.pill.red { background: #3A1A17; color: var(--redText); } .pill.grey { background: #1E2A38; color: #C3CEDA; } .pill.blue { background: #16314F; color: #A9D0FF; }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }

main { flex: 999 1 560px; min-width: 0; padding: 26px 30px 60px; display: flex; flex-direction: column; gap: 22px; }
header.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.sub { color: var(--muted); }
.mode { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.mode.test { background: #16314F; color: #A9D0FF; } .mode.live { background: #13261D; color: var(--greenText); } .mode.paused { background: #3A1A17; color: var(--redText); }

.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi small { color: var(--muted); font-size: 12px; display: block; } .kpi b { font: 600 26px "Space Grotesk", sans-serif; }
.row { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.row > .wide { flex: 999 1 520px; min-width: 0; } .row > .narrow { flex: 1 1 320px; min-width: 0; max-width: 480px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.card > .head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card > .body { padding: 14px 16px; }
.empty { color: var(--muted); padding: 16px; }
.bots { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.bot { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bot .t { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-weight: 600; }
.bot .n { color: var(--soft); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.bot .w { color: var(--muted); font: 12px "IBM Plex Mono", ui-monospace, monospace; }
.list > div { padding: 12px 16px; border-bottom: 1px solid #1F2B39; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.list > div:last-child { border-bottom: 0; }
.list .grow { flex: 1 1 300px; min-width: 0; }
.list .grow b { display: block; } .list .grow span { color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat { display: flex; flex-direction: column; height: 520px; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: #1E2A38; border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: #24476E; border-bottom-right-radius: 4px; }
.msg small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.chat form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.feed { list-style: none; margin: 0; padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 8px; font: 12px/1.5 "IBM Plex Mono", ui-monospace, monospace; max-height: 520px; overflow-y: auto; }
.feed li { display: flex; gap: 10px; } .feed .tm { color: var(--muted); flex: none; } .feed .who { color: var(--link); flex: none; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 500; padding: 9px 14px; }
td { padding: 10px 14px; border-top: 1px solid #1F2B39; vertical-align: top; }
.scroll { overflow-x: auto; }
.tiles { display: grid; grid-template-columns: repeat(11, minmax(40px, 1fr)); grid-template-rows: repeat(8, 46px); gap: 6px; min-width: 520px; }
.tile { border-radius: 8px; font: 600 13px "Space Grotesk", sans-serif; padding: 0; min-height: 0; border: 1px solid transparent; color: #F2FFF8; }
.tile.go { background: var(--go); } .tile.register_first { background: var(--reg); } .tile.confirm { background: var(--conf); } .tile.license_first { background: var(--lic); }
.tile.operating { outline: 2px solid var(--amber); outline-offset: -2px; } .tile.sel { border: 2px solid #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #C3CEDA; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
dl.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; margin: 0; } dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.stages { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border-bottom: 1px solid #1F2B39; flex-wrap: wrap; }
.switch:last-child { border-bottom: 0; }
.switch p { margin: 4px 0 0; color: var(--muted); max-width: 560px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login img { background: #fff; padding: 10px; border-radius: 8px; width: 200px; height: 200px; align-self: center; }
.err { color: var(--redText); font-size: 13px; min-height: 18px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1E2A38; border: 1px solid var(--line2); padding: 12px 16px; border-radius: 10px; max-width: 360px; }
@media (max-width: 720px) { main { padding: 18px 14px 50px; } nav.side { max-width: none; } }
