/* ==========================================================================
   HIGH-CONTRAST & CLEAR READABILITY DESIGN SYSTEM (Mahidol Gold & Cyber Navy)
   ========================================================================== */

:root {
  /* Color Palette - Dark Theme (Super High Contrast Default) */
  --bg-primary: #070a12;
  --bg-secondary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #0f172a;
  
  --border-color: rgba(255, 255, 255, 0.3);
  --border-glow: rgba(56, 189, 248, 0.6);
  --border-accent: #f59e0b;
  
  /* Super High Contrast Text Colors */
  --text-main: #ffffff;
  --text-muted: #e2e8f0; /* Ultra clear light grey */
  --text-heading: #ffffff;
  
  --accent-gold: #fbbf24;
  --accent-gold-glow: rgba(251, 191, 36, 0.35);
  --accent-blue: #38bdf8;
  --accent-blue-glow: rgba(56, 189, 248, 0.35);
  --accent-purple: #c084fc;
  --accent-emerald: #34d399;
  --accent-rose: #fb7185;
  --accent-amber: #fbbf24;

  --font-family: 'Prompt', 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
  
  --glass-blur: blur(12px);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables (Super High Contrast) */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  
  --border-color: #94a3b8;
  --border-glow: rgba(2, 132, 199, 0.4);
  --border-accent: #d97706;
  
  --text-main: #020617;
  --text-muted: #1e293b;
  --text-heading: #000000;
  
  --accent-gold: #b45309;
  --accent-gold-glow: rgba(180, 83, 9, 0.25);
  --accent-blue: #0284c7;
  --accent-blue-glow: rgba(2, 132, 199, 0.25);
  --accent-purple: #7e22ce;
  --accent-emerald: #047857;
  --accent-rose: #be123c;
  --accent-amber: #b45309;

  --shadow-card: 0 4px 20px rgba(15, 23, 42, 0.15);
  --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.2);
}

/* RESET & BASE */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* APP CONTAINER */
.app-container {
  max-width: 1650px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* HEADER NAVBAR */
.header-glass {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 1rem;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent-gold), #b45309);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.6rem;
  box-shadow: 0 4px 15px var(--accent-gold-glow);
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.brand-title-top {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.brand-title h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-heading);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.3;
}

.brand-badges {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 800;
  border: 1.5px solid #34d399;
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
  flex-shrink: 0;
}

/* Real-time Sync Badge Styles */
.live-sync-badge {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border-color: #fbbf24;
}

.live-sync-badge .sync-dot {
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
  animation: syncPulse 1.5s infinite;
}

.live-sync-badge.sync-success {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
  border-color: #34d399;
}

.live-sync-badge.sync-success .sync-dot {
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: none;
}

.live-sync-badge.sync-error {
  background: rgba(251, 113, 133, 0.18);
  color: #fb7185;
  border-color: #fb7185;
}

.live-sync-badge.sync-error .sync-dot {
  background: #fb7185;
  box-shadow: 0 0 8px #fb7185;
  animation: none;
}

@keyframes syncPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.6); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-cyber {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-cyber svg, .btn-cyber i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-cyber:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 0 15px var(--accent-blue-glow);
}

.btn-cyber-primary {
  background: linear-gradient(135deg, var(--accent-gold), #b45309);
  border: none;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 4px 15px var(--accent-gold-glow);
}

.btn-cyber-primary:hover {
  background: linear-gradient(135deg, #fbbf24, var(--accent-gold));
  color: #000000;
}

/* ULTRA HIGH-CONTRAST MULTI-DIMENSIONAL FILTERS PANEL */
.filters-glass {
  background: var(--bg-card);
  border: 2px solid var(--accent-blue);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.6rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.75rem;
  gap: 1rem;
}

.filters-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filters-icon {
  width: 38px;
  height: 38px;
  background: rgba(56, 189, 248, 0.15);
  border: 1.5px solid var(--accent-blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.filters-title h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.2;
}

.filters-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 1.1rem 1.35rem;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.filter-group label {
  font-size: 0.92rem;
  font-weight: 800;
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="light"] .filter-group label {
  color: #020617 !important;
  text-shadow: none;
}

.select-cyber, .input-cyber {
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  color: #ffffff !important;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  outline: none;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

[data-theme="light"] .select-cyber, 
[data-theme="light"] .input-cyber {
  color: #020617 !important;
  border-color: #64748b;
}

.select-cyber:focus, .input-cyber:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px var(--accent-blue-glow);
}

/* TABS NAV */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.6rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-color);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--text-muted);
  padding: 0.8rem 1.35rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
  background: var(--bg-secondary);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 15px var(--accent-gold-glow);
}

/* TAB PANELS */
.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

.tab-panel.active {
  display: flex;
}

/* KPI CARDS GRID */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-card);
  position: relative;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--accent-gold);
}

.kpi-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #ffffff;
  flex-shrink: 0;
}

.kpi-icon.gold { background: linear-gradient(135deg, var(--accent-gold), #b45309); }
.kpi-icon.blue { background: linear-gradient(135deg, var(--accent-blue), #0284c7); }
.kpi-icon.purple { background: linear-gradient(135deg, var(--accent-purple), #7e22ce); }
.kpi-icon.emerald { background: linear-gradient(135deg, var(--accent-emerald), #047857); }

.kpi-info h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-heading);
  margin: 0.2rem 0;
}

.kpi-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* CARDS & TABLES */
.grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 1.5rem;
}

.card-glass {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.85rem;
}

.card-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 380px;
}

/* TABLES WITH HIGH CONTRAST & ACCORDION PROGRAM SUBROWS */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
}

.table-cyber {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.table-cyber th {
  background: var(--bg-secondary);
  color: var(--text-heading);
  padding: 0.95rem 1rem;
  font-weight: 800;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.table-cyber td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  font-weight: 600;
}

.table-cyber tbody tr.faculty-row {
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.table-cyber tbody tr.faculty-row:hover {
  background: rgba(56, 189, 248, 0.18);
}

/* Subrow for Programs under Faculty */
.table-cyber tbody tr.program-subrow {
  background: var(--bg-input);
  display: none;
}

.table-cyber tbody tr.program-subrow.active {
  display: table-row;
}

.table-cyber tbody tr.program-subrow td {
  padding-left: 2rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px dashed var(--border-color);
}

/* RATING BADGES - HIGH CONTRAST */
.badge-rating {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 800;
}

.badge-excellent { background: rgba(16, 185, 129, 0.3); color: #34d399; border: 1.5px solid #34d399; }
.badge-good { background: rgba(56, 189, 248, 0.3); color: #38bdf8; border: 1.5px solid #38bdf8; }
.badge-moderate { background: rgba(245, 158, 11, 0.3); color: #fbbf24; border: 1.5px solid #fbbf24; }
.badge-low { background: rgba(244, 63, 94, 0.3); color: #fb7185; border: 1.5px solid #fb7185; }

/* MODAL STYLES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

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

.modal-box {
  background: var(--bg-secondary);
  border: 2px solid var(--border-accent);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 1.25rem; color: var(--text-heading); font-weight: 800; }
.modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 1.6rem; cursor: pointer; }

.dropzone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  background: rgba(245, 158, 11, 0.05);
  cursor: pointer;
}

/* ===================================================================
   RESPONSIVE DESIGN — PHONE / TABLET / DESKTOP
   =================================================================== */

/* --- FLUID BASE FONT SIZE (scales with viewport width) --- */
html {
  font-size: clamp(13px, 1.6vw, 16px);
}

/* === TABLET (max-width: 992px) === */
@media (max-width: 992px) {
  .app-container {
    padding: 0.75rem;
    gap: 1rem;
  }

  .header-glass {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    position: relative;
    top: 0;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
  }

  .brand-title h1 {
    font-size: 1.15rem;
  }

  .brand-title p {
    font-size: 0.78rem;
    flex-wrap: wrap;
  }

  .live-badge, .live-sync-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .btn-cyber {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
  }

  /* Filters */
  .filters-glass {
    padding: 1rem;
  }

  .filters-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .filters-header h2 {
    font-size: 0.95rem;
  }

  .filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
  }

  .filter-group label {
    font-size: 0.78rem;
  }

  .select-cyber, .input-cyber {
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
  }

  /* Tabs */
  .tabs-nav {
    gap: 0.35rem;
    padding: 0.4rem;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
    gap: 0.3rem;
  }

  .tab-btn svg, .tab-btn i {
    width: 14px;
    height: 14px;
  }

  /* KPI Cards */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .kpi-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .kpi-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .kpi-info h3 {
    font-size: 0.72rem;
  }

  .kpi-value {
    font-size: 1.5rem;
  }

  .kpi-sub {
    font-size: 0.72rem;
  }

  /* Cards & Charts */
  .grid-2col {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .card-glass {
    padding: 1rem;
    gap: 0.85rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-title {
    font-size: 0.95rem;
  }

  .chart-container {
    height: 300px;
  }

  /* Tables */
  .table-cyber {
    font-size: 0.8rem;
  }

  .table-cyber th {
    padding: 0.65rem 0.6rem;
    font-size: 0.75rem;
  }

  .table-cyber td {
    padding: 0.6rem 0.6rem;
    font-size: 0.78rem;
  }

  .table-cyber tbody tr.program-subrow td {
    padding-left: 1.25rem;
    font-size: 0.75rem;
  }

  .badge-rating {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
  }

  /* Modal */
  .modal-box {
    width: 95%;
    padding: 1.25rem;
  }

  .modal-header h3 {
    font-size: 1rem;
  }
}

/* === PHONE (max-width: 600px) === */
@media (max-width: 600px) {
  html {
    font-size: 13px;
  }

  .app-container {
    padding: 0.5rem;
    gap: 0.75rem;
  }

  .header-glass {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
  }

  .brand-section {
    gap: 0.75rem;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    border-radius: var(--radius-sm);
  }

  .brand-title h1 {
    font-size: 0.95rem;
    line-height: 1.3;
  }

  .brand-title p {
    font-size: 0.68rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .live-badge, .live-sync-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.4rem;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .btn-cyber {
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    gap: 0.25rem;
    border-radius: var(--radius-sm);
  }

  /* Filters */
  .filters-glass {
    padding: 0.75rem;
    border-radius: var(--radius-md);
  }

  .filters-header h2 {
    font-size: 0.82rem;
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .filter-group label {
    font-size: 0.72rem;
  }

  .select-cyber, .input-cyber {
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 6px;
  }

  /* Tabs — Horizontal scroll */
  .tabs-nav {
    gap: 0.25rem;
    padding: 0.35rem;
    border-radius: var(--radius-md);
  }

  .tab-btn {
    padding: 0.45rem 0.65rem;
    font-size: 0.68rem;
    gap: 0.2rem;
    border-radius: var(--radius-sm);
    min-width: max-content;
  }

  .tab-btn svg, .tab-btn i {
    width: 12px;
    height: 12px;
  }

  /* KPI Cards — 2 columns on phone */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .kpi-card {
    padding: 0.75rem;
    gap: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--radius-md);
  }

  .kpi-card::after {
    width: 100%;
    height: 3px;
    top: 0;
    left: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .kpi-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .kpi-info h3 {
    font-size: 0.62rem;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  .kpi-sub {
    font-size: 0.62rem;
  }

  /* Cards & Charts */
  .card-glass {
    padding: 0.75rem;
    gap: 0.6rem;
    border-radius: var(--radius-md);
  }

  .card-title {
    font-size: 0.82rem;
  }

  .chart-container {
    height: 250px;
  }

  /* Tables */
  .table-cyber {
    font-size: 0.7rem;
  }

  .table-cyber th {
    padding: 0.5rem 0.4rem;
    font-size: 0.65rem;
  }

  .table-cyber td {
    padding: 0.45rem 0.4rem;
    font-size: 0.68rem;
  }

  .table-cyber tbody tr.program-subrow td {
    padding-left: 0.8rem;
    font-size: 0.65rem;
  }

  .badge-rating {
    font-size: 0.62rem;
    padding: 0.1rem 0.35rem;
  }

  /* Modal */
  .modal-box {
    width: 98%;
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .modal-header h3 {
    font-size: 0.9rem;
  }

  .dropzone {
    padding: 1.25rem;
  }

  .dropzone p {
    font-size: 0.82rem;
  }

  /* IPA & Policy */
  .ipa-grid {
    grid-template-columns: 1fr !important;
  }

  .ipa-item {
    font-size: 0.75rem;
  }

  .policy-block h4 {
    font-size: 0.88rem;
  }

  .policy-block p {
    font-size: 0.78rem;
  }
}

/* === VERY SMALL PHONE (max-width: 380px) === */
@media (max-width: 380px) {
  html {
    font-size: 12px;
  }

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

  .brand-title h1 {
    font-size: 0.85rem;
  }

  .tab-btn {
    font-size: 0.6rem;
    padding: 0.35rem 0.5rem;
  }

  .chart-container {
    height: 220px;
  }
}

@media print {
  body { background: #fff; color: #000; }
  .header-glass, .filters-glass, .tabs-nav, .header-actions { display: none !important; }
  .tab-panel { display: flex !important; }
}

/* ===== LOADING OVERLAY FOR REAL-TIME GOOGLE SHEETS SYNC ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 18, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.6s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  text-align: center;
}

.loading-spinner p {
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-family);
}

.loading-spinner small {
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-family);
}

.spinner-ring {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(251, 191, 36, 0.2);
  border-top: 4px solid #fbbf24;
  border-radius: 50%;
  animation: spinRotate 1s linear infinite;
}

@keyframes spinRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
