/* ════════════════════════════════════════════════════════════════════════
   Painel Contabilidade ZX Control — design system ZX Control (DESIGN-TOKENS.md).
   Estética: console de missão crítica — dark quase-preto, âmbar como único
   acento ativo, JetBrains Mono pra dados. NUNCA inventar cor/fonte fora daqui.
   ════════════════════════════════════════════════════════════════════════ */
:root {
  --primary: #D97706;
  --primary-light: #F59E0B;
  --primary-bright: #FCD34D;
  --primary-dark: #92400E;
  --bg: #0D0D0D;
  --bg-alt: #0A0A0A;
  --surface: #1A1A1A;
  --surface2: #222222;
  --border: #2A2A2A;
  --border-light: #333333;
  --text: #E2E8F0;
  --text-secondary: #9CA3AF;
  --muted: #6B7280;
  --green: #4ADE80;
  --red: #EF4444;
  --indigo: #818CF8;
  --radius: 10px;
  --radius-card: 14px;
  --ui: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary-light); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ── Eyebrow / kicker ── */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--primary);
}

/* ── Login ── */
#login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(217, 119, 6, 0.13), transparent 60%), var(--bg-alt);
}
.login-card {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  padding: 32px 28px;
}
.login-card h1 {
  font-family: var(--mono);
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 8px 0 2px;
}
.login-card .sub { color: var(--text-secondary); font-size: 13px; margin-bottom: 22px; }

/* ── Header sticky ── */
header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(13, 13, 13, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
header.top h1 {
  font-family: var(--mono);
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
header.top h1::after { content: "_"; color: var(--primary); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); display: inline-block; }
.spacer { flex: 1; }
.userbox { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }

/* ── Nav pills ── */
nav.tabs { display: flex; gap: 6px; padding: 14px 22px 0; flex-wrap: wrap; }
nav.tabs button {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
nav.tabs button.active {
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--primary-bright);
}
nav.tabs { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 2px; }

/* ── Dashboard / Início ── */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat-card {
  text-align: left; cursor: pointer; padding: 18px 20px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s, transform 0.1s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-num { font-family: var(--mono); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: 12px; color: var(--text-secondary); }
.stat-card.c-red    { border-top: 3px solid var(--red); }
.stat-card.c-red    .stat-num { color: var(--red); }
.stat-card.c-amber  { border-top: 3px solid var(--primary-light); }
.stat-card.c-amber  .stat-num { color: var(--primary-light); }
.stat-card.c-green  { border-top: 3px solid var(--green); }
.stat-card.c-green  .stat-num { color: var(--green); }
.stat-card.c-indigo { border-top: 3px solid var(--indigo); }
.stat-card.c-indigo .stat-num { color: var(--indigo); }

/* ── Filtro inline ── */
.inline-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.inline-check input { width: auto; }
.inline-check span { display: inline; }
.obs { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

main { padding: 20px 22px 60px; max-width: 1160px; margin: 0 auto; }
.section-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; margin: 4px 0 16px; }

/* ── Cards de agente ── */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-card h3 { margin: 0; font-size: 0.98rem; }
.agent-card p { margin: 0; color: var(--text-secondary); font-size: 12.5px; min-height: 34px; }
.agent-num { font-family: var(--mono); font-size: 11px; color: var(--primary); }

/* ── Botões ── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #0d0d0d; font-weight: 700; }
.btn-primary:hover { background: var(--primary-light); }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, 0.45); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.row-actions { display: flex; gap: 6px; }

/* ── Tabelas ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  background: var(--bg-alt);
  text-align: left;
  padding: 10px 14px;
}
td { padding: 11px 14px; font-size: 13px; color: var(--text-secondary); border-top: 1px solid var(--border); }
td:first-child { color: var(--text); font-weight: 500; }
tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.012); }
tbody tr:hover { background: rgba(217, 119, 6, 0.045); }
/* Linha inteira tintada por urgência (a agenda salta aos olhos) */
tr.row-vencido td { background: rgba(239, 68, 68, 0.09); }
tr.row-vencido td:first-child { box-shadow: inset 3px 0 0 var(--red); color: #fecaca; }
tr.row-alerta td { background: rgba(245, 158, 11, 0.07); }
tr.row-alerta td:first-child { box-shadow: inset 3px 0 0 var(--primary-light); }
tr.row-inativo { opacity: 0.5; }
.toolbar { display: flex; align-items: center; margin-bottom: 14px; gap: 10px; }
.toolbar .spacer { flex: 1; }

/* ── Badges ── */
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.ok, .badge.aberta, .badge.pendente { background: rgba(74, 222, 128, 0.1); color: var(--green); border-color: rgba(74, 222, 128, 0.3); }
.badge.alerta { background: rgba(245, 158, 11, 0.12); color: var(--primary-light); border-color: rgba(245, 158, 11, 0.32); }
.badge.vencido, .badge.falhou { background: rgba(239, 68, 68, 0.1); color: var(--red); border-color: rgba(239, 68, 68, 0.3); }
.badge.cumprido, .badge.fechada { background: rgba(255, 255, 255, 0.05); color: var(--muted); border-color: var(--border-light); }
.badge.regime { background: rgba(129, 140, 248, 0.1); color: var(--indigo); border-color: rgba(129, 140, 248, 0.3); }

/* ── Inputs ── */
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em; color: var(--text-secondary); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 11px;
  font-family: var(--ui);
  font-size: 13px;
}
input.mono, select { font-family: var(--mono); }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: 540px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-card);
  padding: 22px; animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { transform: translateY(8px); opacity: 0; } }
.modal h3 { margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ── Saída de agente (terminal-like) ── */
.output {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; font-size: 13px; white-space: pre-wrap; line-height: 1.6; margin-top: 14px;
}
.output .disclaimer { display: block; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light); color: var(--primary-light); font-family: var(--mono); font-size: 11.5px; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 18px; right: 18px; background: var(--surface2);
  border: 1px solid rgba(217, 119, 6, 0.5); border-radius: var(--radius);
  padding: 11px 16px; font-size: 13px; z-index: 80; opacity: 0; transform: translateY(8px);
  transition: all 0.2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
.empty { color: var(--muted); font-size: 13px; padding: 22px; text-align: center; }

/* ── Spinner âmbar ── */
.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px; margin-right: 6px;
  border: 2px solid rgba(217, 119, 6, 0.25); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
