/* Conexa Report — layout minimalista, azul → lilás sobre branco, com modo escuro */
:root {
  --azul: #3b6cf6;
  --anil: #5b5ff0;
  --lilas: #8b5cf6;
  --lilas-claro: #b8a6fb;
  --grad: linear-gradient(120deg, #3b6cf6 0%, #6a5cf3 55%, #8b5cf6 100%);

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --surface-3: #eef0fa;
  --border: #e5e7f2;
  --border-strong: #d3d6ea;
  --text: #1c1f3a;
  --text-2: #565b7d;
  --text-3: #8a8fae;
  --primary: #5b5ff0;
  --primary-soft: #eef0ff;
  --primary-text: #4347d6;
  --ok: #17915f;
  --ok-soft: #e6f6ef;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --danger: #d63c5e;
  --danger-soft: #fdebef;
  --shadow: 0 1px 2px rgba(28, 31, 58, 0.04), 0 4px 16px rgba(28, 31, 58, 0.06);
  --shadow-lg: 0 20px 60px rgba(28, 31, 58, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 264px;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0e0f1d;
  --surface: #15172a;
  --surface-2: #1b1d34;
  --surface-3: #24274a;
  --border: #272a48;
  --border-strong: #353961;
  --text: #e8e9f7;
  --text-2: #a9acd0;
  --text-3: #7478a0;
  --primary: #8a8cff;
  --primary-soft: #252860;
  --primary-text: #b3b5ff;
  --ok: #4fd39b;
  --ok-soft: #143a2c;
  --warn: #f0b85a;
  --warn-soft: #3c2f16;
  --danger: #ff7d98;
  --danger-soft: #42192a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--lilas-claro); color: #fff; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------- Ícones ---------- */
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px;
}
.btn-primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(91, 95, 240, 0.28); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--lilas); }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.field.invalid .input { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: 12px; }
.field .help { color: var(--text-3); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; padding-top: 6px; margin-top: 4px; border-top: 1px dashed var(--border); }
.form-grid > .form-section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.form-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--lilas); margin-top: 10px; }
.form-grid > .form-section:first-child h4 { margin-top: 0; }

.multi { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); }
.multi-search { border: 0; border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; height: 36px; }
.multi-list { max-height: 220px; overflow: auto; padding: 6px; }
.multi-group { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 6px 4px; }
.multi-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.multi-item:hover { background: var(--surface-2); }
.multi-item input { accent-color: var(--primary); }
.multi-count { padding: 6px 10px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--border); }

/* ---------- Autenticação ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side {
  background: var(--grad); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-side::after {
  content: ''; position: absolute; inset: auto -120px -160px auto; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 65%);
}
.auth-side h1 { font-size: 34px; line-height: 1.15; max-width: 440px; margin-top: 40px; }
.auth-side p { opacity: 0.9; max-width: 420px; font-size: 15px; }
.auth-pill { display: inline-flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.auth-pill span { background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22); padding: 5px 12px; border-radius: 99px; font-size: 12.5px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; position: relative; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.auth-card h2 { font-size: 24px; }
.auth-theme { position: absolute; top: 18px; right: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; flex: none; }
.auth-side .brand-mark { background: rgba(255, 255, 255, 0.2); }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13.5px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--primary-text); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar .brand { padding: 4px 8px 18px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 16px 10px 6px; display: flex; align-items: center; gap: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-weight: 550; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.nav a.active .ico { color: var(--primary); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.crumbs b { color: var(--text); font-weight: 600; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.content { padding: 26px 28px 60px; max-width: 1360px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cartões / KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi .label { color: var(--text-2); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .label .ico { color: var(--lilas); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad); }

.dom-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dom-card .head { display: flex; align-items: center; gap: 10px; }
.sigla { display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 8px; border-radius: 7px; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: 12px; letter-spacing: 0.03em; }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 86px 1fr 24px; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; }
.bar-e > i { background: #3b6cf6; }
.bar-t > i { background: #6a5cf3; }
.bar-o > i { background: #a78bfa; }
.bar-row b { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.coverage { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.gap-list { display: flex; flex-direction: column; max-height: 300px; overflow: auto; }
.gap-list .row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.gap-list .row:last-child { border-bottom: 0; }
.empty { padding: 34px 20px; text-align: center; color: var(--text-3); }

/* ---------- Tabela ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.search input { padding-left: 34px; height: 36px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text-2); }
.table-foot { padding: 10px 16px; font-size: 12.5px; color: var(--text-3); border-top: 1px solid var(--border); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-e { background: color-mix(in srgb, #3b6cf6 14%, transparent); color: #3b6cf6; }
.badge-t { background: color-mix(in srgb, #6a5cf3 14%, transparent); color: #6a5cf3; }
.badge-o { background: color-mix(in srgb, #a78bfa 20%, transparent); color: #8b5cf6; }
:root[data-theme='dark'] .badge-e { color: #8fb0ff; }
:root[data-theme='dark'] .badge-t { color: #a9a3ff; }
:root[data-theme='dark'] .badge-o { color: #c8b6ff; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.progress-mini { width: 60px; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.progress-mini i { display: block; height: 100%; background: var(--grad); }

/* ---------- Colapso ---------- */
.chain { display: flex; flex-direction: column; gap: 0; }
.chain-step { display: flex; gap: 12px; align-items: stretch; }
.chain-rail { display: flex; flex-direction: column; align-items: center; width: 18px; }
.chain-rail i { width: 12px; height: 12px; border-radius: 50%; background: var(--grad); margin-top: 4px; flex: none; }
.chain-rail span { flex: 1; width: 2px; background: var(--border-strong); margin: 3px 0; }
.chain-body { padding-bottom: 14px; }
.chain-body b { display: block; font-size: 13.5px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(14, 15, 35, 0.45); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fade 0.15s ease; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; border: 1px solid var(--border); animation: pop 0.18s ease; }
.modal.lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--primary-text); border-bottom-color: var(--primary); }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 380px; animation: pop 0.18s ease; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }

/* ---------- Política: matriz de ações e condições ---------- */
.matrix { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.matrix-mod { padding: 8px 12px; background: var(--surface-2); font-weight: 700; font-size: 12.5px; display: flex; align-items: center; justify-content: space-between; }
.matrix-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.matrix-row .acts { display: flex; gap: 12px; flex-wrap: wrap; }
.matrix-row .check:has(input:disabled) { opacity: 0.7; cursor: help; }
.cond-row { display: grid; grid-template-columns: 1.3fr 1fr 1.3fr auto; gap: 8px; margin-bottom: 8px; }
.sim-result { padding: 14px; border-radius: 10px; font-weight: 600; }

.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: var(--sidebar); transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 50; }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .cond-row { grid-template-columns: 1fr 1fr; }
}
