:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1c222d;
  --line: #262d3a;
  --line-soft: #1f2632;
  --text: #e6eaf2;
  --muted: #8b95a8;
  --dim: #5e687a;
  --accent: #3b82f6;
  --accent-soft: #1e3a8a33;
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --purple: #a855f7;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────── */
#login {
  height: 100vh; display: grid; place-items: center;
  background: radial-gradient(ellipse at top, #1a2233 0%, var(--bg) 60%);
}
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px;
}
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; margin-top: 20px; background: var(--accent); color: #fff;
  padding: 11px; border-radius: 8px; font-weight: 600;
}
.login-card button:hover { background: #2f6fdd; }
.err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── Layout ──────────────────────────────────────────────── */
#app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }

header {
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px; height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; }
.brand span { color: var(--accent); }
.spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.pill.live { color: var(--green); }
.pill.warn { color: var(--yellow); }
.pill.off  { color: var(--dim); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

.btn {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 7px; font-size: 13px; color: var(--text);
}
.btn:hover { background: #232a37; border-color: #333c4d; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #2f6fdd; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--red); }

/* ── Abas ────────────────────────────────────────────────── */
nav {
  display: flex; align-items: center; gap: 2px;
  padding: 0 16px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
nav button {
  padding: 9px 14px; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav button:hover { color: var(--text); }
nav button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
nav .count {
  display: inline-block; margin-left: 6px; font-size: 11px;
  background: var(--panel-2); border-radius: 999px; padding: 1px 7px; color: var(--muted);
}
nav button.active .count { background: var(--accent); color: #fff; }
nav .count.alert { background: var(--red); color: #fff; }

main { overflow: hidden; min-height: 0; }
.view { height: 100%; overflow: auto; }
.view.split { display: grid; grid-template-columns: 400px 1fr; overflow: hidden; }

/* ── Fila ────────────────────────────────────────────────── */
.queue { border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg); }
.queue-tools {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
  display: flex; gap: 8px;
}
.queue-tools input, .queue-tools select {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 10px; font-size: 13px; outline: none;
}
.queue-tools input { flex: 1; min-width: 0; }
.queue-tools input:focus, .queue-tools select:focus { border-color: var(--accent); }

.qitem {
  padding: 11px 13px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; border-left: 3px solid transparent;
}
.qitem:hover { background: var(--panel); }
.qitem.sel { background: var(--panel-2); border-left-color: var(--accent); }
.qitem-top { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.qitem-text { font-size: 13px; line-height: 1.45; margin-bottom: 5px; }
.qitem-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); }
.qitem-title { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; white-space: nowrap;
}
.tag.acc  { background: #1e293b; color: #94a3b8; }
.tag.auto { background: #14532d; color: #86efac; }
.tag.ok   { background: #14532d; color: #86efac; }
.tag.mid  { background: #422006; color: #fcd34d; }
.tag.low  { background: #450a0a; color: #fca5a5; }
.tag.human{ background: #3b0764; color: #d8b4fe; }
.tag.new  { background: #1e3a8a; color: #93c5fd; }

.age { font-variant-numeric: tabular-nums; }
.age.ok { color: var(--green); }
.age.warn { color: var(--yellow); }
.age.late { color: var(--orange); }
.age.crit { color: var(--red); font-weight: 700; }

.empty { padding: 48px 24px; text-align: center; color: var(--dim); font-size: 13px; }

/* ── Detalhe ─────────────────────────────────────────────── */
.detail { overflow-y: auto; padding: 20px 24px 40px; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.detail-head h2 { font-size: 15px; font-weight: 600; line-height: 1.4; }
.detail-head .sub { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
}
.card h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin-bottom: 10px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.question-text { font-size: 15px; line-height: 1.6; }

.suggest-box { border-color: #2a3550; background: linear-gradient(180deg, #182034 0%, var(--panel) 100%); }
.suggest-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.confidence-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 8px 0 10px; }
.confidence-bar > i { display: block; height: 100%; border-radius: 2px; transition: width .3s; }

textarea#answer {
  width: 100%; min-height: 120px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; line-height: 1.6; outline: none;
}
textarea#answer:focus { border-color: var(--accent); }
.answer-tools { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.charcount { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.charcount.over { color: var(--red); font-weight: 600; }

.macro-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.macro-chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.macro-chip:hover { border-color: var(--accent); color: var(--text); }

.hist { border-top: 1px solid var(--line-soft); padding: 10px 0; }
.hist:first-of-type { border-top: none; padding-top: 0; }
.hist .q { font-size: 13px; color: var(--muted); }
.hist .a { font-size: 13px; margin-top: 4px; padding-left: 12px; border-left: 2px solid var(--line); }

.warnbox {
  background: #3b0764; border: 1px solid #6b21a8; color: #e9d5ff;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
  display: flex; gap: 9px; align-items: flex-start;
}

kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; font-size: 11px; font-family: inherit; color: var(--muted);
}

/* ── Métricas ────────────────────────────────────────────── */
.metrics { padding: 20px 24px 48px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 27px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.8px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 11.5px; color: var(--dim); }
.kpi.excelente .value { color: var(--green); }
.kpi.bom .value { color: #7dd3fc; }
.kpi.atencao .value { color: var(--yellow); }
.kpi.critico .value { color: var(--red); }

.sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:hover td { background: var(--panel); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.chart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12.5px; }
.bar-row .name { width: 130px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; height: 18px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar-row .track > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-row .val { width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ── Formulários ─────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 220px 1fr; gap: 14px 18px; align-items: start; max-width: 820px; }
.form-grid label { font-size: 13px; padding-top: 8px; }
.form-grid label small { display: block; color: var(--dim); font-size: 11.5px; font-weight: 400; margin-top: 2px; }
.form-grid input[type=text], .form-grid input[type=time], .form-grid input[type=number],
.form-grid select, .form-grid textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 11px; outline: none;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 9px; padding-top: 8px; font-size: 13px; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.daybtns { display: flex; gap: 5px; padding-top: 5px; }
.daybtn { width: 36px; height: 32px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.daybtn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 100;
  box-shadow: 0 8px 28px #0008;
}
.toast.ok { border-color: var(--green); }
.toast.bad { border-color: var(--red); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2b3444; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a4557; }
::-webkit-scrollbar-track { background: transparent; }
