/* Visual moderno: fundo azulado, zonas de cor por área, tabela em card.
   Tokens baseados na seção 16 do PRD, repaginados (2026-08-06, pedido do Hélio). */
:root {
  --bg-app: #EDF1F7;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F5F8FC;
  --bg-hover: #E9EEF6;
  --bg-selected: #E2EAF5;
  --bg-row-active: #E6F0FE;
  --border: #E1E8F1;
  --border-strong: #C7D2E1;
  --text-1: #14213D;
  --text-2: #4A5872;
  --text-3: #8A97AC;
  --blue: #2F6FE4;
  --blue-hover: #245BC2;
  --blue-subtle: #E3EDFD;
  --navy-1: #0E2A47;
  --navy-2: #1B3E6B;
  --green-bg: #E4F5EA; --green-text: #1B7A44;
  --amber-bg: #FCF0DF; --amber-text: #92600A;
  --red: #D34040;
  --chip-green-bg: #D9F2E0; --chip-green-text: #0E6B33;
  --chip-red-bg: #FCE3E3; --chip-red-text: #A61B1B;
  --chip-orange-bg: #FFE8D1; --chip-orange-text: #9A4A08;
  --chip-blue-bg: #DCEBFB; --chip-blue-text: #14559C;
  --chip-purple-bg: #EAE3FA; --chip-purple-text: #5B3AA8;
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .06);
  --shadow-md: 0 4px 14px rgba(20, 33, 61, .08);
  --shadow-lg: 0 16px 40px rgba(20, 33, 61, .18);
  --shadow-panel: -10px 0 30px rgba(20, 33, 61, .12);
  --radius: 8px;
  --radius-lg: 12px;
  --focus: 0 0 0 3px rgba(47, 111, 228, .28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-1);
  background: var(--bg-app);
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text-1); }

/* ── Login ── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 500px at 15% 5%, rgba(63, 118, 190, .55), transparent 60%),
    radial-gradient(800px 500px at 95% 95%, rgba(47, 111, 228, .35), transparent 60%),
    linear-gradient(160deg, var(--navy-1), var(--navy-2));
}
.login-card {
  width: 380px;
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-card .logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy-1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.login-card .logo::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--navy-2));
  box-shadow: var(--shadow-sm);
}
.login-card .sub { color: var(--text-2); margin: 6px 0 22px; }
.login-card label { display: block; margin: 14px 0 4px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.login-card .input { height: 38px; border-radius: 10px; }
.login-card .error { color: var(--red); margin-top: 12px; min-height: 16px; font-size: 12px; }
.login-card .btn { width: 100%; height: 40px; border-radius: 10px; margin-top: 18px; }

/* ── Layout ── */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(90deg, var(--navy-1), var(--navy-2));
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.base-name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.base-name::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, #4D8BF0, #2F6FE4);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .12);
}
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a {
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 500;
}
.topnav a:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.topnav a.active { color: #fff; background: rgba(255, 255, 255, .16); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.user-chip { color: rgba(255, 255, 255, .85); font-weight: 500; }
.topbar .btn-secondary { background: rgba(255, 255, 255, .14); border-color: transparent; color: #fff; }
.topbar .btn-secondary:hover { background: rgba(255, 255, 255, .24); }

.tablebar {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.table-tab {
  padding: 6px 16px;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 600;
  border: 0;
  background: transparent;
}
.table-tab.active { background: var(--navy-1); color: #fff; box-shadow: var(--shadow-sm); }
.table-tab:hover:not(.active) { background: var(--bg-hover); }

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 16px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.filterbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
.filterbar[hidden] { display: none; }
.filterbar-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-2);
}
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; background: var(--blue); color: #fff;
  font-size: 11px; font-weight: 700;
}
.view-name { font-weight: 700; color: var(--navy-1); font-size: 14px; }
.search-wrap { position: relative; display: flex; align-items: center; gap: 6px; }
.search {
  height: 30px;
  width: 240px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 12px 0 32px;
  outline: none;
  background: var(--bg-subtle);
}
.search::placeholder { color: var(--text-3); }
.search:focus { border-color: var(--blue); box-shadow: var(--focus); background: #fff; }
.search-wrap .mag { position: absolute; left: 11px; top: 7px; color: var(--text-3); font-size: 12px; pointer-events: none; }
.pill-filter {
  background: var(--green-bg); color: var(--green-text);
  border-radius: 999px; padding: 4px 10px; display: flex; gap: 6px; align-items: center;
  border: 0; font-weight: 600; font-size: 12px;
}
.pill-filter:hover { filter: brightness(.97); }
.pill-x {
  background: none; border: 0; color: inherit;
  padding: 0 0 0 4px; font-size: 10px; opacity: .65;
}
.pill-x:hover { opacity: 1; }
.filters-active { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.pill-warn {
  background: var(--amber-bg); color: var(--amber-text);
  border-radius: 999px; padding: 5px 12px; display: flex; gap: 6px; align-items: center;
  font-size: 12px; font-weight: 500;
}
.pill-warn[hidden], .pill-filter[hidden] { display: none; }
.toolbar-right { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-wrap { display: flex; align-items: center; gap: 6px; }
.filter-name { font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.filter-select {
  min-width: 130px;
  height: 30px;
  border-radius: 999px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border-strong);
  outline: none;
  background: var(--bg-subtle);
  cursor: pointer;
}
.filter-select:focus { border-color: var(--blue); box-shadow: var(--focus); background: #fff; }

/* ── Sidebar de views (PRD §16.3) ── */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 8px;
  padding: 8px 10px; font-weight: 600; color: var(--text-1); font-size: 13px;
  cursor: pointer;
}
.side-item:hover { background: var(--bg-hover); }
.side-item.active { background: var(--blue-subtle); color: var(--blue); }
.side-sub {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); font-weight: 700; margin: 12px 10px 4px;
}
.side-list { display: flex; flex-direction: column; gap: 2px; }
.side-item-row {
  display: flex; align-items: center; gap: 2px;
  border-radius: 8px;
}
.side-item-row:hover { background: var(--bg-hover); }
.side-item-row.active { background: var(--blue-subtle); }
.side-name {
  flex: 1; min-width: 0; text-align: left;
  border: 0; background: transparent; padding: 7px 10px;
  font-size: 12.5px; font-weight: 600; color: var(--text-1); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-item-row.active .side-name { color: var(--blue); }
.side-actions { display: none; gap: 2px; padding-right: 4px; }
.side-item-row:hover .side-actions { display: flex; }
.side-mini {
  border: 0; background: transparent; color: var(--text-3);
  font-size: 11px; padding: 4px 5px; border-radius: 6px; cursor: pointer;
}
.side-mini:hover { background: var(--bg-hover); color: var(--navy-1); }
.side-mini.danger:hover { color: var(--red); }
.side-empty { font-size: 12px; color: var(--text-3); padding: 8px 10px; }
.side-save {
  margin-top: auto; padding: 12px 2px 2px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.side-name-input { width: 100%; height: 30px; }
.side-save-actions { display: flex; gap: 6px; }
.side-rename { width: 100%; height: 30px; }
.side-toggle { display: none; }
.filter-value-wrap { display: inline-flex; align-items: center; gap: 6px; }
.filter-value-wrap[hidden] { display: none; }
.filter-input { height: 30px; border-radius: 999px; padding: 0 12px; border: 1px solid var(--border-strong); outline: none; background: var(--bg-subtle); }
.filter-input:focus { border-color: var(--blue); box-shadow: var(--focus); background: #fff; }

/* ── Grade agrupada (Empregados/Modelos: Razao social → Funcao) ── */
tbody.group { border-bottom: 1px solid var(--border); }
tbody.group:last-child { border-bottom: 0; }
.group-head td, .subgroup-head td {
  background: var(--bg-subtle);
  padding: 7px 14px;
  font-weight: 700; color: var(--navy-1); font-size: 12.5px;
}
.group-head td { background: var(--blue-subtle); }
.group-head:hover td, .subgroup-head:hover td { background: var(--bg-hover); }
.group-toggle {
  border: 0; background: none; cursor: pointer;
  color: var(--text-3); font-size: 10px; padding: 0 6px 0 0;
}
.gcount { color: var(--text-3); font-weight: 600; font-size: 11px; margin-left: 6px; }
tbody.group.collapsed { display: none; }
tbody.group tr.subgroup-head.collapsed ~ tr { display: none; }
tbody.group tr.subgroup-head { display: table-row !important; }

/* ── Grade (tabela em card sobre fundo azulado) ── */
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page[hidden] { display: none; }
.main { display: flex; flex: 1; min-height: 0; }
.grid-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 14px 16px; position: relative; }
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--bg-surface);
}
th, td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  height: 40px;
  padding: 0 10px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
thead th {
  height: 38px;
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-1);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }

/* Grade: cabeçalho fixo + corpo rolável (sem sticky em tabela, que é frágil). */
.grid-table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--bg-surface);
}
.grid-head { flex-shrink: 0; overflow: hidden; }
.grid-body { flex: 1; min-height: 0; overflow-y: auto; }
/* Gutter da scrollbar reservado nos dois lados: cabeçalho e corpo ficam com a
   mesma largura útil, senão a última coluna desalinha onde a barra é clássica. */
.grid-head, .grid-body { scrollbar-gutter: stable; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr.active { background: var(--bg-row-active); }
tbody tr.active td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
tbody tr.sel td { background: var(--blue-subtle); }
th .ticon { color: var(--text-3); margin-right: 6px; font-size: 11px; }
/* Âncora invisível de larguras no corpo agrupado (0px, sem conteúdo). */
.grid-body .row-anchor td { height: 0; padding: 0; border: 0; }
.col-num { width: 48px; text-align: right; color: var(--text-3); }
.col-check { width: 40px; text-align: center; }
.col-check input { cursor: pointer; }

/* Barra de exclusão em massa (fixa sobre a grade quando há seleção). */
.bulkbar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  z-index: 5;
}
.bulkbar[hidden] { display: none; }

/* Botão "+" discreto nos agrupamentos de Modelos. */
.group-add {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 14px;
  padding: 0 4px;
  margin-left: 10px;
  opacity: 0.55;
  border-radius: 6px;
}
.group-add:hover { opacity: 1; color: var(--blue); background: var(--blue-subtle); }
.cell-empty { color: var(--text-3); }
.footer {
  display: flex; align-items: center; gap: 12px;
  min-height: 38px; padding: 0 16px;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  flex-shrink: 0;
  background: var(--bg-surface);
}

/* ── Painel de detalhe (abre só ao clicar num registro ou + Novo) ── */
.panel {
  width: 480px;
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  box-shadow: var(--shadow-panel);
  display: none;
  flex-direction: column;
  flex-shrink: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 700; color: var(--navy-1); }
.panel-head .actions { margin-left: auto; display: flex; gap: 6px; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.panel-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg-subtle);
}
.field-row { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
.field-value { font-size: 14px; }
.input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0 10px;
  outline: none;
  background: var(--bg-surface);
}
.input:focus { border-color: var(--blue); box-shadow: var(--focus); }
textarea.input { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
.input:disabled { background: var(--bg-subtle); color: var(--text-3); cursor: not-allowed; }
.field-ro {
  background: var(--bg-subtle); color: var(--text-2);
  padding: 8px 10px; border-radius: 10px; font-size: 12px;
  border: 1px dashed var(--border-strong);
}
.audit-box { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.audit-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-bottom: 8px; font-weight: 700; }
.audit-line { font-size: 12px; color: var(--text-2); padding: 6px 0; border-bottom: 1px dashed var(--border); }
.audit-line b { color: var(--text-1); font-weight: 700; }
.attach {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--text-1);
  text-decoration: none;
  background: var(--bg-subtle);
}
.attach:hover { background: var(--bg-hover); }
.attach-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.attach-actions { display: inline-flex; gap: 6px; }
[data-upload-label] { cursor: pointer; display: inline-flex; align-items: center; }

/* ── Chips ── */
.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
}
.chip-green { background: var(--chip-green-bg); color: var(--chip-green-text); }
.chip-red { background: var(--chip-red-bg); color: var(--chip-red-text); }
.chip-orange { background: var(--chip-orange-bg); color: var(--chip-orange-text); }
.chip-blue { background: var(--chip-blue-bg); color: var(--chip-blue-text); }
.chip-purple { background: var(--chip-purple-bg); color: var(--chip-purple-text); }
.chip-gray { background: var(--bg-selected); color: var(--text-2); }

/* ── Botões ── */
.btn {
  border-radius: 10px;
  padding: 7px 16px;
  border: 1px solid transparent;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 140ms, background 140ms;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary {
  background: linear-gradient(180deg, #3D7BF0, var(--blue));
  color: #fff;
  box-shadow: 0 1px 3px rgba(47, 111, 228, .45);
}
.btn-primary:hover { filter: brightness(.94); }
.btn-secondary { border-color: var(--border-strong); background: var(--bg-surface); color: var(--text-1); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #B33232; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-2);
  border: 0; background: transparent;
}
.icon-btn:hover { background: var(--bg-hover); }

/* ── Estados ── */
.empty-state { text-align: center; padding: 70px 20px; color: var(--text-2); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }
.skeleton-row {
  height: 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, var(--bg-subtle) 25%, #E7EDF6 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.boot-spinner { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.spinner-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 36px 20px; color: var(--text-3); font-size: 13px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--navy-1); border-right-color: var(--blue); animation: spin 700ms linear infinite; }
.spinner-wrap.sm { padding: 14px; }
.spinner-wrap.sm .spinner { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 21, 38, .45);
  display: grid; place-items: center;
  z-index: 50;
}
.modal {
  width: 420px;
  background: var(--bg-surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.modal h3 { margin: 0 0 8px; font-size: 15px; }
.modal p { color: var(--text-2); margin: 0 0 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Toasts ── */
.toasts {
  position: fixed;
  bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 60;
}
.toast {
  background: var(--navy-1);
  color: #fff;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms ease-out;
}
.toast.error { background: var(--red); }
.toast.ok { background: var(--green-text); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ── Usuários (admin) ── */
.page-users { padding: 24px 28px; max-width: 980px; margin: 0 auto; width: 100%; }
.users-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.users-title { font-size: 22px; font-weight: 800; color: var(--navy-1); }
.users-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.users-table-wrap {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
}
.users-table { width: 100%; border-collapse: collapse; }
.users-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-subtle); font-weight: 700;
}
.users-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.users-table tr:last-child td { border-bottom: 0; }
.users-table tbody tr:hover { background: var(--bg-hover); }
.u-name { font-weight: 600; color: var(--navy-1); }
.u-self { font-size: 11px; color: var(--text-3); font-weight: 400; }
.u-last { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.u-actions { text-align: right; white-space: nowrap; }
.chip-role { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.chip-role.admin { background: var(--navy-1); color: #fff; }
.chip-role.operator { background: var(--green-bg); color: var(--green-text); }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .knob { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.switch .knob::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .knob { background: var(--green-text); }
.switch input:checked + .knob::before { transform: translateX(16px); }
.users-empty { text-align: center; color: var(--text-3); padding: 24px; }
.user-modal { width: 430px; max-width: 92vw; }
.user-modal form { display: flex; flex-direction: column; gap: 8px; }
.email-static { background: var(--bg-subtle); color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: -2px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-1); }

/* ── Relatórios: visão por usuário + gráficos ── */
#page-relatorios { overflow-y: auto; }
.rel-wrap { padding: 24px 28px; max-width: 1100px; margin: 0 auto; width: 100%; }
.rel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.rel-title { font-size: 22px; font-weight: 800; color: var(--navy-1); }
.rel-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.rel-tabs { display: flex; gap: 6px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.rel-tab { border: 0; background: none; color: var(--text-2); border-radius: 999px; padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.rel-tab.active { background: var(--bg-surface); color: var(--navy-1); box-shadow: var(--shadow-sm); }
.period-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 20px; }
.period-pill { border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-2); border-radius: 999px; padding: 5px 14px; font-size: 12px; font-weight: 600; cursor: pointer; }
.period-pill:hover { border-color: var(--navy-2); color: var(--navy-1); }
.period-pill.active { background: var(--navy-1); color: #fff; border-color: var(--navy-1); }
.tl-tab { border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-2); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tl-tab.active { background: var(--navy-1); color: #fff; border-color: var(--navy-1); }
.u-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.u-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; }
.u-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.u-card-name { font-weight: 700; color: var(--navy-1); font-size: 15px; }
.u-card-name .u-self { font-size: 11px; color: var(--text-3); font-weight: 500; }
.u-card-email { color: var(--text-3); font-size: 12px; }
.u-dim { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.u-dim-name { font-size: 12px; font-weight: 700; color: var(--text-2); width: 92px; flex-shrink: 0; }
.u-dim-link { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--blue); font-weight: 600; }
.u-dim-link:hover { text-decoration: underline; }
.u-dim-del { color: var(--red); }
.tl-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-hover); color: var(--navy-1); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* ── Gráficos (visão separada) ── */
.chart-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; }
.chart-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.chart-body { padding: 4px 0; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-2); margin-bottom: 8px; }
.lg::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.lg-created::before { background: var(--green-text); }
.lg-updated::before { background: var(--blue); }
.lg-deleted::before { background: var(--red); }
.chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.chart-label { width: 110px; font-size: 12px; font-weight: 600; color: var(--navy-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.chart-bars { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chart-bar { display: flex; align-items: center; gap: 6px; }
.bar { height: 10px; border-radius: 3px; min-width: 2px; }
.bar-created { background: var(--green-text); }
.bar-updated { background: var(--blue); }
.bar-deleted { background: var(--red); }
.bar-n { font-size: 11px; color: var(--text-2); min-width: 24px; }

/* ── Lightbox da linha do tempo ── */
.tl-lightbox { width: min(760px, 94vw); max-height: 84vh; display: flex; flex-direction: column; }
.tl-lb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tl-lb-title { font-weight: 700; font-size: 16px; color: var(--navy-1); }
.tl-lb-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.tl-lb-search { display: flex; gap: 8px; margin: 14px 0 6px; }
.tl-lb-search .input { flex: 1; }
.tl-lb-body { overflow-y: auto; flex: 1; min-height: 0; padding-top: 6px; }
.tl-lb-meta { font-size: 12px; color: var(--text-2); padding: 6px 2px; }
.tl-event { display: flex; align-items: baseline; gap: 10px; padding: 5px 2px; font-size: 13px; border-bottom: 1px dashed var(--border); }
.tl-event:last-child { border-bottom: 0; }
.tl-time { color: var(--text-3); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-badge { border-radius: 999px; padding: 1px 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; flex-shrink: 0; }
.tl-created { background: var(--green-bg); color: var(--green-text); }
.tl-updated { background: var(--blue-subtle); color: var(--blue); }
.tl-desc { color: var(--text-1); min-width: 0; }
.tl-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tl-name { color: var(--text-1); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-failed { color: var(--red); font-size: 11px; font-weight: 700; }
.tl-more { margin: 8px 0 2px; }

/* ── Responsivo ── */
@media (max-width: 900px) {
  .panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow-lg); width: min(480px, 92vw); }
  .search { width: 170px; }
  .filter-name { display: none; }
  .grid-wrap { padding: 10px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 35;
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
    width: min(280px, 82vw);
    padding-top: 60px;
  }
  .sidebar.open { transform: translateX(0); }
  .side-toggle { display: inline-flex !important; }
}
