:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --primary: #003B6F;
  --primary-light: #1565C0;
  --accent: #FFC107;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: #F0F2F5; color: #333; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-w);
  background: var(--primary); color: #fff;
  display: flex; flex-direction: column;
  transition: width .25s ease; z-index: 1000; overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span:not(.badge),
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .nav-item i { margin: 0; font-size: 1.3rem; }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.15);
  min-height: var(--topbar-h);
}
.brand-logo { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.brand-title { font-weight: 700; font-size: 1rem; letter-spacing: .5px; }
.brand-sub { font-size: .7rem; opacity: .7; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: rgba(255,255,255,.8);
  text-decoration: none; font-size: .875rem; transition: all .15s;
}
.nav-item i { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: .7rem; opacity: .6; }

/* ── Main ── */
.main-content {
  margin-left: var(--sidebar-w); min-height: 100vh;
  transition: margin-left .25s ease; padding-top: var(--topbar-h);
}
.main-content.expanded { margin-left: 64px; }

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h); background: #fff;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1); z-index: 999;
  transition: left .25s ease;
}
.topbar.expanded { left: 64px; }
.topbar-title { font-weight: 600; font-size: 1rem; color: var(--primary); }
.btn-icon { background: none; border: none; padding: 6px; cursor: pointer; color: #555; border-radius: 6px; }
.btn-icon:hover { background: #F0F2F5; }

/* ── Pages ── */
.page { display: none; padding: 20px; }
.page.active { display: block; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 8px;
}
.page-header h5 { color: var(--primary); }

/* ── KPI Cards ── */
.kpi-card {
  border-radius: 12px; padding: 20px; color: #fff;
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.kpi-card::after {
  content: ''; position: absolute; right: -10px; top: -10px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.kpi-icon { font-size: 1.6rem; opacity: .9; }
.kpi-value { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: .8rem; opacity: .9; font-weight: 500; }
.kpi-hint { font-size: .7rem; opacity: 0; margin-top: 6px; transition: opacity .2s; }
.kpi-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.kpi-card:hover .kpi-hint { opacity: .85; }
.kpi-total { background: linear-gradient(135deg, #1565C0, #1976D2); }
.kpi-vencido { background: linear-gradient(135deg, #C62828, #E53935); }
.kpi-urgente { background: linear-gradient(135deg, #E65100, #F57C00); }
.kpi-alta { background: linear-gradient(135deg, #AD1457, #C2185B); }

/* ── Panels ── */
.card-panel {
  background: #fff; border-radius: 12px;
  padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.panel-title { font-weight: 600; color: var(--primary); margin-bottom: 14px; font-size: .9rem; }

/* ── Chart Status ── */
.status-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: .82rem; }
.status-bar-label { width: 150px; flex-shrink: 0; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-bar-track { flex: 1; height: 22px; background: #F0F2F5; border-radius: 6px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 6px; transition: width .6s ease; display: flex; align-items: center; padding-left: 8px; }
.status-bar-fill span { color: #fff; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.status-bar-count { width: 28px; text-align: right; font-weight: 700; color: #333; }
.status-bar-clicavel { cursor: pointer; border-radius: 6px; padding: 2px 4px; transition: background .15s; }
.status-bar-clicavel:hover { background: #F0F2F5; }
.status-bar-clicavel:hover .status-bar-label { color: var(--primary-light); font-weight: 600; }

/* ── Criticidade Chart ── */
.criticidade-chart { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.crit-item { display: flex; align-items: center; gap: 10px; }
.crit-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.crit-label { flex: 1; font-size: .85rem; color: #555; }
.crit-bar-wrap { width: 120px; }
.crit-bar { height: 16px; border-radius: 4px; }
.crit-count { font-weight: 700; font-size: .9rem; min-width: 28px; text-align: right; }

/* ── Alertas ── */
.alerta-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border-radius: 8px; margin-bottom: 8px; border-left: 4px solid;
}
.alerta-item.vencido { background: #FFF5F5; border-color: #E53935; }
.alerta-item.urgente { background: #FFF8F0; border-color: #F57C00; }
.alerta-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; }
.alerta-item.vencido .alerta-icon { color: #E53935; }
.alerta-item.urgente .alerta-icon { color: #F57C00; }
.alerta-obj { font-weight: 600; font-size: .9rem; }
.alerta-meta { font-size: .8rem; color: #666; }

/* ── Tabela ── */
.table th { background: #F8F9FC; color: var(--primary); font-size: .78rem; font-weight: 600;
  border-bottom: 2px solid #E0E4EF; white-space: nowrap; padding: 10px 10px; }
.table td { font-size: .8rem; padding: 9px 10px; vertical-align: middle; }
.table tbody tr:hover { background: #F6F8FF; }
.objeto-clicavel { cursor: pointer; color: var(--primary); }
.objeto-clicavel:hover { color: var(--primary-light); text-decoration: underline; }

/* ── Badges / Status ── */
.badge-status {
  display: inline-block; padding: 3px 8px; border-radius: 20px;
  font-size: .7rem; font-weight: 600; white-space: nowrap;
}
.s-vencido { background: #FFEBEE; color: #C62828; }
.s-ate30 { background: #FFF3E0; color: #E65100; }
.s-ate60 { background: #FFF8E1; color: #F9A825; }
.s-ate90 { background: #FFFDE7; color: #F57F17; }
.s-ate180 { background: #E8F5E9; color: #2E7D32; }
.s-acima180 { background: #E3F2FD; color: #1565C0; }
.s-indet { background: #F5F5F5; color: #757575; }

.badge-crit {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .68rem; font-weight: 700;
}
.c-alta { background: #FFEBEE; color: #B71C1C; }
.c-media { background: #FFFDE7; color: #F57F17; }
.c-baixa { background: #E8F5E9; color: #1B5E20; }

.btn-acao { padding: 3px 7px; font-size: .75rem; border-radius: 5px; }

/* ── Grupos de alerta no dashboard ── */
.alerta-grupo { border-radius: 10px; overflow: hidden; border: 1px solid; }
.alerta-grupo-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-weight: 700; font-size: .82rem;
}
.alerta-grupo-count {
  margin-left: auto; font-size: .75rem; font-weight: 700;
  padding: 1px 8px; border-radius: 20px; background: rgba(0,0,0,.12);
}
.alerta-grupo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-top: 1px solid rgba(0,0,0,.06);
  background: rgba(255,255,255,.6);
}
.alerta-grupo-item-clicavel { cursor: pointer; transition: background .15s, padding-left .15s; }
.alerta-grupo-item-clicavel:hover { background: rgba(255,255,255,.95); padding-left: 20px; }
.alerta-chevron { font-size: .85rem; opacity: .35; flex-shrink: 0; transition: opacity .15s, transform .15s; }
.alerta-grupo-item-clicavel:hover .alerta-chevron { opacity: .8; transform: translateX(3px); }
.btn-ver-alerta {
  flex-shrink: 0; border: 1px solid; border-radius: 6px;
  padding: 3px 10px; font-size: .75rem; background: transparent; cursor: pointer;
}

/* 30 dias — vermelho */
.alerta-30 { border-color: #FFCDD2; }
.alerta-30 .alerta-grupo-header { background: #FFEBEE; color: #B71C1C; }
.alerta-30 .alerta-obj { color: #C62828; font-weight: 600; }
.alerta-30 .btn-ver-alerta { color: #C62828; border-color: #EF9A9A; }
.alerta-30 .btn-ver-alerta:hover { background: #FFEBEE; }

/* 60 dias — amarelo */
.alerta-60 { border-color: #FFE082; }
.alerta-60 .alerta-grupo-header { background: #FFF8E1; color: #F57F17; }
.alerta-60 .alerta-obj { color: #E65100; font-weight: 600; }
.alerta-60 .btn-ver-alerta { color: #E65100; border-color: #FFCC02; }
.alerta-60 .btn-ver-alerta:hover { background: #FFF8E1; }

/* 90 dias — verde */
.alerta-90 { border-color: #A5D6A7; }
.alerta-90 .alerta-grupo-header { background: #E8F5E9; color: #1B5E20; }
.alerta-90 .alerta-obj { color: #2E7D32; font-weight: 600; }
.alerta-90 .btn-ver-alerta { color: #2E7D32; border-color: #81C784; }
.alerta-90 .btn-ver-alerta:hover { background: #E8F5E9; }

/* 180 dias — azul */
.alerta-180 { border-color: #90CAF9; }
.alerta-180 .alerta-grupo-header { background: #E3F2FD; color: #0D47A1; }
.alerta-180 .alerta-obj { color: #1565C0; font-weight: 600; }
.alerta-180 .btn-ver-alerta { color: #1565C0; border-color: #64B5F6; }
.alerta-180 .btn-ver-alerta:hover { background: #E3F2FD; }

/* ── Termos Aditivos ── */
.ta-lista { display: flex; flex-direction: column; gap: 8px; }
.ta-item {
  border: 1px solid #D0D7E8; border-radius: 8px; padding: 10px 12px;
  background: #F8F9FF; position: relative;
}
.ta-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ta-numero { font-weight: 700; font-size: .8rem; color: var(--primary); }
.ta-btn-remover { margin-left: auto; border: none; background: none; color: #E53935; cursor: pointer; font-size: .85rem; padding: 2px 6px; border-radius: 4px; }
.ta-btn-remover:hover { background: #FFEBEE; }
.badge-ta { background: #E3F2FD; color: #1565C0; font-size: .65rem; padding: 2px 6px; border-radius: 10px; font-weight: 700; }

/* ── Responsivo ── */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .brand-text, .sidebar .nav-item span:not(.badge), .sidebar .sidebar-footer { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 12px 0; }
  .main-content { margin-left: 64px; }
  .topbar { left: 64px; }
  .kpi-value { font-size: 1.6rem; }
}
