/* ==========================================================================
   ISP Bench — Design System (tema vermelho IPV7)
   ========================================================================== */

:root {
  --brand-primary: #dc2626;
  --brand-primary-hover: #b91c1c;
  --brand-primary-soft: #fef2f2;
  --brand-dark: #18181b;
  --brand-accent: #991b1b;
  --surface: #ffffff;
  --surface-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.625rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
  --transition: 150ms ease;
  --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Typography ---------- */

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- Navbar ---------- */

.navbar-app {
  background: var(--brand-dark);
  padding: 0;
  border-bottom: 3px solid var(--brand-primary);
  box-shadow: var(--shadow-md);
}

.navbar-app .container-xxl {
  padding-top: 0;
  padding-bottom: 0;
}

.navbar-app .navbar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0;
  color: #fff;
}

.navbar-app .navbar-brand:hover { color: #fff; }

.navbar-app .brand-icon {
  width: 30px;
  height: 30px;
  background: var(--brand-primary);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
}

.navbar-app .nav-link {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.75rem 0.9rem;
  color: rgba(255, 255, 255, 0.65);
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -3px;
}

.navbar-app .nav-link:hover {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.3);
}

.navbar-app .nav-link.active {
  color: #fff;
  border-bottom-color: var(--brand-primary);
}

.navbar-app .nav-link .bi {
  font-size: 0.9rem;
}

.navbar-app .nav-user {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.5rem 0.6rem;
}

.navbar-app .nav-user-link {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.navbar-app .nav-user-link:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.07);
}

.navbar-app .btn-admin {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}

.navbar-app .btn-admin:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* ---------- Page header ---------- */

.page-header {
  margin-bottom: 1.25rem;
}

.page-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.page-header h2 .bi {
  color: var(--brand-primary);
}

.page-header .text-muted {
  font-size: 0.82rem;
}

/* ---------- Cards ---------- */

.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-header .bi {
  color: var(--brand-primary);
}

.card-body {
  padding: 1rem;
}

.card-filter {
  background: var(--surface);
  border-left: 3px solid var(--brand-primary);
}

/* ---------- KPI Cards ---------- */

.kpi-card {
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  height: 100%;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-card .kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-card .kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-unit {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 0.15rem;
}

.kpi-card .kpi-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.kpi-rank {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
}

.kpi-trend-up {
  background: #dcfce7;
  color: #15803d;
}

.kpi-trend-down {
  background: #fee2e2;
  color: #b91c1c;
}

.kpi-trend-neutral {
  background: #f1f5f9;
  color: #64748b;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.kpi-icon-blue    { background: #dbeafe; color: #2563eb; }
.kpi-icon-green   { background: #dcfce7; color: #16a34a; }
.kpi-icon-amber   { background: #fef3c7; color: #d97706; }
.kpi-icon-purple  { background: #ede9fe; color: #7c3aed; }
.kpi-icon-rose    { background: #ffe4e6; color: #dc2626; }
.kpi-icon-teal    { background: #ccfbf1; color: #0d9488; }

/* Accent border colors matching icon */
.kpi-card.kpi-accent-blue   { border-left-color: #2563eb; }
.kpi-card.kpi-accent-green  { border-left-color: #16a34a; }
.kpi-card.kpi-accent-amber  { border-left-color: #d97706; }
.kpi-card.kpi-accent-purple { border-left-color: #7c3aed; }
.kpi-card.kpi-accent-rose   { border-left-color: #dc2626; }
.kpi-card.kpi-accent-teal   { border-left-color: #0d9488; }

/* ---------- Tables ---------- */

.table-app {
  margin-bottom: 0;
  font-size: 0.82rem;
}

.table-app thead th {
  background: #f9fafb;
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
}

.table-app tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.table-app tbody tr:hover {
  background: #fafafa;
}

.table-app tbody tr:last-child td {
  border-bottom: none;
}

.table-app .company-name {
  font-weight: 600;
  color: var(--text-primary);
}

.table-app .cell-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.table-app .cell-empty {
  color: var(--text-muted);
}

/* ---------- Benchmark ---------- */
.bench-col {
  background: #f8fafc;
  border-left: 2px solid #e2e8f0;
  font-weight: 600;
}
.bench-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.bench-up {
  background: #16a34a;
  color: #fff;
}
.bench-down {
  background: #dc2626;
  color: #fff;
}
.bench-neutral {
  background: #94a3b8;
  color: #fff;
}

/* ---------- Ranking ---------- */

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
}

.rank-1 { background: #fef3c7; color: #92400e; }
.rank-2 { background: #e5e7eb; color: #374151; }
.rank-3 { background: #fed7aa; color: #9a3412; }
.rank-default { background: #f3f4f6; color: #6b7280; }

/* ---------- Forms / filters ---------- */

.form-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.form-control,
.form-select {
  font-size: 0.85rem;
  border-color: var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-control[readonly] {
  background: #f9fafb;
  color: var(--text-secondary);
}

.form-text {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  transition: all var(--transition);
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

.btn-success {
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1.25rem;
}

.btn-outline-secondary {
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* ---------- Alerts ---------- */

.alert-app {
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-app .bi { font-size: 1rem; flex-shrink: 0; }
.alert-app.alert-success { background: #dcfce7; color: #166534; }
.alert-app.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-app.alert-warning { background: #fef3c7; color: #92400e; }
.alert-app.alert-info    { background: #dbeafe; color: #1e40af; }

/* ---------- Filter pills ---------- */

.filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.filter-pill .bi { font-size: 0.65rem; }

/* ---------- Entry form table ---------- */

.entry-table .indicator-name {
  font-weight: 600;
  color: var(--text-primary);
}

.entry-table .indicator-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.entry-table .form-control {
  max-width: 170px;
}

.entry-table .badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.18em 0.45em;
  vertical-align: middle;
}

.entry-table .ts-muted {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---------- Module accordion ---------- */

.module-accordion .accordion-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.module-accordion .accordion-button {
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: none;
}

.module-accordion .accordion-button:not(.collapsed) {
  background: linear-gradient(135deg, var(--brand-primary-soft) 0%, var(--surface) 100%);
  color: var(--text-primary);
}

.module-accordion .accordion-button::after {
  width: 0.85rem;
  height: 0.85rem;
  background-size: 0.85rem;
}

.module-accordion .accordion-button .bi {
  color: var(--brand-primary);
  font-size: 1rem;
}

.module-accordion .module-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border: 1px solid rgba(220, 38, 38, 0.12);
}

.module-accordion .accordion-body {
  padding: 1.25rem;
  background: var(--surface-secondary);
}

/* ---------- Chart cards ---------- */

.chart-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-smooth);
}

.chart-card:hover {
  box-shadow: var(--shadow-md);
}

.chart-card .chart-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-card .chart-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-card .chart-unit {
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}

.chart-card .chart-body {
  padding: 0.5rem 0.75rem 0.75rem;
}

/* ---------- Plotly ---------- */

.plotly-chart { min-height: 100px; }

/* ---------- Empty states ---------- */

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .bi {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.85rem;
  max-width: 300px;
  margin: 0 auto;
}

/* ---------- Group badges (user management) ---------- */

.badge-group {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18em 0.55em;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.badge-group.badge-viewer {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: rgba(29, 78, 216, 0.15);
}

.badge-group.badge-editor {
  background: #dcfce7;
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.15);
}

.badge-group.badge-admin {
  background: #fee2e2;
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.15);
}

/* ==========================================================================
   ANATEL Analysis — Design System (SaaS / Executive)
   ========================================================================== */

/* --- Toolbar --- */
.an-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.an-bar form:first-child { flex: 1; }
.an-bar-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.an-bar-field { flex: 0 1 auto; min-width: 120px; }
.an-bar-field--wide { min-width: 180px; }
.an-bar-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.2rem;
}
.an-bar .form-select {
  font-size: 0.8rem;
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  border-radius: 8px;
}
.an-bar-sync { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.an-last-sync {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
}
.an-last-sync i { color: #22c55e; margin-right: 2px; }
.an-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--surface);
  color: #94a3b8;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 150ms;
}
.an-btn-icon:hover { background: #f8fafc; color: #475569; border-color: #cbd5e1; }

/* --- KPI Row --- */
.an-kpi-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.an-kpi {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.an-kpi--hero {
  border-left: 3px solid var(--brand-primary);
  min-width: 180px;
}
.an-kpi--pill {
  justify-content: center;
  padding: 0.5rem 0.75rem;
}
.an-kpi__label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}
.an-kpi__value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.an-kpi__value--sm {
  font-size: 1rem;
  font-weight: 700;
}
.an-kpi__sub {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 500;
}
.an-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}
.an-pill .bi { font-size: 0.55rem; }

/* --- Chart Grid --- */
.an-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.5fr 0.9fr;
  gap: 0.75rem;
  grid-template-areas: "left center right";
}
.an-grid__left   { grid-area: left; }
.an-grid__center { grid-area: center; display: flex; flex-direction: column; gap: 0.75rem; }
.an-grid__right  { grid-area: right; }

/* --- Card (chart panel) --- */
.an-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 200ms ease;
}
.an-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.an-card--stretch { height: 100%; }

.an-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid #f1f5f9;
}
.an-card__head h3 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.an-card__sub {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 500;
}
.an-view-toggle {
  display: inline-flex;
  gap: 2px;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px;
}
.an-view-btn {
  border: none;
  background: transparent;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.an-view-btn:hover { color: #1e3a5f; }
.an-view-btn.active {
  background: #fff;
  color: #1e3a5f;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.an-view-hidden {
  position: absolute;
  top: 0; left: 0; right: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
}
.an-view-hidden * {
  pointer-events: none !important;
}
.an-card__badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #f1f5f9;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.an-card__body {
  padding: 0.3rem 0.5rem 0.5rem;
  flex: 1;
  min-height: 0;
}

/* Plotly overrides within cards */
.an-card__body .js-plotly-plot .plotly .modebar { display: none !important; }
.an-card__body .js-plotly-plot {
  font-family: Inter, system-ui, sans-serif !important;
}
/* Softer hover crosshair */
.an-card__body .js-plotly-plot .nsewdrag { cursor: default !important; }

/* --- Empty states --- */
.an-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1rem;
  color: #94a3b8;
  height: 100%;
}
.an-empty .bi { font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.35; }
.an-empty p { font-size: 0.78rem; margin: 0; }

.an-empty-full {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #94a3b8;
}
.an-empty-full .bi { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; opacity: 0.3; }
.an-empty-full h4 { color: var(--text-primary); margin-bottom: 0.5rem; }
.an-empty-full p { font-size: 0.82rem; max-width: 380px; margin: 0 auto; }

/* --- HTMX loading --- */
#analysis-results { transition: opacity .2s ease; }
#analysis-results.htmx-request { opacity: .3; pointer-events: none; }

/* --- Responsive --- */
@media (max-width: 1199.98px) {
  .an-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "left center" "right right";
  }
}
@media (max-width: 767.98px) {
  .an-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "left" "center" "right";
  }
  .an-bar-row { gap: 0.4rem; }
  .an-bar-field { min-width: 0; flex: 1 1 45%; }
  .an-kpi-row { flex-direction: column; }
  .an-kpi__value { font-size: 1.2rem; }
}

/* ---------- Searchable select ---------- */

.ss-wrapper {
  position: relative;
}

.ss-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: calc(1.5em + 0.75rem + 2px);
}

.ss-trigger:hover {
  border-color: var(--text-muted);
}

.ss-wrapper.ss-open .ss-trigger {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.ss-trigger-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-trigger-arrow {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.ss-wrapper.ss-open .ss-trigger-arrow {
  transform: rotate(180deg);
}

.ss-dropdown {
  display: none;
  position: absolute;
  z-index: 1050;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.ss-wrapper.ss-open .ss-dropdown {
  display: block;
}

.ss-search {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border-color);
}

.ss-search input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  outline: none;
  font-family: inherit;
}

.ss-search input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.08);
}

.ss-options {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.2rem 0;
}

.ss-option {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
}

.ss-option:hover,
.ss-option.ss-highlighted {
  background: var(--surface-secondary);
}

.ss-option.ss-selected {
  background: var(--brand-primary-soft);
  font-weight: 600;
}

.ss-option.ss-hidden {
  display: none;
}

/* ---------- Compare checkbox list ---------- */

.compare-actions {
  display: flex;
  gap: 0.25rem;
}

.btn-compare-action {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.btn-compare-action:hover {
  background: var(--surface-secondary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.compare-checkbox-list {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 160px;
  overflow-y: auto;
  background: var(--surface);
  padding: 0.25rem 0;
}

.compare-checkbox-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.compare-checkbox-list li {
  margin: 0;
  padding: 0;
}

.compare-checkbox-item,
.compare-checkbox-list li label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}

.compare-checkbox-item:hover,
.compare-checkbox-list li label:hover {
  background: var(--surface-secondary);
}

.compare-checkbox-list input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.compare-checkbox-label {
  line-height: 1.3;
}

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-secondary);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--brand-primary);
  color: #fff;
  font-size: 1.4rem;
  margin-bottom: 0.6rem;
}

.login-brand-text {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-subtitle {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-error {
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
  margin-bottom: 1.25rem;
}

.login-field {
  margin-bottom: 1rem;
}

.login-field .form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.login-field .input-group-text {
  background: var(--surface-secondary);
  border-color: var(--border-color);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-field .form-control {
  border-color: var(--border-color);
  font-size: 0.85rem;
}

.login-field .form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.login-btn {
  margin-top: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.login-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
  .kpi-card .kpi-value { font-size: 1.15rem; }
  .kpi-card { padding: 0.7rem 0.8rem; }
  .table-app { font-size: 0.78rem; }
  .table-app thead th { font-size: 0.68rem; padding: 0.5rem; }
  .table-app tbody td { padding: 0.45rem 0.5rem; }
  .module-accordion .accordion-body { padding: 1rem; }
}

@media (max-width: 575.98px) {
  .page-header h2 { font-size: 1.15rem; }
  .card-body { padding: 0.75rem; }
  .entry-table .form-control { max-width: 110px; }
  .navbar-app .nav-link { padding: 0.5rem 0.75rem; margin-bottom: 0; border-bottom: none; }
  .navbar-app .nav-link.active { background: rgba(255,255,255,0.08); border-radius: var(--radius-sm); }
}
