/* =============================================================================
   TrafficPulse PRO v2.4 - Luxury Cyber-Glass Design System
   High-End Dark Mode, Zero-Clutter Architecture & Full Responsiveness
   ============================================================================= */

:root {
  --bg-base: #080c16;
  --bg-surface: #0e1526;
  --bg-card: rgba(14, 21, 38, 0.75);
  --bg-card-hover: rgba(22, 32, 56, 0.85);
  --bg-glass-input: rgba(15, 23, 42, 0.65);

  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-bright: rgba(255, 255, 255, 0.16);
  --border-glass-glow: rgba(99, 102, 241, 0.35);

  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-cyan: #06b6d4;
  --primary-cyan-light: #22d3ee;
  --primary-gradient: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
  --primary-gradient-hover: linear-gradient(135deg, #0891b2 0%, #4f46e5 100%);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.3);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 12px 35px -5px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.06);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.3);
  --transition-smooth: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-base);
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(6, 182, 212, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-text {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: var(--transition-smooth);
}
a:hover {
  color: #fff;
}

/* -----------------------------------------------------------------------------
   NAVIGATION BAR
   ----------------------------------------------------------------------------- */
.navbar {
  background: rgba(14, 21, 38, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
}

.navbar-container {
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.brand-icon-wrap {
  width: 38px;
  height: 38px;
  background: var(--primary-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-accent {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-badge {
  font-size: 0.65rem;
  font-family: 'Inter', sans-serif;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.live-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: #6ee7b7;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot-anim 2s infinite;
}

@keyframes pulse-dot-anim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

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

#btnNavNewCampaign {
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
  font-weight: 600;
  padding: 0.5rem 1rem;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  color: #94a3b8;
  border: 1px solid var(--border-glass);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.btn-logout:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.3);
}

/* -----------------------------------------------------------------------------
   BUTTONS & CONTROLS
   ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  white-space: nowrap;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-xs);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  background: var(--primary-gradient-hover);
  box-shadow: 0 6px 22px rgba(6, 182, 212, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--border-glass-bright);
  transform: translateY(-1px);
}

.btn-send-now, .btn-dispatch-now {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: var(--transition-smooth);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.btn-send-now:hover:not(:disabled), .btn-dispatch-now:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}
.btn-send-now:disabled, .btn-dispatch-now:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-warning-glow {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.btn-warning-glow:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fef08a;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.25);
}

.btn-danger-ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: bold;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.btn-danger-ghost:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.35);
}

.table-actions-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.batch-dispatch-capsule {
  display: inline-flex;
  align-items: center;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.18rem;
  gap: 0.3rem;
  transition: var(--transition-smooth);
}
.batch-dispatch-capsule:hover {
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}

.batch-select {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-xs);
  color: #6ee7b7;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.32rem 0.55rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.batch-select:focus {
  border-color: #34d399;
}
.batch-select option {
  background: #0f172a;
  color: #fff;
}

/* -----------------------------------------------------------------------------
   GLASS CARDS & SURFACES
   ----------------------------------------------------------------------------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.section-card {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* -----------------------------------------------------------------------------
   EXECUTIVE KPI CARDS GRID (4 Balanced Metrics)
   ----------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 16px 35px -8px rgba(0, 0, 0, 0.7), 0 0 20px rgba(99, 102, 241, 0.15);
}

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.icon-indigo {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
}
.icon-cyan {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #22d3ee;
}
.icon-green {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}
.icon-amber {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  font-family: 'Outfit', sans-serif;
}
.stat-value.stat-small {
  font-size: 1.1rem;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 400;
}

.stat-progress-sub {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #67e8f9;
  font-weight: 600;
}

.stat-mini-bar {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.stat-mini-bar div {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.stat-footer-action {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary-light);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.72rem;
  padding: 0;
}
.link-btn:hover {
  color: #fff;
}

/* -----------------------------------------------------------------------------
   TOOLBARS & CONTROL HEADERS
   ----------------------------------------------------------------------------- */
.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.section-title {
  font-size: 1.3rem;
  color: #fff;
  margin: 0;
}

.section-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.badge-chip {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-full);
}

.status-filter-pills {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 0.2rem;
  gap: 0.25rem;
}

.filter-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.28rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.filter-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.filter-pill.active {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.search-input-wrap {
  width: 210px;
}

.form-control-sm {
  font-size: 0.82rem;
  padding: 0.42rem 0.75rem;
}

.form-select-sm {
  font-size: 0.82rem;
  padding: 0.42rem 0.65rem;
  width: 130px;
}

.bulk-btn-group {
  display: inline-flex;
  gap: 0.35rem;
}

.pulse-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse-dot-anim 2s infinite;
}

/* -----------------------------------------------------------------------------
   FORMS & INPUTS
   ----------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  width: 100%;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  font-size: 0.88rem;
  transition: var(--transition-smooth);
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: rgba(15, 23, 42, 0.85);
}

.form-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.65rem center;
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  padding-right: 2.2rem;
}

.btn-pwd-eye {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.05rem;
}

.code-pill {
  color: #67e8f9;
  background: rgba(6, 182, 212, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--text-main);
  cursor: pointer;
}

/* -----------------------------------------------------------------------------
   DATA TABLES
   ----------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

/* -----------------------------------------------------------------------------
   LIVE TRAFFIC STREAM
   Five tracked columns only, so the feed fits the card instead of scrolling
   sideways. Fixed layout keeps the widths stable while rows stream in.
   ----------------------------------------------------------------------------- */
.live-stream-table {
  table-layout: fixed;
}

.live-stream-table th:nth-child(1),
.live-stream-table td:nth-child(1) { width: 78px; }

.live-stream-table th:nth-child(2),
.live-stream-table td:nth-child(2) { width: 84px; }

.live-stream-table th:nth-child(3),
.live-stream-table td:nth-child(3) { width: 104px; }

.live-stream-table th:nth-child(4),
.live-stream-table td:nth-child(4) { width: 118px; }

/* Beats the generic .data-table td padding rule above (same file, earlier). */
.data-table.live-stream-table tbody td { padding: 0.62rem 0.75rem; }

.live-stream-table .ls-time {
  font-family: monospace;
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.live-stream-table .ls-campaign {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.live-stream-table .ls-geo {
  white-space: nowrap;
}

/* Country chip, shared by the live feed and the campaign list */
.geo-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid var(--border-glass);
  border-radius: 4px;
  padding: 0.08rem 0.34rem;
  white-space: nowrap;
}

.badge-count-extra {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary-light);
  font-size: 0.7rem;
}

.live-stream-table .ls-device {
  margin-left: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.live-stream-table .ls-status {
  white-space: nowrap;
}

.live-stream-table .ls-latency {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Two lines of context, then ellipsis. The full text stays in the tooltip. */
.live-stream-table .ls-detail {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

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

.data-table thead th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-glass);
}

.data-table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: rgba(30, 41, 59, 0.25);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
}

.badge-running {
  background: var(--success-bg);
  color: #34d399;
  border: 1px solid var(--success-border);
}
.badge-paused {
  background: var(--warning-bg);
  color: #fbbf24;
  border: 1px solid var(--warning-border);
}
.badge-completed {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.progress-container {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.35rem;
}

.progress-bar {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* -----------------------------------------------------------------------------
   MODALS & POPUPS
   ----------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  overflow-y: auto;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #0f172a;
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 35px rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(6px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  margin: auto;
}
.modal-overlay.active .modal-dialog {
  transform: scale(1) translateY(0);
}

/* Modal Form Flex Wrapper - Ensures form expands, flexes, and enables internal scrolling */
.modal-dialog > form,
.modal-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  margin: 0;
}

.modal-header {
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #0f172a;
}

.modal-icon-badge {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-smooth);
}
.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Sleek modern scrollbar for modal body */
.modal-body::-webkit-scrollbar {
  width: 7px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.45);
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.5);
  border-radius: 999px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.8);
}

.modal-footer {
  padding: 0.95rem 1.4rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  background: #0f172a;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 10;
}

.modal-template-bar {
  padding: 0.55rem 1.4rem;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Form Grid Helpers for Modal Rows */
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.form-row-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.template-chip {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-glass);
  color: #c7d2fe;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.template-chip:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* Engine Toggle Pill */
.engine-toggle-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.engine-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.engine-pill span {
  font-weight: 600;
  font-size: 0.85rem;
}
.engine-pill.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

/* Country Grid */
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.4rem;
  max-height: 165px;
  overflow-y: auto;
  padding: 0.55rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}

.country-item {
  transition: all 0.15s ease;
  user-select: none;
}

.country-item:hover {
  background: rgba(49, 66, 95, 0.6) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
  transform: translateY(-1px);
}

.country-item input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
  width: 14px;
  height: 14px;
  margin: 0;
}

/* Delivery Mode Buttons & Timeframe Box */
.delivery-timeframe-box {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease;
}
.delivery-timeframe-box:focus-within {
  border-color: rgba(99, 102, 241, 0.4);
}
.delivery-mode-btn {
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
  user-select: none;
}
.delivery-mode-btn.active {
  background: rgba(99, 102, 241, 0.3) !important;
  border-color: rgba(99, 102, 241, 0.7) !important;
  color: #fff !important;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.35);
  font-weight: 600;
}

/* Settings Sub-Tabs */
.settings-tab-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-glass);
}
.settings-tab-bar .btn-secondary.active {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.5);
  font-weight: 600;
}

.proxy-info-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.82rem;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.danger-box {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1.5rem;
}

/* Live Terminal */
.live-terminal {
  background: #030712;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-family: monospace;
  font-size: 0.78rem;
  overflow-y: auto;
}

.term-line {
  margin-bottom: 0.25rem;
  word-break: break-all;
}
.term-dim { color: var(--text-dim); }
.term-success { color: #34d399; }
.term-fail { color: #fb7185; }

/* Toast Notifications */
#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.toast-item {
  background: #0f172a;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 280px;
  max-width: 420px;
  animation: toastIn 0.25s ease-out;
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------------------------------------------------
   RESPONSIVENESS (Mobile, Tablet & Large Screens)
   ----------------------------------------------------------------------------- */
.main-wrapper {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  width: 100%;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 35px rgba(99, 102, 241, 0.2);
}

.login-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 1.1rem;
  font-size: 1.85rem;
}

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

@media (max-width: 768px) {
  .navbar-container {
    padding: 0;
  }
  .live-status-chip {
    display: none;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .toolbar-left {
    justify-content: space-between;
  }
  .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
  }
  .search-input-wrap {
    flex: 1;
    min-width: 180px;
  }
}

/* Modal Responsive Rules for Tablets, Mobiles & Small Viewports */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0.75rem;
  }
  .modal-dialog {
    max-height: 92vh;
    border-radius: var(--radius-md);
  }
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 0.35rem 0.35rem 0;
    align-items: flex-end; /* Sheets up from bottom on phones */
  }
  .modal-dialog {
    max-height: 95vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100% !important;
    max-width: 100% !important;
    border-bottom: none;
  }
  .modal-header {
    padding: 0.85rem 1rem;
  }
  .modal-header h3 {
    font-size: 1.05rem !important;
  }
  .modal-header p {
    font-size: 0.72rem !important;
  }
  .modal-template-bar {
    padding: 0.45rem 1rem;
    gap: 0.3rem;
  }
  .template-chip {
    font-size: 0.68rem;
    padding: 0.18rem 0.45rem;
  }
  .modal-body {
    padding: 0.85rem 1rem;
    gap: 0.85rem;
  }
  .form-row-2col,
  .form-row-3col,
  .modal-dialog [style*="grid-template-columns: 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns:1fr 1fr"],
  .modal-dialog [style*="grid-template-columns: 1fr 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
  .modal-footer {
    padding: 0.75rem 1rem;
    flex-direction: column-reverse;
    gap: 0.5rem;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
  }
  .engine-toggle-wrap {
    grid-template-columns: 1fr !important;
  }
  .country-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)) !important;
    max-height: 130px !important;
  }
  .delivery-mode-btn {
    flex: 1 1 45%;
    font-size: 0.7rem;
    padding: 0.3rem 0.45rem;
    text-align: center;
  }
  .delivery-timeframe-box {
    padding: 0.7rem !important;
  }
  #createDeliveryInputsRow,
  #editDeliveryInputsRow {
    grid-template-columns: 1fr !important;
  }
}

@media (max-height: 650px) {
  .modal-overlay {
    padding: 0.25rem;
  }
  .modal-dialog {
    max-height: 98vh;
  }
  .modal-header {
    padding: 0.55rem 0.9rem;
  }
  .modal-template-bar {
    padding: 0.35rem 0.9rem;
  }
  .modal-body {
    padding: 0.75rem 0.9rem;
    gap: 0.7rem;
  }
  .modal-footer {
    padding: 0.55rem 0.9rem;
  }
  .country-grid {
    max-height: 110px !important;
  }
}
