:root {
  --bg: #0f1115;
  --panel: #171b22;
  --line: #2a3140;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --red: #c8102e;
  --red-2: #e11d48;
  --gold: #e8b84a;
  --ok: #22c55e;
  --warn: #f59e0b;
  --info: #38bdf8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.top {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: #12151b;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--red), #7f0a1c); font-weight: 800; letter-spacing: .04em;
}
.brand h1 { margin: 0; font-size: 16px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.operador { display: grid; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.operador input, .toolbar input, .toolbar select, label input, label select, label textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.operador input { width: 180px; }
.kv-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted);
}
.kv-pill.ok { color: #86efac; border-color: #14532d; background: #052e16; }
.kv-pill.bad { color: #fda4af; border-color: #7f1d1d; background: #3b0a14; }
.banner {
  margin: 12px 20px 0; padding: 10px 14px; border-radius: 10px;
  border: 1px solid #7f1d1d; background: #3b0a14; color: #fecaca;
}
.operador strong { display: block; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 14px; }
.login-gate {
  position: fixed; inset: 0; background: rgba(8,10,14,.82); display: grid; place-items: center;
  z-index: 30; padding: 20px;
}
.login-gate[hidden],
.login-card[hidden] {
  display: none !important;
}
.login-card {
  width: min(420px, 100%); background: #151922; border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; display: grid; gap: 12px;
}
.login-card h2 { margin: 0; }
.login-card p { margin: 0; color: var(--muted); }
.login-card .mark { width: 42px; height: 42px; }
.users-table { margin: 0 18px 18px; max-height: 320px; }
#usersModal { width: min(820px, 96vw); }
#usersModal form { padding-bottom: 0; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; padding: 16px 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 22px; }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi.p1 b { color: var(--red-2); }
.kpi.p2 b { color: var(--gold); }
.kpi.done b { color: var(--ok); }

.toolbar { display: flex; gap: 8px; padding: 0 20px 12px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { min-width: 260px; flex: 1; }
.toolbar select { min-width: 170px; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); }

.table-wrap { overflow: auto; margin: 0 20px; border: 1px solid var(--line); border-radius: 12px; max-height: calc(100vh - 320px); }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #1c222c; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: #1b2029; }
.nome { font-weight: 600; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.p1 { background: #3b0a14; color: #fda4af; }
.badge.p2 { background: #3b2d0a; color: #fde68a; }
.badge.p3 { background: #0b2236; color: #7dd3fc; }
.badge.ok { background: #052e16; color: #86efac; }
.badge.warn { background: #3b2a08; color: #fcd34d; }
.badge.pend { background: #1f2430; color: #cbd5e1; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px 24px; color: var(--muted); }

.btn { border: 1px solid var(--line); background: #222833; border-radius: 8px; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.btn:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--red); border-color: #9f0e24; font-weight: 700; }
.btn.danger { color: #fda4af; }
.icon { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
.cell-copy { display: inline-flex; align-items: center; gap: 6px; }
.copy-btn {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 22px; height: 22px; min-width: 22px;
  border: 1px solid #4b5568; background: #1f2937; color: #e5e7eb;
  border-radius: 5px; cursor: pointer; padding: 0; line-height: 1;
}
.copy-btn:hover { color: #fff; border-color: #93c5fd; background: #1e3a5f; }
.m-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; }
.meta-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

dialog { border: 1px solid var(--line); background: #151922; color: var(--text); border-radius: 16px; padding: 0; width: min(640px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog form { padding: 18px; display: grid; gap: 12px; }
dialog header { display: flex; justify-content: space-between; align-items: start; }
dialog h2 { margin: 0; font-size: 18px; }
.meta { color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: grid; gap: 6px; }
textarea { resize: vertical; }
dialog footer { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }

#toast {
  position: fixed; bottom: 18px; right: 18px; background: #111827; border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .top { flex-direction: column; align-items: stretch; }
  .grid { grid-template-columns: 1fr; }
}
