:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: #eef1f7;
  --border: #e2e6ef;
  --text: #1a2233;
  --text-muted: #6b7488;
  --primary: #4f6bff;
  --primary-hover: #3a54d6;
  --primary-soft: rgba(79, 107, 255, 0.12);
  --sidebar-bg: #fbfcfe;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.12);
  --success: #12a670;
  --success-soft: rgba(18, 166, 112, 0.12);
  --warning: #cc8a00;
  --warning-soft: rgba(204, 138, 0, 0.13);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 22px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), 0 0 10px rgba(91, 140, 255, 0.7);
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 11px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.75; }

.nav a:hover { background: var(--surface-muted); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav a.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.content { flex: 1; min-width: 0; }

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-titulos h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.topbar-titulos p { margin: 3px 0 0; font-size: 13px; color: var(--text-muted); }

main.page { padding: 28px 32px; max-width: 1200px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.fluxo-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 280px));
  gap: 14px;
}

.fluxo-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 220px));
  gap: 12px;
}

.fluxo-card { padding: 16px; margin-bottom: 0; }

.fluxo-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.fluxo-card-head h3 { margin: 0; font-size: 14px; line-height: 1.3; }

.fluxo-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fluxo-icon svg { width: 17px; height: 17px; }

.fluxo-icon.muted { background: var(--surface-muted); color: var(--text-muted); }

.fluxo-card .btn {
  width: 100%;
  text-align: center;
  font-size: 12.5px;
  padding: 8px 12px;
}

.mono { font-family: var(--mono); letter-spacing: -0.01em; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}

.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-card.stat-aberto .stat-value { color: var(--danger); }
.stat-card.stat-andamento .stat-value { color: var(--warning); }
.stat-card.stat-resolvido .stat-value { color: var(--success); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card h3 { margin-top: 0; font-size: 15px; }
.card h3 small { color: var(--text-muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-muted); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-aberto { background: var(--danger-soft); color: var(--danger); }
.badge-em_andamento { background: var(--warning-soft); color: var(--warning); }
.badge-resolvido { background: var(--success-soft); color: var(--success); }

form.inline { display: inline; }

label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin: 14px 0 5px;
}

input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

table select {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}

button, .btn {
  cursor: pointer;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}

button:hover, .btn:hover { background: var(--primary-hover); }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger-soft); }
.danger:hover { background: var(--danger-soft); }
.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.ghost:hover { background: var(--surface-muted); color: var(--text); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  width: 30px;
  height: 30px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.divider { height: 1px; background: var(--border); margin: 20px 0; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 320px;
}

.login-card .brand { padding: 0 0 20px; justify-content: center; }
.login-card button { width: 100%; margin-top: 8px; }

.alert {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 4px;
}

.conta-link {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 10px; margin-bottom: 10px;
  border-radius: var(--radius-sm); text-decoration: none; font-size: 13px;
}
.conta-link span { color: var(--text-muted); font-size: 12px; }
.conta-link:hover, .conta-link.active { background: var(--surface-muted); }

.perm-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px; }
.perm-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; font-weight: 400; color: var(--text); margin: 0; cursor: pointer; }
.perm-item input { margin-top: 2px; flex-shrink: 0; }
.perm-item small { display: block; color: var(--text-muted); }

.alert.ok { background: var(--success-soft); color: var(--success); }
.badge-alerta { background: var(--warning-soft); color: var(--warning); }

/* barra de filtros das listas */
.filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.filtros .filtro { width: 170px; }
.filtros .filtro label { margin: 0 0 5px; }
.filtros input[type="date"], .filtros select { font-family: inherit; height: 38px; }
.filtros button { height: 38px; }

/* tela de Acessos do usuario */
.acessos { max-width: 760px; }
.acessos .card { margin-bottom: 14px; }
.acesso-usuario { display: flex; align-items: center; gap: 14px; }
.acesso-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 18px;
}
.acesso-usuario-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.acesso-usuario-info span { color: var(--text-muted); font-size: 12.5px; }
.acesso-secao-titulo { margin-bottom: 12px; }

.perfil-opcoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.perfil-opcao {
  display: flex; gap: 10px; align-items: flex-start; margin: 0; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-weight: 400; color: var(--text); font-size: 13px; transition: border-color 0.15s, background 0.15s;
}
.perfil-opcao input { margin-top: 2px; accent-color: var(--primary); }
.perfil-opcao small { display: block; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.perfil-opcao:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.acesso-modelos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 14px; font-size: 12.5px; color: var(--text-muted); }
.acesso-modelos button { padding: 6px 12px; font-size: 12.5px; }

.acesso-modulo { padding-top: 16px; padding-bottom: 6px; border-left: 3px solid var(--border); }
.acesso-modulo.ativo { border-left-color: var(--primary); }
.acesso-modulo-cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.acesso-modulo-cabecalho h3 { margin: 0 0 2px; }
.acesso-modulo-cabecalho small { color: var(--text-muted); font-size: 12.5px; }
.acesso-modulo-acoes { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.acesso-contador { font-size: 12px; color: var(--text-muted); background: var(--surface-muted); padding: 3px 8px; border-radius: 999px; }
.acesso-todos { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; cursor: pointer; }

.acesso-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: 0; padding: 12px 0; border-bottom: 1px solid var(--border);
  font-weight: 400; color: var(--text); cursor: pointer;
}
.acesso-item:last-child { border-bottom: none; }
.acesso-item-texto { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.acesso-item-texto small { color: var(--text-muted); font-size: 12.5px; }
.acesso-item-texto .acesso-requer { color: var(--warning); font-size: 11.5px; }

.switch { position: relative; display: inline-flex; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-trilho {
  width: 38px; height: 22px; border-radius: 999px; background: var(--border);
  position: relative; transition: background 0.15s;
}
.switch-trilho::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25); transition: transform 0.15s;
}
.switch input:checked + .switch-trilho { background: var(--primary); }
.switch input:checked + .switch-trilho::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-trilho { box-shadow: 0 0 0 3px var(--primary-soft); }

.acesso-nota { color: var(--text-muted); font-size: 12px; margin: 4px 0 14px; }
.acesso-rodape {
  position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 13px; color: var(--text-muted);
}
@media (max-width: 600px) {
  .acesso-modulo-cabecalho, .acesso-rodape { flex-direction: column; align-items: stretch; }
}

/* dica (tooltip) ao passar o mouse: use data-tip="texto" */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 20;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }
.acoes-icones { display: flex; gap: 6px; }

/* janelas de dialogo do sistema (dialogo.js) */
dialog.dlg {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(440px, 92vw);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.28);
}
dialog.dlg[open] { animation: dlg-entrada 0.16s ease-out; }
dialog.dlg::backdrop { background: rgba(26, 34, 51, 0.45); backdrop-filter: blur(2px); }
@keyframes dlg-entrada { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dlg-form { padding: 24px 24px 20px; }
.dlg-cabecalho { display: flex; gap: 14px; align-items: flex-start; }
.dlg-icone {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.dlg-perigo .dlg-icone { background: var(--danger-soft); color: var(--danger); }
.dlg-texto { flex: 1; min-width: 0; }
.dlg-titulo { margin: 2px 0 6px; font-size: 16px; }
.dlg-msg { margin: 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.dlg-input { margin-top: 16px; }
.dlg-acoes { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
button.dlg-ok-perigo { background: var(--danger); }
button.dlg-ok-perigo:hover { background: #c93a3f; }
