:root {
  --bg: #0a0e14;
  --panel: #111723;
  --panel-2: #172031;
  --line: #222c3d;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --teal: #2ee6c5;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --green: #34d399;
  --red: #f43f5e;
  --blue: #60a5fa;
  --radius: 14px;
  --topbar: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { font-family: 'Space Grotesk', system-ui, sans-serif; margin: 0; }

/* ---------- topo ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 20;
  display: flex; align-items: center; gap: 20px; padding: 0 18px;
  background: rgba(10, 14, 20, 0.92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font: 800 18px 'Space Grotesk'; letter-spacing: 0.06em; }
.brand small { font: 600 11px Inter; color: var(--teal); letter-spacing: 0.1em; text-transform: uppercase; }
.logo { width: 22px; height: 22px; border: 3px solid var(--teal); border-radius: 4px; box-shadow: 0 0 12px var(--teal); }
.tabs { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--teal); color: #04221d; }
.hud-kpis { display: flex; gap: 18px; margin-left: auto; }
.kpi { display: flex; flex-direction: column; line-height: 1.15; }
.kpi span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi b { font: 700 18px 'Space Grotesk'; }
.kpi.accent b { color: var(--amber); }
.speed { display: flex; gap: 4px; }
.speed button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; color: var(--muted); }
.speed button.active { border-color: var(--teal); color: var(--teal); }

/* ---------- views ---------- */
main { position: fixed; inset: var(--topbar) 0 0 0; }
.view { position: absolute; inset: 0; display: none; }
.view.active { display: block; }
#game-canvas { position: absolute; inset: 0; }
#game-canvas canvas { display: block; }
.game-feed {
  position: absolute; left: 16px; bottom: 60px; width: 290px; max-height: 210px; overflow: hidden;
  background: rgba(10, 14, 20, 0.82); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; pointer-events: none;
}
.game-feed h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(10, 14, 20, 0.8); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.link { background: none; border: 0; color: var(--teal); padding: 0; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- feed ---------- */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-size: 12.5px; }
.feed-list li::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; background: var(--teal); }
.feed-list li.good::before { background: var(--green); }
.feed-list li.bad::before { background: var(--red); }
.feed-list li.warn::before { background: var(--amber); }
.feed-list time { color: var(--muted); flex: none; }

/* ---------- gaveta ---------- */
.drawer {
  position: fixed; top: calc(var(--topbar) + 12px); right: 12px; bottom: 12px; width: min(420px, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; z-index: 30;
  transform: translateX(110%); transition: transform 0.25s ease; overflow-y: auto; padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.drawer.open { transform: none; }
.drawer .close { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 26px; color: var(--muted); }
.drawer h2 { font-size: 22px; margin-bottom: 4px; }
.drawer h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.drawer .card { margin-top: 12px; }
.detail-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.detail-head p { margin: 0; color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #0a0e14; font: 700 16px 'Space Grotesk'; flex: none; }
.avatar.big { width: 58px; height: 58px; font-size: 24px; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06), 0 0 24px var(--c); }
.model { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-top: 4px; }
.mission { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.status { margin: 8px 0; color: var(--muted); }
.status.busy { color: var(--text); }
.status.busy::before { content: '● '; color: var(--c, var(--teal)); }
.rules { margin: 0; padding-left: 18px; }
.rules li { margin: 4px 0; }
.actions { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #04221d; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.facts div { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.facts span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 85%; padding: 7px 11px; border-radius: 14px; font-size: 13px; }
.msg.lead { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.msg.agent { align-self: flex-end; background: rgba(46, 230, 197, 0.16); border: 1px solid rgba(46, 230, 197, 0.35); border-bottom-right-radius: 4px; }
.msg.owner { align-self: flex-end; background: rgba(251, 191, 36, 0.16); border: 1px solid rgba(251, 191, 36, 0.4); }
.msg.owner small { display: block; color: var(--amber); font-weight: 700; }
.msg.system { align-self: center; color: var(--muted); font-size: 12px; background: none; }

/* ---------- aprovações ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 25; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--amber); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 0 30px rgba(251, 191, 36, 0.25); animation: pop 0.3s ease; }
.toast-title { font-weight: 700; color: var(--amber); margin-bottom: 6px; }
.toast .approval { border: 0; padding: 0; margin: 0; background: none; }
.approval { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.07); border-radius: 12px; margin: 10px 0; }
.approval p { margin: 2px 0; }
.approval small { color: var(--muted); }
.approval .actions { margin: 6px 0 0; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* ---------- painel (site) ---------- */
#view-site { overflow-y: auto; }
.site { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; display: flex; flex-direction: column; gap: 16px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; padding: 6px 0 8px; }
.hero h1 { font-size: 30px; max-width: 700px; line-height: 1.15; }
.eyebrow { margin: 0 0 6px; color: var(--teal); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; font-size: 12px; }
.onair { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 700; }
.onair.on { color: #fff; background: var(--red); border-color: var(--red); box-shadow: 0 0 24px rgba(244, 63, 94, 0.5); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.7; } }
.kpis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat b { display: block; font: 700 28px 'Space Grotesk'; margin: 4px 0; }
.stat small { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h3 { font-size: 17px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h4 { margin: 16px 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar.big { height: 16px; margin: 10px 0 4px; }
.bar i { display: block; height: 100%; border-radius: 999px; transition: width 0.4s; }
i.teal { background: var(--teal); } i.violet { background: var(--violet); } i.amber { background: var(--amber); } i.green { background: var(--green); }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.frow { display: grid; grid-template-columns: 100px 1fr 40px; gap: 12px; align-items: center; }
.frow b { text-align: right; font: 700 16px 'Space Grotesk'; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 5px 12px; }
.chip b { margin-left: 4px; }
.badge { font: 700 11px Inter; padding: 3px 9px; border-radius: 999px; }
.badge.amber { background: var(--amber); color: #2a1a00; }
.badge.red { background: var(--red); color: #fff; }
.row-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.money { color: var(--green); white-space: nowrap; }
.agents { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.agent-card { background: var(--panel-2); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: 12px; padding: 14px; }
.agent-head { display: flex; gap: 10px; align-items: center; }
.agent-head small { display: block; color: var(--muted); }
.agent-head .model { margin-left: auto; align-self: flex-start; }
.agent-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td small { display: block; color: var(--muted); font-size: 12px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel-2); }
.r { text-align: right; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); }
.pill.teal { color: var(--teal); background: rgba(46, 230, 197, 0.12); }
.pill.violet { color: var(--violet); background: rgba(167, 139, 250, 0.14); }
.pill.amber { color: var(--amber); background: rgba(251, 191, 36, 0.14); }
.pill.green { color: var(--green); background: rgba(52, 211, 153, 0.14); }
.pill.red { color: var(--red); background: rgba(244, 63, 94, 0.14); }
.pill.gray { color: var(--muted); }
.temp { font-size: 11px; font-weight: 700; margin-left: 4px; }
.temp.t0 { color: var(--blue); } .temp.t1 { color: var(--amber); } .temp.t2 { color: var(--red); }
.slot { display: flex; gap: 14px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); margin-bottom: 8px; border: 1px solid transparent; }
.slot b { color: var(--teal); min-width: 100px; font-family: 'Space Grotesk'; }
.slot small { display: block; color: var(--muted); }
.slot.live { border-color: var(--red); background: rgba(244, 63, 94, 0.08); }
.slot.live b { color: var(--red); }
.inv { display: grid; grid-template-columns: 1fr 90px 42px; gap: 10px; align-items: center; padding: 6px 0; }
.inv b { text-align: right; color: var(--green); }
.inv b.out { color: var(--red); }
.goal b { font: 700 28px 'Space Grotesk'; margin-right: 8px; }
.goal span { color: var(--muted); }
.checks { list-style: none; padding: 0; margin: 12px 0 0; }
.checks li { padding: 4px 0; }
.checks li::before { content: '☐ '; color: var(--muted); }
.checks li.ok::before { content: '✔ '; color: var(--green); }
.kpi { white-space: nowrap; }
@media (max-width: 1180px) { .kpi.minor { display: none; } }
.kpi .clock { color: var(--teal); font-variant-numeric: tabular-nums; }
.kpi.alert b { color: var(--red); animation: blink 1s steps(2) infinite; }
.wait-card { border-color: rgba(244, 63, 94, 0.35); }
.wait-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); margin-top: 8px; cursor: pointer; border: 1px solid transparent; }
.wait-row .face { font-size: 22px; text-align: center; }
.wait-row small { display: block; color: var(--muted); }
.wait-row .bar { height: 6px; margin-top: 6px; }
.wait-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.wait-side b { font: 700 18px 'Space Grotesk'; color: var(--red); }
.wait-row.lvl0 .wait-side b { color: var(--muted); }
.wait-row.lvl3, .wait-row.lvl4 { border-color: rgba(244, 63, 94, 0.4); }
.wait-row.lvl5 { border-color: var(--red); background: rgba(244, 63, 94, 0.1); }
.wait-alert { border-color: rgba(244, 63, 94, 0.6); background: rgba(244, 63, 94, 0.08); }
.small { font: 400 12px Inter; }
.kommo-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--blue); background: rgba(96, 165, 250, 0.1); border: 1px solid rgba(96, 165, 250, 0.3); border-radius: 6px; padding: 2px 8px; margin: 2px 0 8px; }
.kommo-card { border-color: rgba(96, 165, 250, 0.35); }
.grid-2.inner { margin-top: 8px; gap: 24px; }
.inv b.plain { color: var(--muted); }
i.red { background: var(--red); }
.emptyval { color: var(--muted); font-style: italic; font-weight: 400; }
.kommo-log { list-style: none; padding: 0; margin: 0; border-left: 2px solid rgba(96, 165, 250, 0.4); }
.kommo-log li { padding: 4px 0 4px 12px; font-size: 12.5px; }
.kommo-log time { color: var(--muted); margin-right: 8px; }
.sparks { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.sparks i { flex: 1; background: var(--violet); border-radius: 3px 3px 0 0; }
.sparks i.slow { background: var(--red); }

@media (max-width: 900px) {
  .hud-kpis { display: none; }
  .game-feed { display: none; }
  .brand small { display: none; }
  .hint { font-size: 11px; white-space: normal; text-align: center; width: calc(100% - 32px); border-radius: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
}
@media (max-width: 560px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand { font-size: 0; gap: 0; }
  .tabs { margin-left: auto; }
  .tabs button { padding: 6px 10px; white-space: nowrap; }
  .speed button:not([data-action='pause']):not([data-id='4']) { display: none; }
}

/* ---------- alarme de incêndio ---------- */
.fire-banner { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 8px 16px; border-radius: 999px; background: #7f1d1d; color: #fff; font-weight: 600; font-size: 13px; text-align: center; display: none; box-shadow: 0 0 30px rgba(239, 68, 68, 0.6); animation: alarmText 0.6s steps(2) infinite; z-index: 5; }
#view-game.alarm .fire-banner { display: block; }
#view-game::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0); transition: box-shadow 0.3s; }
#view-game.alarm::after { animation: alarm 0.9s ease-in-out infinite; }
@keyframes alarm { 0%, 100% { box-shadow: inset 0 0 40px 6px rgba(239, 68, 68, 0.15); } 50% { box-shadow: inset 0 0 120px 30px rgba(239, 68, 68, 0.55); } }
@keyframes alarmText { 50% { background: #b91c1c; } }
.fire-row { border-color: #ea580c !important; background: rgba(234, 88, 12, 0.12) !important; }

/* ---------- modo ao vivo e login ---------- */
.mode-chip { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; white-space: nowrap; }
.mode-live .mode-chip { color: var(--green); border-color: rgba(52, 211, 153, 0.4); }
.mode-chip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 4px; box-shadow: 0 0 8px var(--green); animation: blink 1.4s steps(2) infinite; }
.logout { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; color: var(--muted); font-size: 12px; }
.mode-live .logout { display: block; }
.mode-live .speed { display: none; }
.warn-text { color: var(--amber); display: block; font-size: 12px; }
.login { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(5, 8, 12, 0.82); backdrop-filter: blur(6px); padding: 16px; }
.login.open { display: grid; }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card h2 { font-size: 24px; }
.login-card p { margin: 0; }
.login-card input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--text); font: inherit; }
.login-card input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.login-msg { color: var(--teal); min-height: 1em; font-size: 13px; }
.brand.big { font-size: 20px; }
a.btn { text-decoration: none; display: inline-block; }
@media (max-width: 560px) { .mode-chip { display: none; } }

/* ---------- logo Blackframe ---------- */
.logo-bf { height: 28px; width: auto; color: #fff; display: block; flex: none; }
.brand.big .logo-bf { height: 40px; }
.brand { gap: 12px; }
@media (max-width: 560px) { .logo-bf { height: 22px; } }
.local-dev .logout { display: none; }
.local-dev .mode-chip i { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* ---------- seletor de andar ---------- */
.floor-switch { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 6; }
.floor-switch button { width: 108px; padding: 10px 12px; text-align: left; border-radius: 12px; border: 1px solid var(--line); background: rgba(10, 14, 20, 0.86); color: var(--muted); display: flex; flex-direction: column; line-height: 1.2; backdrop-filter: blur(6px); }
.floor-switch button span { font: 700 15px 'Space Grotesk'; color: var(--text); }
.floor-switch button small { font-size: 11px; }
.floor-switch button.active { border-color: var(--teal); box-shadow: 0 0 18px rgba(46, 230, 197, 0.25); }
.floor-switch.alert button[data-id='porao'] small { color: var(--red); font-weight: 700; }
.floor-switch.alert button[data-id='porao']:not(.active) { border-color: rgba(244, 63, 94, 0.6); }
.floor-porao .game-feed { opacity: 0.85; }
@media (max-width: 900px) { .floor-switch { top: auto; bottom: 70px; right: 12px; transform: none; flex-direction: row; } .floor-switch button { width: auto; } }

.kpi.money-risk b { color: var(--amber); font-size: 20px; }
.kpi.money-risk.alert-soft b { color: #fb7185; }
