/* CSS Custom Properties - Ahkili Theme */
:root {
  --bg-dark: #0f1923;
  --bg-darker: #0a1118;
  --bg-card: rgba(26, 77, 110, 0.25);
  --bg-card-hover: rgba(26, 77, 110, 0.35);
  
  --primary: #FF9F1C;
  --primary-glow: rgba(255, 159, 28, 0.3);
  --secondary: #2EC4B6;
  --accent: #6A4C93;
  --mint: #CBF3F0;
  --warning: #FFD166;
  --error: #E71D36;
  
  --text: #e8edf3;
  --text-muted: #8899aa;
  --border: rgba(255, 255, 255, 0.08);
  
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.02em;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
}

/* Utilities */
.status-good { color: var(--secondary); }
.status-warning { color: var(--warning); }
.status-error { color: var(--error); }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.logo-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 15px var(--primary-glow);
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--secondary);
}

.status-dot.online {
  background-color: var(--secondary);
  box-shadow: 0 0 8px var(--secondary);
  animation: pulse-green 2s infinite;
}

.status-dot.syncing {
  background-color: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse-yellow 2s infinite;
}

.status-dot.offline {
  background-color: var(--error);
  box-shadow: 0 0 8px var(--error);
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(46, 196, 182, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(46, 196, 182, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 196, 182, 0); }
}

@keyframes pulse-yellow {
  0% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(255, 209, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0); }
}

.last-updated-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.last-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.45rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--primary);
  transform: rotate(45deg);
}
.refresh-btn.spinning {
  animation: spin 0.8s linear infinite;
  color: var(--primary);
  pointer-events: none;
}

.logout-btn {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.logout-btn:hover {
  color: var(--error);
}

/* Global Filter */
.global-filter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.date-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="date"] {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  color-scheme: dark;
}

.separator {
  color: var(--text-muted);
}

.primary-btn {
  background: var(--primary);
  color: var(--bg-darker);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: all 0.2s;
}
.primary-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 10px var(--primary-glow);
}

.primary-btn.sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.preset-buttons {
  display: flex;
  gap: 0.5rem;
}

.preset-btn {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  transition: all 0.2s;
}
.preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.preset-btn.active {
  background: var(--primary);
  color: var(--bg-darker);
  border-color: var(--primary);
  font-weight: 600;
}

/* Tab Navigation */
.tabs-nav {
  display: flex;
  gap: 1rem;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 1rem 0.5rem;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color 0.3s;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  color: var(--primary);
}
.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}
.tab-btn.active::after {
  transform: scaleX(1);
}

/* Main Content */
.main-content {
  padding: 2rem;
  flex: 1;
}

.tab-pane {
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}
.tab-pane.active {
  display: block;
  opacity: 1;
  animation: fadeIn 0.25s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  background: var(--bg-card-hover);
}

.kpi-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.kpi-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 700;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.kpi-value.kpi-value-sm {
  font-size: clamp(0.95rem, 1.8vw, 1.25rem);
  line-height: 1.3;
}

.kpi-delta {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.delta-positive { color: var(--secondary); }
.delta-negative { color: var(--error); }
.delta-neutral { color: var(--text-muted); }

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.chart-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-date-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  font-size: 1rem;
  transition: background 0.2s;
  flex-shrink: 0;
}
.chart-date-btn:hover {
  background: rgba(255,255,255,0.1);
}

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.chart-container canvas {
  max-width: 100% !important;
  max-height: 100% !important;
  display: block;
}

/* Sections */
.section-container {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.section-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.section-header h2 {
  font-size: 1.25rem;
}
.table-scroll-hint {
  display: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Tracking & Marketing Status Grid */
.tracking-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.tracking-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.tracking-status-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.tracking-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.tracking-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.tracking-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.tracking-id {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
  overflow-wrap: anywhere;
}

.tracking-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  align-self: flex-start;
  margin-top: 0.2rem;
}

.tracking-badge.active {
  background: rgba(46, 196, 182, 0.15);
  color: var(--secondary);
  border: 1px solid rgba(46, 196, 182, 0.3);
}

.tracking-badge.pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 0 6px var(--secondary);
}

.tracking-badge.tiktok {
  background: rgba(254, 44, 85, 0.15);
  color: #FE2C55;
  border: 1px solid rgba(254, 44, 85, 0.3);
}

.tracking-badge.tiktok.pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FE2C55;
  box-shadow: 0 0 6px #FE2C55;
}

.tracking-badge.meta {
  background: rgba(24, 119, 242, 0.15);
  color: #1877F2;
  border: 1px solid rgba(24, 119, 242, 0.3);
}

.tracking-badge.meta.pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1877F2;
  box-shadow: 0 0 6px #1877F2;
}

/* Multi-Surfaces Tracking Diagnostics Grid */
.tracking-diag-section {
  margin-bottom: 1.5rem;
}

.tracking-diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.tracking-diag-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tracking-diag-card:hover {
  transform: translateY(-2px);
  border-color: rgba(254, 44, 85, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.tracking-diag-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tracking-diag-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.tracking-diag-title .diag-icon {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
}

.tracking-diag-details {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tracking-diag-details li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.tracking-diag-details li strong {
  color: var(--text);
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.tracking-diag-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.tracking-diag-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(254, 44, 85, 0.1);
  color: #FE2C55;
  border: 1px solid rgba(254, 44, 85, 0.2);
}

.tracking-diag-tag.cyan {
  background: rgba(37, 244, 238, 0.1);
  color: #25F4EE;
  border: 1px solid rgba(37, 244, 238, 0.2);
}

.tracking-diag-tag.teal {
  background: rgba(46, 196, 182, 0.1);
  color: var(--secondary);
  border: 1px solid rgba(46, 196, 182, 0.2);
}

/* Alerts & Notices */
.notice-banner {
  background: rgba(46, 196, 182, 0.15);
  border: 1px solid var(--secondary);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.alert-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--border);
  background: rgba(0,0,0,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.alert-card.critical, .alert-card.error { border-left-color: var(--error); background: rgba(231, 29, 54, 0.1); }
.alert-card.warning { border-left-color: var(--warning); background: rgba(255, 209, 102, 0.1); }
.alert-card.info { border-left-color: var(--secondary); background: rgba(46, 196, 182, 0.1); }

/* Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}
.data-table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}
.data-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}
.timeline-item {
  position: relative;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.4rem;
  top: 0.3rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}
.timeline-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.timeline-item .error { color: var(--error); font-weight: 600; }
.timeline-item .warning, .timeline-item .warn { color: var(--warning); font-weight: 600; }
.timeline-item .info { color: var(--secondary); font-weight: 600; }

/* Config Grid */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.config-item {
  background: rgba(0,0,0,0.2);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
}
.config-item span {
  display: block;
}
.config-item .cfg-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.config-item .cfg-value {
  font-weight: 600;
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 17, 24, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  backdrop-filter: blur(20px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.auth-card h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}
#authForm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
#authForm input {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 1rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  width: 100%;
}
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.password-input-wrapper input {
  padding-right: 3rem !important;
}
.toggle-password-btn {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  user-select: none;
}
.toggle-password-btn:hover {
  opacity: 0.8;
}
#authForm input:focus {
  outline: none;
  border-color: var(--primary);
}
#authSubmit {
  background: var(--primary);
  color: var(--bg-darker);
  padding: 1rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  margin-top: 1rem;
}
.auth-error {
  margin-top: 1rem;
  color: var(--error);
  font-size: 0.9rem;
  background: rgba(231, 29, 54, 0.1);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

/* Date Popover */
.date-popover {
  position: absolute;
  background: var(--bg-darker);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 499;
}

/* Responsive */
@media (max-width: 1024px) {
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* Header */
  .header {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-direction: column;
    align-items: stretch;
  }
  .header-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
  }
  .logo-text {
    font-size: 1.25rem;
  }
  .badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
  }
  .header-right {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
    font-size: 0.8rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
  }
  .status-indicator {
    font-size: 0.8rem;
  }
  .last-updated {
    font-size: 0.75rem;
    color: var(--text-muted);
  }
  .logout-btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(231, 29, 54, 0.12);
    color: var(--error);
  }

  /* Global Filter */
  .global-filter {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .date-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
  }
  .date-inputs input[type="date"] {
    width: 100%;
    min-width: 0;
    padding: 0.45rem 0.35rem;
    font-size: 0.85rem;
  }
  .date-inputs .separator {
    text-align: center;
    font-size: 0.9rem;
  }
  .date-inputs .primary-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  .preset-buttons {
    display: flex;
    width: 100%;
    gap: 0.35rem;
  }
  .preset-btn {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.25rem;
    font-size: 0.8rem;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Tabs Navigation */
  .tabs-nav {
    padding: 0 0.75rem;
    gap: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  .tab-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
  }

  /* Main Content */
  .main-content {
    padding: 1rem 0.75rem;
  }

  /* KPI Grid: 2 columns on mobile! */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }
  .kpi-card {
    padding: 1rem 0.75rem;
  }
  .kpi-icon {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
  }
  .kpi-label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    line-height: 1.25;
  }
  .kpi-value {
    font-size: 1.35rem;
  }
  .kpi-delta {
    font-size: 0.75rem;
    margin-top: 0.25rem;
  }

  /* Charts Grid: 1 column on mobile */
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }
  .chart-card {
    padding: 1rem 0.75rem;
  }
  .chart-header h3 {
    font-size: 0.95rem;
    line-height: 1.25;
  }
  .chart-container {
    height: 270px;
  }

  /* Tracking Status Grid */
  .tracking-status-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .tracking-status-card {
    padding: 0.85rem;
    gap: 0.75rem;
  }
  .tracking-icon {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
  }
  .tracking-name {
    font-size: 0.85rem;
  }
  .tracking-id {
    font-size: 0.75rem;
  }

  /* Alerts */
  .alert-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .alert-card > span {
    align-self: flex-start;
  }

  /* Sections */
  .section-container {
    padding: 1rem 0.75rem;
    margin-bottom: 1.25rem;
  }
  .section-header h2 {
    font-size: 1.05rem;
  }

  /* Tables */
  .table-scroll-hint {
    display: inline-flex;
  }
  .data-table th, .data-table td {
    padding: 0.65rem 0.5rem;
    font-size: 0.8rem;
  }

  /* Auth overlay */
  .auth-card {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }
  .auth-card h1 {
    font-size: 2rem;
  }

  /* Popover as mobile modal */
  .date-popover {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: calc(100vw - 2rem);
    max-width: 340px;
    z-index: 1000;
  }
}

@media (max-width: 480px) {
  .date-inputs {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
  }
  .date-inputs .primary-btn {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0.25rem;
  }
  .kpi-value {
    font-size: 1.2rem;
  }
  .kpi-value.kpi-value-sm {
    font-size: 0.9rem;
  }
}
