:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #0e3a55;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --critical: #8e44ad;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-muted: #bdc3c7;
  --border: #e1e5e9;
  --sidebar-bg: #0e1726;
  --sidebar-hover: #162236;
  --sidebar-active: #1a5276;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #c8d6e5;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-user div,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .brand-logo { width: 36px; height: auto; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .nav-item i { margin: 0; font-size: 1.15rem; }

.sidebar-brand {
  display: flex !important; flex-direction: column !important; align-items: center !important;
  gap: 8px; padding: 22px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}
.brand-logo {
  width: 90px; height: auto; border-radius: 10px;
  object-fit: contain; flex-shrink: 0;
  display: block; margin: 0 auto;
}
.brand-icon {
  width: 38px; height: 38px; background: var(--primary-light);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
.brand-text { text-align: center; }
.brand-name { font-weight: 700; font-size: 0.95rem; color: #fff; display: block; letter-spacing: 2px; text-align: center; }
.brand-version { display: block; font-size: 0.62rem; color: #576574; letter-spacing: 0.5px; margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1.5px;
  color: #576574; padding: 8px 20px 4px; display: block; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; color: #8395a7; text-decoration: none;
  font-size: 0.88rem; transition: all 0.2s; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #dfe6e9; }
.nav-item.active {
  background: rgba(41,128,185,0.15); color: #fff;
  border-left-color: var(--primary-light);
}
.nav-item i { width: 20px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user > i { font-size: 1.6rem; color: #576574; }
.user-name { display: block; font-size: 0.85rem; color: #dfe6e9; font-weight: 500; }
.user-role { display: block; font-size: 0.7rem; color: #576574; }

/* ===================== MAIN WRAPPER ===================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}
.main-wrapper.sidebar-collapsed { margin-left: 64px; }

/* ===================== TOPBAR ===================== */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.btn-toggle-sidebar {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: var(--text-light); padding: 8px;
  border-radius: 8px; transition: background 0.2s;
}
.btn-toggle-sidebar:hover { background: var(--bg); }
.page-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.topbar-action {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-light); text-decoration: none; transition: all 0.2s;
}
.topbar-action:hover { background: #fdebd0; color: var(--danger); }

/* Empresa dropdown */
.empresa-selector { position: relative; }
.empresa-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-size: 0.88rem; color: var(--text); font-family: inherit;
  transition: all 0.2s;
}
.empresa-btn:hover { border-color: var(--primary-light); }
.empresa-btn .chevron { font-size: 0.7rem; color: var(--text-light); transition: transform 0.2s; }
.empresa-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 280px; display: none; z-index: 200;
  overflow: hidden;
}
.empresa-dropdown.show { display: block; }
.dropdown-header { padding: 12px 16px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-light); border-bottom: 1px solid var(--border); font-weight: 600; }
.dropdown-list { max-height: 300px; overflow-y: auto; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; text-decoration: none; color: var(--text);
  font-size: 0.88rem; transition: background 0.15s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.active { background: #eaf2f8; color: var(--primary); font-weight: 600; }

/* Panorama filters */
.panorama-selector { display: flex; align-items: center; gap: 8px; }
.panorama-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 8px; font-size: 0.8rem;
  font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  font-family: inherit; transition: all 0.2s; white-space: nowrap;
}
.panorama-btn:hover { border-color: var(--primary-light); color: var(--primary); background: #eaf2f8; }
.panorama-active-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 8px; font-size: 0.8rem;
  font-weight: 600; text-decoration: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border: none; transition: all 0.2s; white-space: nowrap;
}
.panorama-active-badge:hover { opacity: 0.85; }
.panorama-active-badge .fa-xmark { font-size: 0.7rem; opacity: 0.7; margin-left: 4px; }
.topbar-divider { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }

.segmento-selector { position: relative; }
.segmento-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 240px; display: none; z-index: 200;
  overflow: hidden;
}
.segmento-dropdown.show { display: block; }

/* Panorama banner (nas páginas) */
.panorama-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; margin-bottom: 20px; border-radius: var(--radius);
  background: linear-gradient(135deg, #1a5276, #2980b9);
  color: #fff; font-size: 0.88rem;
  box-shadow: 0 2px 8px rgba(26,82,118,0.25);
}
.panorama-banner i.fa-globe { font-size: 1.1rem; }
.panorama-banner span { opacity: 0.85; font-size: 0.82rem; }
.panorama-banner-close {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 6px; font-size: 0.78rem;
  background: rgba(255,255,255,0.15); color: #fff; text-decoration: none;
  transition: background 0.2s;
}
.panorama-banner-close:hover { background: rgba(255,255,255,0.3); }

/* ===================== CONTENT ===================== */
.content { padding: 24px; }
.subtitle { color: var(--text-light); margin-bottom: 20px; font-size: 0.9rem; }

/* ===================== CARDS ===================== */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header-row h3 { font-size: 0.95rem; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-header-row h3 i { color: var(--primary-light); }
.card-link { margin-bottom: 20px; }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 16px; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; flex-shrink: 0;
}
.bg-blue { background: linear-gradient(135deg, #2980b9, #3498db); }
.bg-green { background: linear-gradient(135deg, #27ae60, #2ecc71); }
.bg-orange { background: linear-gradient(135deg, #e67e22, #f39c12); }
.bg-red { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.bg-purple { background: linear-gradient(135deg, #8e44ad, #9b59b6); }
.bg-teal { background: linear-gradient(135deg, #16a085, #1abc9c); }
.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-light); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===================== TABLES ===================== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); }
.table td { font-size: 0.88rem; }
.table tbody tr:hover { background: #f8f9fa; }
.fonte-text { font-size: 0.78rem; max-width: 220px; color: var(--text-light); line-height: 1.4; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-baixa, .badge-baixo { background: #d5f5e3; color: #1e8449; }
.badge-media, .badge-medio { background: #fef5e7; color: #b9770e; }
.badge-alta, .badge-alto { background: #fdedec; color: #c0392b; }

.badge-risco {
  display: inline-block; padding: 4px 14px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 700; color: #fff; letter-spacing: 0.3px;
}
.badge-risco-baixo { background: var(--success); }
.badge-risco-medio { background: var(--warning); }
.badge-risco-alto { background: var(--danger); }
.badge-risco-critico { background: var(--critical); }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.85rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.9rem; font-family: inherit;
  background: var(--card-bg); transition: all 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}
.form-inline-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.form-inline-row .form-group { flex: 1; min-width: 180px; }
.filter-form { display: flex; align-items: center; gap: 12px; }
.filter-form label { font-weight: 600; font-size: 0.85rem; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.filter-form select { width: auto; min-width: 250px; }
.radio-lg { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--card-bg);
  color: var(--text); font-size: 0.88rem;
  cursor: pointer; text-decoration: none; font-family: inherit;
  transition: all 0.2s; white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: #ccc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ===================== ALERTS ===================== */
.alert {
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 0.88rem; display: flex; align-items: center; gap: 8px;
  background: #eaf2f8; color: var(--primary); border: 1px solid #d4e6f1;
}
.alert-error { background: #fdedec; color: #c0392b; border-color: #f5c6cb; }
.alert-warning { background: #fef9e7; color: #7d6608; border-color: #fce8a6; }

/* ===================== UTILITIES ===================== */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

.link-copy { display: flex; gap: 8px; margin: 8px 0; }
.link-copy input { flex: 1; font-family: 'JetBrains Mono', monospace; background: var(--bg); font-size: 0.85rem; }
.hint { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }
.slug-code { background: var(--bg); padding: 3px 8px; border-radius: 4px; font-size: 0.78rem; }

/* ===================== PESQUISA (formulário público) ===================== */
.pesquisa-container { max-width: 800px; margin: 0 auto; padding: 24px; }
.pesquisa-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
  color: #fff; padding: 36px 32px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.pesquisa-header h1 { font-size: 1.4rem; margin-bottom: 4px; }
.pesquisa-header h2 { font-size: 1.05rem; font-weight: 400; opacity: 0.9; margin-bottom: 16px; }
.pesquisa-intro { font-size: 0.88rem; opacity: 0.85; margin-bottom: 8px; line-height: 1.5; }

.pesquisa-form { background: var(--card-bg); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow-md); }
.form-section { padding: 24px 32px; border-bottom: 1px solid var(--border); }
.topico-section h3 { color: var(--primary); margin-bottom: 16px; font-size: 0.95rem; }

.pergunta-card { padding: 16px 0; border-bottom: 1px solid #f5f5f5; }
.pergunta-card:last-child { border-bottom: none; }
.pergunta-texto { font-size: 0.92rem; margin-bottom: 4px; }
.pergunta-orientacao { font-size: 0.78rem; color: var(--text-light); margin-bottom: 12px; font-style: italic; }

.escala-container { margin-top: 8px; }
.escala-labels { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--text-light); margin-bottom: 4px; padding: 0 8px; }
.escala-options { display: flex; justify-content: space-between; gap: 8px; }
.escala-option { flex: 1; text-align: center; cursor: pointer; }
.escala-option input { display: none; }
.escala-circle {
  display: inline-flex; width: 42px; height: 42px;
  border-radius: 50%; border: 2px solid var(--border);
  align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem; transition: all 0.2s; color: var(--text-light);
}
.escala-option input:checked + .escala-circle { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.05); }
.escala-option:hover .escala-circle { border-color: var(--primary-light); }

.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); width: 0%; transition: width 0.3s; border-radius: 3px; }
.progress-text { font-size: 0.82rem; color: var(--text-light); margin-bottom: 16px; }
.form-actions { padding: 24px 32px; }

/* ===================== LOGIN ===================== */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--primary) 100%);
}
.login-brand {
  text-align: center; margin-bottom: 20px;
}
.login-logo {
  width: 180px; height: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
  margin-bottom: 8px;
}
.login-program-name {
  color: var(--primary); font-size: 1.4rem; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase;
  margin: 0;
}
.login-card {
  background: var(--card-bg); padding: 40px; border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 420px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header p { color: var(--text-light); font-size: 0.9rem; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .brand-text, .sidebar .nav-section-title,
  .sidebar .nav-item span, .sidebar .sidebar-user div { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 12px; }
  .sidebar .nav-item i { margin: 0; }
  .main-wrapper { margin-left: 64px; }
  .content { padding: 16px; }
  .cards-row { grid-template-columns: 1fr 1fr; }
  .form-section { padding: 16px; }
  .pesquisa-header { padding: 20px; }
  .escala-labels { display: none; }
  .empresa-btn span { display: none; }
  .panorama-selector { display: none; }
  .topbar-divider { display: none; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-form select { min-width: 100%; }
}
@media (max-width: 480px) {
  .cards-row { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-wrapper { margin-left: 0; }
}
