/* Sala de controle: azul-noite com três sinais tirados do jogo (esmeralda = ok, lápis = ação, redstone = perigo). */
:root {
  --bg: #080d19; --bg2: #0b1222; --surface: #101a30; --raised: #16233f; --line: #22314f; --line2: #30456f;
  --text: #e7eeff; --muted: #8b9cc4; --faint: #5d6e98;
  --lapis: #5b8cff; --lapis-d: #3d66d8; --emerald: #2fd69b; --redstone: #ff5748; --amber: #ffbf3c;
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --r: 14px; color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef2fa; --bg2: #e4eaf6; --surface: #ffffff; --raised: #f3f6fd; --line: #d5ddee; --line2: #b9c6e2;
    --text: #131c33; --muted: #52618a; --faint: #8392b6;
    --lapis: #2f5fe0; --lapis-d: #2349b8; --emerald: #0f9d6e; --redstone: #d83a2c; --amber: #b87400;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
code { font-family: var(--mono); font-size: .92em; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--lapis); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
input, select {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus { border-color: var(--lapis); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lapis) 25%, transparent); }
button { cursor: pointer; border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; background: none; transition: background .15s, border-color .15s, transform .05s; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--lapis); color: #fff; font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--lapis-d); }
.ghost { border-color: var(--line2); background: var(--raised); }
.ghost:hover:not(:disabled) { border-color: var(--lapis); }
.danger-ghost { border-color: color-mix(in srgb, var(--redstone) 55%, var(--line)); color: var(--redstone); background: color-mix(in srgb, var(--redstone) 8%, transparent); }
.danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--redstone) 18%, transparent); }
.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.wide { width: 100%; padding: 11px; }
.grow { flex: 1; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--lapis) 14%, transparent), transparent), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px 26px 26px; display: flex; flex-direction: column; gap: 6px; }
.login-mark { height: 30px; margin-bottom: 10px; }
.mark-svg { height: 100%; fill: none; stroke: var(--emerald); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.login-card h1 { font-size: 22px; }
.login-sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-card input { width: 100%; }
.pw { display: flex; gap: 8px; align-items: center; }
.login-err { margin: 8px 0 0; color: var(--redstone); font-size: 14px; }
.login-card .primary { margin-top: 16px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--faint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--faint) 22%, transparent); flex: none; }
.brand-dot.ok { background: var(--emerald); box-shadow: 0 0 0 4px color-mix(in srgb, var(--emerald) 22%, transparent); }
.brand-dot.warn { background: var(--amber); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 22%, transparent); }
.brand-dot.bad { background: var(--redstone); box-shadow: 0 0 0 4px color-mix(in srgb, var(--redstone) 22%, transparent); }
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font: 12px var(--mono); color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; color: var(--muted); border-radius: 10px; }
.nav button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav button:hover { background: var(--raised); color: var(--text); }
.nav button.on { background: var(--raised); color: var(--text); box-shadow: inset 3px 0 0 var(--emerald); }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; }
.whoami { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

.main { padding: 22px 28px 40px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.top-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top h2 { font-size: 22px; }
.power { display: flex; gap: 8px; }
.pill { font-size: 13px; padding: 3px 11px; border-radius: 99px; border: 1px solid var(--line2); background: var(--raised); color: var(--muted); }
.pill.ok { color: var(--emerald); border-color: color-mix(in srgb, var(--emerald) 45%, var(--line)); }
.pill.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.pill.bad { color: var(--redstone); border-color: color-mix(in srgb, var(--redstone) 45%, var(--line)); }

.view { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hint { font-size: 13px; color: var(--faint); margin-top: 8px; }
.unit { color: var(--muted); font-size: 14px; margin-left: 6px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; }

/* ---------- pulso (assinatura) ---------- */
.pulse-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.pulse-sub { font-size: 13px; color: var(--faint); margin-top: 2px; }
.pulse-val { display: flex; align-items: baseline; }
.pulse-val .mono { font-size: 40px; font-weight: 300; letter-spacing: -.03em; line-height: 1; }
.pulse { width: 100%; height: 104px; display: block; margin-top: 12px; overflow: visible; }
.pulse .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; }
.pulse .sig { fill: none; stroke: var(--emerald); stroke-width: 2.4; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.pulse .dip { fill: none; stroke: var(--redstone); stroke-width: 2.6; vector-effect: non-scaling-stroke; }
.pulse .area { fill: color-mix(in srgb, var(--emerald) 10%, transparent); stroke: none; }
.pulse-axis { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--faint); margin-top: 6px; }

.kpi-val { display: flex; align-items: baseline; margin-top: 6px; }
.kpi-val .mono { font-size: 30px; font-weight: 300; letter-spacing: -.02em; }
.kpi-note { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 20px; overflow-wrap: anywhere; }
.bar { height: 6px; border-radius: 6px; background: var(--raised); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--lapis); border-radius: 6px; transition: width .5s; }
.bar i.warn { background: var(--amber); } .bar i.bad { background: var(--redstone); } .bar i.ok { background: var(--emerald); }
.spark { width: 100%; height: 70px; display: block; margin-top: 10px; }
.spark path.l { fill: none; stroke: var(--lapis); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark path.a { fill: color-mix(in srgb, var(--lapis) 14%, transparent); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 12px 0 0; }
.facts dt { color: var(--muted); font-size: 14px; } .facts dd { margin: 0; }

/* ---------- console ---------- */
.console-card { display: flex; flex-direction: column; gap: 12px; }
.console-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.console {
  background: #050913; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; height: min(58vh, 560px);
  overflow: auto; font: 12.5px/1.55 var(--mono); color: #c8d4f0; overflow-wrap: anywhere;
}
@media (prefers-color-scheme: light) { .console { background: #0f1830; } }
.ln { white-space: pre-wrap; }
.ln .t { color: #566796; margin-right: 8px; }
.ln.WARN { color: var(--amber); } .ln.ERROR, .ln.FATAL { color: var(--redstone); }
.ln.chat { color: #9ed0ff; } .ln.cmd { color: var(--emerald); }
.console-input { display: flex; gap: 8px; align-items: center; }
.prompt { color: var(--emerald); font: 18px var(--mono); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: 12.5px var(--mono); padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line2); color: var(--muted); }
.chip:hover { color: var(--text); border-color: var(--lapis); }

/* ---------- chat ---------- */
.chat-card { display: flex; flex-direction: column; gap: 14px; }
.chat-feed { height: min(56vh, 540px); overflow: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.msg { display: flex; gap: 10px; align-items: baseline; }
.msg .who { font-weight: 600; flex: none; color: hsl(var(--h, 200) 70% 70%); }
@media (prefers-color-scheme: light) { .msg .who { color: hsl(var(--h, 200) 60% 36%); } }
.msg .body { overflow-wrap: anywhere; }
.msg .when { margin-left: auto; font: 12px var(--mono); color: var(--faint); flex: none; }
.msg.sys { color: var(--faint); font-size: 13px; }
.msg.panel .who { color: var(--amber); }
.empty { color: var(--faint); text-align: center; padding: 36px 8px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; align-self: flex-start; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: var(--raised); color: var(--text); box-shadow: inset 0 -2px 0 var(--lapis); }
.seg input:focus-visible + span { outline: 2px solid var(--lapis); outline-offset: -2px; }
.chat-form { display: flex; flex-direction: column; gap: 6px; }
.chat-form .inline-form { margin-top: 0; }
.chat-form .hint { margin: 0; text-align: right; font-family: var(--mono); }

/* ---------- jogadores / tabelas ---------- */
.plist { display: flex; flex-direction: column; margin-top: 10px; }
.prow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.prow:first-child { border-top: 0; }
.avatar { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font: 600 15px var(--mono); color: #06101f; flex: none; }
.pname { font-weight: 600; min-width: 120px; }
.pacts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.table { display: flex; flex-direction: column; margin-top: 12px; }
.trow { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); align-items: center; }
.trow:first-child { border-top: 0; }
.trow .a { overflow-wrap: anywhere; } .trow .b, .trow .c { color: var(--muted); font: 13px var(--mono); }
.trow.audit { grid-template-columns: 150px 130px 1fr; }
.tag { font: 12px var(--mono); padding: 2px 8px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); }

/* ---------- dialogo e avisos ---------- */
.dlg { border: 1px solid var(--line2); border-radius: 16px; background: var(--surface); color: var(--text); padding: 22px; width: min(420px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(3, 6, 14, .66); backdrop-filter: blur(3px); }
.dlg h3 { font-size: 18px; } .dlg p { color: var(--muted); margin: 8px 0 14px; }
.dlg input { width: 100%; margin-bottom: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dlg-actions .danger { background: var(--redstone); color: #fff; font-weight: 600; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100% - 36px)); }
.toast { background: var(--raised); border: 1px solid var(--line2); border-left: 3px solid var(--lapis); border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: rise .18s ease-out; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--emerald); } .toast.bad { border-left-color: var(--redstone); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- mobile ---------- */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding-bottom: 68px; }
  .side { position: fixed; z-index: 20; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-between; }
  .nav button { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 11px; flex: 1; align-items: center; }
  .nav button.on { box-shadow: inset 0 3px 0 var(--emerald); }
  .main { padding: 16px 14px 28px; }
  .cols { grid-template-columns: 1fr; }
  .top { align-items: flex-start; }
  .trow.audit { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 460px) {
  .kpis { grid-template-columns: 1fr; }
  .pulse-val .mono { font-size: 32px; }
}
