:root {
  --bg: #0d0f12;
  --bg2: #13161b;
  --panel: #171b21;
  --panel2: #1d222a;
  --line: #262c36;
  --line2: #323a46;
  --text: #e6e9ee;
  --muted: #8a93a3;
  --dim: #5d6573;
  --accent: #e8a33d;
  --accent2: #f3bd63;
  --green: #3ecf8e;
  --red: #f0575a;
  --blue: #4c9aff;
  --purple: #a78bfa;
  --yellow: #f5c542;
  --radius: 10px;
  --mono: ui-monospace, 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--accent2); }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a303a; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #2a1f0d 0%, transparent 60%), var(--bg); }
.login { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 24px; color: var(--muted); }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #111;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; margin-bottom: 18px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.side { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side .brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; }
.side .brand .brand-mark { width: 34px; height: 34px; font-size: 16px; margin: 0; border-radius: 9px; }
.side .brand b { display: block; font-size: 14px; line-height: 1.1; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .brand small { color: var(--muted); font-size: 12px; }
.nav { overflow-y: auto; padding: 6px 10px 16px; flex: 1; }
.nav .sec { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side .me { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center;
  font-weight: 700; color: var(--accent2); flex: none; }
.side .me .who { flex: 1; min-width: 0; }
.side .me .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.side .me .who small { color: var(--muted); font-size: 12px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { height: 58px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.top h2 { margin: 0; font-size: 17px; font-weight: 650; }
.top .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--panel);
  border: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(62,207,142,.15); }
.dot.off { background: var(--red); }
.content { flex: 1; overflow: auto; padding: 22px 24px 40px; }
.menu-btn { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card > .hd .grow { flex: 1; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 16px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--dim); font-size: 12px; margin-top: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line2);
  background: var(--panel2); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 550;
  font-size: 13px; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #252b35; border-color: #3d4655; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #17120a; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: rgba(240,87,90,.12); border-color: rgba(240,87,90,.4); color: #ff8b8d; }
.btn.danger:hover { background: rgba(240,87,90,.22); }
.btn.good { background: rgba(62,207,142,.1); border-color: rgba(62,207,142,.35); color: #6ee7b0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

.input, select.input, textarea.input { width: 100%; background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 11px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,163,61,.15); }
textarea.input { resize: vertical; min-height: 80px; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; font-weight: 550; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; color: var(--muted); }
.search { max-width: 320px; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #1b2028; }
.t .num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--dim); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 650; background: var(--panel2);
  color: var(--muted); border: 1px solid var(--line2); white-space: nowrap; }
.badge.green { color: #6ee7b0; background: rgba(62,207,142,.1); border-color: rgba(62,207,142,.3); }
.badge.red { color: #ff8b8d; background: rgba(240,87,90,.1); border-color: rgba(240,87,90,.3); }
.badge.yellow { color: var(--yellow); background: rgba(245,197,66,.1); border-color: rgba(245,197,66,.3); }
.badge.blue { color: #8cbcff; background: rgba(76,154,255,.1); border-color: rgba(76,154,255,.3); }
.badge.purple { color: #c4b5fd; background: rgba(167,139,250,.1); border-color: rgba(167,139,250,.3); }

.bar { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; width: 80px; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.bar.armor > i { background: var(--blue); }
.bars { display: grid; gap: 4px; }

/* ---------- drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,6,8,.6); z-index: 40; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--bg2); border-left: 1px solid var(--line);
  z-index: 41; display: flex; flex-direction: column; box-shadow: -30px 0 80px rgba(0,0,0,.4); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer .dh { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.drawer .dh h3 { margin: 0; font-size: 17px; }
.drawer .tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 11px 12px; cursor: pointer; font-weight: 550;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.drawer .db { flex: 1; overflow: auto; padding: 18px 20px 40px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 13px; }
.kv > div:nth-child(even) { word-break: break-all; }
.group-t { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 18px 0 8px; font-weight: 650; }
.group-t:first-child { margin-top: 0; }
.idlist { display: grid; gap: 6px; }
.idlist div { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.idlist div span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(5,6,8,.65); }
.modal { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: pop .14s ease-out; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal .mh { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 15px; display: flex; align-items: center; }
.modal .mb { padding: 18px; overflow: auto; }
.modal .mf { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--green); padding: 10px 14px;
  border-radius: 8px; min-width: 240px; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: pop .15s ease-out; }
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }

/* ---------- tela ao vivo ---------- */
.screens { display: grid; gap: 10px; }
.screens.n1 { grid-template-columns: 1fr; }
.screens.n4 { grid-template-columns: repeat(2, 1fr); }
.screens.n9 { grid-template-columns: repeat(3, 1fr); }
.screens.n16 { grid-template-columns: repeat(4, 1fr); }
.screen { position: relative; background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.screen video, .screen img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.screen .sh { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 6px; align-items: center; padding: 8px;
  background: linear-gradient(rgba(0,0,0,.75), transparent); }
.screen .sh b { font-size: 13px; text-shadow: 0 1px 2px #000; }
.screen .sf { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.8)); font-size: 12px; color: #cfd5de; opacity: 0; transition: opacity .15s; }
.screen:hover .sf { opacity: 1; }
.screen .state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; pointer-events: none; }
.screen .state:empty { display: none; }
.screen .tools { margin-left: auto; display: flex; gap: 4px; }
.screen .tools .btn { background: rgba(20,22,26,.75); backdrop-filter: blur(4px); }
.screen.add { display: grid; place-items: center; background: var(--panel); border-style: dashed; cursor: pointer; color: var(--muted); }
.screen.add:hover { border-color: var(--accent); color: var(--text); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- mapa ---------- */
.map-wrap { position: relative; height: calc(100vh - 160px); min-height: 420px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: #0a1a26; }
.map-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.map-wrap canvas.drag { cursor: grabbing; }
.map-hint { position: absolute; left: 12px; bottom: 12px; }
.map-tip { position: absolute; pointer-events: none; background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; display: none; z-index: 2; }

/* ---------- console / chat ---------- */
.term { background: #08090b; font-family: var(--mono); font-size: 12px; line-height: 1.55; padding: 12px 14px; height: calc(100vh - 230px);
  min-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: var(--radius) var(--radius) 0 0; }
.term .ln .ts { color: #4a5160; margin-right: 8px; }
.term .ln .ch { color: #7c8aa5; margin-right: 6px; }
.term .ln.err { color: #ff8b8d; }
.term .ln.warn { color: var(--yellow); }
.term-in { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--panel); border-radius: 0 0 var(--radius) var(--radius); }
.feed { display: grid; gap: 2px; }
.feed .it { padding: 8px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.feed .it:last-child { border-bottom: 0; }
.feed .it .ts { color: var(--dim); font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- reports ---------- */
.reports { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100vh - 140px); min-height: 460px; }
.rlist { overflow: auto; }
.rlist .r { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.rlist .r:hover { background: #1b2028; }
.rlist .r.on { background: var(--panel2); box-shadow: inset 2px 0 0 var(--accent); }
.chatbox { display: flex; flex-direction: column; min-height: 0; }
.chatbox .msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; padding: 9px 12px; border-radius: 12px; background: var(--panel2); }
.msg.staff { align-self: flex-end; background: rgba(232,163,61,.14); border: 1px solid rgba(232,163,61,.3); }
.msg small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }

.chart { width: 100%; height: 160px; display: block; }
.spark-legend { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; margin-top: 6px; }

.inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.inv .it { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.inv .it b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv .it small { color: var(--muted); }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reports { grid-template-columns: 1fr; height: auto; }
  .screens.n9, .screens.n16 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: 250px; transform: translateX(-100%); transition: transform .18s; }
  .side.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px 14px 40px; }
  .top { padding: 0 14px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .screens.n4, .screens.n9, .screens.n16 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .hide-sm { display: none; }
}
