/* Painel gestor — claro, denso, uma tabela só.
 * Cor aqui tem função de estado (em dia / vencida / suspensa / sem contato);
 * o resto é grafite sobre branco para a leitura de 30 linhas caber na tela.
 */
:root {
  --ink: #14181d;
  --ink-soft: #4c5764;
  --line: #d5dbe2;
  --line-strong: #b6bfc9;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --accent: #1d4ed8;
  --danger: #a4262c;
  --ok: #14532d;
  --warn: #7a4b00;
}

* { box-sizing: border-box; }

/* [hidden] perde de display:grid/flex sem esta regra — a tela de login ficava
   atrás do painel depois de entrar. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { margin: 2px 0 4px; font-size: 24px; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }

.eyebrow { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-soft); }
.sub { margin: 0; color: var(--ink-soft); }
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── login ── */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login-box h1 { font-size: 20px; }
.login-sub { color: var(--ink-soft); margin: 6px 0 18px; }

/* ── topo ── */
.page { padding: 20px clamp(14px, 3vw, 34px) 40px; }
.top { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); }

.banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; background: #eef2f7; border: 1px solid var(--line); }
.banner.error { background: #fbe9e9; border-color: #e5b6b8; color: #7f1d1d; }

/* ── faixa de métricas (linha, não grade de cards) ── */
.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0 26px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.metric { display: flex; align-items: baseline; gap: 6px; }
.metric b { font-size: 18px; font-variant-numeric: tabular-nums; }
.metric span { color: var(--ink-soft); font-size: 12px; }

/* ── filtros ── */
.filters { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer;
}
.chip i { font-style: normal; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on i { color: #dfe4ea; }
.chip:focus-visible, .btn:focus-visible, .sort:focus-visible, .help:focus-visible, .search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.search input { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; min-width: 220px; }

/* ── tabela ── */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid thead th { position: sticky; top: 0; background: #fbfcfd; z-index: 1; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.arrow { font-size: 10px; margin-left: 4px; }
th.active .sort { color: var(--ink); font-weight: 600; }
tbody tr:hover { background: #f9fafb; }
tfoot .totals td { font-weight: 600; background: #fbfcfd; border-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.stack small { color: var(--ink-soft); font-size: 12px; }
.stack small.warn {
  color: var(--danger);
  /* mensagem longa não pode esticar a linha: o resto está no "?" */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 24ch;
}
.actions, .row-actions { white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.empty { color: var(--ink-soft); padding: 18px 2px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.pill.active { background: #e7f4ea; color: var(--ok); border-color: #b9dfc2; }
.pill.past_due { background: #fdf1dc; color: var(--warn); border-color: #e8cf9b; }
.pill.suspended { background: #fbe9e9; color: #7f1d1d; border-color: #e5b6b8; }
.pill.cancelled { background: #ececf1; color: #3f3f46; border-color: #cbcbd4; }
.pill.offline, .pill.unknown { background: #e8eef7; color: #1e3a5f; border-color: #bccfe6; }
.pill.reading { background: #f2f4f8; color: #3f3f46; border-color: #cbcbd4; border-style: dashed; }

/* ── botões ── */
.btn { padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.btn:hover { background: #f2f4f7; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #262c34; }
.btn.danger { color: var(--danger); border-color: #d9a2a5; }
.btn.ghost { border-color: transparent; color: var(--ink-soft); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── modal largo ── */
.overlay { position: fixed; inset: 0; background: rgba(14, 18, 24, 0.42); display: grid; place-items: start center; padding: 32px 16px; overflow: auto; z-index: 40; }
.modal { width: min(1040px, 100%); background: var(--surface); border-radius: 12px; border: 1px solid var(--line); }
.modal header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.note { margin: 0; color: var(--ink-soft); }
.warn { margin: 8px 0 0; color: var(--danger); }
.block .kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 22px; }
.kv-item { display: flex; flex-direction: column; gap: 1px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv-item span { font-size: 12px; color: var(--ink-soft); }
table.inner { width: 100%; border-collapse: collapse; }
table.inner th, table.inner td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.inner thead th { color: var(--ink-soft); font-weight: 600; }

/* ── formulário ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 20px; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); }
.fld input, .fld select, .fld textarea { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; color: var(--ink); background: var(--surface); }
.msg { min-height: 18px; margin: 6px 0 0; font-size: 13px; }
.msg.error { color: var(--danger); }

/* ── "?" com balão fixo: absoluto dentro da tabela com overflow rolling some ── */
.help { width: 17px; height: 17px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); font-size: 11px; line-height: 1; cursor: help; }
.help-bubble { position: fixed; z-index: 60; max-width: 330px; background: #14181d; color: #f4f6f8; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.4; }
.help-bubble strong { display: block; margin-bottom: 3px; }
.help-bubble p { margin: 0; color: #dbe1e8; }
