:root {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-elevated: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --border-glow: rgba(2, 132, 199, 0.2);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-sub: #64748b;
  
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-glow: rgba(2, 132, 199, 0.25);
  --emerald: #059669;
  --amber: #d97706;
  --rose: #e11d48;
  --cyan: #0891b2;
  --purple: #7c3aed;
  --indigo: #4f46e5;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  background-image: 
    radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.04) 0px, transparent 40%),
    radial-gradient(at 100% 0%, rgba(124, 58, 237, 0.03) 0px, transparent 40%),
    radial-gradient(at 50% 100%, rgba(5, 150, 105, 0.03) 0px, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

/* ==========================================================================
   Top Navigation Bar (Light Theme)
   ========================================================================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  margin-bottom: 20px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 22px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
  color: #ffffff;
}

.brand h1 {
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.3px;
  color: #0f172a;
}

.badge-pro {
  font-size: 10px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 8px;
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
  border-radius: 20px;
}

.tagline {
  font-size: 11px;
  color: var(--text-muted);
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  font-weight: 600;
  transition: all 0.2s ease;
}

.status-chip:hover {
  background: #f1f5f9;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-sub);
}

.chip-green .dot { background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }
.chip-green { color: #059669; background: #ecfdf5; border-color: #a7f3d0; }

.chip-blue .dot { background: var(--primary); box-shadow: 0 0 6px var(--primary); }
.chip-blue { color: #0284c7; background: #f0f9ff; border-color: #bae6fd; }

.chip-cyan .dot { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.chip-cyan { color: #0891b2; background: #ecfeff; border-color: #a5f3fc; }

.chip-amber .dot { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.chip-amber { color: #d97706; background: #fffbeb; border-color: #fde68a; }

.chip-rose .dot { background: var(--rose); box-shadow: 0 0 6px var(--rose); }
.chip-rose { color: #e11d48; background: #fff1f2; border-color: #fecdd3; }

/* ==========================================================================
   Navigation Tab Bar (Light Theme)
   ========================================================================== */
.client-nav-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  width: fit-content;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.5);
}

.nav-tab-btn.active {
  background: #ffffff;
  color: #0284c7;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Hero KPI Overview Cards (Light Theme)
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

@media (max-width: 960px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.04);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.08);
}

.metric-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.bg-purple { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }
.bg-indigo { background: #eef2ff; color: #4f46e5; border: 1px solid #c7d2fe; }
.bg-green { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.bg-emerald { background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7; }
.bg-rose { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; }
.bg-cyan { background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; }

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.metric-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}

/* ==========================================================================
   2-Column Split: Modern Companion QR & Live Ingestion Table
   ========================================================================== */
.content-two-split {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
}

@media (max-width: 1100px) {
  .content-two-split { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f172a;
}

.panel-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Minimalist QR Card (Light Theme)
   ========================================================================== */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-box {
  width: 220px;
  height: 220px;
  background: #f8fafc;
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  position: relative;
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.qr-connected-box {
  width: 100%;
  height: 100%;
  background: #f0fdf4;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  border: 1px solid #86efac;
}

.connected-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.qr-connected-box h4 {
  font-size: 15px;
  font-weight: 800;
  color: #059669;
}

.qr-connected-box p {
  font-size: 11px;
  color: #475569;
  margin-top: 4px;
  line-height: 1.4;
}

.qr-spinner-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #0f172a;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #0284c7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn-sm {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.btn-secondary {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #64748b;
}

.btn-outline:hover {
  color: #0f172a;
  border-color: #94a3b8;
  background: #f8fafc;
}

.w-full { width: 100%; }

/* ==========================================================================
   Live Telemetry Ingestion Feed Table (Light Theme)
   ========================================================================== */
.table-container {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tx-table th {
  text-align: left;
  padding: 11px 14px;
  color: #475569;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tx-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.tx-table tr:hover td {
  background: #f8fafc;
}

.badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}

.status-VALID_INVOICE { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.status-SCHEDULED_DISPATCH { background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; }
.status-DELIVERED { background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7; font-weight: 800; }
.status-IGNORED_KOT { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.status-DUPLICATE_SUPPRESSED { background: #ecfeff; color: #0891b2; border: 1px solid #a5f3fc; }
.status-ANONYMOUS_WALKIN { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.status-QUEUED_QUIET_HOURS { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0284c7;
  box-shadow: 0 0 8px #0284c7;
  display: inline-block;
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* ==========================================================================
   Admin Portal Elements & Period Tabs (Light Theme)
   ========================================================================== */
.period-tabs {
  display: flex;
  gap: 4px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

.period-tab-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.period-tab-btn:hover {
  color: #0f172a;
}

.period-tab-btn.active {
  background: #ffffff;
  color: #0284c7;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.clients-table-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

.table-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.btn-add-client {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
  transition: all 0.2s;
}

.btn-add-client:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.secret-key-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: #f8fafc;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  color: #0284c7;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.btn-copy {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 11px;
}

.btn-copy:hover { color: #0f172a; }

.action-btns {
  display: flex;
  gap: 6px;
}

.btn-action {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  color: #334155;
  transition: all 0.2s;
}

.btn-action:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-edit:hover { background: #e0f2fe; border-color: #bae6fd; color: #0284c7; }
.btn-delete:hover { background: #fee2e2; border-color: #fecdd3; color: #e11d48; }

/* ==========================================================================
   Modals & Input Controls (Light Theme)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  color: #0f172a;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
}

.btn-close-modal:hover { color: #0f172a; }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

.input-group input, .input-group select, .input-group textarea {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
  background: #ffffff;
}

/* ==========================================================================
   Flyer Studio & Interactive Canvas (Light Theme)
   ========================================================================== */
.flyer-studio-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
}

.flyer-studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.flyer-studio-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.flyer-canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 12px auto;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border: 1px solid #cbd5e1;
  cursor: crosshair;
  background: #e2e8f0;
}

.flyer-bg-img {
  width: 100%;
  display: block;
  user-select: none;
  pointer-events: none;
}

.flyer-name-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 800;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  user-select: none;
  pointer-events: none;
  transition: top 0.05s linear, left 0.05s linear;
}

.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-btn:hover {
  background: #e0f2fe;
  color: #0284c7;
  border-color: #bae6fd;
}

.studio-controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.studio-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.studio-slider-group label {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
}

.studio-slider-group input[type="range"] {
  accent-color: #0284c7;
  cursor: pointer;
}

/* Outage alert banner */
.outage-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  color: #92400e;
}

.btn-reconnect {
  background: #d97706;
  color: #ffffff;
  font-weight: 700;
  border: none;
}
