/* RBCTECH M365 Insight — estilos (0.3)
   Painel administrativo claro e arejado: menu lateral com ícones, barra
   superior com busca, cartões brancos arredondados e azul como cor de ação.
   Modo claro e escuro: segue o sistema; o botão do topo fixa a escolha
   (data-theme no <html>, aplicado por theme.js antes de a página aparecer). */

@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/poppins-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/poppins-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/poppins-latin-700-normal.woff2") format("woff2"); }

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef1f8;
  --ink: #1b2136;
  --ink-2: #4b546e;
  --ink-3: #858ea8;
  --line: #e5e8f1;
  --line-2: #eff1f7;
  --primary: #2f55e4;
  --primary-hover: #2445c8;
  --primary-ink: #2a4ccf;
  --primary-soft: #ebf0ff;
  --on-primary: #ffffff;
  --ok: #12805a;
  --ok-bg: #e2f5ec;
  --warn: #a96200;
  --warn-bg: #fff2d9;
  --danger: #cc3426;
  --danger-bg: #fdeae8;
  --info: #2f55e4;
  --info-bg: #ebf0ff;
  --violet: #6c3fd1;
  --violet-bg: #efe9fd;
  --focus: #2f55e4;
  --scrim: rgba(17, 24, 48, .38);
  --shadow-card: 0 1px 2px rgba(22, 30, 60, .04), 0 10px 28px -14px rgba(22, 30, 60, .14);
  --shadow-pop: 0 18px 50px -12px rgba(22, 30, 60, .28);
  --radius: 14px;
  --radius-m: 12px;
  --radius-s: 9px;
  --hero-bg: linear-gradient(165deg, #f8f7f2 0%, #f1f3fb 100%);
  --hero-solid: #f2f3f9;
  --side-w: 264px;
  --top-h: 76px;
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;
  color-scheme: light;
}

/* Escuro: tokens repetidos de propósito — o CSS não deixa compartilhar um
   bloco entre a preferência do sistema e a escolha explícita. */
:root[data-theme="dark"] {
  --bg: #0e1222;
  --surface: #161b30;
  --surface-2: #1b2139;
  --surface-3: #222a47;
  --ink: #e9ecf6;
  --ink-2: #b4bbd2;
  --ink-3: #7f88a7;
  --line: #262e4b;
  --line-2: #1e2540;
  --primary: #5577ff;
  --primary-hover: #6d8bff;
  --primary-ink: #93a8ff;
  --primary-soft: #1e2853;
  --on-primary: #ffffff;
  --ok: #45d39a;
  --ok-bg: #133229;
  --warn: #f2b955;
  --warn-bg: #352a14;
  --danger: #ff8073;
  --danger-bg: #3a1b20;
  --info: #93a8ff;
  --info-bg: #1e2853;
  --violet: #b59bff;
  --violet-bg: #2a2150;
  --focus: #93a8ff;
  --scrim: rgba(3, 6, 16, .6);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 12px 30px -16px rgba(0, 0, 0, .7);
  --shadow-pop: 0 20px 60px -10px rgba(0, 0, 0, .75);
  --hero-bg: radial-gradient(900px 600px at 50% 30%, #1a2350 0%, #0e1328 70%);
  --hero-solid: #0e1328;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1222;
    --surface: #161b30;
    --surface-2: #1b2139;
    --surface-3: #222a47;
    --ink: #e9ecf6;
    --ink-2: #b4bbd2;
    --ink-3: #7f88a7;
    --line: #262e4b;
    --line-2: #1e2540;
    --primary: #5577ff;
    --primary-hover: #6d8bff;
    --primary-ink: #93a8ff;
    --primary-soft: #1e2853;
    --on-primary: #ffffff;
    --ok: #45d39a;
    --ok-bg: #133229;
    --warn: #f2b955;
    --warn-bg: #352a14;
    --danger: #ff8073;
    --danger-bg: #3a1b20;
    --info: #93a8ff;
    --info-bg: #1e2853;
    --violet: #b59bff;
    --violet-bg: #2a2150;
    --focus: #93a8ff;
    --scrim: rgba(3, 6, 16, .6);
    --shadow-card: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 12px 30px -16px rgba(0, 0, 0, .7);
    --shadow-pop: 0 20px 60px -10px rgba(0, 0, 0, .75);
    --hero-bg: radial-gradient(900px 600px at 50% 30%, #1a2350 0%, #0e1328 70%);
    --hero-solid: #0e1328;
    color-scheme: dark;
  }
}

/* Ícone do botão de tema: mostra o tema para o qual ele leva. */
.theme-toggle .ic-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ic-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ic-moon { display: none; }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
svg { flex: none; }

/* ---------- Estrutura ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
:root[data-side="mini"] .app { grid-template-columns: 84px minmax(0, 1fr); }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  z-index: 15;
}
.brand { display: flex; gap: 12px; align-items: center; min-height: var(--top-h); padding: 0 24px; }
.brand svg { width: 40px; height: 40px; color: var(--primary); }
.brand b { display: block; font-weight: 700; font-size: 18px; line-height: 1.1; letter-spacing: -.01em; }
.brand span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; font-weight: 500; }
.side .brand { border-bottom: 1px solid var(--line-2); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 18px; }
.nav .group { margin: 14px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.nav .group:first-child { margin-top: 2px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px;
  white-space: nowrap;
}
.nav a svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primary); }
.side-foot { margin-top: auto; padding: 16px 20px 20px; display: grid; gap: 10px; }
.side-note { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: var(--radius-m); padding: 12px 14px; color: var(--ink-2); font-size: 12px; line-height: 1.45; }
.side-note svg { width: 18px; height: 18px; stroke: var(--primary); fill: none; stroke-width: 1.8; margin-top: 1px; }
.side-ver { font-size: 11.5px; color: var(--ink-3); padding-left: 2px; }

/* Menu recolhido (só ícones) */
:root[data-side="mini"] .side .brand { padding: 0 22px; }
:root[data-side="mini"] .side .brand div,
:root[data-side="mini"] .nav a span,
:root[data-side="mini"] .nav .group,
:root[data-side="mini"] .side-foot { display: none; }
:root[data-side="mini"] .nav a { justify-content: center; padding: 11px 0; }
:root[data-side="mini"] .nav a + .group, :root[data-side="mini"] .nav .group + a { margin-top: 0; }

.side-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 18px;
  min-height: var(--top-h); padding: 10px 32px 10px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.top-title { flex: 0 0 auto; min-width: 0; max-width: 40%; }
.top-title h1 { margin: 0; font-size: 21px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-org { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2); text-decoration: none;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-ink); }
.icon-btn.plain { background: transparent; color: var(--primary-ink); }
.icon-btn.plain:hover { background: var(--primary-soft); }
.icon-btn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font-size: 10.5px; font-weight: 600; line-height: 19px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.icon-btn .badge.danger { background: var(--danger); }

.gsearch { position: relative; margin-left: auto; flex: 0 1 340px; min-width: 180px; }
.gsearch > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.gsearch input[type=search] {
  width: 100%; height: 44px; min-height: 44px; padding: 0 16px 0 42px; border-radius: 12px;
  border: 1px solid transparent; background: var(--surface-2);
}
.gsearch input[type=search]:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.gsearch-list {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop); padding: 6px; max-height: 360px; overflow-y: auto;
}
.gsearch-list button {
  display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; align-items: center; text-align: left;
  width: 100%; border: 0; background: none; border-radius: var(--radius-s); padding: 8px 10px; cursor: pointer;
}
.gsearch-list button .avatar { grid-row: span 2; width: 34px; height: 34px; font-size: 12px; }
.gsearch-list button b { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-list button small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-list button:hover, .gsearch-list button[aria-selected="true"] { background: var(--primary-soft); }
.gsearch-list .none { padding: 10px 12px; color: var(--ink-3); font-size: 13px; }

.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.user-menu { position: relative; margin-left: 6px; padding-left: 16px; border-left: 1px solid var(--line); }
.user-btn { display: flex; align-items: center; gap: 12px; border: 0; background: none; cursor: pointer; padding: 4px; border-radius: 12px; text-align: left; }
.user-btn:hover { background: var(--surface-2); }
.avatar {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7a5cff); color: #fff; font-weight: 600; font-size: 14px; letter-spacing: .02em;
}
.avatar.ms { background: linear-gradient(135deg, #0f8a8a, var(--primary)); }
.who-text { display: grid; line-height: 1.25; max-width: 210px; }
.who-text b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-btn .chev { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 250px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop); padding: 6px;
}
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; display: grid; }
.menu-head small { color: var(--ink-3); overflow-wrap: anywhere; }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 10px 12px; border-radius: var(--radius-s); cursor: pointer; text-align: left; color: var(--ink-2); }
.menu button:hover { background: var(--surface-2); color: var(--ink); }
.menu button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.seal {
  display: inline-flex; align-items: center; gap: 7px; max-width: 280px;
  background: var(--primary-soft); color: var(--primary-ink);
  border-radius: 999px; padding: 6px 14px 6px 10px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seal svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.seal.admin { background: var(--warn-bg); color: var(--warn); }
.demo-flag { background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.page { padding: 30px 32px 64px; width: 100%; max-width: 1360px; outline: none; }
.page > .lead { color: var(--ink-2); margin: 0 0 24px; max-width: 78ch; }
h2 { font-size: 17px; line-height: 1.35; font-weight: 600; margin: 0 0 14px; letter-spacing: -.005em; }

.panel { background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-card); border: 1px solid var(--line-2); }
:root[data-theme="dark"] .panel { border-color: var(--line); }
.panel + .panel, .stack > * + * { margin-top: 22px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.grid2 > .panel { margin-top: 0; }
.grid2 + .panel, .panel + .actions, .panel + .notice { margin-top: 22px; }
.panel + div:not(:empty), .panel + section:not(.panel):not(:empty), details.panel + div:not(:empty) { margin-top: 22px; }

/* ---------- Números do painel (cartões) ---------- */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; margin-bottom: 22px; }
.figure {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 14px;
  background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-card); border: 1px solid var(--line-2);
}
.figure b { display: block; font-size: 38px; line-height: 1.05; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.figure span { display: block; color: var(--ink-3); font-size: 13px; margin-top: 8px; max-width: 18ch; }
.figure .fic { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); align-self: start; }
.figure .fic svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.figure.warn .fic { background: var(--warn-bg); color: var(--warn); }
.figure.ok .fic { background: var(--ok-bg); color: var(--ok); }
.figure.violet .fic { background: var(--violet-bg); color: var(--violet); }

/* ---------- Alertas (cartões tipo "lista de tarefas") ---------- */
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.alerts li { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 16px 0; border-top: 1px solid var(--line-2); }
.alerts li:first-child { border-top: 0; padding-top: 2px; }
.alerts .bar { display: none; }
.alerts .tag { justify-self: start; border-radius: 8px; padding: 3px 12px; font-size: 12px; font-weight: 600; color: #fff; }
.lvl-danger .tag { background: var(--danger); }
.lvl-warn .tag { background: #e8a120; color: #3a2600; }
.lvl-info .tag { background: var(--primary); }
.lvl-ok .tag { background: var(--ok); }
.alerts .t { font-weight: 600; font-size: 14.5px; }
.alerts .d { color: var(--ink-2); font-size: 13.5px; }
.empty { color: var(--ink-3); padding: 8px 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 2px 0 0; color: var(--ink-3); font-size: 12.5px; }
.panel-head + .alerts, .panel-head + .rows-bars { margin-top: 16px; }
.count-pill { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }

/* ---------- Barras ---------- */
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: 999px; width: 0; }
.meter.hi i { background: #e8a120; }
.meter.full i { background: var(--danger); }
.rows-bars { display: grid; gap: 16px; }
.rows-bars .r { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; font-size: 13.5px; }
.rows-bars .r > span:first-child { font-weight: 500; }
.rows-bars .r .meter { grid-column: 1 / -1; }

/* ---------- Pílulas de situação ---------- */
.pill { display: inline-block; border-radius: 8px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.plain { background: var(--surface-3); color: var(--ink-2); }

/* ---------- Formulários ---------- */
.form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; align-items: end; }
.form .wide { grid-column: span 2; }
.form .full { grid-column: 1 / -1; }
label.f { display: grid; gap: 7px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
label.f small { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=password], input[type=search], input[type=datetime-local], input[type=email], input[type=number], select, textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; width: fit-content; max-width: 100%; }
.chips button {
  border: 0; background: transparent; border-radius: 9px; color: var(--ink-2);
  padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.chips button:hover { color: var(--ink); }
.chips button[aria-pressed="true"] { background: var(--surface); color: var(--primary-ink); font-weight: 600; box-shadow: 0 1px 3px rgba(22, 30, 60, .12); }
:root[data-theme="dark"] .chips button[aria-pressed="true"] { background: var(--primary-soft); box-shadow: none; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary);
  border-radius: var(--radius-s); padding: 10px 20px; font-weight: 500; cursor: pointer; min-height: 44px; text-decoration: none;
  box-shadow: 0 6px 16px -8px var(--primary);
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--primary-ink); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--primary-soft); border-color: var(--primary-soft); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.mt { margin-top: 24px; }
.toolbar h2 { margin: 0; flex: 1; }
.drawer .body h2 { margin-top: 24px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 360px; background: var(--surface-2); border-color: transparent; }
.toolbar input[type=search]:focus { background: var(--surface); border-color: var(--primary); }

/* ---------- Tabelas ---------- */
.tablewrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.t th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  padding: 12px 12px; background: var(--surface-2); white-space: nowrap; border-bottom: 0;
}
table.t th:first-child { border-radius: 10px 0 0 10px; }
table.t th:last-child { border-radius: 0 10px 10px 0; }
table.t td { padding: 13px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t td.r, table.t th.r { text-align: right; }
table.t td.num { white-space: nowrap; }
.cell-2 small { display: block; color: var(--ink-3); font-size: 12px; }
.trunc { max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Progresso de consulta ---------- */
.progress { display: grid; gap: 10px; padding: 20px 22px; border-radius: var(--radius); background: var(--surface); border: 1px dashed var(--line); }
.progress .meter i { transition: width .4s ease; background: linear-gradient(90deg, var(--primary), #7a5cff); }
.progress .msg { color: var(--ink-2); }
.notice { padding: 12px 16px; border-radius: var(--radius-s); background: var(--info-bg); color: var(--info); margin: 12px 0; font-size: 13.5px; }
.notice.err { background: var(--danger-bg); color: var(--danger); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Gaveta lateral ---------- */
.drawer-bg { position: fixed; inset: 0; background: var(--scrim); z-index: 40; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(580px, calc(100% - 24px));
  background: var(--surface); z-index: 41; box-shadow: var(--shadow-pop); border-radius: 18px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slidein .22s ease;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer header { display: flex; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line-2); }
.drawer header h2 { margin: 0; }
.drawer .body { padding: 20px 24px 40px; overflow-y: auto; }
.drawer .close { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); border: 0; cursor: pointer; font-size: 20px; line-height: 1; color: var(--ink-2); flex: none; }
.drawer .close:hover { background: var(--danger-bg); color: var(--danger); }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0 0 18px; font-size: 13.5px; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Investigação ---------- */
.case { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.case-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.case-head .subj { font-size: 21px; line-height: 1.3; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; }
.case-head .sum { color: var(--ink-2); max-width: 78ch; }
.whereabouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.box { position: relative; border-radius: var(--radius-m); padding: 18px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line-2); }
.box .who { font-weight: 600; }
.box .addr { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
.box .role { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.box .path { margin-top: 10px; font-size: 13.5px; }
.box .path b { display: block; font-size: 14.5px; }
.stamp {
  display: inline-block; transform: rotate(-3deg); margin-top: 4px;
  border: 2px solid currentColor; border-radius: 8px;
  padding: 3px 10px; font-weight: 700; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
}
.stamp.ok { color: var(--ok); }
.stamp.warn { color: var(--warn); }
.stamp.danger { color: var(--danger); }
.stamp.info { color: var(--info); }

.route { list-style: none; margin: 0; padding: 0 0 0 4px; }
.route li { position: relative; display: grid; grid-template-columns: 110px 22px 1fr; gap: 0 14px; padding-bottom: 22px; }
.route li::before { content: ""; position: absolute; left: 134px; top: 18px; bottom: -2px; width: 2px; background: var(--line); }
.route li:last-child::before { display: none; }
.route .when { text-align: right; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 1px; }
.route .when b { display: block; color: var(--ink); font-weight: 600; }
.route .dot { width: 14px; height: 14px; border-radius: 50%; margin: 4px 0 0 4px; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--ink-3); background: var(--ink-3); z-index: 1; position: relative; }
.route .dot.ok { background: var(--ok); box-shadow: 0 0 0 2px var(--ok); }
.route .dot.warn { background: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.route .dot.danger { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.route .dot.info { background: var(--info); box-shadow: 0 0 0 2px var(--info); }
.route .what { min-width: 0; overflow-wrap: anywhere; }
.route .what b { display: block; font-weight: 600; }
.route .what .meta { font-size: 12.5px; color: var(--ink-3); }
.route details { margin-top: 4px; font-size: 12.5px; }
.route details pre { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 12px; border-radius: var(--radius-s); max-height: 260px; overflow: auto; }
.limits { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; }
.limits li + li { margin-top: 6px; }

/* ---------- Saúde ---------- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 32px 1fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line-2); }
.checks li:first-child { border-top: 0; padding-top: 0; }
.checks .ic { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.checks .ok .ic { background: var(--ok-bg); color: var(--ok); }
.checks .warn .ic { background: var(--warn-bg); color: var(--warn); }
.checks .fail .ic { background: var(--danger-bg); color: var(--danger); }
.checks b { font-weight: 600; }
.checks .fix { font-size: 13px; color: var(--ink-2); margin-top: 4px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 560px); }
.login-hero {
  position: relative; overflow: hidden; color: var(--ink); padding: 40px 56px 44px;
  display: flex; flex-direction: column; gap: 28px;
  background: url("img/login-art.svg") 64% 10% / auto min(60%, 620px) no-repeat, var(--hero-bg);
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, var(--hero-solid) 22%, transparent 42%);
}
.hero-logo { position: relative; z-index: 1; width: clamp(120px, 11vw, 160px); height: auto; filter: drop-shadow(0 12px 24px rgba(20, 30, 70, .22)); }
.card-logo { display: none; width: 120px; height: auto; margin: 0 auto 22px; }
.brand.light { padding: 0; min-height: 0; position: relative; z-index: 1; }
.hero-copy { position: relative; z-index: 1; max-width: 560px; margin-top: auto; }
.hero-copy h2 { font-size: clamp(24px, 2.4vw, 32px); line-height: 1.22; font-weight: 600; letter-spacing: -.02em; margin: 0 0 18px; }
.hero-copy ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14.5px; color: var(--ink-2); }
.hero-copy li { display: flex; gap: 12px; align-items: center; }
.hero-copy li::before { content: ""; width: 22px; height: 22px; flex: none; border-radius: 7px; background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 14px no-repeat; }
.hero-foot { position: relative; z-index: 1; margin: 0; font-size: 12.5px; color: var(--ink-3); }
.login-side { position: relative; display: grid; place-items: center; padding: 40px 32px; background: var(--surface); }
.login-theme { position: absolute; top: 20px; right: 20px; }
.login .card { width: min(400px, 100%); }
.login .card .brand { padding: 0; min-height: 0; margin-bottom: 34px; }
.login-title { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.forgot-row { margin-top: 14px; text-align: center; }
#recover { display: grid; gap: 4px; }
#recover form { display: grid; gap: 16px; }
#recover form .btn { width: 100%; }
#recover .notice { margin-bottom: 16px; }
.login-ver { margin: 18px 0 0; text-align: center; letter-spacing: .02em; }
.login .org { margin: 4px 0 26px; color: var(--ink-3); font-size: 14px; }
.login form { display: grid; gap: 16px; }
.login form .btn { width: 100%; }
.ms-box { display: grid; gap: 10px; }
.btn.ms { width: 100%; min-height: 50px; font-size: 15px; }
.ms-box .linkish { justify-self: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; margin: 16px 0 6px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.device { border: 1px dashed var(--line); border-radius: var(--radius-m); padding: 16px; display: grid; gap: 10px; text-align: center; background: var(--surface-2); }
.device .code-box { margin: 0 auto; }
.device .spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .9s linear infinite; display: inline-block; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-bg { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 18px; padding: 28px; width: min(460px, 100%); box-shadow: var(--shadow-pop); }
.modal h2 { font-size: 19px; }
.modal form { display: grid; gap: 14px; }

/* ---------- 0.2: formulários compostos, resultados, administração ---------- */
.grid-sub { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; align-items: end; }
.grid-sub .wide { grid-column: span 2; }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
details.more { grid-column: 1 / -1; border-top: 1px solid var(--line-2); padding-top: 12px; }
details.more > summary, details.help > summary { cursor: pointer; color: var(--primary-ink); font-weight: 600; font-size: 13.5px; }
details.more[open] > summary { margin-bottom: 14px; }
details.help { margin-top: 22px; }
details.help[open] > summary { margin-bottom: 12px; }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.result-head h2 { margin: 0; }
.ok-line { color: var(--ok); margin: 4px 0 12px; }
.btn.sm { min-height: 34px; padding: 5px 14px; font-size: 13px; box-shadow: none; }
.rule { border-top: 1px solid var(--line-2); padding: 14px 0; display: grid; gap: 6px; }
.rule:first-of-type { border-top: 0; }
.rule-h { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rule .notice { margin: 4px 0 0; padding: 8px 12px; font-size: 13px; }
.pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 14px; border-radius: var(--radius-s); max-height: 420px; overflow: auto; font-size: 12.5px; font-family: var(--mono); }
.pre.body { font-family: var(--font); font-size: 13.5px; }
.adm-on { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.steps { padding-left: 20px; line-height: 2; }
.code-box { display: inline-block; font: 700 22px/1.3 var(--mono); letter-spacing: .14em; border: 2px dashed var(--primary); color: var(--primary-ink); background: var(--surface); padding: 6px 16px; border-radius: 12px; margin-left: 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--primary-ink); cursor: pointer; font: inherit; text-align: left; }
.linkish:hover { text-decoration: underline; }
table.folders td.d2 { padding-left: 30px; } table.folders td.d3 { padding-left: 50px; } table.folders td.d4 { padding-left: 70px; } table.folders td.d5, table.folders td.d6 { padding-left: 90px; }
tr.perm-row > td { background: var(--surface-2); }
.modal.wide { width: min(660px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
fieldset.levels { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.level { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; }
.level:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.level small { display: block; color: var(--ink-3); font-size: 12.5px; }
.rights { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 13.5px; }
.check small { flex-basis: 100%; padding-left: 24px; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
.preview { background: var(--info-bg); color: var(--ink); border-radius: var(--radius-s); padding: 12px 14px; font-size: 13.5px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1520px) { .who-text, .user-btn .chev { display: none; } .user-menu { padding-left: 10px; } }
@media (max-width: 1200px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .who-text { display: none; }
}
@media (max-width: 980px) {
  .app, :root[data-side="mini"] .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-pop); z-index: 45; }
  :root[data-side="mini"] .side .brand div, :root[data-side="mini"] .nav a span, :root[data-side="mini"] .nav .group, :root[data-side="mini"] .side-foot { display: revert; }
  :root[data-side="mini"] .nav a { justify-content: flex-start; padding: 10px 14px; }
  body.side-open .side { transform: none; }
  body.side-open .side-scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 44; }
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .top-title { flex: 1; }
  .top-title h1 { font-size: 18px; }
  .gsearch { order: 5; flex: 1 1 100%; width: 100%; margin: 0; }
  .top-title { max-width: none; }
  .seal span, .demo-flag { display: none; }
  .seal { padding: 9px; }
  .user-menu { padding-left: 8px; margin-left: 0; border-left: 0; }
  .user-btn .chev { display: none; }
  .page { padding: 20px 16px 48px; }
  .figures { gap: 14px; }
  .figure { padding: 18px; }
  .figure b { font-size: 30px; }
  .figure .fic { width: 44px; height: 44px; border-radius: 13px; }
  .grid2, .form { grid-template-columns: minmax(0, 1fr); }
  .form .wide { grid-column: auto; }
  .route li { grid-template-columns: 78px 22px 1fr; gap: 0 10px; }
  .route li::before { left: 98px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .grid-sub, .dates, .rights { grid-template-columns: minmax(0, 1fr); }
  .grid-sub .wide { grid-column: auto; }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-hero { display: none; }
  .card-logo { display: block; }
  .login-side { min-height: 100vh; padding: 72px 20px 32px; }
  .panel { padding: 18px; }
}
@media (max-width: 520px) {
  .figures { grid-template-columns: minmax(0, 1fr); }
  .top-org { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  .side, .top, .no-print, form, .drawer-bg, details.help, .progress, .side-scrim { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .panel { border: 0; padding: 0; box-shadow: none; }
  .page { padding: 0; max-width: none; }
  section.panel:has(form) { display: none; }
  .tablewrap { overflow: visible; }
  .trunc { white-space: normal; max-width: none; }
}


/* ---------- Central de clientes (0.4.0) ---------- */
.top-title { position: relative; }
.client-switch { position: relative; }
.client-pick { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; border: 0; background: none; padding: 0; cursor: pointer; font-size: 12px; color: var(--primary-ink); font-weight: 600; }
.client-pick:hover { text-decoration: underline; }
.client-pick.none { color: var(--warn); }
.client-pick span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-pick svg { width: 14px; height: 14px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.client-menu { left: 0; right: auto; top: calc(100% + 8px); min-width: 300px; max-width: min(420px, 90vw); max-height: 70vh; overflow-y: auto; }
.client-menu .pad { padding: 8px 12px; }
.cl-item { align-items: flex-start !important; }
.cl-item.on { background: var(--primary-soft) !important; color: var(--primary-ink) !important; }
.cl-t { display: grid; min-width: 0; }
.cl-t b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.cl-t small { color: var(--ink-3); font-size: 12px; }
.dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--line); display: inline-block; }
.dot.ok { background: var(--ok); }
td .dot { margin-top: 0; margin-right: 4px; vertical-align: 0; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.client-tile { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-m); padding: 14px 16px; cursor: pointer; color: var(--ink); }
.client-tile:hover { border-color: var(--primary); background: var(--primary-soft); }
.client-tile .dot { margin: 0; grid-row: span 2; }
.client-tile small { color: var(--ink-3); }
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { filter: brightness(.92); }
.block { display: block; }
.consent { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; margin-bottom: 16px; background: var(--surface-2); }
.consent p { margin: 6px 0 10px; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; font: 12px/1.4 var(--mono); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
ol.steps { padding-left: 20px; display: grid; gap: 10px; }
select[disabled] { opacity: .6; }
@media (max-width: 980px) { .client-menu { position: fixed; left: 16px; right: 16px; top: 72px; max-width: none; } }

/* ---------- Configurações (0.5) ---------- */
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; line-height: 1.45; }
label.check input { width: 18px; height: 18px; flex: none; margin-top: 1px; accent-color: var(--primary); }
label.check small { font-weight: 400; color: var(--ink-3); display: block; }
fieldset.checks { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; }
fieldset.checks legend { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 0; margin-bottom: 8px; }
.divider { height: 1px; background: var(--line-2); margin: 22px 0 16px; }
h3.sub { font-size: 15px; margin: 0 0 4px; }
textarea { resize: vertical; min-height: 84px; }
.form.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.form.cols2 .wide, .form.cols2 .actions { grid-column: 1 / -1; }
.form.cols2 label.f > small:first-of-type { min-height: 0; }
