:root {
  --primary-300: #44c0c6;
  --primary-400: #009ecb;
  --primary-500: #006788;
  --primary-600: #233a5d;
  --primary-700: #0c1c37;
  --accent-green: #88ff26;
  --accent-green-muted: #7cc123;
  --accent-coral: #e76d53;
  --accent-mint: #32d3b0;
  --accent-cyan: #53d8e7;
  --accent-yellow: #d99211;
  --gray-100: #eef2f8;
  --gray-200: #e0e6f0;
  --gray-300: #c5cedd;
  --gray-400: #a6b1c4;
  --gray-500: #8792a8;
  --gray-600: #6a7690;
  --gray-700: #525e7a;
  --gray-800: #343e58;
  --white: #ffffff;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 9999px;
  /* Tactile, beveled shadows — outer drop + inner highlight, the Aqua way */
  --shadow-sm: 0 1px 1px rgba(8,22,45,0.13), 0 2px 5px rgba(8,22,45,0.10);
  --shadow-md: 0 1px 1px rgba(8,22,45,0.13), 0 14px 30px rgba(8,22,45,0.18);
  --shadow-lg: 0 3px 7px rgba(8,22,45,0.20), 0 34px 70px rgba(8,22,45,0.30);
  --bevel-top: inset 0 1px 0 rgba(255,255,255,0.95);
  --transition: 0.18s cubic-bezier(0.32,0.72,0,1);
  --sidebar-width: 264px;
  /* Reusable glossy sheen (top half white highlight, hard cutoff = wet look) */
  --gloss: linear-gradient(180deg, rgba(255,255,255,0.68) 0%, rgba(255,255,255,0.24) 46%, rgba(255,255,255,0.0) 47%, rgba(255,255,255,0.05) 88%, rgba(255,255,255,0.22) 100%);
  /* Fine grain for tactile surfaces (CSP allows data: under img-src) */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Lucida Grande", "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--primary-700);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-color: #e4e9f1;
  background-image: var(--noise), radial-gradient(135% 95% at 50% -14%, #f5f8fd 0%, #e5eaf2 56%, #d0d8e6 100%);
}
::selection { background: rgba(0,158,203,0.22); }

/* Slim, beveled scrollbars */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gray-400), var(--gray-500));
  border-radius: var(--radius-pill);
  border: 4px solid transparent;
  background-clip: padding-box;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--gray-500), var(--gray-600)); background-clip: padding-box; }

/* ===== SIDEBAR — dark woven linen ===== */
.sidebar {
  width: 84vw;
  max-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  transform: translateX(-100%);
  background-color: var(--primary-700);
  background-image:
    var(--noise),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.032) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.085) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 24% -5%, rgba(0,158,203,0.22) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 105%, rgba(136,255,38,0.06) 0%, transparent 50%),
    linear-gradient(180deg, #13284a 0%, #0a1730 100%);
  background-color: #0b1830;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  box-shadow: inset -8px 0 14px -10px rgba(0,0,0,0.7), inset -1px 0 0 rgba(0,0,0,0.5), inset -2px 0 0 rgba(255,255,255,0.04);
  visibility: hidden; /* off-canvas: keep nav out of the tab order until opened */
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1), visibility 0s linear 0.32s;
}
.sidebar.open {
  transform: translateX(0);
  visibility: visible;
  box-shadow: var(--shadow-lg);
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1), visibility 0s;
}
.sidebar-brand {
  padding: 30px 24px 22px;
  border-bottom: 1.5px dashed rgba(170,195,230,0.17);
  box-shadow: 0 1px 0 rgba(0,0,0,0.5), 0 2px 0 rgba(255,255,255,0.04);
}
.sidebar-brand h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.sidebar-brand h1 .brand-314 { color: var(--accent-green); text-shadow: 0 0 14px rgba(136,255,38,0.45), 0 1px 1px rgba(0,0,0,0.6); }
.sidebar-brand h1 .brand-action { color: var(--white); }
.sidebar-brand .brand-sync {
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-top: 6px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

.sidebar-nav { flex: 1; padding: 14px 0; }
.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--gray-600);
  padding: 18px 26px 8px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}
.nav-section-label:first-child { padding-top: 4px; }
/* Decodes the AK/SB/TT/AN abbreviations used in the Sync nav items. */
.nav-legend {
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--gray-500);
  padding: 0 26px 10px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 12px;
  padding: 10px 14px;
  color: var(--gray-300);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-radius: 11px;
  text-decoration: none;
  user-select: none;
  text-shadow: 0 1px 0 rgba(0,0,0,0.45);
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
  box-shadow: var(--bevel-top), 0 1px 2px rgba(0,0,0,0.25);
  border-color: rgba(0,0,0,0.3);
}
.nav-item:active { transform: translateY(0.5px); }
.nav-item.active {
  color: var(--white);
  font-weight: 600;
  background-image: var(--gloss), linear-gradient(180deg, #1aa0c8 0%, #0a6f93 50%, #00617f 100%);
  border-color: rgba(0,0,0,0.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.4);
  text-shadow: 0 -1px 0 rgba(0,0,0,0.35);
}
.nav-item-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.nav-item:hover .nav-item-icon,
.nav-item.active .nav-item-icon { opacity: 1; }

.sidebar-footer {
  padding: 18px 18px 22px;
  border-top: 1.5px dashed rgba(170,195,230,0.17);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.sidebar-footer label {
  display: block;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 7px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}
.sidebar-footer input[type="password"] {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(0,0,0,0.55);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: rgba(0,0,0,0.28);
  color: var(--white);
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.06);
  transition: box-shadow var(--transition);
}
.sidebar-footer input[type="password"]::placeholder { color: var(--gray-600); }
.sidebar-footer input[type="password"]:focus {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 0 0 3px rgba(0,158,203,0.4);
}
.sidebar-nuke-btn {
  margin-top: 12px;
  width: 100%;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.5);
  color: #ffd9cf;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.4);
  background-image: var(--gloss), linear-gradient(180deg, #c45842 0%, #a23420 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 2px rgba(0,0,0,0.35);
  transition: all var(--transition);
}
.sidebar-nuke-btn:hover { filter: brightness(1.08); }
.sidebar-nuke-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); }

/* Mobile bar — brushed dark glass (shown by default; hidden on desktop) */
.mobile-header {
  display: flex;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background-image: var(--gloss), linear-gradient(180deg, #1a2c4d 0%, #0b1830 100%);
  border-bottom: 1px solid rgba(0,0,0,0.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 2px 6px rgba(0,0,0,0.3);
  z-index: 101;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.hamburger {
  background: none; border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0,0,0,0.5);
}
.mobile-header .mobile-brand { font-size: 16px; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,0.5); }
.mobile-header .mobile-brand .brand-314 { color: var(--accent-green); }
.mobile-header .mobile-brand .brand-action { color: var(--white); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8,16,32,0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ===== MAIN CONTENT (mobile-first base: full width below the mobile bar) ===== */
.main-content {
  margin-left: 0;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 76px 16px 28px;
  max-width: 100%;
}

.page-header { margin-bottom: 26px; }
.page-header h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-700);
  letter-spacing: -0.5px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.85);
}
.page-header .page-subtitle {
  color: var(--gray-600);
  font-size: 14px;
  margin-top: 5px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.7);
}

/* Hidden legacy elements */
.header { display: none; }
.api-key-bar { display: none; }
.tabs { display: none; }
.direction-arrow { display: none; }

/* Panels — glossy raised cards with a glass top edge */
.panel {
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 16%),
    linear-gradient(180deg, #ffffff 0%, #ecf2f9 100%);
  border-radius: var(--radius-md);
  padding: 22px 18px;
  display: none;
  border: 1px solid rgba(8,22,45,0.22);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,1),
    inset 0 0 0 1px rgba(255,255,255,0.55),
    0 1px 2px rgba(8,22,45,0.12),
    0 22px 50px rgba(8,22,45,0.20);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px) scale(0.992); }
  to { opacity: 1; transform: none; }
}
.panel.active { display: block; animation: panelIn 0.3s cubic-bezier(0.32,0.72,0,1); }

/* Form Elements */
.form-group { margin-bottom: 20px; }
label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--gray-600);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}

/* Glossy segmented control */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2px;
  border-radius: var(--radius-md);
  background-image: linear-gradient(180deg, #dde3ee, #eef1f7);
  border: 1px solid rgba(8,22,45,0.22);
  box-shadow: inset 0 1px 3px rgba(8,22,45,0.18), var(--bevel-top);
  overflow: hidden;
}
.toggle-option {
  flex: 1;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  padding: 11px 12px;
  background: transparent;
  transition: all var(--transition);
  color: var(--gray-700);
  border: none;
  border-radius: calc(var(--radius-md) - 4px);
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(255,255,255,0.7);
}
.toggle-option:has(input:checked) {
  color: var(--white);
  text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
  background-image: var(--gloss), linear-gradient(180deg, #2f93b6 0%, #0a6f93 50%, #00607e 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 0 0 1px rgba(8,22,45,0.25), 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-option:hover:not(:has(input:checked)) { color: var(--primary-600); }
.toggle-option input[type="radio"] { display: none; }

/* Recessed, "inset well" text fields (16px avoids mobile focus-zoom) */
input[type="number"], input[type="password"], input[type="text"], input[type="date"], select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--gray-300);
  border-top-color: var(--gray-400);
  border-radius: var(--radius-md);
  font-size: 16px;
  color: var(--primary-700);
  background-image: linear-gradient(180deg, #f6f8fc 0%, #ffffff 60%);
  box-shadow: inset 0 2px 5px rgba(8,22,45,0.18), inset 0 1px 1px rgba(8,22,45,0.10), 0 1px 0 rgba(255,255,255,0.85);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input::placeholder { color: var(--gray-500); }
input:focus, select:focus {
  border-color: var(--primary-400);
  box-shadow: inset 0 2px 3px rgba(8,22,45,0.1), 0 0 0 3px rgba(0,158,203,0.28), 0 0 7px rgba(0,158,203,0.35);
}
select { cursor: pointer; }
select[multiple] { padding: 5px; }
select[multiple] option { border-radius: 7px; padding: 7px 9px; }

/* Override sidebar input styles so they don't get panel input styles */
.sidebar-footer input[type="password"] {
  border: 1px solid rgba(0,0,0,0.55);
  background: rgba(0,0,0,0.28);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 13px;
  padding: 9px 13px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.06);
}
.sidebar-footer input[type="password"]:focus {
  border-color: rgba(0,158,203,0.6);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 0 0 3px rgba(0,158,203,0.4);
}

/* Glossy gel buttons (Aqua) */
button[type="submit"], .sync-btn {
  width: 100%;
  padding: 15px 24px;
  color: var(--white);
  border: 1px solid rgba(8,22,45,0.55);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.38);
  background-image: var(--gloss), linear-gradient(180deg, #3aa6c9 0%, #0e82af 48%, #006788 52%, #014a68 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.78),
    inset 0 2px 2px rgba(255,255,255,0.22),
    inset 0 -3px 6px rgba(0,0,0,0.24),
    inset 0 0 0 1px rgba(255,255,255,0.07),
    0 1px 1px rgba(8,22,45,0.22),
    0 7px 18px rgba(0,103,136,0.42);
  transition: filter var(--transition), box-shadow var(--transition), transform var(--transition);
  letter-spacing: 0.1px;
}
button[type="submit"]:hover, .sync-btn:hover { filter: brightness(1.07) saturate(1.05); }
button[type="submit"]:active, .sync-btn:active {
  transform: translateY(1px);
  filter: brightness(0.96);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(8,22,45,0.3), 0 1px 1px rgba(8,22,45,0.18);
}
button:active { transform: translateY(1px); }
button:disabled {
  background-image: linear-gradient(180deg, #eef1f7, #dde3ed) !important;
  color: var(--gray-500) !important;
  text-shadow: 0 1px 0 rgba(255,255,255,0.7) !important;
  border-color: var(--gray-300) !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: var(--bevel-top), inset 0 0 0 1px rgba(255,255,255,0.3) !important;
  filter: none !important;
}

/* Results — recessed parchment panel */
.results {
  margin-top: 20px;
  padding: 22px;
  border-radius: var(--radius-md);
  display: none;
  background-image: linear-gradient(180deg, #eef2f8, #e4e9f2);
  border: 1px solid rgba(8,22,45,0.16);
  box-shadow: inset 0 1px 3px rgba(8,22,45,0.1), var(--bevel-top);
}
@keyframes resultsIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.results.show { display: block; animation: resultsIn 0.26s cubic-bezier(0.32,0.72,0,1); }
.results.error { background-image: linear-gradient(180deg, #fdeee9, #f8ddd4); border-color: #e8b3a6; }
.results.success { background-image: linear-gradient(180deg, #effaf0, #dcf2df); border-color: #b2dfb9; }
.results h3 { margin: 0 0 12px 0; font-size: 16px; font-weight: 700; letter-spacing: -0.3px; text-shadow: 0 1px 0 rgba(255,255,255,0.7); }
.results.error h3 { color: #c0432b; }
.results.success h3 { color: #3f8f3a; }

/* Stats — embossed gel tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.stat {
  padding: 14px 10px;
  border-radius: var(--radius-md);
  text-align: center;
  background-image: linear-gradient(180deg, #ffffff, #e9eef6);
  border: 1px solid rgba(8,22,45,0.14);
  box-shadow: var(--bevel-top), 0 1px 2px rgba(8,22,45,0.08);
}
.stat-value { font-size: 21px; font-weight: 700; color: var(--primary-600); letter-spacing: -0.6px; text-shadow: 0 1px 0 rgba(255,255,255,0.85); }
.stat-label { font-size: 10px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600; margin-top: 3px; text-shadow: 0 1px 0 rgba(255,255,255,0.7); }

/* Direction chip (queue table) — engraved gel pill */
.dir-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  color: var(--primary-600);
  background-image: linear-gradient(180deg, #ffffff, #dde4ef);
  border: 1px solid rgba(8,22,45,0.16);
  box-shadow: var(--bevel-top);
  text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}

/* Tags/Labels — glossy navy lozenge */
.label-name, .tag-name {
  color: var(--white);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  margin-bottom: 14px;
  word-break: break-all;
  font-size: 13px;
  text-align: center;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
  background-image: var(--gloss), linear-gradient(180deg, #2e4a72 0%, #233a5d 50%, #182a47 100%);
  border: 1px solid rgba(8,22,45,0.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 2px rgba(8,22,45,0.25);
}

/* Progress */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-text { text-align: center; color: var(--gray-700); font-size: 13px; margin-top: 8px; text-shadow: 0 1px 0 rgba(255,255,255,0.6); }
.progress-text .spinner {
  border-color: rgba(0,103,136,0.25);
  border-top-color: var(--primary-500);
  width: 14px; height: 14px;
}
/* Recessed track + glossy candy-striped fill (the classic barber-pole) */
.progress-bar-container {
  border-radius: var(--radius-pill);
  height: 26px;
  overflow: hidden;
  margin: 14px 0;
  background-image: linear-gradient(180deg, #c2cbdc, #dfe5ef);
  border: 1px solid rgba(8,22,45,0.24);
  box-shadow: inset 0 2px 6px rgba(8,22,45,0.32), inset 0 -1px 0 rgba(255,255,255,0.5);
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  transition: width 0.45s cubic-bezier(0.32,0.72,0,1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0) 50%),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.34) 0 15px, rgba(255,255,255,0) 15px 30px),
    linear-gradient(110deg, var(--primary-400) 0%, var(--accent-cyan) 48%, var(--accent-mint) 100%);
  background-size: 100% 100%, 42px 42px, 100% 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.62), inset 0 0 0 1px rgba(8,22,45,0.18);
  animation: barberpole 0.8s linear infinite;
}
@keyframes barberpole { from { background-position: 0 0, 0 0, 0 0; } to { background-position: 0 0, 42px 0, 0 0; } }

/* Stop Button — glossy red gel */
.stop-btn {
  margin-top: 10px;
  background-image: var(--gloss), linear-gradient(180deg, #e8745c 0%, #cf4b35 50%, #b3341f 100%) !important;
  border: 1px solid rgba(120,20,10,0.7) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 1px rgba(8,22,45,0.18), 0 5px 12px rgba(231,109,83,0.28) !important;
  display: none;
}
.stop-btn:hover { filter: brightness(1.07) saturate(1.05); }

.small-hint { font-size: 12px; color: var(--gray-500); margin-top: 5px; text-shadow: 0 1px 0 rgba(255,255,255,0.6); }

/* Secondary "silver" gel button */
.save-schedule-btn {
  width: auto; flex: 0; padding: 13px 20px;
  color: var(--primary-600);
  border: 1px solid var(--gray-300);
  border-top-color: var(--gray-200);
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255,255,255,0.9);
  background-image: var(--gloss), linear-gradient(180deg, #fbfcfe 0%, #e6ebf3 100%);
  box-shadow: var(--bevel-top), 0 1px 1px rgba(8,22,45,0.1);
  transition: all var(--transition);
}
.save-schedule-btn:hover { filter: brightness(1.02); border-color: var(--gray-400); }
.save-schedule-btn:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(8,22,45,0.18); }

/* Select dropdown styling */
select optgroup { font-weight: 700; color: var(--primary-600); font-size: 13px; }
select option { font-weight: 400; color: var(--primary-700); padding: 6px 8px; }

/* Conditional form sections */
.form-group[id] { transition: opacity 0.15s ease; }

/* Two-column form layout for range inputs */
.range-row { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.range-row input { flex: 1; }
.range-row .range-sep { color: var(--gray-500); font-size: 13px; flex-shrink: 0; display: none; }

/* Section divider */
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--gray-500); margin: 18px 0 9px; font-weight: 700; text-shadow: 0 1px 0 rgba(255,255,255,0.7); }
.section-label:first-child { margin-top: 0; }

/* Card-style form groups — inset grouped well */
.config-card {
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  background-image: linear-gradient(180deg, #e9eef6, #eff3f9);
  border: 1px solid rgba(8,22,45,0.14);
  box-shadow: inset 0 1px 2px rgba(8,22,45,0.08), var(--bevel-top);
}
.config-card label { margin-bottom: 6px; }
.config-card .small-hint { margin-bottom: 10px; }
.config-card input:last-child, .config-card select:last-child { margin-bottom: 0; }

/* Tag list */
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; max-height: 300px; overflow-y: auto; padding: 4px; }
.tag-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: var(--radius-pill);
  font-size: 12px; cursor: pointer; user-select: none;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  background-image: var(--gloss), linear-gradient(180deg, #ffffff, #e8edf5);
  box-shadow: var(--bevel-top);
  text-shadow: 0 1px 0 rgba(255,255,255,0.8);
  transition: all var(--transition);
}
.tag-chip.selected {
  color: #fff;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
  border-color: rgba(120,20,10,0.6);
  background-image: var(--gloss), linear-gradient(180deg, #e8745c, #cf4b35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 1px 2px rgba(8,22,45,0.2);
}
.tag-chip:hover { filter: brightness(1.02); border-color: var(--primary-400); }
.tag-chip:active { transform: translateY(0.5px); }
.tag-actions { display: flex; gap: 8px; margin-top: 8px; }
.tag-actions button {
  font-size: 12px; padding: 8px 16px; border-radius: var(--radius-pill); cursor: pointer; font-weight: 700;
  color: var(--primary-600);
  border: 1px solid var(--gray-300);
  text-shadow: 0 1px 0 rgba(255,255,255,0.85);
  background-image: var(--gloss), linear-gradient(180deg, #fbfcfe, #e6ebf3);
  box-shadow: var(--bevel-top), 0 1px 1px rgba(8,22,45,0.1);
  transition: all var(--transition);
}
.tag-actions button:hover { filter: brightness(1.02); }
.tag-actions button:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(8,22,45,0.18); }

/* Button row */
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn-row button[type="submit"] { flex: 1; }

/* Consolidated from repeated inline styles — same rendering, now reusable. */
.empty-state { text-align: center; color: var(--gray-500); font-size: 13px; padding: 24px; }
.panel-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toggle-inline { display: flex; gap: 8px; align-items: center; justify-content: flex-start; }
.multi-select-list { min-height: 140px; }

/* ===== Pill button system (consolidated from ~12 inline-styled buttons) ===== */
.btn-pill {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.btn-pill:disabled { opacity: 0.6; cursor: default; }
.btn-pill-sm { padding: 6px 14px; font-size: 12px; }
.btn-pill-xs { padding: 4px 10px; font-size: 11px; }
/* Variants */
.btn-pill-primary { border-color: transparent; background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: #fff; }
.btn-pill-secondary { border-color: var(--gray-300); color: var(--gray-700); }
.btn-pill-accent { border-color: var(--primary-400); color: var(--primary-600); }
.btn-pill-danger { border-color: var(--accent-coral); color: var(--accent-coral); }
.btn-pill-success { border-color: var(--accent-green-muted); color: var(--accent-green-muted); }
/* Hover/active */
.btn-pill:not(:disabled):hover { transform: translateY(-1px); }
.btn-pill:not(:disabled):active { transform: translateY(1px); }
.btn-pill-primary:not(:disabled):hover { filter: brightness(1.07) saturate(1.05); }
.btn-pill-secondary:not(:disabled):hover,
.btn-pill-accent:not(:disabled):hover,
.btn-pill-danger:not(:disabled):hover,
.btn-pill-success:not(:disabled):hover { background: rgba(0, 0, 0, 0.04); }

/* ===== New Sync — unified Source -> Destination picker ===== */
.newsync-picker { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--gray-200); }
.newsync-step { display: flex; flex-direction: column; gap: 8px; }
.newsync-step-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); }
.newsync-options { display: flex; gap: 8px; flex-wrap: wrap; }
.newsync-opt { padding: 8px 16px; border-radius: var(--radius-pill); border: 1.5px solid var(--gray-300); background: transparent; color: var(--gray-700); font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.newsync-opt:not(.active):hover { border-color: var(--primary-400); color: var(--primary-600); }
.newsync-opt.active { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); border-color: transparent; color: #fff; }
.newsync-arrow { font-size: 22px; color: var(--gray-400); padding-bottom: 6px; }
.newsync-section[hidden] { display: none; }

/* ===== PLAYFUL MICRO-INTERACTIONS ===== */

/* A light streak sweeps across the gel buttons on hover */
button[type="submit"], .sync-btn { position: relative; overflow: hidden; }
button[type="submit"]::after, .sync-btn::after {
  content: "";
  position: absolute;
  top: -60%; left: 0;
  width: 45%; height: 220%;
  background: linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%);
  transform: rotate(9deg) translateX(-260%);
  opacity: 0;
  pointer-events: none;
}
button[type="submit"]:not(:disabled):hover, .sync-btn:not(:disabled):hover { transform: translateY(-1px); }
button[type="submit"]:not(:disabled):active, .sync-btn:not(:disabled):active { transform: translateY(1px); }
button[type="submit"]:not(:disabled):hover::after, .sync-btn:not(:disabled):hover::after {
  animation: sheenSweep 0.85s cubic-bezier(0.3,0.1,0.2,1);
}
@keyframes sheenSweep {
  0% { opacity: 0; transform: rotate(9deg) translateX(-260%); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: rotate(9deg) translateX(520%); }
}

/* Nav icons hop on hover; the row gives a springy pop when it goes active */
@keyframes iconHop { 0% { transform: translateY(0); } 35% { transform: translateY(-3px) scale(1.14); } 65% { transform: translateY(1px); } 100% { transform: translateY(0); } }
.nav-item:hover .nav-item-icon { animation: iconHop 0.5s cubic-bezier(0.32,0.72,0,1); }
@keyframes navPop { 0% { transform: scale(0.95); } 55% { transform: scale(1.035); } 100% { transform: scale(1); } }
.nav-item.active { animation: navPop 0.34s cubic-bezier(0.34,1.5,0.64,1); }

/* Panels bounce in with a little overshoot */
@keyframes panelIn { 0% { opacity: 0; transform: translateY(12px) scale(0.985); } 60% { opacity: 1; transform: translateY(-3px) scale(1.005); } 100% { opacity: 1; transform: none; } }
.panel.active { animation: panelIn 0.44s cubic-bezier(0.34,1.45,0.5,1); }

/* The lime "314" breathes a soft glow */
@keyframes brandGlow {
  0%, 100% { text-shadow: 0 0 12px rgba(136,255,38,0.40), 0 1px 1px rgba(0,0,0,0.6); }
  50% { text-shadow: 0 0 22px rgba(136,255,38,0.75), 0 1px 1px rgba(0,0,0,0.6); }
}
.sidebar-brand h1 .brand-314 { animation: brandGlow 3.4s ease-in-out infinite; }

/* Progress fill shimmers as it marches */
@keyframes barGlow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.13) saturate(1.08); } }
.progress-bar { animation: barberpole 0.8s linear infinite, barGlow 1.7s ease-in-out infinite; }

/* Stat tiles lift toward you on hover */
.stat { transition: transform var(--transition), box-shadow var(--transition); }
.stat:hover { transform: translateY(-3px); box-shadow: var(--bevel-top), 0 8px 16px rgba(8,22,45,0.16); }

/* Selected tag chips pop */
@keyframes chipPop { 0% { transform: scale(0.9); } 55% { transform: scale(1.09); } 100% { transform: scale(1); } }
.tag-chip.selected { animation: chipPop 0.3s cubic-bezier(0.34,1.55,0.64,1); }

/* Respect reduced-motion preferences — but keep the loading spinner spinning */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .spinner { animation: spin 0.8s linear infinite !important; }
}

/* ===== HIP & MODERN LAYER ===== */

/* Soft, slowly-drifting brand-colored aurora behind everything */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 48% at 18% 20%, rgba(0,158,203,0.22), transparent 60%),
    radial-gradient(36% 44% at 84% 16%, rgba(50,211,176,0.20), transparent 60%),
    radial-gradient(46% 56% at 78% 84%, rgba(83,216,231,0.18), transparent 62%),
    radial-gradient(42% 52% at 22% 88%, rgba(136,255,38,0.10), transparent 60%);
  background-position: var(--aurora-x, 0px) var(--aurora-y, 0px);
  filter: blur(34px) saturate(1.15);
  /* drift animation is desktop-only (see min-width:769px) to spare phone GPUs */
}
@keyframes auroraDrift {
  0% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(2.5%, -2%, 0) scale(1.07); }
  100% { transform: translate3d(-2.5%, 2%, 0) scale(1.04); }
}

/* (The frosted-glass panel treatment is applied on desktop only — see the
   min-width:769px block — so phones keep cheap, opaque, readable panels.) */

/* Vivid gradient page title */
.page-header h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.8px;
  text-shadow: none;
  background-image: linear-gradient(120deg, var(--primary-700) 0%, var(--primary-500) 55%, var(--primary-400) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--primary-600);
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.7));
}

/* ===== WIDE TABLES — scroll sideways instead of overflowing the viewport ===== */
#historyContent, #queueContent { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#historyContent table, #queueContent table { min-width: 540px; }

/* ===== DESKTOP / LARGER SCREENS =====
   Mobile-first: everything above targets phones. This layer adds the desktop
   layout (persistent sidebar) and the GPU-heavier eye-candy (frosted-glass
   panels, drifting aurora) only where there's room and power for it. */
@media (min-width: 769px) {
  .mobile-header { display: none; }
  .sidebar { width: var(--sidebar-width); max-width: none; transform: none; visibility: visible; }
  .main-content { margin-left: var(--sidebar-width); padding: 36px 44px; max-width: 980px; }
  .page-header h2 { font-size: 30px; }
  .panel {
    padding: 30px 32px;
    border-radius: var(--radius-lg);
    background-color: rgba(255,255,255,0.85);
    background-image:
      linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0) 18%),
      linear-gradient(180deg, rgba(255,255,255,0.55), rgba(236,242,249,0.40));
    -webkit-backdrop-filter: blur(16px) saturate(1.45);
    backdrop-filter: blur(16px) saturate(1.45);
  }
  .toggle-group { flex-direction: row; }
  .stat-value { font-size: 25px; }
  .range-row { flex-direction: row; align-items: center; }
  .range-row .range-sep { display: inline; }
  body::before { animation: auroraDrift 24s ease-in-out infinite alternate; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .main-content { padding: 30px 26px; }
}

/* ===== ACCESSIBILITY & SMALL-SCREEN PERF ===== */
/* Visible keyboard focus ring for custom (non-native) controls */
button:focus-visible,
.nav-item:focus-visible {
  outline: 3px solid rgba(0,158,203,0.65);
  outline-offset: 2px;
}
/* Drop the blurred aurora entirely on small phones — pure GPU/battery saving */
@media (max-width: 480px) {
  body::before { display: none; }
}

/* ===== EMAIL PERFORMANCE ===== */
/* Source-health strip: each source's status lives here, never in the data, so one
   failing CRM/FBL feed can't blank the table below. */
.perf-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
}
.perf-src {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  background-image: linear-gradient(180deg, #ffffff, #eef2f8);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  box-shadow: var(--shadow-sm);
}
.perf-asof { margin-left: auto; font-size: 11px; color: var(--gray-500); white-space: nowrap; }

.perf-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.perf-card {
  position: relative;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background-image: var(--gloss), linear-gradient(180deg, #ffffff 0%, #eef2f9 100%);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm), var(--bevel-top);
  overflow: hidden;
}
.perf-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background-image: linear-gradient(90deg, var(--primary-400), var(--accent-mint), var(--accent-yellow), var(--accent-coral));
}
.perf-card-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--gray-500); }
.perf-card-value { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; margin: 4px 0 2px; }
.perf-card-caption { font-size: 11px; color: var(--gray-500); }

.perf-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.perf-filters select,
.perf-filters input[type="search"],
.perf-days {
  font: inherit;
  font-size: 13px;
  color: var(--primary-700);
  background-image: linear-gradient(180deg, #ffffff, #f1f4fa);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  box-shadow: var(--bevel-top);
}
.perf-filters input[type="search"] { flex: 1; min-width: 180px; }
.perf-check { font-size: 13px; color: var(--gray-700); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.perf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perf-table thead th {
  text-align: left;
  padding: 8px 12px;
  color: var(--gray-500);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.perf-table th.num, .perf-table td.num { text-align: right; }
.perf-table tbody td { padding: 9px 12px; border-bottom: 1px solid var(--gray-200); vertical-align: top; }
.perf-table tbody tr:hover { background: var(--gray-100); }
.perf-crm-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--white);
  background-image: linear-gradient(180deg, #2f93b6, #00607e);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.perf-acct { font-size: 11px; color: var(--gray-500); margin-top: 3px; }
.perf-subject { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary-700); font-weight: 500; }
.perf-sender { color: var(--gray-600); font-size: 12px; }
.perf-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  vertical-align: middle;
  color: var(--white);
}
.perf-badge.coral { background: var(--accent-coral); }
.perf-badge.yellow { background: var(--accent-yellow); color: #3a2a05; }
.perf-badge.green { background: var(--accent-green-muted); }
.perf-badge.gray { background: var(--gray-400); color: #2a2a2a; }

@media (max-width: 768px) {
  .perf-cards { grid-template-columns: 1fr; }
  .perf-asof { margin-left: 0; width: 100%; }
}
