/* ============================================================================
   Obelisco · Painel de Controle — estilos (tema claro, vanilla)
   Paleta alinhada ao Obelisco ("azul"). Sem dependencias externas.
   Escala COMPACTA/delicada: densidade de console admin (Linear/Vercel).
   ============================================================================ */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-soft: #475569;
  --muted: #64748b;
  --accent: #1e5fbf;      /* azul Obelisco */
  --accent-600: #184e9e;
  --accent-050: #eaf1fc;
  --ok: #157347;
  --ok-bg: #e5f4ec;
  --warn: #a15c07;
  --warn-bg: #fbf1e0;
  --danger: #b42318;
  --danger-bg: #fbeae8;
  --neutral-bg: #eef1f6;
  --shadow: 0 1px 1px rgba(15,23,42,.04), 0 2px 8px rgba(15,23,42,.05);
  --radius: 8px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* garante que [hidden] esconde de fato (classes com display: flex derrotavam o hidden nativo) */
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.muted { color: var(--muted); }
.hint { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 24px; height: 24px; flex: none;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 11px; box-shadow: 0 3px 10px rgba(15,23,42,.12); }
.brand-txt { display: inline-flex; align-items: baseline; gap: 5px; line-height: 1.15; }
.brand-txt strong { font-size: 13.5px; font-weight: 700; letter-spacing: .2px; }

.topnav { display: flex; gap: 3px; margin-left: 6px; }
.topnav a {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 13px;
}
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.active { background: var(--accent-050); color: var(--accent); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.token-pill {
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ===== Botoes ===== */
.btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }

/* ===== Gate ===== */
.gate {
  position: fixed; inset: 0; z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  /* azul infinito (tema deep-blue do módulo de Tarefas) */
  background:
    radial-gradient(130% 90% at 50% -8%, rgba(18,102,176,.45), transparent 62%),
    linear-gradient(135deg, #021a33 0%, #063a6b 60%, #0a4f8f 100%);
}
.gate-brand {
  position: absolute; top: 16px; left: 20px;
  display: flex; align-items: center; gap: 9px; color: #fff;
}
.gate-brand img { width: 24px; height: 24px; border-radius: 6px; display: block; }
.gate-brand strong { font-size: 13.5px; font-weight: 700; letter-spacing: .2px; display: inline-flex; gap: 5px; }
.brand-sep { opacity: .55; font-weight: 400; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 10px 34px rgba(2,26,51,.28);
  padding: 26px 24px;
  width: 100%;
  max-width: 352px;
  text-align: center;
}
.gate-card h1 { font-size: 17px; margin: 12px 0 4px; }
.gate-card p { text-align: left; font-size: 12.5px; margin: 10px 0 16px; }
.gate-card form { text-align: left; }
.gate-err {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f3c9c4;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  margin-bottom: 11px;
}

/* ===== Campos ===== */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-050);
}
textarea { resize: vertical; min-height: 100px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; }

/* ===== View / layout ===== */
.view { max-width: 1060px; margin: 0 auto; padding: 22px 18px 52px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; margin: 0; }
.page-head .spacer { flex: 1; }
.crumbs { font-size: 12.5px; margin-bottom: 7px; color: var(--muted); }
.crumbs a { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 13.5px; margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 15px; }
.card-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  margin-bottom: 12px;
}
.card-note.warn { background: var(--warn-bg); color: var(--warn); }

/* ===== Tabela ===== */
.table-wrap { width: 100%; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 640px; }
table.grid th, table.grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
table.grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover { background: var(--accent-050); }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid td.num { font-variant-numeric: tabular-nums; }
table.grid tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--neutral-bg); color: var(--text-soft);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ativo { background: var(--ok-bg); color: var(--ok); }
.badge-onboarding { background: var(--accent-050); color: var(--accent); }
.badge-suspenso { background: var(--warn-bg); color: var(--warn); }
.badge-cancelado { background: var(--danger-bg); color: var(--danger); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: var(--neutral-bg); color: var(--muted); }
.badge-err { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* ===== Planos ===== */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.plan-card .card-body { display: flex; flex-direction: column; gap: 8px; }
.plan-lims { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; font-size: 12.5px; }
.plan-mods-title { font-size: 12px; color: var(--muted); margin-top: 5px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: var(--neutral-bg); color: var(--muted); border-radius: 999px; padding: 2px 8px; font-size: 11.5px; }
.chip-premium { background: var(--accent-050); color: var(--accent); font-weight: 600; }
.plan-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-featured { border-color: var(--accent); box-shadow: 0 1px 1px rgba(15,23,42,.05), 0 6px 18px rgba(30,95,191,.10); }
.plan-tag { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--accent-050); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

/* ===== Detalhe: grid de infos ===== */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kv { }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.kv .v { font-size: 13px; word-break: break-word; }
.kv .v.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; }
.tile .t-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.tile .t-value { font-size: 18px; font-weight: 600; margin-top: 3px; }

/* inline row form (OAB) */
.row-form { display: flex; gap: 9px; align-items: flex-end; flex-wrap: wrap; }
.row-form .field { margin-bottom: 0; }
.row-form .field.uf { width: 80px; }
.row-form .field.num { width: 150px; }
.row-form .field.nome { flex: 1; min-width: 160px; }

.inline-form { display: flex; gap: 9px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ===== Estados ===== */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.spin {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-line { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 7px; }

/* ===== Toasts ===== */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 9px; max-width: 340px;
}
.toast {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 13px 10px 30px;
  font-size: 13px;
  animation: toastIn .18s ease;
}
.toast::before {
  content: ""; position: absolute; left: 12px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.toast.ok::before { background: var(--ok); }
.toast.err::before { background: var(--danger); }
.toast.info::before { background: var(--accent); }
.toast strong { display: block; margin-bottom: 1px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15,23,42,.42);
  display: grid; place-items: center;
  padding: 18px;
}
.modal {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(15,23,42,.25);
  width: 100%; max-width: 440px;
  max-height: 88vh; overflow-y: auto;
  padding: 18px 18px 15px;
  animation: toastIn .16s ease;
}
.modal-actions { position: sticky; bottom: -15px; background: var(--surface); padding-top: 11px; margin-top: 4px; }
.modal h3 { margin: 0 0 7px; font-size: 15.5px; }
.modal p { margin: 0 0 16px; color: var(--text-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* ===== Responsivo ===== */
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-txt .brand-sep, .brand-txt strong + strong { display: none; }
  .topnav a { padding: 5px 9px; }
  .token-pill { display: none; }
  .view { padding: 16px 12px 44px; }
  .row-form .field.uf, .row-form .field.num { width: 100%; }
}
