@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --brand: #2563EB;
  --brand-secondary: #3B82F6;
  --brand-light: #93C5FD;
  --brand-soft: #DBEAFE;
  --nav: #172554;
  --white: #FFFFFF;
  --bg: #F8FAFC;
  --border: #E2E8F0;
  --muted: #64748B;
  --text: #1E293B;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #DC2626;
  --info: #0EA5E9;
  --shadow: 0 18px 45px rgba(37, 99, 235, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; min-height: 100vh; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .app-shell { margin-left: 0; }
a { color: inherit; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 280px; padding: 24px 18px;
  background: #2563EB !important; color: var(--white); display: flex; flex-direction: column; gap: 22px;
  border-right: 1px solid rgba(255,255,255,.18);
  transition: transform .2s ease;
}
.brand { padding-bottom: 20px; border-bottom: 1px solid rgba(219,234,254,.28); }
.brand img { width: 136px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 14px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1.08rem; font-weight: 800; color: var(--white); }
.brand span { color: var(--brand-soft); font-size: .88rem; margin-top: 4px; }
.side-nav { display: grid; gap: 6px; overflow-y: auto; }
.side-nav a { padding: 9px 12px; border-radius: 8px; text-decoration: none; color: #E0ECFF; font-weight: 600; font-size: .94rem; }
.side-nav a:hover, .side-nav a.is-active { background: rgba(255,255,255,.16); color: var(--white); }
.nav-home { display: grid; gap: 2px; border: 1px solid rgba(219,234,254,.28); background: rgba(255,255,255,.12); }
.nav-home span, .visitor-nav span, .tool-nav span { font-weight: 900; }
.nav-home small, .visitor-nav small, .tool-nav small { color: var(--brand-soft); font-size: .76rem; }
.nav-group { border-top: 1px solid rgba(219,234,254,.22); padding-top: 10px; }
.nav-group summary {
  list-style: none; cursor: pointer; color: #FFFFFF; font-size: .84rem; font-weight: 900;
  text-transform: uppercase; padding: 7px 10px; display: flex; align-items: center; justify-content: space-between;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: "+"; color: var(--white); font-size: .9rem; }
.nav-group[open] summary::after { content: "-"; }
.nav-group a { display: block; margin: 3px 0; padding-left: 12px; }
.visitor-nav, .tool-nav {
  margin-top: 10px; display: grid; gap: 2px; border: 1px solid rgba(255,255,255,.35);
  background: var(--nav); color: var(--white) !important;
}
.tool-nav { margin-top: 0; background: rgba(255,255,255,.14); }

.app-shell { min-height: 100vh; margin-left: 280px; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar {
  min-height: 76px; padding: 16px 30px; background: var(--white);
  color: var(--text); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
}
.sidebar-toggle {
  min-height: 38px;
  padding: 8px 12px;
  background: var(--brand-soft);
  border-color: var(--brand-soft);
  color: var(--brand);
}
.topbar h1 { margin: 0; font-size: 1.45rem; line-height: 1.2; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.user-menu { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.user-menu a { text-decoration: none; color: var(--brand); border: 1px solid var(--border); border-radius: 8px; padding: 8px 13px; }

.content { width: min(1240px, calc(100% - 40px)); margin: 28px auto; flex: 1; }
.footer { padding: 16px 24px; background: var(--white); color: var(--muted); text-align: center; border-top: 1px solid var(--border); }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.span-wide { grid-column: span 2; }
.stack { display: grid; gap: 12px; }
.card, .panel {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.metric span { color: var(--muted); font-size: .82rem; font-weight: 800; text-transform: uppercase; }
.metric strong { display: block; margin-top: 8px; font-size: 2rem; }
.metric small { display: block; margin-top: 6px; color: var(--muted); font-weight: 700; }
.hero-panel {
  margin-bottom: 22px; padding: 28px; border-radius: var(--radius); color: var(--text);
  background: linear-gradient(135deg, var(--white), var(--brand-soft));
  display: flex; justify-content: space-between; align-items: center; gap: 18px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.hero-panel span { color: var(--brand-secondary); font-weight: 800; text-transform: uppercase; font-size: .78rem; }
.hero-panel h2 { margin: 8px 0; font-size: clamp(1.7rem, 3vw, 2.4rem); }
.hero-panel p { margin: 0; color: var(--muted); }
.dashboard-hero { background: linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 52%, #DBEAFE 100%); }
.metric-grid .card { box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06); }
.metric-grid .card { position: relative; overflow: hidden; }
.metric-grid .card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); }
.metric-grid .metric-caixas::before { background: var(--info); }
.metric-grid .metric-emprestimos::before { background: var(--warning); }
.metric-grid .metric-requisicoes::before { background: var(--success); }
.hero-search { display: flex; gap: 10px; flex-wrap: wrap; min-width: min(460px, 100%); }
.hero-search input { flex: 1; min-width: 220px; }
.section-title { margin: 28px 0 14px; }
.section-title h2 { margin: 0; font-size: 1.25rem; }
.section-title p { margin: 4px 0 0; color: var(--muted); }
.action-card {
  min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); text-decoration: none;
  background: var(--white); box-shadow: var(--shadow);
}
.action-card strong { font-size: 1.05rem; color: var(--brand); }
.action-card span { color: var(--muted); line-height: 1.4; }
.action-card:hover { border-color: var(--brand-secondary); background: var(--brand-soft); }
.dashboard-hero-v2 {
  margin-bottom: 22px; padding: 30px; border-radius: var(--radius); background: var(--white);
  border: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  align-items: center; gap: 22px; box-shadow: var(--shadow);
}
.dashboard-hero-v2 > div { border-left: 4px solid var(--brand); padding-left: 18px; }
.dashboard-hero-v2 span { color: var(--brand); font-size: .78rem; font-weight: 900; text-transform: uppercase; }
.dashboard-hero-v2 h2 { margin: 8px 0; font-size: clamp(1.8rem, 3vw, 2.6rem); color: var(--nav); }
.dashboard-hero-v2 p { margin: 0; color: var(--muted); font-weight: 600; }
.dashboard-grid { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; }
.dashboard-quick { margin: 0 0 18px; }
.dashboard-quick-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.dashboard-quick-form input { min-height: 50px; font-size: 1.05rem; }
.dashboard-quick-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 14px; }
.dashboard-quick-card { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.dashboard-quick-card strong { color: var(--nav); font-size: 1.08rem; }
.dashboard-quick-card span, .dashboard-quick-card p, .dashboard-quick-card small { display: block; margin: 0; color: var(--muted); }
.dashboard-quick-card span { margin-top: 3px; color: var(--text); font-weight: 700; }
.recent-panel { grid-column: 1 / -1; }
.section-title.compact { margin: 0 0 16px; }
.workflow-list { display: grid; gap: 10px; }
.workflow-item {
  display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; background: var(--bg);
}
.workflow-item:hover { border-color: var(--brand-light); background: var(--brand-soft); }
.workflow-item span { color: var(--brand); font-weight: 900; }
.workflow-item strong { color: var(--text); }
.workflow-item em { color: var(--muted); font-style: normal; font-size: .85rem; font-weight: 800; }
.activity-list { display: grid; gap: 10px; }
.activity-item { display: grid; gap: 4px; padding: 13px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; background: var(--bg); }
.activity-item strong { color: var(--nav); }
.activity-item span { color: var(--muted); font-size: .9rem; }
.empty-state { padding: 18px; color: var(--muted); background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); }
.backup-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}
.backup-summary div {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.backup-summary span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}
.backup-summary strong {
  display: block;
  margin-top: 8px;
  color: var(--nav);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.health-grid div {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.health-grid span { color: var(--muted); font-size: .78rem; font-weight: 900; text-transform: uppercase; }
.health-grid strong { color: var(--nav); overflow-wrap: anywhere; }
.health-grid em { width: fit-content; padding: 4px 8px; border-radius: 999px; font-style: normal; font-weight: 900; font-size: .76rem; }
.health-grid em.ok { background: #DCFCE7; color: var(--success); }
.health-grid em.warn { background: #FEF3C7; color: var(--warning); }
.update-notice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, .66);
}
.update-notice {
  width: min(620px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: 0 30px 80px rgba(15, 23, 42, .32);
}
.update-notice span {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}
.update-notice h2 { margin: 16px 0 10px; color: var(--nav); font-size: 1.8rem; }
.update-notice p { margin: 12px 0; color: var(--text); line-height: 1.6; }
.update-notice form { display: flex; justify-content: flex-end; margin-top: 20px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; }
.form-panel { max-width: 860px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-weight: 800; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.autocomplete-field { position: relative; }
.autocomplete-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  max-height: 280px;
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 45px rgba(15, 23, 42, .16);
}
.autocomplete-menu.is-open { display: grid; }
.autocomplete-menu button {
  min-height: auto;
  padding: 10px 12px;
  display: grid;
  justify-items: start;
  gap: 3px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--white);
  color: var(--text);
  text-align: left;
}
.autocomplete-menu button:hover { background: var(--brand-soft); color: var(--text); }
.autocomplete-menu strong { font-size: .94rem; }
.autocomplete-menu small { color: var(--muted); font-weight: 700; }

input, select, textarea {
  min-height: 42px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--white); color: var(--text); font: inherit;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-secondary); box-shadow: 0 0 0 4px rgba(37,99,235,.14); }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 14px;
  border-radius: 8px; border: 1px solid var(--brand-secondary); background: var(--brand-secondary); color: var(--white);
  text-decoration: none; font: inherit; font-weight: 800; cursor: pointer;
}
.btn:hover, button:hover { background: var(--brand-light); border-color: var(--brand-light); color: var(--brand); }
.btn.secondary { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--white); }
.btn.sm { min-height: 32px; padding: 6px 10px; font-size: .86rem; }

table { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; border-collapse: separate; border-spacing: 0; background: var(--white); }
th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--nav); color: var(--white); font-weight: 800; }
tr:nth-child(even) td { background: var(--bg); }
tr:hover td { background: var(--brand-soft); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; font-weight: 800; font-size: .78rem; background: var(--brand-soft); color: var(--brand); }
.badge.success { background: #DCFCE7; color: var(--success); }
.badge.warning { background: #FEF3C7; color: var(--warning); }
.badge.danger { background: #FEE2E2; color: var(--danger); }
.print-toolbar { display: flex; justify-content: flex-end; margin: 14px 0; }
.label-preview { display: flex; justify-content: center; padding: 20px; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); }
.box-label {
  width: 120mm;
  min-height: 200mm;
  background: var(--white);
  border: 3px solid var(--nav);
  padding: 6mm;
  display: flex;
  flex-direction: column;
  gap: 3.5mm;
  color: var(--nav);
}
.box-label-head {
  display: flex;
  align-items: center;
  gap: 4mm;
  padding-bottom: 3mm;
  border-bottom: 2px solid var(--border);
}
.box-label-head img { width: 48mm; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5mm; }
.box-label-head span { display: block; font-size: 12pt; font-weight: 900; text-transform: uppercase; color: var(--brand); }
.box-label-head small { display: block; margin-top: 1mm; font-size: 8pt; font-weight: 800; color: var(--muted); }
.box-label-main {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1mm;
  padding: 4mm;
  border: 2px solid var(--brand-soft);
  background: #F8FAFC;
}
.box-label-main span { font-size: 18pt; font-weight: 900; text-transform: uppercase; color: var(--brand); }
.box-label-main strong { font-size: 58pt; line-height: .92; letter-spacing: 0; color: var(--nav); }
.box-label-main small { font-size: 20pt; font-weight: 900; color: var(--muted); }
.box-label-subtitle { margin: 0; font-size: 10pt; font-weight: 900; color: var(--text); text-transform: uppercase; }
.label-grid { width: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .8mm; font-size: 7.2pt; }
.label-grid div {
  min-height: 4.6mm;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  font-weight: 800;
  color: var(--text);
  background: var(--white);
}
.loan-protocol {
  width: min(190mm, 100%);
  min-height: 270mm;
  margin: 0 auto;
  padding: 12mm;
  background: var(--white);
  border: 2px solid var(--nav);
  color: var(--text);
}
.loan-protocol header {
  display: grid;
  grid-template-columns: 48mm minmax(0, 1fr) auto;
  align-items: center;
  gap: 8mm;
  padding-bottom: 6mm;
  border-bottom: 2px solid var(--border);
}
.loan-protocol header img { width: 48mm; }
.loan-protocol header strong { display: block; color: var(--nav); font-size: 18pt; }
.loan-protocol header span { display: block; margin-top: 2mm; color: var(--muted); font-weight: 800; }
.loan-protocol header em {
  font-style: normal;
  font-weight: 900;
  color: var(--brand);
  padding: 3mm;
  border: 1px solid var(--brand-light);
  border-radius: var(--radius);
  background: var(--brand-soft);
}
.protocol-grid { margin-top: 8mm; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4mm; }
.protocol-grid .span-2 { grid-column: 1 / -1; }
.protocol-grid div { padding: 4mm; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.protocol-grid span { display: block; color: var(--muted); font-size: 9pt; font-weight: 900; text-transform: uppercase; }
.protocol-grid strong { display: block; margin-top: 2mm; color: var(--text); font-size: 12pt; }
.protocol-text { margin: 10mm 0; font-size: 12pt; line-height: 1.6; }
.signature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12mm; margin-top: 26mm; }
.signature-grid div { border-top: 1px solid var(--text); padding-top: 3mm; text-align: center; color: var(--muted); font-weight: 800; }
.pagination { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.pagination a, .pagination span { min-width: 40px; min-height: 40px; padding: 9px 13px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--brand); font-weight: 800; background: var(--white); }
.pagination .is-current { background: var(--brand-secondary); color: var(--white); border-color: var(--brand-secondary); }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-weight: 700; border: 1px solid var(--border); background: var(--white); }
.alert.success { color: var(--success); border-color: rgba(22,163,74,.25); background: #F0FDF4; }
.alert.error { color: var(--danger); border-color: rgba(220,38,38,.25); background: #FEF2F2; }
.alert.info { color: var(--info); border-color: rgba(14,165,233,.25); background: #F0F9FF; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #EFF6FF; }
.auth-card { width: min(980px, 100%); display: grid; grid-template-columns: 1fr 420px; background: var(--white); border-radius: 8px; overflow: hidden; box-shadow: 0 30px 80px rgba(15,23,42,.28); }
.auth-brand { padding: 44px; background: var(--brand); color: var(--white); display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand img { width: 150px; background: var(--white); border-radius: 8px; padding: 8px; }
.auth-brand h1 { font-size: 2rem; margin: 26px 0 10px; }
.auth-brand p { color: #CBD5E1; line-height: 1.6; }
.auth-form { padding: 44px 34px; display: grid; align-content: center; gap: 16px; }
.auth-form h2 { margin: 0; }
.auth-form p { margin: 6px 0 0; color: var(--muted); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-links a { color: var(--brand); font-weight: 700; text-decoration: none; }
.auth-links a:hover { color: var(--brand-secondary); }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { width: 100%; padding-right: 92px; }
.password-toggle {
  position: absolute; right: 6px; min-height: 32px; padding: 6px 10px;
  background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); font-size: .82rem;
}

@media (max-width: 920px) {
  .sidebar { position: static; width: 100%; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell { margin-left: 0; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .hero-panel { flex-direction: column; align-items: stretch; }
  .dashboard-hero-v2, .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-quick-form { grid-template-columns: 1fr; }
  .workflow-item { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-card { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  html,
  body:not(.visitor-page) {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
  }
  body:not(.visitor-page) * { visibility: hidden; }
  body:not(.visitor-page) #print-area,
  body:not(.visitor-page) #print-area * { visibility: visible; }
  body:not(.visitor-page) #print-area {
    position: fixed;
    left: 0;
    top: 0;
    width: 210mm;
    height: 297mm;
    padding: 0;
    border: 0;
    background: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    page-break-after: avoid;
    break-after: avoid;
  }
  .box-label {
    width: 120mm;
    min-height: 200mm;
    height: 200mm;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .loan-protocol {
    width: 190mm;
    min-height: 270mm;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

.visitor-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #F8FAFC 0%, #DBEAFE 100%);
}
.visitor-header {
  min-height: 86px; padding: 16px 32px; background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.visitor-header img { width: 132px; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px; background: var(--white); }
.visitor-header strong, .visitor-header span { display: block; }
.visitor-header strong { font-size: 1.15rem; color: var(--nav); }
.visitor-header span { color: var(--muted); margin-top: 3px; }
.visitor-header a { margin-left: auto; color: var(--brand); font-weight: 800; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.visitor-shell {
  width: min(1180px, calc(100% - 36px)); margin: 30px auto; display: grid;
  grid-template-columns: minmax(0, 1fr) 380px; gap: 20px;
}
.visitor-card, .visitor-badge-panel, .visitor-recent {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.visitor-title span { color: var(--brand-secondary); font-weight: 900; text-transform: uppercase; font-size: .78rem; }
.visitor-title h1 { margin: 8px 0; font-size: 2rem; color: var(--nav); }
.visitor-title p { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.visitor-form { display: grid; gap: 16px; }
.visitor-form label { display: grid; gap: 8px; color: var(--muted); font-weight: 900; }
.visitor-form input { min-height: 52px; font-size: 1.05rem; }
.visitor-form input[readonly] { background: var(--brand-soft); color: var(--brand); font-weight: 900; }
.visitor-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.visitor-generic { background: var(--nav); border-color: var(--nav); }
.visitor-badge-panel { display: grid; gap: 14px; align-content: start; }
.visitor-badge-panel p { color: var(--muted); margin: 0; text-align: center; }
.label-controls { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.label-controls strong { color: var(--nav); }
.label-controls span { color: var(--muted); font-size: .9rem; }
.label-controls label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; }
.label-position-status { padding: 10px; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); font-weight: 900; text-align: center; }
.label-sheet-preview {
  width: min(230px, 100%);
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(var(--preview-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--preview-rows), minmax(0, 1fr));
  gap: 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #f8fafc);
  box-shadow: inset 0 0 0 6px #fff;
}
.label-sheet-preview button {
  min-height: auto;
  padding: 2px;
  border: 1px dashed #CBD5E1;
  background: #F8FAFC;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}
.label-sheet-preview button.is-selected {
  border: 2px solid var(--brand);
  background: var(--brand);
  color: var(--white);
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
  transform: scale(1.04);
}
.label-map-legend { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: .78rem; }
.label-map-legend span { width: 13px; height: 13px; border-radius: 3px; display: inline-block; align-self: center; }
.legend-current { background: var(--brand); }
.legend-empty { background: var(--bg); border: 1px dashed #CBD5E1; }
.label-map, .sheet-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(34px, 1fr)); gap: 5px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); }
.label-map button, .sheet-preview button { min-height: 32px; padding: 4px; border-color: var(--border); background: var(--bg); color: var(--text); font-size: .78rem; }
.label-map button.is-selected, .sheet-preview button.is-selected { background: var(--brand); border-color: var(--brand); color: var(--white); box-shadow: 0 0 0 3px rgba(37,99,235,.16); }
.config-label-preview {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 210 / 297;
  margin: 14px auto;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(226,232,240,.42) 1px, transparent 1px),
    linear-gradient(180deg, rgba(226,232,240,.42) 1px, transparent 1px),
    #fff;
  background-size: 20px 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.config-label-preview::before {
  content: "Folha A4";
  position: absolute;
  left: 10px;
  top: 8px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 900;
}
.config-label-preview button {
  position: absolute;
  min-height: auto;
  padding: 0;
  border: 1px dashed #94A3B8;
  background: rgba(219,234,254,.72);
  color: var(--brand);
  font-size: .72rem;
  font-weight: 900;
}
.config-label-preview button.is-selected {
  z-index: 2;
  border: 2px solid var(--brand-secondary);
  background: var(--brand-secondary);
  color: var(--white);
  box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}
.visitor-badge {
  width: 320px; min-height: 160px; margin: 0 auto; padding: 14px; border: 2px solid var(--nav);
  display: grid; justify-items: center; align-content: center; gap: 7px; background: var(--white); text-align: center;
}
.visitor-badge img { width: 100px; }
.visitor-badge span { color: var(--brand); font-weight: 900; font-size: .8rem; }
.visitor-badge strong { font-size: 1.5rem; color: var(--nav); text-transform: uppercase; line-height: 1.1; }
.visitor-badge small { color: var(--muted); font-weight: 800; }
.visitor-recent { grid-column: 1 / -1; }
.visitor-recent h2 { margin-top: 0; }
.visitor-print-sheet { display: none; }

@media (max-width: 920px) {
  .visitor-header { flex-wrap: wrap; }
  .visitor-header a { margin-left: 0; }
  .visitor-shell { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  html,
  body.visitor-page {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
  }
  .visitor-page * { visibility: hidden; }
  .visitor-print-sheet, .visitor-print-sheet * { visibility: visible; }
  .visitor-print-sheet {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    width: 210mm;
    height: 297mm;
    background: #fff;
    overflow: hidden;
    page-break-after: avoid;
    break-after: avoid;
  }
  .visitor-print-slot {
    position: absolute;
    width: var(--label-width);
    height: var(--label-height);
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .visitor-print-slot .visitor-badge {
    width: var(--label-width);
    min-height: var(--label-height);
    height: var(--label-height);
    margin: 0;
    padding: 1mm 1.5mm;
    border: 0;
    box-shadow: none;
    gap: .35mm;
    line-height: 1;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .visitor-print-slot .visitor-badge img {
    width: min(var(--label-logo-width, 46mm), calc(var(--label-width) - 4mm));
    max-height: 58%;
    object-fit: contain;
  }
  .visitor-print-slot .visitor-badge span {
    display: none;
    font-size: var(--label-title-font, 5pt);
    line-height: 1;
  }
  .visitor-print-slot .visitor-badge strong {
    font-size: var(--label-name-font, 15pt);
    line-height: .95;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .visitor-print-slot .visitor-badge small {
    font-size: var(--label-date-font, 8pt);
    line-height: 1;
  }
}

.quick-search-shell { max-width: 820px; margin: 0 auto; }
.quick-search-form {
  position: sticky; top: 12px; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px;
  padding: 14px; margin-bottom: 16px; background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.quick-search-form label { display: grid; gap: 6px; color: var(--muted); font-weight: 900; }
.quick-search-form input { min-height: 50px; font-size: 1.05rem; }
.quick-empty {
  display: grid; gap: 6px; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--white); color: var(--muted);
}
.quick-empty strong { color: var(--nav); }
.quick-results { display: grid; gap: 12px; }
.quick-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.quick-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.quick-card-head strong { font-size: 1.25rem; color: var(--nav); }
.quick-card p { margin: 12px 0; color: var(--text); font-weight: 700; }
.quick-card dl { display: grid; gap: 8px; margin: 0 0 14px; }
.quick-card dl div { padding: 10px; background: var(--bg); border-radius: var(--radius); }
.quick-card dt { color: var(--muted); font-size: .78rem; font-weight: 900; text-transform: uppercase; }
.quick-card dd { margin: 4px 0 0; color: var(--text); font-weight: 800; }

.help-hero {
  padding: 26px; border-radius: var(--radius); background: var(--brand); color: var(--white);
  display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 20px;
}
.help-hero span { color: var(--brand-soft); font-weight: 900; text-transform: uppercase; font-size: .78rem; }
.help-hero h2 { margin: 8px 0; font-size: 2rem; }
.help-hero p { margin: 0; color: #EFF6FF; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 20px; }
.help-card { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.help-card strong { color: var(--brand); font-size: 1.05rem; }
.help-card p { margin: 10px 0 0; color: var(--muted); line-height: 1.5; }
.help-steps ol { margin-bottom: 0; }
.help-steps li { margin: 10px 0; color: var(--text); }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.settings-card { display: grid; gap: 8px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); text-decoration: none; }
.settings-card strong { color: var(--brand); font-size: 1.1rem; }
.settings-card span { color: var(--muted); line-height: 1.45; }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; }
.sheet-preview { grid-template-columns: repeat(3, 1fr); margin-top: 12px; aspect-ratio: 210 / 297; align-content: start; }
.permissions-panel { overflow-x: auto; }

.sorteio-shell { grid-template-columns: 1fr; }
.sorteio-card { display: grid; gap: 18px; }
.sorteio-inner-header { margin: -24px -24px 0; box-shadow: none; border-radius: 8px 8px 0 0; }
.draw-stage { overflow-x: auto; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.draw-stage canvas { display: block; max-width: 100%; height: auto; margin: 0 auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
.draw-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.draw-audit { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.draw-audit strong { color: var(--nav); }
.draw-audit span { color: var(--muted); }
.password-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, .55); }
.modal-card { width: min(420px, 100%); padding: 24px; background: var(--white); border-radius: var(--radius); box-shadow: 0 24px 70px rgba(15,23,42,.25); }
.modal-card h2 { margin: 0 0 8px; color: var(--nav); }
.modal-card p { margin: 0 0 16px; color: var(--muted); }
.modal-card input { width: 100%; }
.modal-error { margin-top: 10px; color: var(--danger); font-weight: 800; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .quick-search-form { grid-template-columns: 1fr; top: 0; border-radius: 0 0 var(--radius) var(--radius); }
  .quick-search-shell { width: calc(100% + 20px); margin-left: -10px; }
  .quick-card { border-radius: 0; border-left: 0; border-right: 0; }
  .help-hero { align-items: flex-start; flex-direction: column; }
  .settings-layout { grid-template-columns: 1fr; }
}
