@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700;800&display=swap');

/* ============================================
   SIGNAGE HUB — Sesame Brand Dashboard Theme
   Purple #6C63FF · Navy #1F2D52 · Mint #55E5BC · Slate #94A3B8
   Typeface: Figtree
   ============================================ */

:root {
  /* Default (dark) theme. color-scheme tells the browser to paint native
     controls — notably the <option> dropdown popup — dark, so they stay
     readable. The light theme flips it below. */
  color-scheme: dark;
  /* Overlay ink: surfaces/borders are built as rgba(var(--ink), a).
     White on dark themes, navy on the light theme. */
  --ink: 255,255,255;
  --sidebar-bg: rgba(15,20,35,0.6);
  --modal-bg: linear-gradient(165deg, rgba(21,29,48,0.95), rgba(10,14,26,0.98));
  --bg: #0e1626;
  --bg-deep: #1f2d52;
  --bg-card: rgba(var(--ink),0.04);
  --bg-input: rgba(var(--ink),0.06);
  --border: rgba(var(--ink),0.08);
  --border-hover: rgba(var(--ink),0.16);
  --text: #eef1f8;
  --text-dim: #94a3b8;
  --primary: #6c63ff;
  --primary-hover: #5a51e6;
  --primary-glow: rgba(108,99,255,0.28);
  --accent: #55e5bc;
  --accent-glow: rgba(85,229,188,0.25);
  --success: #2bd9a4;
  --success-glow: rgba(43,217,164,0.25);
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-glow: rgba(244,63,94,0.25);
  --warning: #f59e0b;
  --warning-glow: rgba(245,158,11,0.25);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px -4px rgba(8,12,28,0.5);
  --transition: 0.25s ease;
  --font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

/* Hidden until JS confirms the user is an admin (see admin.js). Non-admins
   never see these elements; admins get them revealed after /api/me. */
.requires-admin { display: none !important; }

body {
  font-family: var(--font);
  background: linear-gradient(145deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
  line-height: 1.6;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(var(--ink),0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--ink),0.18); }

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* ==================
   SIDEBAR
   ================== */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.sidebar-logo h1 {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sesame-style geometric hexagon isotype next to the wordmark */
.sidebar-logo h1::before {
  content: '';
  width: 24px;
  height: 27px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: initial;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.sidebar-logo small {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 0; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  margin: 2px 0;
  position: relative;
}

.sidebar nav a:hover {
  color: var(--text);
  background: rgba(var(--ink),0.04);
  border-left-color: rgba(108,99,255,0.4);
}

.sidebar nav a.active {
  color: var(--primary);
  background: rgba(108,99,255,0.08);
  border-left-color: var(--primary);
  box-shadow: inset 0 0 20px rgba(108,99,255,0.05);
}

.sidebar nav a.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px var(--primary-glow);
}

.sidebar nav a .icon { font-size: 1.2rem; width: 24px; text-align: center; }

/* ==================
   MAIN CONTENT
   ================== */
.main {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
  max-height: 100vh;
}

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

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ==================
   STATS GRID & CARDS
   ================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, transparent 40%, var(--primary-glow) 50%, transparent 60%);
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 32px -8px rgba(108,99,255,0.15);
}

.stat-card:hover::before {
  opacity: 1;
  animation: gradientBorder 3s ease infinite;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: subtlePulse 4s ease-in-out infinite;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@keyframes gradientBorder {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes subtlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* ---- General Card ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 8px 32px -8px rgba(0,0,0,0.3);
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ==================
   TABLES
   ================== */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.05em;
}

tr {
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

tr:hover {
  background: rgba(108,99,255,0.03);
  border-left-color: var(--primary);
}

/* ==================
   BUTTONS
   ================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #5a51e6);
  box-shadow: 0 2px 12px var(--primary-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5a51e6, var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-hover));
  box-shadow: 0 2px 12px var(--danger-glow);
}
.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--danger-glow);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  box-shadow: 0 2px 12px var(--success-glow);
}
.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--success-glow);
}

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--text);
  background: rgba(108,99,255,0.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(108,99,255,0.1);
}

/* ==================
   FORMS
   ================== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: all var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 0 0 1px var(--primary);
  background: rgba(108,99,255,0.04);
  animation: focusRing 0.3s ease;
}

@keyframes focusRing {
  0% { box-shadow: 0 0 0 6px rgba(108,99,255,0.3), 0 0 0 1px var(--primary); }
  100% { box-shadow: 0 0 0 3px var(--primary-glow), 0 0 0 1px var(--primary); }
}

textarea { resize: vertical; min-height: 80px; }

/* The native <option> popup doesn't reliably resolve CSS custom properties
   (they're set inline on :root by the theme JS) nor translucent backgrounds,
   so pin literal solid colors per theme. Default below is the dark theme;
   the other themes override it (see bottom of file). */
select option {
  background-color: #1f2d52;
  color: #eef1f8;
}

/* ==================
   BADGES
   ================== */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(var(--ink),0.06);
}

.badge-primary { background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(85,229,188,0.2)); color: var(--primary); }
.badge-success { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(16,185,129,0.1)); color: var(--success); }
.badge-danger { background: linear-gradient(135deg, rgba(244,63,94,0.2), rgba(244,63,94,0.1)); color: var(--danger); }
.badge-warning { background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(245,158,11,0.1)); color: var(--warning); }

.status-online { color: var(--success); text-shadow: 0 0 8px var(--success-glow); }
.status-offline { color: var(--danger); text-shadow: 0 0 8px var(--danger-glow); }

/* ==================
   MODAL
   ================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,8,18,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 1px rgba(var(--ink),0.1) inset;
  animation: modalSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ==================
   UPLOAD ZONE
   ================== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='rgba(var(--ink),0.1)' stroke-width='2' stroke-dasharray='8 6' stroke-dashoffset='0' stroke-linecap='round'/%3e%3c/svg%3e");
  border-color: transparent;
}

.upload-zone .icon,
.upload-zone [class*="icon"] {
  transition: transform var(--transition);
}

.upload-zone:hover, .upload-zone.dragover {
  background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='rgba(108,99,255,0.5)' stroke-width='2' stroke-dasharray='8 6' stroke-dashoffset='0' stroke-linecap='round'/%3e%3c/svg%3e");
  background-color: rgba(108,99,255,0.04);
  color: var(--text);
}

.upload-zone:hover .icon,
.upload-zone:hover [class*="icon"],
.upload-zone.dragover .icon,
.upload-zone.dragover [class*="icon"] {
  transform: scale(1.15);
}

/* ==================
   CONTENT GRID & CARDS
   ================== */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.content-card:hover {
  border-color: rgba(108,99,255,0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px -8px rgba(108,99,255,0.12);
}

.content-card .preview {
  height: 120px;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.content-card .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.content-card:hover .preview img {
  transform: scale(1.05);
}

.content-card .preview .type-icon { font-size: 2.5rem; }

.content-card .info {
  padding: 12px;
}

.content-card .info h4 {
  font-size: 0.88rem;
  overflow-wrap: break-word;
  word-break: break-word;
  font-weight: 600;
}

.content-card .info small { color: var(--text-dim); font-size: 0.78rem; }

.content-card .actions {
  padding: 0 12px 12px;
  display: flex;
  gap: 6px;
}

/* ==================
   CAMPAIGN ITEMS
   ================== */
.campaign-items {
  list-style: none;
  min-height: 60px;
}

.campaign-items li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(var(--ink),0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: grab;
  transition: all var(--transition);
}

.campaign-items li:hover {
  background: rgba(108,99,255,0.04);
  border-color: var(--border-hover);
}

.campaign-items li:active { cursor: grabbing; transform: scale(1.01); }
.campaign-items li .drag-handle { color: var(--text-dim); cursor: grab; }
.campaign-items li .item-name { flex: 1; font-size: 0.9rem; font-weight: 500; }
.campaign-items li .item-type { font-size: 0.75rem; color: var(--text-dim); }

/* ==================
   DAY & GROUP CHECKBOXES
   ================== */
.day-checkboxes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.day-checkboxes label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: rgba(var(--ink),0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  text-transform: none;
  font-weight: 500;
  transition: all var(--transition);
}

.day-checkboxes label:hover {
  border-color: var(--border-hover);
  background: rgba(var(--ink),0.05);
}

.day-checkboxes input:checked + span {
  color: var(--primary);
}

.group-checkboxes label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.9rem;
  text-transform: none;
  font-weight: 500;
  transition: color var(--transition);
}

.group-checkboxes label:hover { color: var(--primary); }

/* ==================
   COPY BUTTON
   ================== */
.copy-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: all var(--transition);
}

.copy-btn:hover {
  color: var(--primary);
  background: rgba(108,99,255,0.08);
}

/* ==================
   TOAST NOTIFICATIONS
   ================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.4, 0.64, 1), toastFadeOut 0.35s ease 2.65s forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toast.success {
  background: linear-gradient(135deg, var(--success), #059669);
  box-shadow: 0 8px 32px var(--success-glow);
}
.toast.error {
  background: linear-gradient(135deg, var(--danger), var(--danger-hover));
  box-shadow: 0 8px 32px var(--danger-glow);
}
.toast.info {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 8px 32px var(--primary-glow);
}

@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastFadeOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* legacy keyframe names for compatibility */
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ==================
   TIMELINE / SCHEDULE
   ================== */
.timeline {
  overflow-x: auto;
}

.timeline-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.timeline-label {
  width: 120px;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.timeline-bar {
  flex: 1;
  height: 36px;
  background: rgba(var(--ink),0.03);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.timeline-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: filter var(--transition);
}

.timeline-block:hover { filter: brightness(1.2); }

.timeline-hours {
  display: flex;
  margin-left: 120px;
  margin-bottom: 4px;
}

.timeline-hours span {
  flex: 1;
  font-size: 0.65rem;
  color: var(--text-dim);
}

/* ==================
   TOGGLE SWITCH
   ================== */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
  position: absolute;
  inset: 0;
  background: rgba(var(--ink),0.1);
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.toggle .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .slider {
  background: var(--success);
  box-shadow: 0 0 12px var(--success-glow);
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
}

/* ==================
   PREVIEW FRAME
   ================== */
.preview-frame {
  width: 640px;
  height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(var(--ink),0.04) inset;
}

/* ==================
   PROGRESS BAR (new)
   ================== */
.progress-bar {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  position: relative;
  overflow: hidden;
  animation: progressGlow 2s ease infinite;
}

.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(var(--ink),0.3), transparent);
  animation: progressShimmer 1.5s ease infinite;
}

@keyframes progressGlow {
  0%, 100% { box-shadow: 0 0 8px var(--primary-glow); }
  50% { box-shadow: 0 0 16px var(--accent-glow); }
}

@keyframes progressShimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ==================
   LOADING SKELETON (new)
   ================== */
.skeleton {
  background: linear-gradient(90deg, rgba(var(--ink),0.04) 25%, rgba(var(--ink),0.08) 50%, rgba(var(--ink),0.04) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
  min-height: 20px;
}

.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-title { height: 22px; margin-bottom: 12px; width: 50%; }
.skeleton-card { height: 120px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==================
   EMERGENCY CARD
   ================== */
.card.emergency,
.emergency-card {
  border: 1px solid rgba(244,63,94,0.4);
  box-shadow: 0 0 20px var(--danger-glow), 0 4px 24px rgba(0,0,0,0.3);
  animation: emergencyPulse 2s ease-in-out infinite;
  padding: 26px;
}

@keyframes emergencyPulse {
  0%, 100% { box-shadow: 0 0 20px var(--danger-glow), 0 4px 24px rgba(0,0,0,0.3); border-color: rgba(244,63,94,0.4); }
  50% { box-shadow: 0 0 40px rgba(244,63,94,0.35), 0 4px 24px rgba(0,0,0,0.3); border-color: rgba(244,63,94,0.6); }
}

/* ── Status indicator on content cards ───────────────────────── */
.content-card { position: relative; }
.content-card .preview { position: relative; }

.content-card .status-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.4);
  z-index: 2;
}

.content-card .status-dot.live {
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow, rgba(16,185,129,0.4));
  animation: statusPulse 2s ease-in-out infinite;
}

.content-card .status-dot.idle {
  background: var(--text-dim);
  opacity: 0.5;
}

@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 6px var(--success-glow, rgba(16,185,129,0.3)); }
  50% { box-shadow: 0 0 14px var(--success-glow, rgba(16,185,129,0.6)); }
}

/* ── Drag & Drop visual feedback ─────────────────────────────── */
[draggable="true"] { cursor: grab; }
[draggable="true"]:active { cursor: grabbing; }

.dragging {
  opacity: 0.35 !important;
  transform: scale(0.96) !important;
  transition: all 0.15s ease !important;
}

.drop-hover {
  border-color: var(--primary) !important;
  background: rgba(108,99,255,0.06) !important;
  box-shadow: 0 0 24px rgba(108,99,255,0.15), inset 0 0 16px rgba(108,99,255,0.04) !important;
  transition: all 0.2s ease !important;
}

.drop-above { border-top: 3px solid var(--primary) !important; }
.drop-below { border-bottom: 3px solid var(--primary) !important; }

/* ── Board / Kanban layout ───────────────────────────────────── */
.board-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: 400px;
}

.board-lane {
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.25s ease;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.board-lane-header {
  font-weight: 700;
  font-size: 0.9rem;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

.board-lane-header .count-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(var(--ink),0.06);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.board-card {
  padding: 10px;
  background: rgba(var(--ink),0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: grab;
}

.board-card:hover {
  border-color: var(--border-hover, rgba(var(--ink),0.15));
  transform: translateY(-1px);
}

.board-card:active { cursor: grabbing; }

.board-card .card-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-card .card-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Content sidebar / library panel ─────────────────────────── */
.content-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-sidebar h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  transition: all 0.2s ease;
}

.mini-card:hover {
  border-color: var(--primary);
  background: rgba(108,99,255,0.04);
}

.mini-card:active { cursor: grabbing; }

.mini-card .mini-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.mini-card .mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-card .mini-info {
  flex: 1;
  min-width: 0;
}

.mini-card .mini-info .mini-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-card .mini-info .mini-type {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ── Dashboard two-panel layout ──────────────────────────────── */
.dashboard-board {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.dashboard-board .side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 24px;
}

.side-panel .panel-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.side-panel .panel-section h4 {
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--text);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Campaign visual strip ───────────────────────────────────── */
.campaign-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 80px;
  padding: 12px;
  background: rgba(var(--ink),0.02);
  border: 2px dashed var(--border);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.campaign-strip.drop-hover {
  border-color: var(--primary) !important;
  border-style: solid !important;
  background: rgba(108,99,255,0.04) !important;
}

.campaign-strip .strip-item {
  width: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: all 0.2s ease;
}

.campaign-strip .strip-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.campaign-strip .strip-item .strip-thumb {
  width: 100%;
  height: 60px;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.campaign-strip .strip-item .strip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.campaign-strip .strip-item .strip-name {
  padding: 4px 6px;
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.campaign-strip .strip-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 60px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ── Group drop card (in side panel) ─────────────────────────── */
.group-drop-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-drop-card .group-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.group-drop-card .group-info {
  flex: 1;
}

.group-drop-card .group-info .group-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.group-drop-card .group-info .group-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ── Campaign chip (draggable in side panel) ─────────────────── */
.campaign-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: grab;
  transition: all 0.2s ease;
}

.campaign-chip:hover {
  border-color: var(--primary);
  background: rgba(108,99,255,0.04);
}

.campaign-chip .chip-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.campaign-chip .chip-status.active { background: var(--success); }
.campaign-chip .chip-status.paused { background: var(--text-dim); }

.campaign-chip .chip-name {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
}

.campaign-chip .chip-count {
  font-size: 0.75rem;
  color: var(--text-dim);
}

@media (max-width: 1024px) {
  .dashboard-board { grid-template-columns: 1fr; }
}

/* ==================
   RESPONSIVE
   ================== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  /* ── Sidebar → bottom tab bar ── */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0;
    z-index: 100;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .sidebar-logo { display: none; }
  .sidebar nav {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow-x: auto;
    padding: 0;
    gap: 0;
  }
  .sidebar nav a {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px 4px 6px;
    border-left: none;
    gap: 2px;
    min-width: 0;
  }
  .sidebar nav a span:not(.icon) {
    font-size: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
  }
  .sidebar nav a .icon { font-size: 1rem; width: auto; }
  .sidebar nav a.active {
    border-left: none;
    border-bottom: none;
    color: var(--primary);
    background: rgba(108,99,255,0.1);
  }
  .sidebar nav a.active::after { display: none; }
  .theme-picker { display: none; }
  .sidebar-logout { display: none; }

  /* ── Main content ── */
  .main {
    padding: 16px 12px 80px;
    max-height: none;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header h2 { font-size: 1.2rem; }
  .page-header > div { width: 100%; }
  .page-header > div[style*="display:flex"] {
    flex-wrap: wrap !important;
  }

  /* ── Stats ── */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .stat-card .stat-label { font-size: 0.72rem; }

  /* ── Content grid ── */
  .content-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* ── Dashboard layout ── */
  .dashboard-board { grid-template-columns: 1fr !important; gap: 16px; }
  .dashboard-board .side-panel {
    position: static;
  }

  /* ── Buttons larger touch targets ── */
  .btn { padding: 10px 16px; font-size: 0.85rem; min-height: 40px; }
  .btn-sm { padding: 7px 12px; font-size: 0.78rem; min-height: 34px; }
  .btn-mini { width: 34px; height: 34px; }

  /* ── Inputs larger for touch ── */
  input, select, textarea {
    padding: 12px 14px;
    font-size: 1rem;
    min-height: 44px;
  }

  /* ── Modals full-width ── */
  .modal {
    width: 95%;
    max-width: none;
    padding: 20px;
    max-height: 85vh;
    border-radius: 14px;
  }

  /* ── Preview ── */
  .preview-frame { width: 100%; height: auto; aspect-ratio: 16/9; }

  /* ── Tables card-like ── */
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr {
    margin-bottom: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    border-left: 3px solid var(--primary);
  }
  td {
    padding: 6px 10px;
    border: none;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
  }
  td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }

  /* ── Upload zone ── */
  .upload-zone { padding: 24px 16px; }

  /* ── Show mobile-only elements ── */
  .mobile-only { display: inline-flex !important; }
}

/* Theme Picker */
.theme-picker {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.theme-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active { border-color: var(--text); }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 8px 12px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-logout:hover {
  color: var(--danger);
  border-color: rgba(244,63,94,0.3);
  background: rgba(244,63,94,0.06);
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .modal { width: 98%; padding: 16px; margin: 8px; }
  .page-header h2 { font-size: 1.1rem; }
}

/* ==========================================================
   LIGHT THEME (Sesame website style)
   Activated via <html data-theme="light"> from the theme picker.
   Surfaces resolve from --ink (navy) so the rgba(var(--ink),a)
   overlays flip from white to navy automatically.
   ========================================================== */
:root[data-theme="light"] {
  color-scheme: light;
  --ink: 31,45,82;
  --sidebar-bg: rgba(255,255,255,0.85);
  --modal-bg: #ffffff;
  --shadow: 0 6px 24px -8px rgba(31,45,82,0.18);
}

/* Literal per-theme colors for the native <option> popup (see note by the
   default `select option` rule near the top). Mirrors each theme's palette. */
:root[data-theme="midnight"] select option { background-color: #161b22; color: #c9d1d9; }
:root[data-theme="ocean"]    select option { background-color: #112240; color: #ccd6f6; }
:root[data-theme="sunset"]   select option { background-color: #2d1233; color: #f0e6f6; }
:root[data-theme="light"]    select option { background-color: #ffffff; color: #1f2d52; }

/* Dashed upload zone uses a baked-in SVG stroke — recolor for light. */
:root[data-theme="light"] .upload-zone {
  background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='rgba(31,45,82,0.18)' stroke-width='2' stroke-dasharray='8 6' stroke-linecap='round'/%3e%3c/svg%3e");
}

/* Toggle tracks need a touch more contrast on white. */
:root[data-theme="light"] .toggle .slider,
:root[data-theme="light"] .toggle-slider {
  background: rgba(31,45,82,0.18);
}

/* Soften heavy black drop shadows that were tuned for dark. */
:root[data-theme="light"] .modal {
  box-shadow: 0 24px 80px rgba(31,45,82,0.22), 0 0 1px rgba(31,45,82,0.1) inset;
}
:root[data-theme="light"] .toast { box-shadow: 0 8px 28px rgba(31,45,82,0.18); }
