:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #172029;
  --border: #222c37;
  --border-2: #2c3845;
  --text: #e4e9ef;
  --muted: #8593a3;
  --faint: #5a6878;
  --accent: #22c55e;
  --accent-ink: #06240f;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --violet: #a78bfa;
  --gray: #64748b;
  --radius: 8px;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: #22c55e44; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.layout > div { min-width: 0; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: #22c55e18; color: var(--accent); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a .pill { margin-left: auto; }
.nav-sep { margin: 12px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; font-size: 12px; color: var(--muted); }
.sidebar-foot .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.main { min-width: 0; padding: 22px 28px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mobile-top { display: none; }

/* ---------- Componentes ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--panel-2); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #3a4858; background: #1c2732; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #fca5a5; border-color: #7f1d1d; background: #2a1215; }
.btn.danger:hover { background: #3a1519; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.icon { width: 28px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }

.input, select.input, textarea.input { height: 34px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border-2); background: #0e141a; outline: none; min-width: 0; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #22c55e22; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.kpi { padding: 14px 16px; cursor: default; }
.kpi[data-go] { cursor: pointer; }
.kpi[data-go]:hover { border-color: var(--border-2); }
.kpi .lab { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 500; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 2fr 1fr; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.st-em_uso { background: #22c55e1a; color: #4ade80; border-color: #22c55e33; }
.st-sem_uso { background: #64748b1f; color: #a3b0bf; border-color: #64748b33; }
.st-offline { background: #f59e0b1a; color: #fbbf24; border-color: #f59e0b33; }
.st-manutencao { background: #3b82f61a; color: #60a5fa; border-color: #3b82f633; }
.st-banido { background: #ef44441a; color: #f87171; border-color: #ef444433; }
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 600; }
.pill.red { background: #ef444425; color: #f87171; }
.pill.green { background: #22c55e22; color: #4ade80; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px #22c55e2a; }
.dot.ban { background: var(--red); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.red { color: #f87171; }
.green { color: #4ade80; }
.amber { color: #fbbf24; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--panel); user-select: none; }
.t th.sort { cursor: pointer; }
.t th.sort:hover { color: var(--text); }
.t th .arr { color: var(--accent); }
.t td { padding: 9px 12px; border-bottom: 1px solid #1a222b; vertical-align: middle; }
.t tbody tr:hover td { background: #141c25; }
.t tr.sel td { background: #22c55e0d; }
.t tr:last-child td { border-bottom: 0; }
.t .name-link { font-weight: 600; cursor: pointer; text-decoration: none; }
.t .name-link:hover { color: var(--accent); }
.t input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .input { height: 32px; }
.search { position: relative; }
.search .input { padding-left: 30px; width: 230px; }
.search::before { content: '⌕'; position: absolute; left: 10px; top: 50%; transform: translateY(-52%); color: var(--faint); font-size: 16px; }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; background: #22c55e12; border-bottom: 1px solid #22c55e33; }
.bulkbar b { color: var(--accent); }

.secret { display: inline-flex; align-items: center; gap: 4px; }
.secret .val { font-family: var(--mono); font-size: 12.5px; min-width: 64px; }
.copy-btn { border: 0; background: transparent; color: var(--faint); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-size: 13px; line-height: 1; }
.copy-btn:hover { color: var(--text); background: var(--panel-2); }
.cbtn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--faint); cursor: pointer; vertical-align: middle; flex: none; transition: background .12s, color .12s, transform .08s; }
.cbtn:hover { background: var(--panel-2); color: var(--text); }
.cbtn:active { transform: scale(.9); }
.cbtn.ok { color: var(--accent); background: #22c55e22; }
.cbtn svg { display: block; pointer-events: none; }
.name-link + .cbtn { opacity: 0; }
tr:hover .name-link + .cbtn, .drawer-h .name-link + .cbtn, .cbtn.ok { opacity: 1; }
.drawer-h .cbtn { opacity: .6; }
.drawer-h .cbtn:hover { opacity: 1; }

/* ---------- Quadro (kanban) ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 300px; max-height: calc(100vh - 170px); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.col-h .bar { width: 4px; height: 16px; border-radius: 2px; }
.col-b { padding: 8px; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; flex: 1; }
.col.drag-over { border-color: var(--accent); background: #22c55e08; }
.kcard { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 7px; padding: 9px 10px; cursor: grab; }
.kcard:hover { border-color: #3d4c5c; }
.kcard.dragging { opacity: .4; }
.kcard .n { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.kcard .m { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.kcard .warn { color: #fbbf24; font-size: 11.5px; margin-top: 4px; }

/* ---------- Pipeline de criação ---------- */
.pipe { display: grid; grid-template-columns: repeat(4, minmax(252px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.pcard { cursor: default; }
.pcard .n { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.pcard .m { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.fld { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 12.5px; }
.fld .k { color: var(--faint); width: 52px; flex: none; }
.fld .v { display: flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.fld .v .mono { overflow-wrap: anywhere; }
@media (max-width: 820px) { .pipe { grid-template-columns: 1fr; } }

/* ---------- Máquinas ---------- */
.machines { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.mstats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.mstats b { color: var(--text); font-variant-numeric: tabular-nums; }
.vm-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid #1a222b; cursor: pointer; }
.vm-row:hover { background: #141c25; }
.vm-row .nm { font-weight: 500; flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Modal / Drawer ---------- */
.overlay { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px #0008; }
.modal.wide { width: min(760px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-b { padding: 16px 18px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field .input { width: 100%; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.drawer-bg { position: fixed; inset: 0; background: #0007; z-index: 40; animation: fade .12s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--border-2); z-index: 41; overflow-y: auto; animation: slide .16s ease-out; }
.drawer-h { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.drawer-h h2 { margin: 0; font-size: 19px; display: flex; align-items: center; gap: 9px; }
.drawer-sec { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.drawer-sec h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.status-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.status-pick .badge { cursor: pointer; height: 28px; padding: 0 11px; opacity: .55; }
.status-pick .badge:hover { opacity: .85; }
.status-pick .badge.cur { opacity: 1; outline: 2px solid currentColor; outline-offset: 1px; }
.ban-box { background: #ef444414; border: 1px solid #ef444440; color: #fca5a5; border-radius: 7px; padding: 10px 12px; font-size: 13px; }
.list-compact { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.list-compact .it { display: flex; gap: 10px; }
.list-compact .it .when { color: var(--faint); white-space: nowrap; font-size: 12px; min-width: 92px; }

.feed { display: flex; flex-direction: column; }
.feed .it { display: flex; gap: 10px; padding: 8px 16px; border-top: 1px solid #1a222b; font-size: 13px; align-items: baseline; }
.feed .it:first-child { border-top: 0; }
.feed .when { color: var(--faint); font-size: 12px; white-space: nowrap; min-width: 70px; }
.act { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.act.banido_detectado, .act.excluido, .act.morte, .act.nao_encontrado { background: #ef44441f; color: #f87171; }
.act.level_up, .act.criado, .act.ficou_online, .act.ban_removido { background: #22c55e1a; color: #4ade80; }
.act.status, .act.movido { background: #3b82f61a; color: #60a5fa; }
.act.ficou_offline, .act.level_down { background: #f59e0b1a; color: #fbbf24; }

#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel-2); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 7px; min-width: 220px; max-width: 380px; box-shadow: 0 8px 30px #0007; animation: slide-up .15s; }
.toast.err { border-left-color: var(--red); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at top, #22c55e14, transparent 60%), var(--bg); }
.login { width: min(370px, 100%); padding: 28px; }
.login .brand { justify-content: center; padding-bottom: 22px; }
.login .field { margin-bottom: 12px; }
.login .btn { width: 100%; justify-content: center; height: 38px; margin-top: 6px; }
.err-msg { color: #f87171; font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }

.spark { display: block; width: 100%; height: 60px; }
.spark path.l { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark path.a { fill: #22c55e18; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes slide-up { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 1100px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; width: 250px; transform: translateX(-100%); transition: transform .18s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 60px #000c; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px 16px 60px; }
  .search .input { width: 100%; }
  .search { flex: 1 1 100%; }
  .form { grid-template-columns: 1fr; }
  .machines { grid-template-columns: 1fr; }
}
