:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #6b7891;
  --line: #e3e9f2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #059669;
  --orange: #d97706;
  --red: #dc2626;
  --purple: #7c3aed;
  --sidebar: #111c33;
  --sidebar-soft: #1b2945;
  --shadow: 0 6px 24px rgba(20, 35, 70, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
a { color: var(--primary); }

/* Login */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #1e3a8a 0%, transparent 45%),
              radial-gradient(circle at 80% 80%, #0f766e 0%, transparent 40%),
              #0b1223;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 20px;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.login-card h1 { margin: 26px 0 6px; font-size: 26px; }
.login-card p { margin-top: 0; }
.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
code { background: #eef2f9; padding: 2px 6px; border-radius: 5px; font-size: 12px; }

/* Layout */
.layout { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: #dbe6ff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand strong { display: block; color: #fff; font-size: 18px; letter-spacing: .2px; }
.brand small { display: block; color: #8fa5cc; font-size: 11px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: white; font-weight: 800; font-size: 19px;
}
.brand-lg { padding: 0 0 8px; }
.brand-lg .brand-mark { width: 46px; height: 46px; font-size: 24px; }
.brand-lg strong { color: var(--ink); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  border: 0; border-radius: 10px;
  background: transparent; color: #b9c8e4;
  text-align: left; cursor: pointer;
  transition: .15s;
}
.nav button span { width: 20px; text-align: center; font-size: 17px; }
.nav button:hover { background: var(--sidebar-soft); color: #fff; }
.nav button.active { background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, .35); }
.sidebar-footer { margin-top: auto; }
.user-box { padding: 12px; border-radius: 10px; background: var(--sidebar-soft); margin-bottom: 10px; }
.user-box strong { display: block; color: #fff; font-size: 13px; }
.user-box small { color: #9db0d4; font-size: 11px; }

.main { min-width: 0; }
.topbar {
  height: 78px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.topbar h1 { margin: 2px 0 0; font-size: 21px; }
.breadcrumb { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.top-actions { display: flex; gap: 8px; }
.view { padding: 22px 28px 42px; }

/* Components */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.card .value { font-size: 30px; font-weight: 750; margin-top: 8px; }
.card .foot { margin-top: 8px; font-size: 12px; color: var(--muted); }
.card .icon { float: right; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: #eff4ff; color: var(--primary); }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 600; font-size: 13px;
  transition: .15s;
}
.btn:hover { border-color: #b8c6dc; transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #fff1f2; border-color: #fecdd3; color: var(--red); }
.btn-soft { background: #eef4ff; border-color: #dbe7ff; color: var(--primary-dark); }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.14); }
.btn-ghost:hover { background: var(--sidebar-soft); border-color: rgba(255,255,255,.2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 6px; }
.icon-btn:hover { background: #f0f4fa; color: var(--ink); }

.form-stack { display: grid; gap: 13px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 650; color: #40506b; }
input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea { min-height: 92px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.form-error { color: var(--red); font-size: 12px; }

.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto; gap: 12px; align-items: end; }
.search-wrap { position: relative; }
.search-wrap input { padding-left: 34px; }
.search-wrap::before { content: '⌕'; position: absolute; left: 11px; top: 7px; color: var(--muted); font-size: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; background: #fafbfd; }
tbody tr:hover { background: #f8fbff; }
tbody tr.selected { background: #eef4ff; }
.table-wrap { overflow-x: auto; }
.table-actions { display: flex; gap: 5px; justify-content: flex-end; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-aberto { background: #eff6ff; color: #2563eb; }
.b-em_analise { background: #fff7ed; color: #c2410c; }
.b-aguardando { background: #fefce8; color: #a16207; }
.b-aprovado { background: #ecfdf5; color: #047857; }
.b-rejeitado { background: #fef2f2; color: #b91c1c; }
.b-arquivado { background: #f1f5f9; color: #475569; }
.b-baixa { background: #f1f5f9; color: #64748b; }
.b-media { background: #eff6ff; color: #2563eb; }
.b-alta { background: #fff7ed; color: #c2410c; }
.b-critica { background: #fef2f2; color: #b91c1c; }
.b-admin { background: #f5f3ff; color: var(--purple); }
.b-gestor { background: #eff6ff; color: var(--primary); }
.b-analista { background: #ecfdf5; color: var(--green); }
.b-visualizador { background: #f1f5f9; color: #475569; }
.b-geojson, .b-shapefile { background: #eff6ff; color: var(--primary); }
.b-image { background: #f5f3ff; color: var(--purple); }

.bars { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { height: 9px; background: #edf1f7; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #06b6d4); border-radius: 99px; }

.process-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .9fr); gap: 18px; align-items: start; }
.detail-empty { display: grid; place-items: center; min-height: 300px; color: var(--muted); text-align: center; }
.detail-head { border-bottom: 1px solid var(--line); padding-bottom: 13px; margin-bottom: 14px; }
.detail-head h2 { margin: 6px 0; font-size: 18px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.detail-grid div { background: #f8fafc; border-radius: 9px; padding: 9px 11px; }
.detail-grid small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 9px; font-weight: 700; }
.timeline { border-left: 2px solid #dbe6f5; margin-left: 6px; padding-left: 16px; }
.timeline-item { position: relative; padding-bottom: 14px; }
.timeline-item::before { content: ''; position: absolute; left: -23px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }
.timeline-item strong { display: block; font-size: 12px; }
.timeline-item small { color: var(--muted); font-size: 11px; }
.timeline-item p { margin: 4px 0 0; font-size: 12px; }
.comment { background: #f8fafc; border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; font-size: 12px; }
.comment strong { display: block; margin-bottom: 3px; }

/* Map */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; height: calc(100vh - 132px); min-height: 520px; }
.map-panel { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff; }
#map { height: 100%; width: 100%; }
.map-side { overflow-y: auto; }
#map-base-select { width: 100%; }
.layer-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 9px; background: #fff; }
.layer-item .row { display: flex; align-items: center; gap: 8px; }
.layer-item .row input { width: auto; }
.layer-item .name { font-weight: 650; font-size: 13px; flex: 1; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.map-legend { position: absolute; left: 12px; bottom: 22px; z-index: 500; background: rgba(255,255,255,.94); border-radius: 9px; padding: 8px 11px; box-shadow: var(--shadow); font-size: 11px; }
.map-process-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  padding: 10px 11px;
  margin-bottom: 10px;
  font-size: 12px;
}
.map-process-banner strong { display: block; color: var(--primary-dark); }
.map-process-banner small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.4; }
.query-result { background: #eef4ff; border-radius: 9px; padding: 9px 11px; margin-top: 8px; font-size: 12px; }
.leaflet-container { font-family: inherit; }

/* Modals & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 18, 35, .55); display: grid; place-items: center; z-index: 3000; padding: 20px; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal .modal-body { padding: 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 4000; display: grid; gap: 8px; }
.toast { background: #172033; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: slide .2s ease-out; }
.toast.success { background: #047857; }
.toast.error { background: #b91c1c; }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

.social-login { margin-top: 18px; }
.social-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.social-divider::before, .social-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.social-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.bell {
  position: relative; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 17px;
}
.bell:hover { border-color: var(--primary); }
.bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px;
  border-radius: 99px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; display: grid; place-items: center; padding: 0 5px;
}
.notification-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.notification-item.unread { background: #eff6ff; border-color: #bfdbfe; }
.notification-item strong { display: block; font-size: 13px; }
.notification-item p { margin: 4px 0; font-size: 12px; color: #40506b; }
.notification-item .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.notification-item small { color: var(--muted); }

.signature { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #f8fafc; }
.signature strong { display: block; font-size: 12px; }
.signature code { font-size: 10px; word-break: break-all; }
.map-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.loading { padding: 30px; text-align: center; color: var(--muted); }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }

/* Licenciamento ambiental digital */
.page-intro { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-intro p { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.stat-card strong { display: block; font-size: 26px; margin-top: 6px; }
.stat-card.stat-amber { border-left-color: var(--orange); }
.stat-card.stat-green { border-left-color: var(--green); }
.stat-card.stat-red { border-left-color: var(--red); }
.stat-card.stat-violet { border-left-color: var(--purple); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-bar input { width: auto; flex: 1 1 250px; }
.filter-bar select { width: auto; min-width: 150px; }
.filter-bar .muted { margin-left: auto; }
.licensing-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(360px, 1fr); gap: 18px; align-items: start; }
.licensing-list { max-height: 720px; overflow: auto; }
.licensing-list tbody tr { cursor: pointer; }
.licensing-detail { min-width: 0; }
.licensing-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 16px; flex-wrap: wrap; }
.licensing-tabs button { border: 0; background: transparent; padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 650; font-size: 12px; border-bottom: 2px solid transparent; }
.licensing-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #eef2f8; color: var(--muted); font-size: 10px; margin-left: 4px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.geo-hint {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  padding: 10px 12px;
  line-height: 1.5;
}
.licensing-geo-map {
  height: 260px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
  background: #e5e7eb;
}
.warn-text { color: #b45309; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checklist li { padding: 8px 11px; border-radius: 8px; font-size: 12px; background: #fff7ed; color: #9a3412; }
.checklist li.ok { background: #ecfdf5; color: #047857; }
.checklist li.pending { background: #fff7ed; color: #9a3412; }
.requirement { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-bottom: 9px; background: #f8fafc; font-size: 12px; }
.requirement.aberta { border-color: #fecaca; background: #fff7f7; }
.requirement p { margin: 6px 0; }
.parecer-box, .license-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 12px; }
.license-box { border-color: #a7f3d0; background: #ecfdf5; }
.license-box p { margin: 6px 0; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.doc-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.login-register { margin-top: 14px; }
.b-empresa { background: #ecfdf5; color: #047857; }
.b-atendimento { background: #eff6ff; color: #2563eb; }
.b-licenciamento { background: #f5f3ff; color: var(--purple); }
.b-aviso { background: #fff7ed; color: #c2410c; }

/* Blocos de trabalho do processo — cada etapa com borda colorida visível */
.stat-card[data-lic-action] { cursor: pointer; }
.stat-card[data-lic-action]:hover { box-shadow: 0 6px 18px rgba(20, 35, 70, .12); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.issued-actions { gap: 5px; flex-wrap: wrap; }

.workflow-section { border: 2px solid; border-radius: 12px; padding: 0 16px 16px; margin-top: 16px; background: #fff; }
.workflow-section > h3 {
  margin: 0 -16px 14px; padding: 11px 16px; font-size: 13px;
  border-radius: 10px 10px 0 0; border-bottom: 2px solid;
}
.workflow-section > h3 .small { font-weight: 500; opacity: .82; }
.section-forward { border-color: #93c5fd; }
.section-forward > h3 { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.section-signature { border-color: #86efac; }
.section-signature > h3 { background: #f0fdf4; border-color: #86efac; color: #047857; }
.section-document { border-color: #67e8f9; }
.section-document > h3 { background: #ecfeff; border-color: #67e8f9; color: #0e7490; }
.section-closure { border-color: #c4b5fd; }
.section-closure > h3 { background: #f5f3ff; border-color: #c4b5fd; color: #6d28d9; }
.wf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; }
.wf-grid div { background: #f8fafc; border-radius: 8px; padding: 8px 10px; }
.wf-grid small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.signature-list { display: grid; gap: 8px; margin-top: 12px; }
.closure-done { background: #f8fafc; border-radius: 9px; padding: 12px; }
.closure-done p { margin: 8px 0 0; }
.finalize-options { display: grid; gap: 9px; margin: 14px 0; }
.finalize-option {
  display: flex; align-items: flex-start; gap: 10px;
  border: 2px solid var(--line); border-radius: 10px; padding: 11px 13px; cursor: pointer;
}
.finalize-option:hover { border-color: #bfdbfe; }
.finalize-option:has(input:checked) { border-color: #93c5fd; background: #eff6ff; }
.finalize-option input { width: auto; margin-top: 3px; }
.finalize-option span { display: grid; gap: 3px; }
.finalize-option strong { font-size: 13px; }
.finalize-option small { font-weight: 400; color: var(--muted); font-size: 11px; }

@media (max-width: 1050px) {
  .process-layout, .map-layout, .licensing-layout, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .licensing-list { max-height: 340px; }
  .map-layout { height: auto; }
  .map-panel { height: 520px; }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { margin-top: 14px; }
  .view, .topbar { padding-left: 14px; padding-right: 14px; }
  .form-row, .form-grid, .filters, .doc-row { grid-template-columns: 1fr; }
}
