/* PostSus v5 - Ultra Modern Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0f172a;
  --bg-light: #1e293b;
  --surface: rgba(30,41,59,.72);
  --surface-solid: #1e293b;
  --sidebar-bg: #0c1222;
  --sidebar-hover: rgba(99,102,241,.12);
  --sidebar-active: #6366f1;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-on-dark: #cbd5e1;
  --border: rgba(148,163,184,.12);
  --border-light: rgba(148,163,184,.08);
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --cyan: #06b6d4;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --amber: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow: 0 4px 20px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.4);
  --glass: rgba(30,41,59,.65);
  --glass-border: rgba(148,163,184,.1);
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --glow-primary: 0 0 20px rgba(99,102,241,.15);
  --glow-cyan: 0 0 20px rgba(6,182,212,.15);
  --bg-dark: #0b1120;
  --bg-card: rgba(30,41,59,.8);
  --bg-elevated: rgba(30,41,59,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[x-cloak] { display: none !important; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse at 10% 20%, rgba(99,102,241,.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(6,182,212,.04) 0%, transparent 50%);
  background-attachment: fixed;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.35); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 250px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  backdrop-filter: blur(20px);
  transition: transform .3s ease;
}
.sidebar-brand {
  padding: 22px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.02em;
}
.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--glow-primary);
}
.sidebar-ufs {
  padding: 10px 16px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.uf-pill {
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(99,102,241,.15);
  color: var(--primary-light);
  letter-spacing: .03em;
}
.sidebar-section {
  padding: 18px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(148,163,184,.7);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  user-select: none;
  background: none;
  border: none;
  width: calc(100% - 16px);
  text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,.2), rgba(6,182,212,.1));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,.3);
}
.nav-item i { width: 18px; height: 18px; opacity: .55; flex-shrink: 0; }
.nav-item.active i { opacity: 1; color: var(--primary-light); }
.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== MOBILE ===== */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 150;
  width: 40px;
  height: 40px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.mobile-toggle i { width: 20px; height: 20px; }

/* ===== MAIN AREA ===== */
.main-area {
  margin-left: 250px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}
.topbar.glass {
  background: rgba(15,23,42,.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text); }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ===== CONTENT ===== */
.content { padding: 24px 28px; flex: 1; }

/* ===== GLASS CARD ===== */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

/* ===== CARDS ===== */
.card {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }
.card-body.compact { padding: 0; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon i { width: 22px; height: 22px; color: #fff; }
.bg-indigo { background: linear-gradient(135deg, #6366f1, #818cf8); box-shadow: 0 4px 14px rgba(99,102,241,.3); }
.bg-cyan { background: linear-gradient(135deg, #06b6d4, #22d3ee); box-shadow: 0 4px 14px rgba(6,182,212,.3); }
.bg-green { background: linear-gradient(135deg, #22c55e, #4ade80); box-shadow: 0 4px 14px rgba(34,197,94,.3); }
.bg-amber { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 4px 14px rgba(245,158,11,.3); }
.stat-content { flex: 1; }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  margin-top: 3px;
}
.stat-value.primary { color: var(--primary-light); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-card-mini {
  padding: 8px 0;
}
.stat-value-sm { font-size: 18px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value-sm.primary { color: var(--primary-light); }
.stat-value-sm.danger { color: var(--danger); }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: rgba(15,23,42,.5);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: relative;
}
.sticky-th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(15,23,42,.95) !important;
  backdrop-filter: blur(8px);
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-on-dark);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(99,102,241,.04); }
tbody tr.row-highlight { background: rgba(245,158,11,.07); }
tbody tr.row-highlight:hover { background: rgba(245,158,11,.14); }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.truncate-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw600 { font-weight: 600; }

.table-mini { font-size: 12px; }
.table-mini thead th { padding: 6px 10px; font-size: 10px; }
.table-mini tbody td { padding: 6px 10px; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary-light); }

.table-search-bar { padding: 12px 20px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge-success { background: rgba(34,197,94,.12); color: #4ade80; }
.badge-warning { background: rgba(245,158,11,.12); color: #fbbf24; }
.badge-danger { background: rgba(239,68,68,.12); color: #f87171; }
.badge-info { background: rgba(99,102,241,.12); color: #818cf8; }
.badge-neutral { background: rgba(148,163,184,.12); color: #94a3b8; }
.vs-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
  font-family: inherit;
  color: var(--text);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; box-shadow: 0 2px 8px rgba(99,102,241,.25); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(99,102,241,.4); transform: translateY(-1px); }
.btn-outline { border-color: var(--border); background: transparent; color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); background: rgba(99,102,241,.05); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,.25); }
.btn-danger:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(239,68,68,.4); }

/* ===== FORMS ===== */
.input, select, .select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: rgba(15,23,42,.6);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.input-sm { padding: 5px 10px; font-size: 12px; }
select option { background: var(--surface-solid); color: var(--text); }

/* ===== LOADER ===== */
.loader-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(148,163,184,.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(15,23,42,.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: fit-content;
}
.tab-btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: inherit;
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
}

/* ===== CHART ===== */
.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
  overflow: hidden;
}
.chart-container canvas { display: block; }

/* ===== FNS BLOCO ===== */
.bloco-group { margin-bottom: 4px; }
.bloco-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: rgba(15,23,42,.4);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.bloco-badge {
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
}
.bloco-manut { background: rgba(99,102,241,.15); color: var(--primary-light); }
.bloco-estrut { background: rgba(236,72,153,.12); color: #f472b6; }
.bloco-other { background: rgba(148,163,184,.12); color: var(--text-muted); }

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state i { width: 44px; height: 44px; margin-bottom: 14px; opacity: .25; }
.empty-state p { font-size: 14px; margin-top: 4px; }
.empty-state-sm {
  padding: 28px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  opacity: .7;
}

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===== MUN SEARCH RESULT ===== */
.mun-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.mun-result-item:hover { background: rgba(99,102,241,.05); }

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== POS REL ===== */
.pos-rel { position: relative; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .mobile-toggle { display: flex; }
  .main-area { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid, .stats-4 { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px 14px 60px; }
}
@media (max-width: 480px) {
  .stats-grid, .stats-4 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }
@media (max-width: 900px) { .sidebar-backdrop { display: block; } }

/* Screen-reader only utility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
