:root {
  --rx-bg: #f5f7fb;
  --rx-panel: #ffffff;
  --rx-text: #172033;
  --rx-muted: #64748b;
  --rx-line: #e4eaf3;
  --rx-blue: #2563eb;
  --rx-cyan: #7fc0eb;
  --rx-pink: #ff5381;
  --rx-green: #16a34a;
  --rx-orange: #f59e0b;
  --rx-red: #ef4444;
  --rx-purple: #655499;
  --rx-shadow: 0 18px 50px rgba(15, 23, 42, .08);
  --rx-soft-shadow: 0 10px 28px rgba(15, 23, 42, .06);
  --rx-radius: 28px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--rx-text);
  background:
    radial-gradient(circle at 4% 3%, rgba(37, 99, 235, .10), transparent 34rem),
    radial-gradient(circle at 96% 8%, rgba(255, 83, 129, .12), transparent 30rem),
    var(--rx-bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--rx-blue); text-decoration: none; font-weight: 800; }
a:hover { color: var(--rx-pink); }
button, input { font: inherit; }

.rx-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.rx-sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px; display: flex; flex-direction: column; gap: 22px;
  border-right: 1px solid rgba(228,234,243,.85); background: rgba(255,255,255,.82); backdrop-filter: blur(18px);
}
.rx-brand { display: flex; align-items: center; gap: 12px; color: var(--rx-text); }
.rx-brand img { width: 52px; height: 52px; object-fit: contain; }
.rx-brand strong { display: block; font-size: 1.25rem; letter-spacing: -.04em; }
.rx-brand small { color: var(--rx-muted); font-weight: 800; }
.rx-nav { display: grid; gap: 8px; }
.rx-nav a { padding: 13px 14px; border-radius: 16px; color: var(--rx-muted); }
.rx-nav a.active, .rx-nav a:hover { color: #fff; background: linear-gradient(135deg, var(--rx-blue), var(--rx-pink)); box-shadow: var(--rx-soft-shadow); }
.rx-logout { margin-top: auto; display: grid; gap: 10px; }
.rx-logout small { color: var(--rx-muted); font-weight: 750; }
.rx-logout button, .rx-login-form button, .rx-link-button {
  min-height: 46px; padding: 0 16px; border: 0; border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, var(--rx-blue), var(--rx-pink)); box-shadow: 0 14px 34px rgba(37, 99, 235, .20); font-weight: 900; cursor: pointer;
}
.rx-main { min-width: 0; padding: 34px; }
.rx-page-header { margin-bottom: 24px; }
.rx-kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 7px 12px; border-radius: 999px; color: var(--rx-blue); background: #eaf1ff; font-size: .76rem; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.rx-kicker::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: linear-gradient(135deg, var(--rx-blue), var(--rx-pink)); box-shadow: 0 0 0 6px rgba(37,99,235,.10); }
h1, h2, h3, p { margin: 0; }
.rx-page-header h1 { font-size: clamp(2.2rem, 4vw, 4.2rem); letter-spacing: -.065em; line-height: .95; }
.rx-page-header p { max-width: 920px; margin-top: 14px; color: var(--rx-muted); line-height: 1.65; font-size: 1.03rem; }
.rx-back { display: inline-flex; margin-bottom: 14px; color: var(--rx-muted); }

.rx-alert { margin-bottom: 16px; padding: 14px 16px; border-radius: 16px; font-weight: 800; }
.rx-alert.error { color: #991b1b; background: #fff1f2; border: 1px solid #fecdd3; }
.rx-alert.success { color: #166534; background: #ecfdf5; border: 1px solid #bbf7d0; }

.rx-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.rx-kpi-card, .rx-panel, .rx-login-card {
  position: relative; overflow: hidden; border: 1px solid var(--rx-line); border-radius: var(--rx-radius); background: rgba(255,255,255,.90); box-shadow: var(--rx-shadow);
}
.rx-kpi-card { min-height: 148px; padding: 22px; }
.rx-kpi-card::after, .rx-panel::after { content: ""; position: absolute; right: -110px; top: -120px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(37,99,235,.11), transparent 68%); pointer-events: none; }
.rx-kpi-card small, .rx-split-kpis small { display: block; color: var(--rx-muted); font-size: .76rem; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; }
.rx-kpi-card strong { display: block; margin-top: 12px; font-size: clamp(2rem, 3.2vw, 3.2rem); line-height: .9; letter-spacing: -.07em; color: var(--rx-purple); }
.rx-kpi-card span { display: block; margin-top: 10px; color: var(--rx-muted); font-weight: 750; }
.rx-kpi-card.accent { color: #fff; border-color: transparent; background: radial-gradient(circle at 16% 10%, rgba(255,255,255,.24), transparent 30%), linear-gradient(135deg, var(--rx-blue), var(--rx-pink)); }
.rx-kpi-card.accent small, .rx-kpi-card.accent span, .rx-kpi-card.accent strong { color: #fff; }

.rx-grid { display: grid; gap: 22px; margin-bottom: 22px; }
.rx-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rx-panel { padding: 24px; margin-bottom: 22px; }
.rx-panel-title { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 18px; }
.rx-panel-title h2 { font-size: clamp(1.4rem, 2.2vw, 2rem); letter-spacing: -.045em; }
.rx-muted, .rx-empty { color: var(--rx-muted); line-height: 1.55; }

.rx-region-list { display: grid; gap: 12px; margin-top: 18px; }
.rx-region-item { display: grid; gap: 7px; padding-bottom: 12px; border-bottom: 1px solid var(--rx-line); }
.rx-region-item strong { letter-spacing: -.02em; }
.rx-region-item span { color: var(--rx-muted); font-weight: 750; }
.rx-region-item i { display: block; width: 100%; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--rx-blue) var(--value), #e8edf5 0); }

.rx-split-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.rx-split-kpis > div { padding: 16px; border: 1px solid var(--rx-line); border-radius: 20px; background: linear-gradient(180deg, #fff, #f8fbff); }
.rx-split-kpis strong { display: block; margin-top: 8px; font-size: 1.55rem; color: var(--rx-purple); letter-spacing: -.06em; }

.rx-table-wrap { position: relative; z-index: 1; overflow: auto; border: 1px solid var(--rx-line); border-radius: 20px; background: #fff; }
.rx-table-wrap.compact { max-height: 420px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--rx-line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; background: #f8fbff; color: var(--rx-muted); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; }
td:last-child, th:last-child { text-align: right; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
.rx-status { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 9px; border-radius: 999px; background: #edf2fb; color: #334155; font-size: .78rem; font-weight: 900; white-space: nowrap; }
.rx-status.processado { background: #ecfdf5; color: #166534; }
.rx-status.processado_com_alertas, .rx-status.alerta { background: #fff7ed; color: #9a3412; }
.rx-status.erro, .rx-status.error { background: #fff1f2; color: #991b1b; }

.rx-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.rx-podium-card { padding: 16px; border-radius: 20px; background: linear-gradient(180deg, #fff, #f8fbff); border: 1px solid var(--rx-line); }
.rx-podium-card small { color: var(--rx-muted); font-weight: 900; text-transform: uppercase; font-size: .72rem; }
.rx-podium-card strong { display: block; margin-top: 8px; font-size: 1.4rem; color: var(--rx-purple); }
.rx-podium-card span { color: var(--rx-muted); font-weight: 800; }
.rx-podium-card.rank-1 { color: #fff; background: linear-gradient(135deg, var(--rx-blue), var(--rx-pink)); border-color: transparent; }
.rx-podium-card.rank-1 small, .rx-podium-card.rank-1 strong, .rx-podium-card.rank-1 span { color: #fff; }

.rx-municipio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.rx-municipio-card { padding: 18px; border: 1px solid var(--rx-line); border-radius: 22px; background: #fff; color: var(--rx-text); transition: .18s ease; }
.rx-municipio-card:hover { transform: translateY(-2px); box-shadow: var(--rx-soft-shadow); }
.rx-municipio-card small { display: block; color: var(--rx-muted); font-weight: 850; }
.rx-municipio-card strong { display: block; margin-top: 8px; min-height: 42px; }
.rx-municipio-card span { display: block; margin-top: 8px; color: var(--rx-muted); font-weight: 800; }
.rx-municipio-card.loaded { border-color: rgba(37,99,235,.26); }
.rx-municipio-card.empty { opacity: .72; background: #f8fafc; }
.rx-actions-line { margin: -6px 0 22px; }
.rx-link-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.rx-tabs { display: grid; gap: 14px; }
.rx-tabs details { border: 1px solid var(--rx-line); border-radius: 18px; background: #fff; overflow: hidden; }
.rx-tabs summary { cursor: pointer; padding: 16px 18px; font-weight: 900; }
.rx-tabs summary span { float: right; color: var(--rx-muted); }
.rx-tabs .rx-table-wrap { border: 0; border-top: 1px solid var(--rx-line); border-radius: 0; }
.rx-panel.danger { border-color: #fecdd3; }

.rx-login-body { display: grid; place-items: center; padding: 24px; }
.rx-login-card { width: min(100%, 460px); padding: 34px; text-align: center; }
.rx-login-logo img { width: 86px; height: 86px; object-fit: contain; }
.rx-login-card h1 { font-size: 2.5rem; letter-spacing: -.06em; }
.rx-login-card p { margin: 12px 0 22px; color: var(--rx-muted); line-height: 1.6; }
.rx-login-form { display: grid; gap: 14px; text-align: left; }
.rx-login-form label span { display: block; margin-bottom: 7px; color: var(--rx-muted); font-weight: 900; font-size: .85rem; }
.rx-login-form input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--rx-line); border-radius: 14px; outline: none; }
.rx-login-form input:focus { border-color: var(--rx-blue); box-shadow: 0 0 0 4px rgba(37,99,235,.10); }

@media (max-width: 1120px) {
  .rx-shell { grid-template-columns: 1fr; }
  .rx-sidebar { position: relative; height: auto; }
  .rx-kpi-grid, .rx-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .rx-main, .rx-sidebar { padding: 18px; }
  .rx-kpi-grid, .rx-grid.two, .rx-split-kpis, .rx-podium { grid-template-columns: 1fr; }
  .rx-page-header h1 { font-size: 2.2rem; }
  table { min-width: 900px; }
}
