@font-face { font-family: 'Inter'; font-weight: 400; src: url('/static/fonts/inter-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Inter'; font-weight: 500; src: url('/static/fonts/inter-latin-500-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Inter'; font-weight: 600; src: url('/static/fonts/inter-latin-600-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Inter'; font-weight: 700; src: url('/static/fonts/inter-latin-700-normal.woff2') format('woff2'); font-display: swap; }

:root {
  /* Marca (extraída da logo real) */
  --brand: #004C8B;
  --brand-dark: #00305C;
  --brand-darker: #001E3D;
  --brand-light: #E8F1FA;

  /* Superfícies */
  --bg: #ffffff;
  --surface: #F7F8FA;
  --surface-2: #EEF0F3;
  --sidebar-bg: #001E3D;
  --sidebar-hover: #0A2E52;
  --sidebar-active: #004C8B;
  --sidebar-text: #A9C4E0;
  --sidebar-text-dim: #5C7C9E;

  /* Texto */
  --text: #12151A;
  --text-secondary: #5D6470;
  --text-muted: #97A0AC;

  /* Bordas / elevação (hairline, não sombra) */
  --border: #E4E6EA;
  --border-strong: #D3D6DC;

  /* Semânticas */
  --success: #157A45; --success-bg: #E6F5EC;
  --warning: #B4650A; --warning-bg: #FDF1E2;
  --danger: #C0301F; --danger-bg: #FBEAE8;

  /* Gráficos */
  --chart-1: #004C8B; --chart-2: #2E9BD6; --chart-3: #6FC6E8; --chart-4: #C7E6F5;
  --chart-5: #15804A; --chart-6: #C0301F; --chart-7: #B4650A; --chart-8: #7C5CBF;

  /* Escala de espaçamento (8/12/24/48) e raio */
  --sp-1: 8px; --sp-2: 12px; --sp-3: 24px; --sp-4: 48px;
  --radius: 8px; --radius-lg: 12px; --radius-pill: 9999px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  margin: 0; padding: 0; font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.015em; }
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -4px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 22px; height: 22px; }

/* ===================== APP SHELL ===================== */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text);
  padding: var(--sp-2) var(--sp-1); display: flex; flex-direction: column; gap: var(--sp-1);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-marca { display: flex; align-items: center; gap: 10px; padding: var(--sp-1) var(--sp-1) var(--sp-2); }
.sidebar-marca img { width: 30px; height: 30px; border-radius: 6px; }
.sidebar-marca-texto { font-size: 13px; font-weight: 600; color: white; letter-spacing: -0.01em; }
.sidebar-marca-sub { font-size: 10.5px; color: var(--sidebar-text-dim); }

.sidebar-municipio { background: rgba(255,255,255,0.05); border: 0.5px solid rgba(255,255,255,0.1); border-radius: var(--radius); padding: 10px 12px; margin-bottom: var(--sp-1); }
.sidebar-municipio .nome { font-size: 13px; font-weight: 600; color: white; }
.sidebar-municipio .uf { font-size: 11px; color: var(--sidebar-text-dim); }
.sidebar-municipio a { font-size: 11px; color: var(--chart-3); }

.sidebar-secao-titulo { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sidebar-text-dim); padding: 12px 12px 4px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: var(--sidebar-text); font-size: 13px; font-weight: 500; transition: background .12s; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: white; }
.sidebar-nav a.ativo { background: var(--sidebar-active); color: white; }
.sidebar-nav a .icon { color: inherit; opacity: 0.85; }

.sidebar-footer { margin-top: auto; padding: var(--sp-1) 12px; font-size: 10.5px; color: var(--sidebar-text-dim); border-top: 0.5px solid rgba(255,255,255,0.08); padding-top: var(--sp-1); }

/* ===================== TOPO / CONTEÚDO ===================== */
.topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; border-bottom: 0.5px solid var(--border); background: white;
  position: sticky; top: 0; z-index: 10;
}
.topo-titulo { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.topo-titulo strong { color: var(--text); font-weight: 600; }

.busca-global-wrap { position: relative; }
.busca-global { width: 320px; padding: 8px 12px 8px 34px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface) url('/static/icons/search.svg') no-repeat 10px center; background-size: 15px; font-family: inherit; font-size: 13px; }
.busca-global-resultados { position: absolute; top: 40px; right: 0; width: 360px; background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(10,20,40,0.14); z-index: 50; max-height: 380px; overflow-y: auto; display: none; }
.busca-global-resultados.aberto { display: block; }
.busca-global-item { padding: 10px 14px; border-top: 0.5px solid var(--border); cursor: pointer; font-size: 12.5px; color: var(--text); }
.busca-global-item:first-child { border-top: none; }
.busca-global-item:hover { background: var(--surface); }
.busca-global-item .cat { font-size: 9.5px; color: var(--brand); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.conteudo { padding: var(--sp-3) 32px var(--sp-4); max-width: 1080px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
.subtitle { color: var(--text-secondary); font-size: 13px; margin: 4px 0 var(--sp-3); }

/* ===================== CARTÕES / COMPONENTES ===================== */
.card { background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; margin-bottom: var(--sp-2); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.card h2 { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; margin: 0; }
.card .desc { font-size: 12.5px; color: var(--text-secondary); margin-bottom: var(--sp-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.03em; }
.badge.real { background: var(--success-bg); color: var(--success); }
.badge.estimado { background: var(--warning-bg); color: var(--warning); }
.badge.vazio { background: var(--surface-2); color: var(--text-muted); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.metric-card { background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.metric-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.metric-card .label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.metric-card .icon-wrap { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; background: var(--brand-light); color: var(--brand); }
.metric-card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.metric-card .trend { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 3px; margin-top: 4px; }
.metric-card .trend.up { color: var(--success); }
.metric-card .trend.down { color: var(--danger); }
.metric-card.warning .icon-wrap { background: var(--warning-bg); color: var(--warning); }
.metric-card.warning .value { color: var(--warning); }

.chart-box { position: relative; height: 240px; margin: var(--sp-1) 0; }
.chart-box.pequeno { height: 170px; }
.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--sp-2); align-items: center; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .app-shell { grid-template-columns: 1fr; } .sidebar { display: none; } }

.flow { display: flex; gap: 8px; align-items: stretch; margin: var(--sp-2) 0; flex-wrap: wrap; }
.flow-item { text-align: center; flex: 1; min-width: 100px; padding: var(--sp-1); border-radius: var(--radius); background: var(--surface); }
.flow-item.destaque { background: var(--success-bg); }
.flow-item .v { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.flow-item.destaque .v { color: var(--success); }
.flow-item .l { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-secondary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; padding: var(--sp-1); }
td { padding: 12px var(--sp-1); border-top: 0.5px solid var(--border); }
tr.clickable { cursor: pointer; transition: background .1s; }
tr.clickable:hover { background: var(--surface); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--success); }
.dot.vazio { background: var(--border-strong); }

.vazio-estado { text-align: center; padding: 36px var(--sp-2); color: var(--text-muted); }
.vazio-estado .icon-lg { width: 32px; height: 32px; opacity: 0.4; margin-bottom: 10px; }
.vazio-estado .msg { font-size: 13px; }
.vazio-msg { color: var(--text-muted); font-size: 13px; }
.status-conexao { font-size: 11px; color: var(--text-muted); margin-top: var(--sp-3); text-align: center; }
a { color: var(--brand); text-decoration: none; }

.search-box { width: 100%; padding: 11px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; font-size: 14px; margin-bottom: var(--sp-2); }
.search-resultado { padding: 12px 14px; border-radius: var(--radius); cursor: pointer; border: 0.5px solid transparent; }
.search-resultado:hover { background: var(--surface); border-color: var(--border); }

.modulo-card { display: flex; align-items: center; gap: 14px; background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 10px; cursor: pointer; transition: border-color .1s, box-shadow .1s; }
.modulo-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(0,76,139,0.08); }
.modulo-card .icon-wrap { width: 38px; height: 38px; border-radius: var(--radius); background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.modulo-card .info { flex: 1; }
.modulo-card .nome { font-weight: 600; font-size: 14px; }
.modulo-card .categoria { font-size: 11.5px; color: var(--text-muted); }

.toggle-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 0.5px solid var(--border); }
.toggle-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.toggle-row .campos { flex: 1; display: flex; gap: 8px; }
.toggle-row input[type=text], .toggle-row input[type=date] { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; font-family: inherit; }
.pendencia-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-top: 0.5px solid var(--border); font-size: 13px; }
.pendencia-item.concluido { opacity: 0.45; text-decoration: line-through; }
.severidade-alta { color: var(--danger); } .severidade-media { color: var(--warning); } .severidade-info { color: var(--text-secondary); }
form.inline { display: inline; }

button, .btn { font-family: inherit; background: var(--brand); color: white; border: none; padding: 9px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .12s; }
button:hover, .btn:hover { background: var(--brand-dark); }
button.secundario, .btn.secundario { background: var(--surface-2); color: var(--text); }
button.secundario:hover { background: var(--border); }
button.pequeno { padding: 4px 10px; font-size: 12px; }
input[type=text], input[type=date], select, textarea { font-family: inherit; }

/* ===================== RELATÓRIO / IMPRESSÃO ===================== */
.folha-relatorio { max-width: 900px; margin: 0 auto; padding: var(--sp-3); }
.timbre { width: 100%; margin-bottom: var(--sp-3); border-bottom: 3px solid var(--brand); padding-bottom: var(--sp-1); }
.timbre img { width: 100%; height: auto; display: block; }
.relatorio-titulo { font-size: 19px; font-weight: 700; color: var(--brand-dark); margin-bottom: 2px; }
.relatorio-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: var(--sp-3); }
@media print {
  .no-print { display: none !important; }
  body { font-size: 12px; }
  .card { break-inside: avoid; border: 1px solid #ccc; }
}

/* ===================== CAPA (home) ===================== */
.hero {
  background: linear-gradient(135deg, var(--brand-darker) 0%, var(--brand-dark) 50%, var(--brand) 100%);
  color: white; padding: 56px 40px 64px; margin: -28px -32px 32px; position: relative;
}
.hero-decor { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; z-index: 0; pointer-events: none; }
.hero-decor::after { content: ''; position: absolute; top: -80px; right: -80px; width: 320px; height: 320px; border-radius: 50%; background: rgba(255,255,255,0.05); }
.hero-decor::before { content: ''; position: absolute; bottom: -120px; left: 30%; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,0.04); }
.hero-marca, .wordmark-hero, .hero-sub, .hero-stats, .hero-busca-wrap { position: relative; z-index: 1; }
.hero-marca { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; position: relative; }
.hero-marca img { width: 38px; height: 38px; border-radius: 8px; }
.hero-marca span { font-size: 13px; font-weight: 600; color: #B4D6F2; letter-spacing: 0.02em; }
.hero h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 8px; color: white; position: relative; }
.hero .hero-sub { font-size: 15px; color: #B4D6F2; max-width: 520px; margin-bottom: 32px; position: relative; }
.hero-stats { display: flex; gap: 40px; position: relative; flex-wrap: wrap; }
.hero-stat .v { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.hero-stat .l { font-size: 12px; color: #9EC3E5; margin-top: 2px; }
.hero-busca-wrap { position: relative; margin-top: 32px; max-width: 480px; }
.hero-busca { width: 100%; padding: 14px 18px 14px 44px; border-radius: 12px; border: none; font-family: inherit; font-size: 15px; background: white url('/static/icons/search.svg') no-repeat 16px center; background-size: 18px; box-shadow: 0 12px 32px rgba(0,10,30,0.25); color: var(--text); }
.hero-busca-resultados { position: absolute; top: 58px; left: 0; right: 0; background: white; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,10,30,0.25); z-index: 30; max-height: 320px; overflow-y: auto; display: none; color: var(--text); }
.hero-busca-resultados.aberto { display: block; }

.secao-titulo { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.secao-sub { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 16px; }
.municipios-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.municipio-card-grande { background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; cursor: pointer; transition: border-color .12s, transform .12s; }
.municipio-card-grande:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,76,139,0.1); }
.municipio-card-grande .nome { font-size: 15px; font-weight: 600; }
.municipio-card-grande .uf { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.municipio-card-grande .badge-modulos { display: inline-flex; align-items: center; gap: 5px; }

/* ===================== PORTAL DA PREFEITURA (chrome separado) ===================== */
.pref-topo { background: linear-gradient(120deg, #0F1F2E, #1D4A70); color: white; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; }
.pref-marca { display: flex; align-items: center; gap: 12px; }
.pref-marca img { width: 32px; height: 32px; border-radius: 7px; }
.pref-marca-texto { font-size: 14px; font-weight: 600; }
.pref-marca-sub { font-size: 11px; color: #9EC3E5; }
.pref-user { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: #CFE3F5; }
.pref-user a { color: white; opacity: 0.75; }
.pref-conteudo { max-width: 900px; margin: 0 auto; padding: 32px; }

/* ===================== MARCA / WORDMARK FUTURISTA ===================== */
@keyframes pulso-status { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(79,209,197,0.55); } 50% { opacity: 0.55; box-shadow: 0 0 0 5px rgba(79,209,197,0); } }
@keyframes brilho-linha { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.wordmark { display: inline-flex; flex-direction: column; gap: 3px; }
.wordmark-linha { display: flex; align-items: center; gap: 7px; }
.wordmark-dot { width: 7px; height: 7px; border-radius: 50%; background: #4FD1C5; flex-shrink: 0; animation: pulso-status 2.2s ease-in-out infinite; }
.wordmark-texto {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.045em;
  background: linear-gradient(90deg, #FFFFFF 0%, #9EC3E5 45%, #4FD1C5 70%, #9EC3E5 100%);
  background-size: 220% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: brilho-linha 7s linear infinite;
}
.wordmark-sub { font-size: 9.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: #6E93BC; margin-left: 14px; }

.wordmark-sidebar .wordmark-texto { font-size: 13px; }
.wordmark-hero .wordmark-texto { font-size: 34px; letter-spacing: 0.02em; }
.wordmark-hero .wordmark-dot { width: 10px; height: 10px; }
.wordmark-login .wordmark-texto { font-size: 16px; }
