:root {
  --bg: #e8eef5;
  --card: #ffffff;
  --text: #1a2238;
  --muted: #64748b;
  --bd: #e2e8f0;
  --pri: #0b1a30;
  --pri-hover: #132744;
  --pri-light: #eef3f9;
  --acc: #c5a359;
  --acc-hover: #b08f45;
  --acc-light: #f7f1e4;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --wa: #b45309;
  --wa-bg: #fef3c7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-lift: 0 4px 12px rgba(197, 163, 89, 0.18), 0 14px 32px rgba(17, 24, 39, 0.1);
  --pg-glow: rgba(197, 163, 89, 0.16);
  --sidebar-w: 248px;
  --sidebar-collapsed: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Outfit', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.boot-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.95rem;
}
.boot-card img {
  width: 56px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(15, 37, 71, 0.15));
}
html.restoring-session #boot-screen { display: flex; }
html.restoring-session #login-screen { display: none !important; }

.login-screen {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(11, 26, 48, 0.55), rgba(22, 49, 88, 0.35)),
    url('/tapiratiba.png') center / cover no-repeat fixed;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.login-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  width: min(1100px, 100%);
  min-height: 100vh;
  margin: 0 auto;
}
.login-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 48px 44px;
  color: #fff;
  background: linear-gradient(160deg, rgba(11, 26, 48, 0.72), rgba(22, 49, 88, 0.55));
  backdrop-filter: blur(1.5px);
}
.login-hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.login-hero-brand img {
  width: 48px;
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
}
.login-hero-brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.login-hero-brand span {
  display: block;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.78);
  margin-top: 2px;
}
.login-hero h1 {
  font-size: clamp(1.65rem, 2.4vw, 2.15rem);
  line-height: 1.2;
  font-weight: 700;
  max-width: 18ch;
}
.login-hero > p {
  color: rgba(255,255,255,0.88);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 36ch;
}
.login-hero-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-hero-list li {
  position: relative;
  padding-left: 22px;
  font-size: 0.92rem;
  color: rgba(255,255,255,0.92);
}
.login-hero-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7dcf9a;
  box-shadow: 0 0 0 3px rgba(125, 207, 154, 0.25);
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  background: rgba(244, 246, 249, 0.92);
  backdrop-filter: blur(6px);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  padding: 34px 30px;
  box-shadow: 0 18px 40px rgba(11, 26, 48, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.login-kicker {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e8eef8;
  color: var(--pri);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.login-card h2 {
  font-size: 1.75rem;
  color: #0f172a;
  margin: 0 0 6px;
}
.login-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 22px;
  line-height: 1.4;
}
.input-group { margin-bottom: 14px; }
.input-group label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; }
.input-group input, .field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.btn-login, .btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 650;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}
.btn-login {
  width: 100%;
  background: var(--pri);
  color: #fff;
  margin-top: 8px;
  padding: 13px;
  font-size: 0.98rem;
}
.btn-login:hover, .btn-primary:hover {
  background: var(--pri-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(11, 26, 48, 0.18);
}
.btn-login:active, .btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: none;
}
.btn-primary { background: var(--pri); color: #fff; }
.btn-acc { background: var(--acc); color: #0b1a30; }
.btn-acc:hover {
  background: var(--acc-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(197, 163, 89, 0.35);
}
.btn-ghost { background: var(--pri-light); color: var(--pri); }
.btn-ghost:hover {
  background: #e2eaf4;
  transform: translateY(-1px);
}
.btn-outline {
  background: #fff;
  color: var(--pri);
  border: 1px solid var(--bd);
}
.btn-outline:hover {
  background: var(--pri-light);
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(11, 26, 48, 0.08);
}
.btn-danger { background: var(--err-bg); color: var(--err); }
.btn-danger:hover {
  background: #fecaca;
  transform: translateY(-1px);
}
.login-error { margin-top: 12px; color: var(--err); font-size: 0.88rem; text-align: center; }

@media (max-width: 860px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero {
    min-height: 42vh;
    padding: 32px 24px;
  }
  .login-hero h1 { max-width: none; font-size: 1.55rem; }
  .login-panel { padding: 24px 16px 36px; }
}

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  background-color: #e8eef5;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--pg-glow), transparent 60%),
    linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
}

.rail-spacer {
  width: calc(var(--sidebar-w) + 24px);
  flex-shrink: 0;
  transition: width 0.2s ease;
}
.rail-spacer[data-collapsed="true"] {
  width: calc(var(--sidebar-collapsed) + 24px);
}

.sidebar {
  position: fixed;
  left: 12px;
  top: 12px;
  bottom: 12px;
  z-index: 1200;
  width: var(--sidebar-w);
  padding: 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--bd);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 37, 71, 0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease, box-shadow 0.2s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); padding: 12px 6px; }
.sidebar.collapsed.flyout {
  width: var(--sidebar-w);
  padding: 12px;
  box-shadow: 8px 0 24px rgba(15, 37, 71, 0.16);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--bd);
  min-height: 48px;
}
.sidebar-brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.logo-box {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--bd);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-logo { width: 30px; height: auto; display: block; }
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.logo-kicker {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}
.logo-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}
.logo-subtitle {
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
}
.btn-sidebar-toggle,
.expand-rail-btn,
.icon-btn,
.mobile-menu-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.btn-sidebar-toggle:hover,
.expand-rail-btn:hover,
.mobile-menu-btn:hover,
.icon-btn:hover {
  background: rgba(15, 37, 71, 0.05);
  color: var(--pri);
  transform: translateY(-1px);
}
.icon-btn-logout:hover {
  background: #fee2e2;
  color: #dc2626;
}
.expand-rail-btn {
  display: none;
  align-self: center;
  margin-bottom: 8px;
}
.menu-label {
  padding: 0 8px;
  margin: 0 0 4px;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.65rem;
}

.nav-tabs {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.nav-link, .nav-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.18s ease;
}
.nav-link:hover, .nav-group-btn:hover {
  background: rgba(15, 37, 71, 0.06);
  color: var(--pri);
}
.nav-link:active, .nav-group-btn:active { transform: none; }
.nav-link.active {
  background: var(--pri);
  color: #fff;
  font-weight: 700;
  box-shadow: none;
}
.nav-link.active:hover {
  background: var(--pri-hover);
  color: #fff;
}
.nav-ico { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.9; }
.nav-chevron { margin-left: auto; font-size: 0.75rem; opacity: 0.7; transition: transform 0.2s; }
.nav-group.open .nav-chevron { transform: rotate(180deg); }
.nav-group-btn { font-weight: 600; color: var(--text); }
.nav-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 12px;
}
.nav-group.open .nav-sub { display: flex; }
.nav-sub .nav-link {
  padding: 0 12px;
  font-size: 0.84rem;
  height: 38px;
  color: var(--muted);
}

.sidebar.collapsed:not(.flyout) .sidebar-header {
  justify-content: center;
  align-items: center;
}
.sidebar.collapsed:not(.flyout) .sidebar-brand-text,
.sidebar.collapsed:not(.flyout) .menu-label,
.sidebar.collapsed:not(.flyout) .nav-label,
.sidebar.collapsed:not(.flyout) .nav-chevron,
.sidebar.collapsed:not(.flyout) .nav-sub,
.sidebar.collapsed:not(.flyout) .profile-text,
.sidebar.collapsed:not(.flyout) .icon-btn,
.sidebar.collapsed:not(.flyout) .btn-sidebar-toggle { display: none; }
.sidebar.collapsed:not(.flyout) .nav-group-btn,
.sidebar.collapsed:not(.flyout) .nav-link { justify-content: center; padding: 0 8px; }
.sidebar.collapsed:not(.flyout) .expand-rail-btn { display: inline-flex; }
.sidebar.collapsed:not(.flyout) .profile-section {
  justify-content: center;
  padding: 4px;
}

.profile-section {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 8px;
  margin-top: 8px;
}
.avatar {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  background: var(--acc);
  color: var(--pri);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  flex-shrink: 0;
}
.profile-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.profile-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.profile-role {
  font-size: 0.62rem;
  color: var(--muted);
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1250;
  border: none;
  background: rgba(15, 37, 71, 0.55);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.mobile-menu-btn { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  background: transparent;
  border: none;
  padding: 22px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.topbar h2 { font-size: 1.15rem; color: var(--pri); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-dyn { display: flex; gap: 8px; align-items: center; }
.content { padding: 24px; flex: 1; animation: fadeIn 0.4s ease both; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card h3 { font-size: 0.95rem; margin-bottom: 10px; }
.stat { font-size: 1.6rem; font-weight: 700; color: var(--pri); }
.stat-label { color: var(--muted); font-size: 0.82rem; }
.stat-hint { color: var(--muted); font-size: 0.72rem; margin-top: 4px; }
button.card {
  font: inherit;
  text-align: left;
  color: inherit;
  width: 100%;
}
.card-link {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.card-link:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}
.card-link:active { transform: translateY(0) scale(0.99); }
.alert-compact {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--wa);
  border-radius: 10px;
  background: var(--wa-bg);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: opacity 0.15s;
}
.alert-compact:hover { opacity: 0.92; }
.alert-compact-go {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--wa);
  white-space: nowrap;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  padding: 10px 8px;
  background: var(--pri-light);
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--bd);
}
tbody td { padding: 10px 8px; border-bottom: 1px solid var(--bd); vertical-align: middle; }
tbody tr {
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
tbody tr:hover { background: #f1f5f9; }
.card-table tbody tr:hover {
  background: #eef3f9;
  box-shadow: inset 3px 0 0 var(--acc);
}
.card-table tbody tr:active { background: #e8eef5; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-wa { background: var(--wa-bg); color: var(--wa); }
.badge-muted { background: #e2e8f0; color: #475569; }
.badge-ic { background: #dbeafe; color: #1d4ed8; }
.badge-mp { background: #dcfce7; color: #15803d; }
.badge-p { background: #fef3c7; color: #b45309; }
.badge-up { background: #fee2e2; color: #b91c1c; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.muted { color: var(--muted); font-size: 0.85rem; }
.hidden { display: none !important; }
.panel { display: none; }
.panel.active { display: block; }
.empty { text-align: center; padding: 28px; color: var(--muted); }

.matrix-wrap { overflow: auto; max-height: 58vh; border: 1px solid var(--bd); border-radius: 10px; }
.matrix-wrap input[type="number"] { width: 72px; padding: 6px; }
.matrix-wrap th, .matrix-wrap td { white-space: nowrap; font-size: 0.8rem; }

.table-fit-wrap { width: 100%; overflow: hidden; }
.table-fit {
  width: 100%;
  table-layout: fixed;
  font-size: 0.8rem;
}
.table-fit th, .table-fit td {
  padding: 7px 6px;
  vertical-align: top;
  word-break: break-word;
}
.table-fit .col-num { width: 7%; text-align: right; white-space: nowrap; }
.table-fit .col-saldo { width: 18%; min-width: 120px; }
.table-fit .col-act { width: 9.5rem; }
.table-fit .cell-item { line-height: 1.3; }
.table-fit .cell-tags { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 3px; }
.table-fit .cell-ellip {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-fit .pct-mini { font-size: 0.7rem; margin-top: 1px; }
.btn-xs { padding: 3px 7px; font-size: 0.72rem; border-radius: 7px; }
.td-actions { white-space: nowrap; display: flex; flex-wrap: wrap; gap: 3px; }

.saldo-bar {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: #e8edf3;
  overflow: hidden;
  min-width: 88px;
}
.saldo-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  transition: width 0.25s ease;
}
.saldo-bar-ok .saldo-bar-fill { background: #86efac; }
.saldo-bar-wa .saldo-bar-fill { background: #fdba74; }
.saldo-bar-err .saldo-bar-fill { background: #fca5a5; }
.saldo-bar-muted .saldo-bar-fill { background: #cbd5e1; }
.saldo-bar-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--pri);
  white-space: nowrap;
  padding: 0 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 37, 71, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  animation: backdropIn 0.2s ease;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: min(480px, 100%);
  max-height: min(78vh, 560px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
  animation: pgRiseIn 0.28s ease both;
}
.modal.modal-wide {
  width: min(960px, 100%);
  max-height: min(88vh, 820px);
}
.modal-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bd);
  background: #fff;
}
.modal-hdr h3 {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}
.modal-x {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: var(--pri-light);
  color: var(--pri);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
.modal-x:hover { background: #e2eaf4; transform: scale(1.05); }
.modal-x:active { transform: scale(0.95); }
.modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px 16px;
  min-height: 0;
}
.modal-foot {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--bd);
  background: #f8fafc;
}
.modal-foot:empty { display: none; }
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pgRiseIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.pg-hide-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.pg-hide-scrollbar::-webkit-scrollbar { display: none; }
.doc-frame {
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #fff;
  min-height: 320px;
  padding: 8px;
}
.doc-frame iframe { width: 100%; min-height: 480px; border: none; }

.toast {
  position: fixed; right: 18px; bottom: 18px;
  background: var(--pri); color: #fff;
  padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 2100;
  display: none;
}
.toast.show { display: block; }
.toast.err { background: var(--err); }

.filters-card {
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}
.filters-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filters-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 72px;
}
.filter-date {
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  font-size: 0.85rem;
  color: var(--text);
  min-width: 9.5rem;
}
.btn.active-filter {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}
.filters-line-wrap { row-gap: 8px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.cat-chips button,
.chip-row button {
  border: none;
  background: #eef2f6;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  transition: background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.cat-chips button:hover,
.chip-row button:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}
.cat-chips button:active,
.chip-row button:active { transform: scale(0.97); }
.cat-chips button.active,
.chip-row button.active {
  background: var(--pri);
  border-color: var(--pri);
  color: #fff;
  box-shadow: 0 4px 10px rgba(11, 26, 48, 0.16);
}
.card-table { padding: 0; overflow: hidden; }
.card-table table { margin: 0; }
.card-table h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.card-table thead th {
  padding: 12px 14px;
  background: #f8fafc;
}
.card-table tbody td { padding: 12px 14px; }
.card-table .pager { padding: 12px 14px 14px; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 14px 8px 6px;
  width: 100%;
  margin: 0 auto;
}
.pager button {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: #fff;
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--pri);
  line-height: 1;
}
.pager button:disabled { opacity: 0.35; cursor: default; }
.pager span {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 7.5rem;
  text-align: center;
}
.alerts-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--pri-light); }
.row-warn td { background: rgba(197, 163, 89, 0.08); }
.form-sections { display: flex; flex-direction: column; gap: 14px; }
.form-section h4 {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.inst-editor { display: flex; flex-direction: column; gap: 10px; }
.inst-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
}
.inst-head-main { flex: 1; min-width: 200px; }
.inst-head-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.inst-head-meta { font-size: 0.78rem; margin-top: 3px; line-height: 1.35; }
.inst-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.card-tight { padding: 10px 12px; }
.card-head-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card-head-inline h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.card-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.field textarea {
  width: 100%;
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}
.badge-cha { background: #e0e7ff; color: #3730a3; }
.badge-lic { background: #fce7f3; color: #9d174d; }
.badge-tipo { background: var(--acc-light); color: #7a5c1e; }
.badge-err { background: var(--err-bg); color: var(--err); }
.row-crit td { background: rgba(185, 28, 28, 0.08); }

.dist-editor { display: flex; flex-direction: column; gap: 14px; }
.dist-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.dist-step {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
}
.dist-step .n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--pri); color: #fff; font-size: 0.75rem; font-weight: 700;
  margin-right: 6px;
}
.dist-step h4 { display: inline; font-size: 0.9rem; }
.dist-step p { margin-top: 6px; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.dist-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dist-escola-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.dist-escola-bar .filters-label { margin-top: 8px; }
.dist-escola-bar .chip-row button.has-qty:not(.active) {
  box-shadow: inset 0 0 0 1.5px var(--acc);
}
.dist-escola-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: baseline;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bd);
  font-size: 0.88rem;
}
.dist-fill-table .col-qtd { width: 7.5rem; text-align: right; }
.dist-qtd-input {
  width: 100%;
  max-width: 6.5rem;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: right;
  background: #fff;
}
.dist-qtd-input:focus {
  outline: none;
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(11, 26, 48, 0.08);
}
.dist-qtd-input:disabled { background: #f1f5f9; color: var(--muted); }
.dist-grid-wrap {
  overflow: auto;
  max-height: min(70vh, 640px);
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #fff;
}
.dist-grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
  min-width: 100%;
}
.dist-grid th,
.dist-grid td {
  border-right: 1px solid var(--bd);
  border-bottom: 1px solid var(--bd);
  padding: 3px 5px;
  white-space: nowrap;
  vertical-align: middle;
}
.dist-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f5f9;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 1px 0 var(--bd);
}
.dist-grid th.sticky-col,
.dist-grid td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  min-width: 150px;
  max-width: 220px;
  white-space: normal;
  text-align: left;
  box-shadow: 1px 0 0 var(--bd);
}
.dist-grid thead th.sticky-col {
  z-index: 3;
  background: #e8eef5;
}
.dist-grid tbody tr {
  transition: background 0.15s ease;
}
.dist-grid tbody tr:hover { background: #f8fafc; }
.dist-grid tbody tr.dist-row-wa,
.dist-grid tbody tr.dist-row-wa td.sticky-col { background: rgba(251, 191, 36, 0.12); }
.dist-grid tbody tr.dist-row-err,
.dist-grid tbody tr.dist-row-err td.sticky-col { background: rgba(248, 113, 113, 0.14); }
.dist-grid .cell-saldo {
  font-size: 0.72rem;
  margin-top: 2px;
  line-height: 1.3;
}
.dist-grid .cell-saldo .badge { font-size: 0.65rem; padding: 0 4px; }
.dist-grid .dist-cell { padding: 1px; text-align: center; }
.dist-grid .dist-qtd-input {
  width: 3.5rem;
  max-width: none;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.12s;
}
.dist-grid .dist-qtd-input:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: #fff;
  transform: scale(1.04);
}
.dist-grid .dist-qtd-input:focus {
  border-color: var(--acc);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(197, 163, 89, 0.35);
  transform: scale(1.06);
}
.dist-grid .dist-row-total {
  font-weight: 700;
  text-align: right;
  background: #f8fafc;
}
.dist-grid-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.dist-grid-tools select {
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  font: inherit;
}
.dist-row-actions {
  padding: 2px !important;
  text-align: center;
}
.btn-fill-row {
  border: 1px solid var(--bd);
  background: #fff;
  color: var(--pri);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.btn-fill-row:hover {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
  transform: scale(1.05);
}
.btn-fill-row:active { transform: scale(0.96); }
.nf-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #f8fafc, #f7f1e4);
}
.nf-pendente-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}
.nf-pendente-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #fff;
}
.nf-check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #f8fafc;
}
.nf-check-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.85rem;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.nf-check-item input { margin-top: 2px; }
.nf-conf-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--bd);
}
.nf-conf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.nf-conf-toolbar strong { font-size: 0.92rem; }
.nf-conf-table { margin: 0 0 10px; }
.nf-conf-table input[type="date"] {
  width: 100%;
  min-width: 9.5rem;
  font-size: 0.82rem;
}
.nf-conf-dia {
  margin: 12px 0 6px;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
.nf-conf-resumo {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--bd);
}
.nf-conf-resumo:empty { display: none; }
.nf-conf-resumo.is-off {
  background: #fff7ed;
  border-color: #fdba74;
}
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #f8fafc;
}
.pick-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
}
.pick-item:hover { border-color: var(--pri); }
.pick-item.is-on {
  background: rgba(11, 61, 145, 0.08);
  border-color: var(--pri);
  box-shadow: inset 0 0 0 1px var(--pri);
}
.pick-item input { width: 16px; height: 16px; accent-color: var(--pri); flex-shrink: 0; }
.nf-vinculo-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  line-height: 1.55;
  max-height: 220px;
  overflow: auto;
}
@media (max-width: 720px) {
  .nf-hero { flex-direction: column; }
}
@media (max-width: 900px) {
  .dist-steps { grid-template-columns: 1fr; }
}

.ctrl-inst-select {
  min-width: 220px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
}
.pnae-overview-hint { margin: 0 0 12px; }
.pnae-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.pnae-card { text-align: left; }
.pnae-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.pnae-card-num { margin-left: 4px; }
.pnae-card-pct {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--pri);
  white-space: nowrap;
}
.pnae-card-meta { font-size: 0.8rem; margin-bottom: 10px; }
.pnae-bars { display: flex; flex-direction: column; gap: 10px; }
.pnae-bars-compact { gap: 6px; margin-top: 4px; }
.pnae-bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) 1.5fr auto;
  gap: 10px;
  align-items: center;
}
.pnae-bars-compact .pnae-bar-row {
  grid-template-columns: 52px 1fr 42px;
  gap: 6px;
}
.pnae-bar-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pnae-bar-name { font-size: 0.82rem; color: var(--text); }
.pnae-bars-compact .pnae-bar-name { display: none; }
.pnae-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8edf3;
  overflow: hidden;
}
.pnae-bars-compact .pnae-bar-track { height: 8px; }
.pnae-bar-fill { height: 100%; border-radius: 999px; min-width: 0; }
.pnae-fill-ic { background: #3b82f6; }
.pnae-fill-mp { background: #22c55e; }
.pnae-fill-p { background: #eab308; }
.pnae-fill-up { background: #ef4444; }
.pnae-fill-sem { background: #94a3b8; }
.pnae-bar-pct { font-size: 0.82rem; text-align: right; white-space: nowrap; }
.pnae-bars-compact .pnae-bar-pct { font-size: 0.75rem; }
@media (max-width: 640px) {
  .pnae-bar-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .pnae-bar-pct { text-align: left; }
}

/* —— Cascata ao trocar de menu + microinterações —— */
@keyframes cascadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.cascade-in {
  animation: cascadeIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--cascade-i, 0) * 48ms);
}
.pick-item {
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.12s;
}
.pick-item:hover {
  border-color: var(--pri);
  transform: translateY(-1px);
}
.pick-item:active { transform: scale(0.99); }
.sidebar-foot.profile-section {
  margin-top: auto;
}
code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.84em;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 6px;
}

.pnae-adeq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.pnae-adeq-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.pnae-adeq-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.pnae-adeq-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s ease;
}
.pnae-adeq-ok .pnae-adeq-fill { background: #4ade80; }
.pnae-adeq-wa .pnae-adeq-fill { background: #fbbf24; }
.pnae-adeq-err .pnae-adeq-fill { background: #f87171; }
.pnae-adeq-muted .pnae-adeq-fill { background: #94a3b8; }
.pnae-adeq-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #0f172a;
  opacity: 0.35;
}

@media (max-width: 900px) {
  .rail-spacer { display: none; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar {
    margin: 12px 16px 0;
    padding: 8px 12px;
    min-height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
  }
  .content { padding: 16px; }
  .sidebar,
  .sidebar.collapsed,
  .sidebar.collapsed.flyout {
    left: 0;
    top: 0;
    bottom: 0;
    width: 248px;
    padding: 12px;
    border-radius: 0 8px 8px 0;
    box-shadow: 8px 0 24px rgba(15, 37, 71, 0.16);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 1300;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar .btn-sidebar-toggle,
  .sidebar .expand-rail-btn,
  .sidebar.collapsed:not(.flyout) .btn-sidebar-toggle,
  .sidebar.collapsed:not(.flyout) .expand-rail-btn { display: none; }
  .sidebar.collapsed:not(.flyout) .sidebar-brand-text,
  .sidebar.collapsed:not(.flyout) .menu-label,
  .sidebar.collapsed:not(.flyout) .nav-label,
  .sidebar.collapsed:not(.flyout) .nav-chevron,
  .sidebar.collapsed:not(.flyout) .profile-text,
  .sidebar.collapsed:not(.flyout) .icon-btn { display: flex; }
  .sidebar.collapsed:not(.flyout) .nav-group.open .nav-sub { display: flex; }
  .sidebar.collapsed:not(.flyout) .nav-group-btn,
  .sidebar.collapsed:not(.flyout) .nav-link { justify-content: flex-start; padding: 0 12px; }
  .sidebar.collapsed:not(.flyout) .profile-section { justify-content: flex-start; padding: 8px; }
  .sidebar.collapsed:not(.flyout) .sidebar-header { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .cascade-in,
  .modal,
  .modal-backdrop,
  .content {
    animation: none !important;
  }
  .btn:hover,
  .btn-login:hover,
  .btn-primary:hover,
  .btn-acc:hover,
  .btn-ghost:hover,
  .btn-outline:hover,
  .btn-danger:hover,
  .nav-link:hover,
  .nav-group-btn:hover,
  .card-link:hover,
  .chip-row button:hover,
  .cat-chips button:hover,
  .dist-grid .dist-qtd-input:hover:not(:disabled),
  .dist-grid .dist-qtd-input:focus,
  .pick-item:hover {
    transform: none !important;
  }
}
