/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --omega: #1d7192;
  --omega-dark: #0f363e;
  --bg: #071114;
  --bg-soft: #0b1a1f;
  --panel: rgba(14, 22, 28, 0.85);
  --panel-solid: #0e161c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef6f8;
  --muted: #7a9bb0;
  --success: #22c55e;
  --warning: #facc15;
  --danger: #ef4444;
  --cyan: #38bdf8;
  --purple: #a78bfa;
  --orange: #f97316;
  --pink: #f472b6;
  --green: #4ade80;
  --teal: #2dd4bf;
  --indigo: #818cf8;
  --yellow: #fbbf24;
  --red: #f87171;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.28);
  --sidebar-width: 17.5rem;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse at 8% 8%, rgba(29, 113, 146, 0.2) 0%, transparent 42%),
    radial-gradient(ellipse at 92% 85%, rgba(167, 139, 250, 0.07) 0%, transparent 38%),
    linear-gradient(160deg, #061013 0%, #0b1a20 50%, #040a0d 100%);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
p { line-height: 1.5; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(56, 189, 248, 0.5); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.75rem;
  background: rgba(4, 11, 15, 0.94);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(28px);
  z-index: 40;
  transition: transform var(--transition);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 39;
  backdrop-filter: blur(3px);
}

.brand {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

.brand img {
  width: 9rem;
  max-height: 2.5rem;
  object-fit: contain;
}

.nav { display: grid; gap: 0.2rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  text-align: left;
}

.nav-link svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; }

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.18);
}

.sidebar-sep {
  height: 1px;
  background: var(--line);
  margin: 0.6rem 0.35rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem 0.5rem 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
  border-top: 1px solid var(--line);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  padding: 1.4rem 1.5rem;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5.5rem;
  margin-bottom: 1.25rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.hamburger svg { width: 1.2rem; height: 1.2rem; }

.eyebrow {
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.2rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.primary-button,
.ghost-button,
.filters-toggle,
.pagination button,
.icon-button {
  min-height: 2.35rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius-sm);
  padding: 0 0.85rem;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 600;
  transition: all var(--transition);
}

.primary-button {
  background: linear-gradient(135deg, #1d7192, #0ea5c7);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 4px 18px rgba(29, 113, 146, 0.35);
}

.primary-button:hover {
  box-shadow: 0 6px 26px rgba(29, 113, 146, 0.5);
  transform: translateY(-1px);
}

.ghost-button, .filters-toggle, .pagination button {
  background: rgba(255, 255, 255, 0.05);
}

.ghost-button:hover, .filters-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.icon-button {
  width: 2.35rem;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
}

.icon-button:hover { background: rgba(255, 255, 255, 0.1); }

.primary-button svg,
.ghost-button svg,
.icon-button svg { width: 0.9rem; height: 0.9rem; }

/* ============================================================
   STATUS BANNER
   ============================================================ */
.status-banner {
  margin-bottom: 1.1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: var(--radius-sm);
  color: #fde68a;
  background: rgba(250, 204, 21, 0.07);
  font-size: 0.85rem;
}

.hidden { display: none !important; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters-panel {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}

.filters-toggle {
  display: none;
  width: 100%;
  margin-bottom: 0;
  justify-content: flex-start;
  gap: 0.5rem;
}

.toggle-arrow { margin-left: auto; transition: transform var(--transition); }
.filters-toggle.open .toggle-arrow { transform: rotate(180deg); }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
}

label {
  display: grid;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input, select {
  width: 100%;
  min-height: 2.4rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
  color: var(--text);
  background: rgba(3, 8, 10, 0.75);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}

.search-field { grid-column: span 2; }
.clear-button { width: 100%; }

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  position: relative;
  min-height: 8rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--kpi-color, var(--cyan));
  border-radius: 12px 12px 0 0;
}

.kpi-card::after {
  content: "";
  position: absolute;
  bottom: -2rem;
  right: -2rem;
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  background: var(--kpi-color, var(--cyan));
  opacity: 0.05;
  pointer-events: none;
}

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

.kpi-icon {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--kpi-color, var(--cyan));
  margin-bottom: 0.6rem;
}

.kpi-icon svg { width: 1.1rem; height: 1.1rem; }

.kpi-value {
  font-size: clamp(1.35rem, 2.2vw, 1.9rem);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  word-break: break-word;
  hyphens: auto;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 0.4rem;
}

.kpi-hint {
  color: var(--kpi-color, var(--cyan));
  font-size: 0.7rem;
  margin-top: 0.15rem;
}

/* ============================================================
   CHARTS GRID
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.panel {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}

.panel.wide { grid-column: 1 / -1; }

.chart-panel { }

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.panel-header h2 { margin: 0; }

canvas {
  width: 100% !important;
  max-height: 22rem;
}

/* ============================================================
   COLORED ICON CHIPS
   ============================================================ */
.ph-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  flex-shrink: 0;
}

.ph-icon svg { width: 1rem; height: 1rem; }

.ph-icon.cyan   { background: rgba(56, 189, 248, 0.12);  color: var(--cyan);   }
.ph-icon.green  { background: rgba(74, 222, 128, 0.12);  color: var(--green);  }
.ph-icon.yellow { background: rgba(251, 191, 36, 0.12);  color: var(--yellow); }
.ph-icon.orange { background: rgba(249, 115, 22, 0.12);  color: var(--orange); }
.ph-icon.red    { background: rgba(248, 113, 113, 0.12); color: var(--red);    }
.ph-icon.purple { background: rgba(167, 139, 250, 0.12); color: var(--purple); }
.ph-icon.pink   { background: rgba(244, 114, 182, 0.12); color: var(--pink);   }
.ph-icon.teal   { background: rgba(45, 212, 191, 0.12);  color: var(--teal);   }
.ph-icon.indigo { background: rgba(129, 140, 248, 0.12); color: var(--indigo); }

/* ============================================================
   SECTION HEADING
   ============================================================ */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.section-heading .panel-header { margin-bottom: 0; }

/* ============================================================
   INSIGHTS
   ============================================================ */
.insights-panel, .table-panel { margin-bottom: 1.25rem; }

.insights-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.insight {
  padding: 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  transition: transform var(--transition);
}

.insight:hover { transform: translateY(-1px); }

.insight-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-size: 0.86rem;
  font-weight: 700;
}

.insight-header svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; }

.insight p {
  color: var(--muted);
  font-size: 0.81rem;
  line-height: 1.55;
}

.insight.warning { border-left-color: var(--warning); }
.insight.warning .insight-header { color: var(--warning); }
.insight.danger  { border-left-color: var(--danger);  }
.insight.danger  .insight-header { color: var(--danger);  }
.insight.success { border-left-color: var(--success); }
.insight.success .insight-header { color: var(--success); }
.insight.info    { border-left-color: var(--cyan);    }
.insight.info    .insight-header { color: var(--cyan);    }

/* ============================================================
   TABLE
   ============================================================ */
.table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.table-search-wrap {
  position: relative;
  flex: 1;
  max-width: 22rem;
}

.table-search-wrap > svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9rem;
  height: 0.9rem;
  color: var(--muted);
  pointer-events: none;
}

.table-search-wrap input { padding-left: 2.15rem; }

.pagination {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.pagination button {
  width: 2.1rem;
  min-height: 2.1rem;
  padding: 0;
}

.pagination button svg { width: 0.9rem; height: 0.9rem; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 72rem;
  border-collapse: collapse;
}

th, td {
  padding: 0.72rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}

th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: rgba(8, 18, 24, 0.95);
  cursor: pointer;
  user-select: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  transition: color var(--transition);
}

th:hover { color: var(--text); }
td { color: #cde5f5; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(56, 189, 248, 0.03); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  max-width: 14rem;
  min-height: 1.45rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge.success { background: rgba(34, 197, 94, 0.14);  color: #86efac; }
.badge.warning { background: rgba(250, 204, 21, 0.14); color: #fde68a; }
.badge.danger  { background: rgba(239, 68, 68, 0.14);  color: #fca5a5; }
.badge.info    { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }

/* ============================================================
   HEATMAP
   ============================================================ */
.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.5rem;
}

.heat-cell {
  min-height: 4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem;
  background: rgba(29, 113, 146, var(--heat));
  transition: transform var(--transition), box-shadow var(--transition);
}

.heat-cell:hover { transform: scale(1.04); box-shadow: var(--shadow-sm); }
.heat-cell b { display: block; font-size: 0.78rem; }
.heat-cell span { color: var(--muted); font-size: 0.73rem; }

/* ============================================================
   MOBILE NAV
   ============================================================ */
.mobile-nav { display: none; }

/* ============================================================
   MODAL DE AJUDA
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 40rem;
  max-height: 88vh;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: #0c1a22;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.modal-header .panel-header { margin-bottom: 0; }
.modal-header h2 { font-size: 1.05rem; }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.help-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.1rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.help-tab {
  padding: 0.38rem 0.8rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.help-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.help-tab.active {
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.2);
}

.help-pane { display: none; }
.help-pane.active { display: grid; gap: 0.75rem; }

.help-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  align-items: flex-start;
}

.help-item .ph-icon { flex-shrink: 0; margin-top: 0.05rem; }

.help-item strong {
  display: block;
  font-size: 0.87rem;
  margin-bottom: 0.3rem;
}

.help-item p {
  color: var(--muted);
  font-size: 0.81rem;
  line-height: 1.55;
}

.help-item code {
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: grid;
  gap: 0.45rem;
  max-width: 22rem;
  width: calc(100% - 2.5rem);
  pointer-events: none;
}

.toast {
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: 10px;
  background: #0d1e27;
  color: var(--text);
  font-size: 0.83rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.22s ease;
  pointer-events: auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

.toast.success { border-left-color: var(--success); }
.toast.danger  { border-left-color: var(--danger);  }
.toast.info    { border-left-color: var(--cyan);    }
.toast svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE — 1320px
   ============================================================ */
@media (max-width: 1320px) {
  .filters-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid     { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ============================================================
   RESPONSIVE — 980px (tablet / mobile)
   ============================================================ */
@media (max-width: 980px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .app-shell {
    width: 100%;
    margin-left: 0;
    padding-bottom: 5.25rem;
  }

  .hamburger { display: flex; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
    gap: 0.75rem;
  }

  .topbar-left { width: 100%; }
  .top-actions { width: 100%; }

  .filters-toggle {
    display: flex;
    margin-bottom: 0;
  }

  .filters-grid {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0.9rem;
  }

  .filters-grid.open { display: grid; }

  .kpi-grid, .insights-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts-grid { grid-template-columns: 1fr; }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 4.25rem;
    border-top: 1px solid var(--line);
    background: rgba(4, 11, 15, 0.97);
    backdrop-filter: blur(28px);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mob-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.45rem 0.2rem;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: color var(--transition);
    letter-spacing: 0.02em;
  }

  .mob-link svg { width: 1.25rem; height: 1.25rem; }
  .mob-link.active { color: var(--cyan); }
  .mob-link:hover { color: var(--text); }

  .modal { border-radius: 16px; }
}

/* ============================================================
   RESPONSIVE — 640px (mobile)
   ============================================================ */
@media (max-width: 640px) {
  .app-shell { padding: 0.85rem 0.75rem 5.5rem; }

  h1 { font-size: 1.35rem; }

  .top-actions .ghost-button span,
  .top-actions .primary-button span { display: none; }

  .top-actions .ghost-button,
  .top-actions .primary-button {
    padding: 0;
    width: 2.35rem;
  }

  .filters-grid,
  .kpi-grid,
  .charts-grid,
  .insights-list { grid-template-columns: 1fr; }

  .search-field, .panel.wide { grid-column: auto; }

  .kpi-card { min-height: 6rem; }

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .table-tools { flex-direction: column; align-items: stretch; }
  .table-search-wrap { max-width: none; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }

.toast-container { right: 0.75rem; left: 0.75rem; width: auto; }
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.auth-shell { width: min(100%, 28rem); }

.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.4rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-logo {
  width: 11rem;
  max-width: 70%;
  margin-bottom: 1.2rem;
}

.auth-card h1 {
  margin-bottom: 0.65rem;
  font-size: 1.9rem;
}

.auth-copy,
.auth-note {
  color: var(--muted);
  line-height: 1.5;
}

.auth-note {
  margin: 1rem 0 0;
  font-size: 0.85rem;
}

.auth-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.2rem;
}

.auth-form .primary-button { width: 100%; }

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.65rem;
  gap: 0.45rem;
}

.password-field input {
  min-width: 0;
}

.password-field .icon-button {
  width: 2.65rem;
  height: 2.65rem;
}

.password-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.password-actions .ghost-button {
  width: 100%;
  gap: 0.45rem;
}

.password-hint {
  margin-top: -0.35rem;
  color: var(--muted);
  line-height: 1.4;
}

.auth-alert {
  margin-top: 1rem;
  padding: 0.85rem;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
}

.auth-alert.success {
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.1);
}

.auth-link {
  display: inline-flex;
  margin-top: 1rem;
  color: var(--cyan);
  text-decoration: none;
}

.user-chip {
  display: grid;
  min-height: 2.55rem;
  align-content: center;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.user-chip span {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
}

.user-chip small {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.csv-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: -0.25rem 0 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(29, 113, 146, 0.08);
  font-size: 0.86rem;
  font-weight: 700;
}

.csv-meta svg {
  width: 1rem;
  height: 1rem;
  color: var(--cyan);
  flex: 0 0 auto;
}

.kpi-card,
.chart-panel canvas,
.heat-cell {
  cursor: pointer;
}

.kpi-card:focus-visible,
.heat-cell:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.45);
  outline-offset: 3px;
}

.detail-modal { max-width: min(92rem, calc(100vw - 2rem)); }

.detail-hero {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 8px;
  background: rgba(29, 113, 146, 0.1);
}

.detail-hero span {
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1;
}

.detail-hero p {
  margin: 0;
  color: var(--muted);
}

.detail-list {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.detail-row {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.detail-row b { color: var(--text); }

.detail-row span {
  color: var(--muted);
  line-height: 1.4;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.detail-actions .ghost-button {
  gap: 0.45rem;
}

.detail-data-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
}

.detail-table-wrap {
  max-height: 24rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#detailDataTable {
  min-width: 68rem;
}

#detailDataTable th,
#detailDataTable td {
  font-size: 0.78rem;
}

.mini-button {
  min-height: 1.9rem;
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 8px;
  padding: 0 0.6rem;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
  cursor: pointer;
}

.mini-button:hover {
  color: var(--text);
  background: rgba(56, 189, 248, 0.16);
}

@media (max-width: 640px) {
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-actions .ghost-button {
    width: 100%;
  }
}
