/* admin.css — Giftly Admin Dashboard
   Matches existing blue/teal/mint design system.
   Max 400 lines.
*/

/* ── Overlay ── */
/* Define all --admin-* tokens here so every child element in the admin
   panel gets consistent dark-theme values regardless of the app theme.  */
#admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-y;

  /* Admin-scoped dark theme tokens */
  --admin-bg:       #1e293b;
  --admin-bg2:      #0f172a;
  --admin-text:     #f1f5f9;
  --admin-muted:    #94a3b8;
  --admin-border:   #334155;
}
#admin-overlay.admin-open {
  display: flex;
}

/* ── Hide window scrollbar when admin is open (it sits on top of admin-body
   scrollbar and intercepts clicks). Scroll wheel still works on the page
   behind the overlay — only the visible track is removed. ── */
body:has(#admin-overlay.admin-open) {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge legacy */
}
body:has(#admin-overlay.admin-open)::-webkit-scrollbar {
  display: none;                 /* Chrome / Safari / Opera */
}

/* ── Header ── */
.admin-header {
  background: linear-gradient(
    135deg,
    #FDFAF6 0%,
    #f0eaff 30%,
    #fff8e6 60%,
    #ffe4e6 100%
  );
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(
      90deg,
      var(--blue),
      var(--accent),
      var(--gold),
      var(--accent),
      var(--blue)
    )
    1;
  box-shadow: 0 2px 16px rgba(108, 60, 225, 0.08);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.admin-header-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--blue2);
  flex: 1;
}
.admin-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
  font-size: 0.7rem;
  font-weight: 800;
}
.admin-live-pill span { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.13); }
.admin-hero-action {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  padding: 7px 11px;
  border-radius: 9px;
  font-size: .74rem;
  font-weight: 750;
  cursor: pointer;
}
.admin-hero-action:hover { background: rgba(255,255,255,.22); }
.admin-back-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.admin-back-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.admin-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition:
    color 0.15s,
    background 0.15s;
}
.admin-close-btn:hover {
  color: var(--text);
  background: var(--bg3);
}

/* ── Tab bar ── */
.admin-tabs {
  display: flex;
  justify-content: safe center;
  gap: 4px;
  padding: 10px 20px 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  /* iOS momentum scroll without bounce propagation */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  /* Hide scrollbar on all browsers */
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}

@media (max-width: 820px) {
  .admin-header { padding: 10px 12px; gap: 9px; }
  .admin-header-title { font-size: 1rem; }
  #admin-header-context, .admin-live-pill { display: none; }
  .admin-tabs { padding-left: 10px; padding-right: 10px; justify-content: flex-start; }
  .admin-tab { padding: 9px 12px; }
  .enh-card-grid { grid-template-columns: 1fr !important; }
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition:
    color 0.15s,
    border-color 0.15s;
  scroll-snap-align: center;
}
.admin-tab:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  border-radius: 7px 7px 0 0;
}
.admin-tab:hover {
  color: var(--text);
}
.admin-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ── Sub-tabs scroll wrapper (arrow nav) ─────────────────────────────────── */
.sub-tabs-scroll-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  align-items: stretch;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

/* Arrow buttons */
.sub-tabs-arrow {
  flex-shrink: 0;
  width: 32px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  padding: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  z-index: 2;
}
.sub-tabs-arrow:hover { color: var(--text); background: var(--bg3, #f1f5f9); }
.sub-tabs-arrow[hidden] { display: none; }

/* Fade edges when scrollable */
.sub-tabs-scroll-wrap::before,
.sub-tabs-scroll-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 2px; /* above border */
  width: 28px;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.2s;
  opacity: 0;
}
.sub-tabs-scroll-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  align-items: stretch;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  /* needed for ::before/::after positioning */
  overflow: visible;
}
.sub-tabs-scroll-wrap::before {
  left: 32px;
  background: linear-gradient(to right, var(--bg), transparent);
}
.sub-tabs-scroll-wrap::after {
  right: 32px;
  background: linear-gradient(to left, var(--bg), transparent);
}
.sub-tabs-scroll-wrap.can-scroll-left::before  { opacity: 1; }
.sub-tabs-scroll-wrap.can-scroll-right::after  { opacity: 1; }

/* ── Sub-tabs bar (used on Subscriptions, Settings, API Gateways, Community, Investors) ── */
.sub-tabs-bar {
  display: flex;
  justify-content: flex-start;
  gap: 2px;
  /* padding-top gives the bar the same visual height as the main tab bar above it */
  padding: 8px 4px 0;
  margin-bottom: 0;
  border-bottom: none; /* border now on wrapper */
  /* Sticky handled by wrapper */
  position: static;
  background: transparent;
  /* Mobile: scroll horizontally without the whole page bouncing */
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  flex-shrink: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sub-tabs-bar::-webkit-scrollbar { display: none; }

/* Nested sub-tabs wrapper offset */
.settings-sub-panel .sub-tabs-scroll-wrap,
.comm-sub-panel .sub-tabs-scroll-wrap {
  top: 38px;
  z-index: 9;
}

.sub-tab {
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.sub-tab:hover { color: var(--text); }

.sub-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.sub-tab-panel { display: none; }

.sub-tab-panel.active { display: block; }

/* ── Nested sub-tabs (3rd level: e.g. Settings→API Gateways, Community→Subscriptions) ──
   When a .sub-tabs-bar appears inside a .settings-sub-panel or .comm-sub-panel,
   the outer sticky bar is already occupying ~38px at top:0.
   Offset the inner bar so it sticks just below the outer one. ── */
.settings-sub-panel .sub-tabs-bar,
.comm-sub-panel .sub-tabs-bar {
  /* position/top now handled by .sub-tabs-scroll-wrap above */
}

/* ── Panel body ── */
.admin-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* No top padding — sub-tabs bars sit flush under the main tab row.
     Horizontal + bottom padding kept for card spacing. */
  padding: 0 20px 20px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.admin-panel {
  display: none;
}
.admin-panel.active {
  display: block;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
/* Panels that do NOT start with a sub-tabs bar need top padding restored */
#admin-panel-overview.active,
#admin-panel-fightfixer.active {
  padding-top: 20px;
}

/* ── Stat cards ── */
#admin-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.admin-stat-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.admin-stat-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  opacity: 0.45;
}
.admin-stat-card:nth-child(2)::after {
  background: var(--gold);
}
.admin-stat-card:nth-child(3)::after {
  background: var(--green);
}
.admin-stat-card:nth-child(4)::after {
  background: var(--blue);
}
.admin-stat-card:nth-child(5)::after {
  background: var(--accent);
}
.admin-stat-card:nth-child(6)::after {
  background: var(--pink);
}
.admin-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.admin-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue);
}

/* ── Section card ── */
.admin-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.admin-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--blue2);
}

/* ── Search box ── */
.admin-search {
  width: 100%;
  max-width: 360px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  font-size: 16px; /* ≥16px prevents iOS Safari auto-zoom on focus */
  margin-bottom: 14px;
}
.admin-search:focus {
  outline: none;
  border-color: var(--blue);
}

/* ── Users table ── */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td {
  border-bottom: none;
}
.admin-table tr:hover td {
  background: var(--bg2);
}

/* ── Role badges ── */
.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.role-badge.admin {
  background: rgba(108, 60, 225, 0.12);
  color: var(--blue);
  border: 1px solid rgba(255, 93, 108, 0.25);
}
.role-badge.user {
  background: rgba(6, 214, 160, 0.1);
  color: var(--gold2);
  border: 1px solid rgba(6, 214, 160, 0.25);
}
.role-badge.banned {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.25);
}
.role-badge.investor {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.disabled-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
  margin-left: 4px;
}

/* ── Action buttons ── */
.admin-btn {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}
.admin-btn:hover {
  background: var(--bg3);
  border-color: var(--blue);
}
.admin-btn.danger {
  border-color: rgba(220, 38, 38, 0.3);
  color: #dc2626;
}
.admin-btn.danger:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: #dc2626;
}
.admin-btn.active-toggle {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.5);
  color: #15803d;
  font-weight: 700;
}
.admin-btn.active-toggle:hover {
  background: rgba(22, 163, 74, 0.2);
  border-color: #15803d;
}

/* ── Gear action button ── */
.admin-user-gear-btn {
  background: none;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted, #64748b);
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, transform 0.2s;
}
.admin-user-gear-btn:hover {
  background: var(--bg3, #f1f5f9);
  border-color: var(--blue, #6C3CE1);
}
.admin-user-gear-btn.open {
  background: var(--bg3, #f1f5f9);
  border-color: var(--blue, #6C3CE1);
  transform: rotate(45deg);
}

/* ── User action popover menu ── */
.admin-user-menu {
  position: absolute;
  z-index: 10000;
  min-width: 200px;
  background: var(--card-bg, #fff);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
  animation: adminMenuFadeIn 0.12s ease;
}
@keyframes adminMenuFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.admin-user-menu-header {
  padding: 10px 14px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border, #e2e8f0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text, #0a2540);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
  line-height: 1.3;
}
.admin-user-menu-item:hover {
  background: var(--bg2, #f8fafc);
}
.admin-user-menu-item.active {
  color: #15803d;
  font-weight: 700;
  background: rgba(22,163,74,0.07);
}
.admin-user-menu-item.active:hover {
  background: rgba(22,163,74,0.13);
}
.admin-user-menu-item.danger {
  color: #dc2626;
}
.admin-user-menu-item.danger:hover {
  background: rgba(220,38,38,0.07);
}
.admin-user-menu-divider {
  height: 1px;
  background: var(--border, #e2e8f0);
  margin: 4px 0;
}

/* ── Event sponsor modal: validation, viewport safety, mobile layout ── */
#esp-modal-overlay { touch-action: pan-y; }
#esp-modal { overscroll-behavior: contain; }
#esp-modal .esp-field-invalid {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14) !important;
}
.esp-gear-menu { overscroll-behavior: contain; }
@media (max-width: 560px) {
  #esp-modal-overlay { padding: 0 !important; align-items: stretch !important; }
  #esp-modal {
    max-width: none !important;
    max-height: 100dvh !important;
    min-height: 100dvh;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
  }
  #esp-modal .esp-contact-grid,
  #esp-modal .esp-price-grid { grid-template-columns: 1fr !important; }
  #esp-modal .esp-tier-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #esp-modal-footer-edit {
    position: sticky;
    bottom: 0;
    z-index: 70;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    background: var(--card-bg, #fff);
  }
  .esp-gear-menu .admin-user-menu-item { min-height: 44px; }
}

/* ── Inline user flag badges (email cell) ── */
.user-flag-badge {
  display: inline-block;
  font-size: 0.72rem;
  margin-left: 5px;
  vertical-align: middle;
  line-height: 1;
  opacity: 0.85;
}

.admin-btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Feature requests ── */
.fr-row {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.fr-row:hover {
  border-color: var(--blue);
  background: var(--bg2);
}
.fr-row.expanded {
  border-color: var(--blue);
  background: var(--bg2);
}
.fr-row-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.fr-title {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
}
.fr-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}
.fr-detail {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.fr-row.expanded .fr-detail {
  display: block;
}
.fr-desc {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 14px;
}
.fr-admin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fr-admin-form label {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
}
.fr-admin-form select,
.fr-admin-form textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.fr-admin-form textarea {
  resize: vertical;
  min-height: 60px;
}

/* Type + status badges */
.type-badge,
.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.type-badge.feature {
  background: rgba(108, 60, 225, 0.1);
  color: var(--blue);
}
.type-badge.bug {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}
.type-badge.improvement {
  background: rgba(6, 214, 160, 0.1);
  color: var(--gold2);
}
.status-badge.pending {
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
}
.status-badge.in-progress {
  background: rgba(234, 179, 8, 0.15);
  color: #ca8a04;
}
.status-badge.done {
  background: rgba(6, 214, 160, 0.15);
  color: var(--gold2);
}
.status-badge.rejected {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

/* ── Settings ── */
.admin-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.admin-setting-row:last-child {
  border-bottom: none;
}
.admin-setting-label {
  font-size: 0.9rem;
  font-weight: 600;
}
.admin-setting-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}
.admin-btn-primary {
  padding: 9px 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #FF5D6C, #e04a58);
  color: #fff;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.admin-btn-primary:hover {
  opacity: 0.87;
}
.admin-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Toast (in-overlay) ── */
.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: adminToastIn 0.25s ease;
  max-width: 380px;
}
@keyframes adminToastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.admin-mini-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 2px solid #ddd6fe;
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: adminMiniSpin .8s linear infinite;
}
@keyframes adminMiniSpin { to { transform: rotate(360deg); } }
.admin-toast.success {
  border-left: 4px solid var(--gold);
}
.admin-toast.error {
  border-left: 4px solid #dc2626;
}

/* ── Secondary button (used throughout admin) ── */
.admin-btn-secondary {
  padding: 7px 16px;
  border-radius: 8px;
  background: var(--bg2, #f1f5f9);
  color: var(--text, #0a2540);
  border: 1px solid var(--border, #e2e8f0);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  /* iOS: remove 300ms tap delay */
  touch-action: manipulation;
}
.admin-btn-secondary:hover {
  background: var(--bg3, #e8deff);
  border-color: var(--blue, #6C3CE1);
}
.admin-btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── All admin buttons: remove 300ms tap delay on iOS ── */
.admin-btn,
.admin-btn-primary,
.admin-btn-secondary,
.sub-tab,
.admin-tab,
.admin-mlist-list-btn,
.admin-mlist-sort-btn,
.admin-mlist-del-btn,
.admin-mlist-add-btn {
  touch-action: manipulation;
}

/* ── Responsive ── */
@media (max-width: 680px) {
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3),
  .admin-table th:nth-child(4),
  .admin-table td:nth-child(4) {
    display: none;
  }
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-body {
    padding: 0 12px 12px;
  }
}

/* ── Subscriptions & Processors ────────────────────────────────────────── */

.sub-plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}

.quantum-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  background: rgba(236, 72, 153, 0.15);
  color: #ec4899;
  border: 1px solid rgba(236, 72, 153, 0.35);
  margin-left: 6px;
}

.sub-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.sub-status-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.35);
}
.sub-status-badge.trialing {
  background: rgba(108, 60, 225, 0.12);
  color: var(--blue);
  border: 1px solid rgba(108, 60, 225, 0.3);
}
.sub-status-badge.cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.sub-status-badge.past_due {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.plan-edit-form {
  animation: fadeInDown 0.15s ease;
}

.admin-select {
  background: var(--card-bg, #fff);
  color: var(--text, #0a2540);
  border: 1px solid var(--border, #e2e8f0);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.admin-select:focus {
  outline: none;
  border-color: var(--blue, #6C3CE1);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── MRR Stats Panel ────────────────────────────────────────────────────── */

.sub-mrr-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 4px;
}

.sub-mrr-stat {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  min-width: 140px;
}

.sub-mrr-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.2;
}

.sub-mrr-label {
  font-size: 0.72rem;
  color: var(--muted, #64748b);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Audit event badge ──────────────────────────────────────────────────── */

.sub-audit-event {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(108, 60, 225, 0.12);
  color: var(--blue);
  border: 1px solid rgba(108, 60, 225, 0.3);
  white-space: nowrap;
}

/* Inline audit collapsible header hover */
#sub-inline-audit-card [onclick] {
  user-select: none;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.15s;
}

#sub-inline-audit-card [onclick]:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* ── Subscription table action column ──────────────────────────────────── */

.sub-action-cell {
  white-space: nowrap;
}

.sub-action-cell .admin-btn-group {
  flex-wrap: nowrap;
}

/* ── Plan breakdown bar (MRR card) ──────────────────────────────────────── */

.sub-plan-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--admin-border, #334155);
}

.sub-plan-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.sub-plan-bar-label {
  width: 110px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-plan-bar-track {
  flex: 1;
  height: 8px;
  background: var(--admin-bg2, #0f172a);
  border-radius: 4px;
  overflow: hidden;
}

.sub-plan-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.sub-plan-bar-count {
  width: 28px;
  text-align: right;
  color: var(--muted, #64748b);
  flex-shrink: 0;
}

/* ── Subscriber filter bar ─────────────────────────────────────────────── */

.sub-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

/* ── Audit log filter bar ───────────────────────────────────────────────── */

.sub-audit-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}

.sub-audit-filter-bar label {
  font-size: 0.8rem;
  color: var(--muted, #64748b);
}

/* ── Processor card header ──────────────────────────────────────────────── */

.pp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pp-env-live {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.pp-env-test {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.pp-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-left: auto;
}

/* ── Mobile: subscription tab ───────────────────────────────────────────── */

@media (max-width: 680px) {
  /* Hide Provider, Period ends, Seats columns in subscriber table */
  .sub-subscribers-table th:nth-child(4),
  .sub-subscribers-table td:nth-child(4),
  .sub-subscribers-table th:nth-child(5),
  .sub-subscribers-table td:nth-child(5),
  .sub-subscribers-table th:nth-child(6),
  .sub-subscribers-table td:nth-child(6) {
    display: none;
  }

  .sub-mrr-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sub-plan-bar-label {
    width: 80px;
  }
}

@media (max-width: 600px) {
  /* Hide Packs column at very narrow widths — pack info visible in row detail */
  .sub-subscribers-table th[scope='col']:nth-child(7),
  .sub-subscribers-table td[data-label='Packs'] {
    display: none;
  }
}

/* ── Subscription action buttons: small variants ────────────────────────── */

.sub-btn-override {
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid rgba(108, 60, 225, 0.3);
  background: rgba(108, 60, 225, 0.08);
  color: var(--blue);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.sub-btn-override:hover {
  background: rgba(108, 60, 225, 0.2);
}

.sub-btn-audit {
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--admin-border, #334155);
  background: var(--admin-bg2, #0f172a);
  color: var(--admin-text, #f1f5f9);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.sub-btn-audit:hover {
  background: var(--admin-bg, #1e293b);
}

.sub-btn-cancel {
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.sub-btn-cancel:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* ── Churn Analytics: KPI tiles ── */
.admin-stat-tile {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 140px;
  text-align: center;
  flex: 1 1 140px;
}
.admin-stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--blue, #6C3CE1);
  line-height: 1.2;
  margin-bottom: 4px;
}

/* ── Responsive: hide on small screens ── */
@media (max-width: 640px) {
  .hide-sm {
    display: none;
  }
}

/* ── Managed Lists ── */

/* Settings card list of buttons */
.admin-mlist-list-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-mlist-list-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--bg2, #e8f4fd);
  border: 1px solid var(--border, #b8d8f0);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text, #0a2540);
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  transition: background 0.15s;
}
.admin-mlist-list-btn:hover { background: var(--bg, #f0f7ff); }
.admin-mlist-list-icon { font-size: 1.1rem; }
.admin-mlist-list-label { flex: 1; }
.admin-mlist-count { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.admin-mlist-list-arrow { color: var(--muted); font-size: 1rem; }

/* Popout overlay */
.admin-mlist-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.admin-mlist-overlay--open { opacity: 1; }

/* Popout modal */
.admin-mlist-modal {
  background: var(--card-bg, #fff);
  border-radius: 14px;
  overflow: hidden;
  width: min(520px, 96vw);
  max-height: min(88vh, 680px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  transform: translateY(12px);
  transition: transform 0.18s ease;
}
.admin-mlist-overlay--open .admin-mlist-modal { transform: translateY(0); }

/* On small screens, use full-width bottom sheet style */
@media (max-width: 540px) {
  .admin-mlist-overlay {
    align-items: flex-end;
  }
  .admin-mlist-modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .admin-mlist-overlay--open .admin-mlist-modal {
    transform: translateY(0);
  }
}

/* Teal gradient header */
.admin-mlist-modal-header {
  background: linear-gradient(135deg, #6C3CE1, #8b5cf6);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.admin-mlist-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  flex: 1;
}
.admin-mlist-modal-close {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.admin-mlist-modal-close:hover { background: rgba(255,255,255,0.35); }

/* Modal body */
.admin-mlist-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 12px;
  gap: 8px;
}

/* Search */
.admin-mlist-search-wrap {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.admin-mlist-search {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 8px 12px;
  border: 1px solid var(--border, #b8d8f0);
  border-radius: 8px;
  background: var(--bg, #f0f7ff);
  font-size: 1rem;   /* 16px — prevents iOS auto-zoom */
  color: var(--text, #0a2540);
  box-sizing: border-box;
}
.admin-mlist-search:focus { outline: 2px solid #6C3CE1; outline-offset: 1px; }

/* Scrollable rows area */
.admin-mlist-rows-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
}
.admin-mlist-loading,
.admin-mlist-empty {
  padding: 14px 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* Rows */
.admin-mlist-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border, #e8f4fd);
  transition: background 0.4s;
  overflow: hidden;
  min-width: 0;
}
.admin-mlist-row:last-child { border-bottom: none; }
.admin-mlist-row--saved { background: #e6faf5; }
.admin-mlist-emoji-input {
  width: 44px;
  min-width: 44px;
  text-align: center;
  padding: 5px 4px;
  border: 1px solid var(--border, #b8d8f0);
  border-radius: 6px;
  background: var(--card-bg, #fff);
  font-size: 1rem;   /* 16px — prevents iOS auto-zoom */
  min-height: 36px;
  flex-shrink: 0;
  box-sizing: border-box;
  cursor: pointer;
}
.admin-mlist-emoji-input:hover {
  border-color: #6C3CE1;
  background: #f5f3ff;
}
.admin-mlist-name-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border, #b8d8f0);
  border-radius: 6px;
  background: var(--card-bg, #fff);
  font-size: 1rem;   /* 16px — prevents iOS auto-zoom */
  color: var(--text, #0a2540);
  min-height: 36px;
  box-sizing: border-box;
}
.admin-mlist-category-input,
.admin-mlist-threshold-input,
.admin-mlist-points-input,
.admin-mlist-value-input {
  min-height: 36px;
  padding: 5px 6px;
  border: 1px solid var(--border, #b8d8f0);
  border-radius: 6px;
  background: var(--card-bg, #fff);
  font-size: 1rem;   /* 16px — prevents iOS auto-zoom */
  color: var(--text, #0a2540);
  box-sizing: border-box;
  flex-shrink: 0;
}
.admin-mlist-chip {
  display: inline-block;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--bg2, #e8f4fd);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
  vertical-align: middle;
}
.admin-mlist-sort {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}
.admin-mlist-sort-btn {
  background: none;
  border: 1px solid var(--border, #b8d8f0);
  border-radius: 4px;
  padding: 0 5px;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--muted);
  min-width: 26px;
  min-height: 18px;
}
.admin-mlist-sort-btn:disabled { opacity: 0.3; cursor: default; }
.admin-mlist-sort-btn:not(:disabled):hover { background: var(--bg2); }
.admin-mlist-del-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 36px;
  min-width: 36px;
  flex-shrink: 0;
}
.admin-mlist-del-btn:hover { background: #fff0f0; color: #c0392b; border-color: #f5c6c6; }

/* Add row at bottom */
.admin-mlist-add-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, #b8d8f0);
  flex-shrink: 0;
}
.admin-mlist-add-row .admin-mlist-name-input {
  flex: 1;
  min-width: 120px;
}
.admin-mlist-add-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 5px 12px;
  min-height: 32px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #FF5D6C, #e04a58);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
  box-sizing: border-box;
  align-self: center;
}
.admin-mlist-add-btn:hover { opacity: 0.87; }
.admin-mlist-add-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* On very narrow screens, stack add-row inputs vertically */
@media (max-width: 400px) {
  .admin-mlist-add-row {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-mlist-add-row .admin-mlist-emoji-input { width: 100%; text-align: left; }
  .admin-mlist-add-row .admin-mlist-name-input  { width: 100%; }
  .admin-mlist-add-row .admin-mlist-category-input,
  .admin-mlist-add-row .admin-mlist-value-input  { width: 100% !important; }
  .admin-mlist-add-row .admin-mlist-add-btn { width: 100%; justify-content: center; }
}

/* Ensure the search-wrap add button never stretches full-width on any screen size */
.admin-mlist-search-wrap .admin-mlist-add-btn {
  width: auto !important;
  flex-shrink: 0;
}

/* ── Settings sub-panels (mirrors .sub-tab-panel) ── */
.settings-sub-panel { display: none; }
.settings-sub-panel.active { display: block; }

/* ── Community sub-panels ── */
.comm-sub-panel { display: none; }
.comm-sub-panel.active { display: block; }

/* ── Affiliates & Partners tab ─────────────────────────────────────────────── */

/* Status badges in the partners table */
.aff-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.aff-badge--live {
  background: rgba(34, 197, 94, 0.13);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.aff-badge--off {
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.aff-badge--warn {
  background: rgba(245, 158, 11, 0.13);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.aff-badge--primary {
  background: rgba(108, 60, 225, 0.1);
  color: var(--blue);
  border: 1px solid rgba(108, 60, 225, 0.25);
}

/* Order up/down buttons */
.aff-order-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}
.aff-order-btn {
  padding: 3px 7px !important;
  font-size: 0.8rem !important;
  min-width: 26px;
  line-height: 1.2;
}
.aff-order-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

/* Inline edit form */
.aff-edit-form {
  padding: 14px 16px;
  background: var(--bg2, #f3f4f6);
  border-top: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  animation: fadeInDown 0.14s ease;
}
.aff-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.aff-edit-field label {
  display: block;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.aff-edit-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card-bg, #fff);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.aff-edit-input:focus {
  outline: none;
  border-color: var(--blue);
}

/* Analytics bars */
.aff-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.aff-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
}
.aff-bar-label {
  width: 170px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.aff-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg2, #e8f4fd);
  border-radius: 5px;
  overflow: hidden;
  min-width: 60px;
}
.aff-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #8b5cf6);
  border-radius: 5px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.aff-bar-count {
  width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* Top destination chips */
.aff-dest-chip {
  display: inline-block;
  font-size: 0.82rem;
  padding: 2px 8px;
  background: var(--bg2, #f0f7ff);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  white-space: nowrap;
}

/* Responsive: collapse bar label on small screens */
@media (max-width: 540px) {
  .aff-bar-label { width: 100px; }
  .aff-edit-grid { grid-template-columns: 1fr; }
}

/* ── Nightly Test Scheduler UI ──────────────────────────────────────────────── */

/* Schedule banner */
.admin-tests-schedule-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg2, #f8faff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.82rem;
  transition: opacity 0.3s;
}
.admin-tests-schedule-banner--loading { opacity: 0.5; }

.atb-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 160px;
}
.atb-schedule { font-weight: 700; color: var(--text); }
.atb-next     { color: var(--muted); font-size: 0.78rem; }

.atb-status { flex: 2; min-width: 160px; }
.atb-status--ok   .atb-ok   { color: #16a34a; font-weight: 600; }
.atb-status--fail .atb-fail { color: #dc2626; font-weight: 600; }
.atb-status--fail .atb-ok   { color: #64748b; }
.atb-status--none { color: var(--muted); }
.atb-ago          { color: var(--muted); font-size: 0.78rem; margin-left: 4px; }

.atb-run-all-btn {
  background: var(--accent, #6C3CE1);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, opacity 0.2s;
}
.atb-run-all-btn:hover   { opacity: 0.88; }
.atb-run-all-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Per-test last-result badge */
.admin-test-last-badge {
  display: inline-block;
  font-size: 0.82rem;
  line-height: 1;
  vertical-align: middle;
  opacity: 0.7;
  cursor: default;
}
.admin-test-last-badge--pass { opacity: 0.75; }
.admin-test-last-badge--fail { opacity: 1; }

/* History timeline dots */
.admin-test-history-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  vertical-align: middle;
}
.admin-test-history-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  cursor: default;
}
.admin-test-history-dot--pass { background: #22c55e; }
.admin-test-history-dot--fail { background: #ef4444; }

/* History table */
.admin-tests-history-details summary { list-style: none; }
.admin-tests-history-details summary::-webkit-details-marker { display: none; }
.admin-tests-history-details summary::marker { display: none; }

.admin-tests-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.admin-tests-history-table th,
.admin-tests-history-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  text-align: left;
  white-space: nowrap;
  color: var(--text);
}
.admin-tests-history-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  background: var(--bg2, #f8faff);
}

/* Trigger badge */
.admin-test-trigger-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  text-transform: lowercase;
}
.admin-test-trigger-badge--scheduled {
  background: #e0f2fe; color: #0369a1;
}
.admin-test-trigger-badge--manual {
  background: #fef9c3; color: #854d0e;
}

@media (max-width: 560px) {
  .admin-tests-schedule-banner { flex-direction: column; align-items: flex-start; }
  .atb-run-all-btn { width: 100%; text-align: center; }
}

/* ── Sub-tab scroll-hint arrow ── */
.sub-tabs-scroll-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}
.sub-tabs-scroll-arrow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 2px; /* sit above the border-bottom of the bar */
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #64748b;
  background: linear-gradient(to right, transparent, #f8fafc 55%);
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 3;
}
.sub-tabs-scroll-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Skeleton loader shimmer ── */
@keyframes admin-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.admin-skeleton {
  background: linear-gradient(
    90deg,
    #e2e8f0 25%,
    #f1f5f9 50%,
    #e2e8f0 75%
  );
  background-size: 600px 100%;
  animation: admin-shimmer 1.4s infinite linear;
  border-radius: 6px;
}
.admin-skeleton-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.admin-skeleton-title {
  height: 14px;
  width: 40%;
  margin-bottom: 18px;
}
.admin-skeleton-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.admin-skeleton-kpi {
  flex: 1 1 110px;
  height: 72px;
  border-radius: 14px;
}
.admin-skeleton-bar {
  height: 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.admin-skeleton-bar:last-child { margin-bottom: 0; }
.admin-skeleton-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.admin-skeleton-grid-cell {
  height: 64px;
  border-radius: 10px;
}

/* ── Affiliate table: gear action button ── */
.aff-gear-btn {
  font-size: 1.1rem;
  padding: 6px 10px;
  line-height: 1;
  border-radius: 8px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.aff-gear-btn:hover {
  background: var(--bg2);
  border-color: var(--blue);
}

/* ── Affiliate table: hide non-essential columns on mobile ── */
@media (max-width: 640px) {
  .aff-col-hide-mobile {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   EQUITY TAB — SHARED FORM + BUTTON CLASSES
   (used by admin-equity.js, admin-referrals.js, admin-company.js etc.)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Ghost button (secondary, no fill) ── */
.admin-btn-ghost {
  padding: 7px 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--blue, #6C3CE1);
  border: 1px solid var(--border, #d4c6f8);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  touch-action: manipulation;
}
.admin-btn-ghost:hover {
  background: var(--bg2, #f2ecff);
  border-color: var(--blue, #6C3CE1);
}
.admin-btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Shared text/number/select/date input ── */
.admin-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 11px;
  border: 1px solid var(--border, #d4c6f8);
  border-radius: 8px;
  background: var(--card-bg, #fff);
  color: var(--text, #1A1025);
  /* ≥16px prevents iOS Safari auto-zoom on focus */
  font-size: max(16px, 0.87rem);
  font-family: inherit;
  transition: border-color 0.15s;
  touch-action: manipulation;
  min-width: 0;
}
.admin-input:focus {
  outline: none;
  border-color: var(--blue, #6C3CE1);
  box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.12);
}
.admin-input:disabled,
.admin-input[readonly] {
  opacity: 0.6;
  cursor: default;
}

/* ── Equity / referral form grid ── */
/* Already defined in admin-referrals.css but equity uses it too.
   This duplicate is safe — identical specificity, last-write wins. */
.ref-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  align-items: end;
}
.ref-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted, #4a3968);
  margin-bottom: 4px;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EQUITY TAB — MOBILE RESPONSIVENESS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dashboard: donut + pools grid → single column on mobile ── */
#eq-dashboard-body [style*="grid-template-columns:auto 1fr"] {
  /* Override the fixed auto+1fr to a responsive single column */
}

/* ── All equity tables: always scrollable ── */
#eq-captable-body .admin-table-wrap,
#eq-txns-body .admin-table-wrap,
#eq-valuation-body .admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
#eq-captable-body .admin-table {
  min-width: 780px; /* 9 columns */
}
#eq-txns-body .admin-table,
#eq-valuation-body .admin-table {
  min-width: 600px;
}

/* ── Equity form grids: 1-col on phones ── */
@media (max-width: 600px) {
  .ref-form-grid {
    grid-template-columns: 1fr;
  }

  /* Dashboard: donut + right-column stack vertically */
  #eq-dashboard-body [style*="grid-template-columns:auto 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  /* Donut card: don't force min-width on mobile */
  #eq-dashboard-body [style*="min-width:220px"] {
    min-width: 0 !important;
  }

  /* Pools grid: 2-col → 1-col */
  #eq-dashboard-body [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Valuation hero: numbers stack */
  #eq-valuation-body [style*="display:flex"][style*="gap:28px"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }
  #eq-valuation-body [style*="font-size:2.2rem"] {
    font-size: 1.6rem !important;
  }

  /* Cap table: hide less-important columns */
  #eq-captable-body .admin-table th:nth-child(6),
  #eq-captable-body .admin-table td:nth-child(6),
  #eq-captable-body .admin-table th:nth-child(7),
  #eq-captable-body .admin-table td:nth-child(7),
  #eq-captable-body .admin-table th:nth-child(8),
  #eq-captable-body .admin-table td:nth-child(8) {
    display: none;
  }

  /* Transactions table: hide From, Notes columns */
  #eq-txns-body .admin-table th:nth-child(3),
  #eq-txns-body .admin-table td:nth-child(3),
  #eq-txns-body .admin-table th:nth-child(8),
  #eq-txns-body .admin-table td:nth-child(8) {
    display: none;
  }

  /* Valuation history: hide Monthly Rev, ARR, Multiple */
  #eq-valuation-body .admin-table th:nth-child(3),
  #eq-valuation-body .admin-table td:nth-child(3),
  #eq-valuation-body .admin-table th:nth-child(4),
  #eq-valuation-body .admin-table td:nth-child(4),
  #eq-valuation-body .admin-table th:nth-child(5),
  #eq-valuation-body .admin-table td:nth-child(5) {
    display: none;
  }

  /* KPI cards: 2-per-row */
  #eq-dashboard-body [style*="grid-template-columns:repeat(auto-fit,minmax(160px,1fr))"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Toolbar action buttons: wrap nicely */
  #eq-captable-body [style*="display:flex"][style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
}

@media (max-width: 400px) {
  /* KPI cards: 1-col on very small phones */
  #eq-dashboard-body [style*="grid-template-columns:repeat(auto-fit,minmax(160px,1fr))"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Financials: hide secondary columns on very small screens ── */
@media (max-width: 480px) {
  .fin-col-hide-xs {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FINANCIALS TAB — MOBILE RESPONSIVENESS
   Covers: period bar, KPI cards, P&L table, sub-tabs, costs dashboard,
           unit economics, subscriptions table, modals (iOS safe)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Period selector bar ── */
#fin-period-bar {
  /* Allow horizontal scroll on very small screens instead of bleeding */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Ensure it never bleeds past the panel */
  max-width: 100%;
  box-sizing: border-box;
}
#fin-period-bar::-webkit-scrollbar { display: none; }

/* ── Financials KPI tiles (used in P&L, Subs, Unit Economics) ── */
.fin-kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.fin-kpi-tile {
  background: var(--surface2, #f8fafc);
  border-radius: 12px;
  padding: 16px 14px;
  text-align: center;
  flex: 1 1 120px;
  min-width: 0;
  box-sizing: border-box;
}

/* ── Financials tables: always allow horizontal scroll ── */
.fin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  width: 100%;
}
.fin-table-wrap table {
  min-width: 480px;
}

/* ── Costs dashboard: 2-col chart grid → 1-col on mobile ── */
.costs-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ── Modal base: iOS-safe positioning ── */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* Safe area padding for notched phones */
  padding: max(16px, env(safe-area-inset-top))
           max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom))
           max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow: hidden; /* backdrop itself does NOT scroll */
  /* Remove 300ms tap delay */
  touch-action: manipulation;
}
.admin-modal-sheet {
  background: var(--card-bg, #fff);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  /* Inner sheet scrolls, not the backdrop */
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.28);
  flex-shrink: 0;
  box-sizing: border-box;
}

/* ── Destination edit modal — self-contained, no overlay class dependency ── */
/* The modal uses display:none/block toggled by JS.
   The backdrop is the modal element itself (position:fixed;inset:0;overflow-y:auto).
   The inner sheet is a normal block element — no fixed height, scrolls with the backdrop. */
#dest-edit-modal {
  /* Ensure sub-tab bar inside the modal sticks correctly */
  position: fixed;
}
/* Sub-tab bar inside the modal: sticky relative to the modal's scroll container */
#dest-modal-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
}
/* All inputs/selects inside the edit modal: iOS zoom fix */
#dest-edit-modal input,
#dest-edit-modal select,
#dest-edit-modal textarea {
  font-size: max(16px, 0.87rem) !important;
  touch-action: manipulation;
}
/* Sub-tab bar: hide scrollbar */
#dest-modal-tabs::-webkit-scrollbar { display: none; }

/* ── All inputs/selects/textareas inside admin modals:
   font-size ≥ 16px prevents iOS Safari auto-zoom on focus ── */
.admin-modal-sheet input,
.admin-modal-sheet select,
.admin-modal-sheet textarea,
#cost-modal input,
#cost-modal select,
#cost-modal textarea,
#fin-historic-modal-backdrop input,
#fin-historic-modal-backdrop select,
#fin-historic-modal-backdrop textarea,
#dest-edit-modal input,
#dest-edit-modal select,
#dest-edit-modal textarea {
  font-size: max(16px, 0.87rem) !important;
  /* Remove 300ms tap delay on interactive elements */
  touch-action: manipulation;
}

/* ── Destination edit modal: sub-tab bar hides scrollbar ── */
#dest-modal-tabs::-webkit-scrollbar { display: none; }

/* ── Destination edit modal body: inputs full-width, comfortable spacing ── */
#dest-modal-body table {
  width: 100%;
  border-collapse: collapse;
}
#dest-modal-body td {
  padding: 6px 4px;
  vertical-align: top;
}
#dest-modal-body td:first-child {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding-right: 10px;
  width: 1%;
}

@media (max-width: 600px) {
  /* Destination edit modal: label + input stack vertically on mobile */
  #dest-modal-body table,
  #dest-modal-body tbody,
  #dest-modal-body tr,
  #dest-modal-body td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  #dest-modal-body td:first-child {
    padding-bottom: 2px;
    padding-right: 0;
    white-space: normal;
  }
  #dest-modal-body td:last-child {
    padding-bottom: 10px;
  }
  /* Modal sheet: full-height bottom sheet on mobile */
  #dest-edit-modal .admin-modal-sheet {
    border-radius: 14px 14px 0 0;
    max-height: calc(100dvh - 8px);
    margin-top: auto;
  }
  #dest-edit-modal.admin-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
}

/* ── Prevent iOS zoom on any admin form input ── */
#admin-overlay input[type="text"],
#admin-overlay input[type="number"],
#admin-overlay input[type="email"],
#admin-overlay input[type="date"],
#admin-overlay input[type="search"],
#admin-overlay select,
#admin-overlay textarea {
  font-size: max(16px, 0.87rem);
  touch-action: manipulation;
}

/* ── Historic period modal: 2-col grid → 1-col on small screens ── */
#fin-historic-modal-backdrop .fin-historic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {

  /* ── Admin body: tighter padding on phones (no top padding — sub-tabs flush) ── */
  .admin-body {
    padding: 0 10px 10px;
  }
  #admin-panel-overview.active,
  #admin-panel-fightfixer.active {
    padding-top: 12px;
  }

  /* ── Period bar: stack into a scrollable single row ── */
  #fin-period-bar {
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    padding: 8px 0 12px !important;
  }
  #fin-period-bar > div,
  #fin-period-bar > span {
    flex-shrink: 0;
  }

  /* ── KPI tiles: 2-per-row on phones ── */
  .fin-kpi-grid > div,
  #fin-pl-body   [style*="display:flex"][style*="flex-wrap:wrap"] > div,
  #fin-subs-body [style*="display:flex"][style*="flex-wrap:wrap"] > div,
  #fin-units-body [style*="display:flex"][style*="flex-wrap:wrap"] > div {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  /* ── P&L table: hide note column on very small screens ── */
  #fin-pl-body table td:first-child span[style*="color:var(--muted)"] {
    display: none;
  }

  /* ── Costs dashboard: chart grid → single column ── */
  .costs-chart-grid,
  #costs-dashboard-body [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Costs ledger table: hide less-important columns ── */
  #costs-ledger-body table th:nth-child(3),
  #costs-ledger-body table td:nth-child(3),
  #costs-ledger-body table th:nth-child(6),
  #costs-ledger-body table td:nth-child(6),
  #costs-ledger-body table th:nth-child(7),
  #costs-ledger-body table td:nth-child(7) {
    display: none;
  }

  /* ── Subscriptions plan table: hide slug column ── */
  #fin-subs-body table th:nth-child(2),
  #fin-subs-body table td:nth-child(2) {
    display: none;
  }

  /* ── Transactions table: hide type column ── */
  #fin-subs-body .fin-tx-table th:nth-child(3),
  #fin-subs-body .fin-tx-table td:nth-child(3) {
    display: none;
  }

  /* ── Unit economics: metric rows — value wraps below label ── */
  #fin-units-body [style*="display:flex"][style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
  #fin-units-body [style*="font-size:1.1rem"][style*="font-weight:800"] {
    font-size: 1rem !important;
    margin-left: 0 !important;
  }

  /* ── Cost modal: full-width on phones ── */
  #cost-modal {
    border-radius: 14px 14px 0 0 !important;
    max-height: calc(100dvh - 16px) !important;
  }
  #cost-modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* ── Historic period modal: 1-col grid ── */
  #fin-historic-modal-backdrop .fin-historic-grid,
  #fin-historic-modal-backdrop [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Admin header: hide back button text, keep icon ── */
  .admin-back-btn {
    padding: 7px 10px;
    font-size: 0.82rem;
  }

  /* ── Sub-tabs bar: ensure it scrolls, not wraps ── */
  .sub-tabs-bar {
    justify-content: flex-start;
  }
  .sub-tab {
    padding: 7px 11px;
    font-size: 0.78rem;
  }

  /* ── Admin card: tighter padding ── */
  .admin-card {
    padding: 14px 12px;
  }

  /* ── Costs AI comparison: 3-col → 1-col ── */
  #costs-dashboard-body [style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Costs KPI grid: 2-col on phones ── */
  #costs-dashboard-body [style*="grid-template-columns:repeat(auto-fill,minmax(200px,1fr))"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Cost breakdown KPI grid in P&L ── */
  #fin-pl-body [style*="grid-template-columns:repeat(auto-fill,minmax(180px,1fr))"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Subs grid: 2-col → 1-col ── */
  #fin-subs-body [style*="grid-template-columns:repeat(auto-fit,minmax(280px,1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Unit economics AI detail grid ── */
  #fin-units-body [style*="display:flex"][style*="flex-wrap:wrap"][style*="gap:10px"] > div {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }
}

@media (max-width: 400px) {
  /* ── Very small phones: KPI tiles go full-width ── */
  #fin-pl-body   [style*="display:flex"][style*="flex-wrap:wrap"] > div,
  #fin-subs-body [style*="display:flex"][style*="flex-wrap:wrap"] > div,
  #fin-units-body [style*="display:flex"][style*="flex-wrap:wrap"] > div {
    flex: 1 1 100%;
  }

  /* ── Costs KPI: 1-col ── */
  #costs-dashboard-body [style*="grid-template-columns:repeat(auto-fill,minmax(200px,1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Period bar buttons: smaller text ── */
  #fin-period-bar button {
    font-size: 0.72rem !important;
    padding: 4px 9px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ENHANCEMENTS TAB — MOBILE RESPONSIVENESS
   Covers: sub-tab bar, Location Focus section, schedule banner,
           enhancement cards (card header, button cluster, log area),
           all inputs/selects (iOS 16px zoom fix), iOS 300ms tap delay.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Enhancements sub-tab bar: scroll-hint wrapper (mirrors Community tab) ── */
#enh-tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

/* ── Enhancement card: outer wrapper ── */
.enh-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 10px 12px;
  margin-bottom: 0;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  position: relative;
  box-shadow: 0 8px 26px rgba(41, 31, 39, 0.06);
  transition: border-color .16s, box-shadow .16s;
}
.enh-card--expanded {
  border-color: rgba(108,60,225,.3);
  box-shadow: 0 12px 32px rgba(41,31,39,.09);
}

/* Compact pipeline card: identity, count, primary action, disclosure. */
.enh-card-compact-row {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto auto;
  align-items: center;
  gap: 10px;
}
.enh-card-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.enh-card-identity .enh-card-title {
  overflow: hidden;
  text-overflow: ellipsis;
}
.enh-card-chevron {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border,#e2e8f0);
  border-radius: 13px;
  background: var(--bg2,#f8fafc);
  color: var(--muted,#64748b);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .16s, background .16s, color .16s;
}
.enh-card--expanded .enh-card-chevron {
  transform: rotate(180deg);
  background: #f5f3ff;
  color: #5b21b6;
}
.enh-card-detail-body {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--border,#e2e8f0);
  border-radius: 13px;
  background: var(--bg2,#f8fafc);
}
.enh-card-detail-body[hidden],
.enh-log--store { display: none !important; }
.enh-card-description {
  margin: 0 0 10px;
  color: var(--muted,#64748b);
  font-size: .8rem;
  line-height: 1.5;
}
.enh-card-meta-row,
.enh-card-run-options,
.enh-corrector-settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.enh-card-meta-row {
  margin-bottom: 10px;
  color: var(--muted,#64748b);
  font-size: .73rem;
}
.enh-card-meta-row .enh-last-badge { margin-left: auto; }
.enh-card-run-options {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border,#e2e8f0);
}
.enh-card-run-options > label {
  color: var(--muted,#64748b);
  font-size: .74rem;
  font-weight: 700;
}
.enh-card-text-btn,
.enh-show-log-btn {
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  background: #f5f3ff;
  color: #5b21b6;
  font-size: .75rem;
  font-weight: 750;
  cursor: pointer;
}
.enh-card-text-btn { min-height: 30px; margin-left: auto; }
.enh-corrector-settings-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border,#e2e8f0);
}
#admin-corr-list {
  display: grid !important;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px !important;
}

/* ── ⓘ Info button — top-right corner ── */
.enh-info-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: 1.5px solid #ddd6fe;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
  color: #7c3aed;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
  z-index: 2;
}
.enh-info-btn:hover {
  background: #ede9fe;
  color: #5b21b6;
}

/* ── Info popover ── */
.enh-info-popover {
  position: absolute;
  top: 40px;
  right: 10px;
  z-index: 100;
  background: #fff;
  border: 1.5px solid #ddd6fe;
  border-radius: 10px;
  padding: 12px 14px;
  max-width: min(320px, calc(100vw - 32px));
  box-shadow: 0 4px 20px rgba(108,60,225,0.13);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text, #1e293b);
}
.enh-info-popover-text {
  color: var(--muted, #64748b);
}
.enh-info-ai-note {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: #7c3aed;
  font-style: italic;
}
.enh-info-sched {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--muted, #64748b);
  opacity: 0.8;
  border-top: 1px solid #ede9fe;
  padding-top: 6px;
}

/* ── Card header row: emoji + title ── */
.enh-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 36px; /* leave room for ⓘ button */
  margin-bottom: 10px;
}

.enh-card-emoji {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.enh-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text, #1e293b);
  line-height: 1.3;
}

/* ── Run row: Run btn + loop select + run count + badge + result + cancel ── */
.enh-card-run-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* Run count pill */
.enh-run-count {
  font-size: 0.72rem;
  color: var(--muted, #64748b);
  background: var(--bg2, #f3f4f6);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
  font-weight: 600;
}

/* Last-run badge */
.enh-last-badge {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.enh-last-badge--none {
  font-size: 0.8rem;
  color: var(--muted, #94a3b8);
}

/* Loop count select */
.enh-loop-select {
  background: #f5f3ff;
  border: 1.5px solid #ddd6fe;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: max(16px, 0.8rem);
  font-weight: 700;
  color: #5b21b6;
  cursor: pointer;
  outline: none;
  min-height: 36px;
  touch-action: manipulation;
}

/* Run button — icon-only, compact */
.enh-run-btn {
  background: #6c3ce1;
  color: #fff;
  border: none;
  border-radius: 13px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  min-height: 42px;
  min-width: 78px;
  line-height: 1;
  transition: background 0.2s;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.enh-run-btn:hover    { background: #5b21b6; }
.enh-run-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Cancel button */
.enh-cancel-btn {
  display: none;
  padding: 5px 10px;
  font-size: 0.78rem;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
  align-items: center;
  gap: 4px;
}

/* Result span */
.enh-result-span {
  font-size: 0.72rem;
  min-width: 0;
}

/* ── Controls row: Auto toggle + Email toggle ── */
.enh-card-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

/* Toggle buttons — base */
.enh-toggle-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 20px;
  border: 1.5px solid;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
  min-height: 30px;
}
/* Auto: ON */
.enh-toggle-btn--on {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}
.enh-toggle-btn--on:hover { background: #dcfce7; }
/* Auto: OFF — red */
.enh-toggle-btn--off {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}
.enh-toggle-btn--off:hover { background: #fee2e2; }
/* Auto: override (individual ON, global OFF) */
.enh-toggle-btn--override {
  background: #fefce8;
  border-color: #fde68a;
  color: #92400e;
}
/* Email: ON */
.enh-toggle-btn--email-on {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}
.enh-toggle-btn--email-on:hover { background: #ede9fe; }
/* Email: OFF — red */
.enh-toggle-btn--email-off {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}
.enh-toggle-btn--email-off:hover { background: #fee2e2; }
/* Email: override */
.enh-toggle-btn--email-override {
  background: #fefce8;
  border-color: #fde68a;
  color: #92400e;
}

/* ── Latest Results collapsible ── */
.enh-results-details {
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border, #e2e8f0);
}

.enh-results-summary {
  cursor: pointer;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #5b21b6;
  background: #f5f3ff;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.enh-results-summary::-webkit-details-marker { display: none; }
.enh-results-summary::before {
  content: '▶';
  font-size: 0.6rem;
  transition: transform 0.2s;
  display: inline-block;
}
.enh-results-details[open] .enh-results-summary::before {
  transform: rotate(90deg);
}
.enh-results-details[open] .enh-results-summary {
  border-bottom: 1px solid #ddd6fe;
}

/* ── Enhancement card: log area (inside the details) ── */
.enh-log {
  font-family: monospace;
  font-size: 0.77rem;
  background: var(--bg2, #f3f4f6);
  padding: 10px 12px;
  line-height: 1.65;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 420px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  word-break: break-all;
  max-width: 100%;
  box-sizing: border-box;
}

/* Current log modal — logs stay out of cards and remain available on demand. */
.enh-log-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(22,18,28,.46);
  backdrop-filter: blur(5px);
}
.enh-log-modal-shell {
  width: min(760px,calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border,#e2e8f0);
  border-radius: 30px;
  background: var(--card-bg,#fff);
  box-shadow: -16px 28px 80px rgba(35,22,32,.28),0 4px 18px rgba(35,22,32,.1);
}
.enh-log-modal-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  color: #fff;
  background: linear-gradient(135deg,#23164d,#5b21b6 58%,#8b5cf6);
}
.enh-log-modal-header h3 { margin: 3px 0 0; color: #fff; font-size: 1.05rem; }
.enh-log-modal-eyebrow { font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.enh-log-modal-close {
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 13px;
  background: rgba(255,255,255,.14);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.enh-log-modal-body { min-height: 0; padding: 14px; overflow: hidden; }
.enh-log--modal {
  max-height: calc(100dvh - 145px);
  min-height: 240px;
  border: 1px solid var(--border,#e2e8f0);
  border-radius: 15px;
  word-break: break-word;
}
.enh-log-empty { color: var(--muted,#64748b); font-family: inherit; text-align: center; padding: 42px 16px; }
.enh-log-section-title { position:sticky;top:0;margin:0 0 7px;padding:7px 9px;border-radius:8px;background:var(--card-bg,#fff);color:var(--muted,#64748b);font:800 .68rem/1.2 inherit;text-transform:uppercase;letter-spacing:.06em;z-index:1; }

/* ── Header summary bar (history dots + schedule + last run + More pill) ── */
.enh-hour-summary {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto auto;
  align-items: center;
  gap: 11px;
  margin: 0 0 12px;
  padding: 11px 14px;
  border: 1px solid rgba(108,60,225,.2);
  border-radius: 13px;
  background: linear-gradient(135deg,#faf8ff,#f5f3ff);
  color: var(--text,#1e293b);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(76,29,149,.06);
}
.enh-hour-summary:hover { border-color:rgba(108,60,225,.45); transform:translateY(-1px); }
.enh-hour-summary:disabled { opacity:.65; cursor:wait; transform:none; }
.enh-hour-summary-icon { width:37px;height:37px;border-radius:11px;display:grid;place-items:center;background:#6c3ce1;color:#fff;font-size:1.15rem; }
.enh-hour-summary-copy { display:flex;flex-direction:column;min-width:0;gap:2px; }
.enh-hour-summary-eyebrow { font-size:.62rem;text-transform:uppercase;letter-spacing:.1em;color:#7c3aed;font-weight:800; }
.enh-hour-summary-copy strong { font-size:.92rem; }
.enh-hour-summary-period { font-size:.72rem;color:var(--muted,#64748b);white-space:nowrap; }
.enh-hour-summary-arrow { color:#6c3ce1;font-size:1.5rem;line-height:1; }

.enh-hour-modal-backdrop { position:fixed;inset:0;z-index:100300;background:rgba(15,23,42,.64);display:grid;place-items:center;padding:16px;backdrop-filter:blur(5px); }
.enh-hour-modal { width:min(620px,100%);max-height:min(76dvh,680px);display:flex;flex-direction:column;overflow:hidden;border-radius:18px;background:var(--card-bg,#fff);box-shadow:0 28px 80px rgba(15,23,42,.3); }
.enh-hour-modal-head { display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:17px 18px;background:linear-gradient(135deg,#23164d,#6c3ce1);color:#fff; }
.enh-hour-modal-head span { font-size:.62rem;font-weight:800;text-transform:uppercase;letter-spacing:.11em;opacity:.74; }
.enh-hour-modal-head h3 { color:#fff;margin:3px 0;font-size:1.08rem; }
.enh-hour-modal-head p { margin:0;font-size:.72rem;opacity:.8; }
.enh-hour-modal-head button { width:42px;height:42px;border:1px solid rgba(255,255,255,.3);border-radius:12px;background:rgba(255,255,255,.13);color:#fff;cursor:pointer; }
.enh-hour-modal-body { overflow:auto;padding:12px;display:flex;flex-direction:column;gap:8px; }
.enh-hour-row { display:flex;justify-content:space-between;gap:14px;padding:11px 12px;border:1px solid var(--border,#e2e8f0);border-radius:11px;background:var(--bg,#f8fafc); }
.enh-hour-row-main,.enh-hour-row-count { display:flex;flex-direction:column;gap:3px;min-width:0; }
.enh-hour-row-main strong { font-size:.82rem; }
.enh-hour-row-main span,.enh-hour-row-count span { color:var(--muted,#64748b);font-size:.68rem; }
.enh-hour-row-count { text-align:right;flex:none; }
.enh-hour-row-count strong { color:#6c3ce1;font-size:1rem; }
.enh-hour-empty { padding:38px 15px;text-align:center;color:var(--muted,#64748b);font-size:.82rem; }

.enh-focus-state { display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin:0 0 10px;padding:7px 9px;border-radius:9px;background:#f5f3ff;color:#5b21b6;font-size:.68rem; }
.enh-focus-state[hidden] { display:none; }
.enh-focus-state > span:last-child { margin-left:auto;color:var(--muted,#64748b); }
.enh-focus-state[data-stage="fallback"] { background:#fff7ed;color:#c2410c; }
.enh-focus-state[data-stage="default"] { background:#f1f5f9;color:#475569; }
.enh-focus-state[data-stage="global-only"] { background:#eff6ff;color:#1d4ed8; }

.enh-header-summary {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-sizing: border-box;
}

/* History dots bar — shown at top of summary once loaded */
.enh-history-dots-bar {
  display: none; /* shown by JS once dots are ready */
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.enh-history-dots-label {
  font-size: 0.72rem;
  color: var(--muted, #94a3b8);
  font-weight: 600;
  white-space: nowrap;
}

.enh-header-summary-basic {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted, #64748b);
}

.enh-next-run-inline {
  font-size: 0.78rem;
  color: #7c3aed;
  font-weight: 600;
}

/* "More ▾" pill button */
.enh-more-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #5b21b6;
  background: #ede9fe;
  border: 1.5px solid #ddd6fe;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 0.15s;
  margin-left: auto; /* push to right of flex row */
}
.enh-more-pill:hover { background: #ddd6fe; }

.enh-header-more-body {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted, #64748b);
  line-height: 1.6;
  border-top: 1px solid var(--border, #e2e8f0);
  padding-top: 10px;
}
.enh-header-more-body p { margin: 0 0 6px; }
.enh-header-more-body ul { margin: 0 0 6px; padding-left: 18px; }
.enh-header-more-body li { margin-bottom: 4px; }
.enh-header-more-body code {
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
}

/* ── Run All bar ── */
.enh-run-all-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.enh-run-all-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Run All + loop select always on the same line, no wrap */
.enh-run-all-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.enh-run-all-right {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Location Focus collapsible ── */
.enh-focus-details {
  margin-bottom: 12px;
  border: 1.5px solid #ddd6fe;
  border-radius: 10px;
  overflow: hidden;
  box-sizing: border-box;
}

.enh-focus-summary {
  cursor: pointer;
  padding: 9px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #5b21b6;
  background: #f5f3ff;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.enh-focus-summary::-webkit-details-marker { display: none; }
.enh-focus-summary::before {
  content: '▶';
  font-size: 0.55rem;
  transition: transform 0.2s;
  display: inline-block;
}
.enh-focus-details[open] .enh-focus-summary::before {
  transform: rotate(90deg);
}
.enh-focus-details[open] .enh-focus-summary {
  border-bottom: 1.5px solid #ddd6fe;
}

/* ── Location Focus section (inside the details) ── */
.enh-focus-section {
  padding: 12px 14px;
  background: #f5f3ff;
  box-sizing: border-box;
}

.enh-focus-section.active {
  background: #ede9fe;
}

.enh-focus-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #5b21b6;
  margin-bottom: 8px;
}

/* Row 1: text input + Set Focus + Clear */
.enh-focus-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.enh-focus-input {
  flex: 1;
  min-width: 160px;
  padding: 6px 10px;
  border: 1.5px solid #ddd6fe;
  border-radius: 8px;
  /* ≥16px: no iOS zoom */
  font-size: max(16px, 0.83rem);
  outline: none;
  background: #fff;
  box-sizing: border-box;
  touch-action: manipulation;
}

.enh-focus-set-btn {
  background: #6c3ce1;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.enh-focus-clear-btn {
  display: none;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

/* Row 2: auto-enhancer checkbox + duration select */
.enh-focus-row2 {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.enh-focus-auto-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.79rem;
  font-weight: 700;
  color: #5b21b6;
  user-select: none;
}

.enh-focus-auto-chk {
  width: 18px;
  height: 18px;
  accent-color: #6c3ce1;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}

.enh-focus-duration-sel {
  background: #fff;
  border: 1.5px solid #ddd6fe;
  border-radius: 8px;
  padding: 4px 10px;
  /* ≥16px: no iOS zoom */
  font-size: max(16px, 0.79rem);
  font-weight: 600;
  color: #5b21b6;
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
}

.enh-focus-auto-clear-btn {
  display: none;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 4px 11px;
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.enh-focus-status {
  margin-top: 7px;
  font-size: 0.75rem;
  color: #78716c;
}

.enh-focus-auto-status {
  margin-top: 3px;
  font-size: 0.74rem;
  color: #78716c;
  display: none;
}

/* ── Schedule banner: button cluster ── */
.enh-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Loop-all select in banner */
.enh-loop-all-select {
  background: #f5f3ff;
  border: 1.5px solid #ddd6fe;
  border-radius: 8px;
  padding: 5px 10px;
  /* ≥16px: no iOS zoom */
  font-size: max(16px, 0.82rem);
  font-weight: 700;
  color: #5b21b6;
  cursor: pointer;
  outline: none;
  min-height: 36px;
  touch-action: manipulation;
}

/* Cancel-all button */
.enh-cancel-all-btn {
  display: none;
  padding: 7px 12px;
  font-size: 0.82rem;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
}

/* Scheduler toggle button */
.enh-scheduler-toggle-btn {
  padding: 7px 10px;
  font-size: 0.82rem;
  border: 1.5px solid #86efac;
  background: #f0fdf4;
  color: #166534;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
}

/* Email toggle button */
.enh-email-toggle-btn {
  padding: 7px 10px;
  font-size: 0.82rem;
  border: 1.5px solid #ddd6fe;
  background: #f5f3ff;
  color: #5b21b6;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
}

/* ── All inputs/selects inside the Enhancements panel: iOS zoom fix ── */
#admin-panel-enhancements input[type="text"],
#admin-panel-enhancements input[type="number"],
#admin-panel-enhancements input[type="search"],
#admin-panel-enhancements select,
#admin-panel-enhancements textarea {
  font-size: max(16px, 0.85rem);
  touch-action: manipulation;
}

/* ── All buttons inside the Enhancements panel: iOS 300ms fix ── */
#admin-panel-enhancements button,
#admin-panel-enhancements input[type="checkbox"],
#admin-panel-enhancements input[type="radio"] {
  touch-action: manipulation;
}

/* ── Enhancements panel: prevent any child from bleeding past the panel ── */
#admin-panel-enhancements {
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

#enhtab-enhancers .admin-card {
  /* Override the max-width:760px inline style on mobile */
  box-sizing: border-box;
  width: 100%;
  padding-bottom: 24px;
}

/* ── Mobile breakpoints for Enhancements ── */
@media (max-width: 600px) {
  .enh-hour-summary { grid-template-columns:auto minmax(0,1fr) auto; }
  .enh-hour-summary-period { grid-column:2;white-space:normal; }
  .enh-hour-summary-arrow { grid-column:3;grid-row:1 / span 2; }
  .enh-hour-modal-backdrop { padding:0; }
  .enh-hour-modal { width:100%;height:100dvh;max-height:none;border-radius:0; }
  .enh-hour-row { align-items:flex-start; }
  .enh-hour-row-count span { max-width:145px; }

  /* Card: tighter padding */
  .enh-card {
    padding: 9px;
  }

  .enh-card-compact-row {
    grid-template-columns: minmax(0,1fr) auto auto;
    gap: 7px;
  }
  .enh-card-compact-row .enh-run-count {
    grid-column: 1;
    justify-self: start;
    margin-left: 42px;
    margin-top: -8px;
  }
  .enh-card-compact-row .enh-run-btn { grid-column: 2; grid-row: 1 / span 2; }
  .enh-card-compact-row .enh-card-chevron { grid-column: 3; grid-row: 1 / span 2; }
  #admin-corr-list { grid-template-columns: 1fr; }
  .enh-card-detail-body { padding: 11px; }
  .enh-log-modal-backdrop { padding: 0; }
  .enh-log-modal-shell { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .enh-log--modal { max-height: calc(100dvh - 125px); height: 100%; }

  /* Run row: tighter gap */
  .enh-card-run-row {
    gap: 6px;
  }

  /* Controls row: tighter gap */
  .enh-card-controls-row {
    gap: 6px;
  }

  /* Toggle buttons: slightly smaller */
  .enh-toggle-btn {
    font-size: 0.72rem;
    padding: 3px 8px;
  }

  /* Loop select: don't shrink too small */
  .enh-loop-select {
    min-width: 64px;
  }

  /* Run button: slightly smaller padding */
  .enh-run-btn {
    padding: 7px 14px;
  }

  /* Location Focus: input takes full width */
  .enh-focus-input {
    min-width: 0;
    width: 100%;
    flex-basis: 100%;
  }

  /* Schedule banner: stack vertically */
  #admin-enh-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .enh-banner-actions {
    width: 100%;
  }

  /* Run-all button: full width */
  #admin-enh-run-all-btn {
    width: 100%;
    text-align: center;
  }

  /* Scheduler + email toggles: side by side */
  .enh-scheduler-toggle-btn,
  .enh-email-toggle-btn {
    flex: 1;
    text-align: center;
  }

  /* Info popover: full-width on small screens */
  .enh-info-popover {
    right: 4px;
    left: 4px;
    max-width: none;
  }

  /* History table: hide less-important columns */
  #admin-enh-history-wrap .admin-tests-history-table th:nth-child(3),
  #admin-enh-history-wrap .admin-tests-history-table td:nth-child(3),
  #admin-enh-history-wrap .admin-tests-history-table th:nth-child(5),
  #admin-enh-history-wrap .admin-tests-history-table td:nth-child(5),
  #admin-enh-history-wrap .admin-tests-history-table th:nth-child(6),
  #admin-enh-history-wrap .admin-tests-history-table td:nth-child(6) {
    display: none;
  }
}

@media (max-width: 400px) {
  /* Very small phones: run button stretches */
  .enh-card-run-row {
    justify-content: flex-start;
  }
  .enh-run-btn {
    flex: 1;
    min-width: 80px;
  }
  /* Controls row: each toggle takes half */
  .enh-toggle-btn {
    flex: 1;
    text-align: center;
  }
}

/* ── Events tab: gear action button ── */
.evt-gear-btn {
  background: none;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted, #64748b);
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.evt-gear-btn:hover {
  background: var(--bg2, #f1f5f9);
  border-color: var(--blue, #6C3CE1);
}

/* ── Events tab: gear popover menu ── */
.evt-gear-menu {
  position: absolute;
  right: 0;
  top: calc(100% - 4px);
  z-index: 500;
  min-width: 140px;
  background: var(--card-bg, #fff);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
  animation: adminMenuFadeIn 0.12s ease;
}
.evt-gear-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text, #0a2540);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
  touch-action: manipulation;
}
.evt-gear-item:hover {
  background: var(--bg2, #f8fafc);
}
.evt-gear-item--danger {
  color: #dc2626;
}
.evt-gear-item--danger:hover {
  background: rgba(220, 38, 38, 0.07);
}
.evt-gear-divider {
  height: 1px;
  background: var(--border, #e2e8f0);
  margin: 2px 0;
}

/* ── Events table: hide Risk, Type, Months on mobile ── */
/* evt-dest-inline: destination key shown inside the Event cell on mobile only */
.evt-dest-inline { display: none; }

@media (max-width: 640px) {
  .evt-col-risk,
  .evt-col-type,
  .evt-col-months,
  .evt-col-dest {
    display: none;
  }
  /* Show the inline destination label inside the Event cell */
  .evt-dest-inline {
    display: block;
  }
}

/* ── Sub-tabs: centre on desktop for panels with few tabs ────────────────────
   Panels with only 3–4 tabs sit awkwardly at the left edge on wide screens.
   Centre them above 680px. On mobile the bars scroll horizontally (flex-start).
   Scoped to specific panels so Settings, Community, API Gateways etc. (which
   have many more items and need to scroll) are unaffected.

   Note: _initSubTabsArrows() dynamically wraps every .sub-tabs-bar in a
   .sub-tabs-scroll-wrap div at runtime, so the bar is no longer a direct child
   of the panel. We target both the wrapper and the bar with descendant selectors.
──────────────────────────────────────────────────────────────────────────── */
@media (min-width: 681px) {
  /* Enhancements: ✈️ Destinations · 📅 Events · ✨ Enhancers */
  #enh-tabs-bar,
  /* Analytics: 🏦 Monetisation · 📊 Trends · 📉 Churn */
  #admin-panel-analytics .sub-tabs-bar,
  /* Financials: 📈 P&L · 💳 Subscriptions · 💰 Costs · 📐 Unit Economics */
  #admin-panel-financials .sub-tabs-bar,
  /* Company: 🏢 Details · 📣 Marketing · ⚙️ Operational · 📈 Equity */
  #admin-panel-company .sub-tabs-bar {
    justify-content: center;
  }
}

/* ── Corrector inner tabs (🔧 Correctors · ⚙️ Settings) ── */
.corr-inner-tab {
  padding: 7px 20px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #64748b);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.corr-inner-tab:hover {
  background: rgba(108, 60, 225, 0.08);
  color: var(--primary, #6c3ce1);
}

.corr-inner-tab--active {
  background: var(--primary, #6c3ce1);
  color: #fff !important;
}

.corr-inner-tab--active:hover {
  background: #5b2fd4;
}
/* ── User protection / blocking intelligence ─────────────────────────────── */
.admin-user-protection-summary { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;margin:10px 0 14px; }
.admin-user-protection-summary > div { padding:11px 9px;border:1px solid color-mix(in srgb,var(--border,#dce4ed) 78%,#dc2626 22%);border-radius:12px;background:color-mix(in srgb,var(--card-bg,#fff) 95%,#dc2626 5%);text-align:center; }
.admin-user-protection-summary strong { display:block;color:#b91c1c;font-size:1.18rem;line-height:1.1; }
.admin-user-protection-summary span { display:block;margin-top:4px;color:var(--muted,#64748b);font-size:.65rem;font-weight:750;text-transform:uppercase;letter-spacing:.04em; }
.admin-block-details { min-width:145px; }
.admin-block-details summary { display:flex;align-items:center;gap:6px;color:#b91c1c;font-size:.72rem;font-weight:800;cursor:pointer;list-style:none; }
.admin-block-details summary::-webkit-details-marker { display:none; }
.admin-block-count { min-width:23px;height:23px;display:inline-grid;place-items:center;border-radius:8px;background:#fee2e2;color:#b91c1c;font-size:.7rem; }
.admin-block-details.repeat summary { color:#fff;padding:5px 7px;border-radius:9px;background:#b91c1c; }
.admin-block-details.repeat .admin-block-count { background:#fff;color:#b91c1c; }
.admin-block-reasons { display:grid;gap:5px;margin-top:7px;padding:8px;border:1px solid #fecaca;border-radius:10px;background:#fff7f7; }
.admin-block-reasons > div { display:flex;flex-direction:column;gap:2px;color:#7f1d1d;font-size:.68rem;line-height:1.35; }
.admin-block-reasons span { color:var(--muted,#64748b);overflow-wrap:anywhere; }
.admin-protection-clear { color:#15803d;font-size:.7rem;font-weight:700; }
.admin-blocks-made { display:block;margin-top:4px;color:var(--muted,#64748b);font-size:.63rem; }
@media(max-width:700px) { .admin-user-protection-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } }
/* Settings → Celebrations: exact visual preview of the personal occasion reveal. */
.admin-occasion-preview{position:fixed;inset:0;z-index:1000200;display:grid;place-items:center;padding:16px;overflow:hidden;background:radial-gradient(circle at 50% 20%,#6645dc 0,#201247 45%,#080c23 100%);backdrop-filter:blur(13px);opacity:0;transition:opacity .22s}.admin-occasion-preview.is-open{opacity:1}.admin-occasion-preview-sky{position:absolute;inset:0;overflow:hidden;pointer-events:none}.admin-occasion-preview-card{position:relative;width:min(560px,calc(100% - 30px));box-sizing:border-box;padding:28px;text-align:center;border:1px solid rgba(255,255,255,.65);border-radius:28px;background:radial-gradient(circle at 50% 0,rgba(255,230,130,.45),transparent 33%),linear-gradient(155deg,#fffdf5,#f3edff 65%,#dff6ff);color:#202238;box-shadow:0 30px 90px rgba(8,12,35,.38)}.admin-occasion-preview-close{position:absolute;right:15px;top:15px;width:38px;height:38px;border:1px solid rgba(60,45,110,.16);border-radius:50%;background:rgba(255,255,255,.8);color:#40345f;font-size:1.5rem;cursor:pointer}.admin-occasion-preview-logo{width:115px;height:115px;object-fit:contain;filter:drop-shadow(0 12px 20px rgba(75,45,150,.28));animation:adminOccasionLogo 1.5s cubic-bezier(.2,.8,.2,1)}.admin-occasion-preview-card>p{color:#6c3ce1;font-size:.72rem;font-weight:900;text-transform:uppercase;letter-spacing:.08em}.admin-occasion-preview-card h2{margin:5px 0;font-size:clamp(2rem,8vw,3.6rem);background:linear-gradient(120deg,#e3488d,#7042df,#1688cb);-webkit-background-clip:text;color:transparent}.admin-occasion-preview-card blockquote{margin:18px 0;padding:18px;border-radius:20px;background:rgba(255,255,255,.68);font-size:1.05rem;line-height:1.55;font-weight:650}.admin-occasion-preview-audio{display:flex;justify-content:center;align-items:center;gap:10px;margin:12px 0;color:#6c3ce1;font-size:.72rem;font-weight:850}.admin-occasion-preview-audio button{border:0;border-radius:999px;padding:9px 13px;background:#6c3ce1;color:#fff;font-weight:800;cursor:pointer}.admin-occasion-preview-from{margin:16px 0;color:#625c70}.admin-occasion-preview-finish{width:100%;border:0;border-radius:16px;padding:13px;background:linear-gradient(135deg,#6c3ce1,#177fca);color:#fff;font-weight:850;cursor:pointer}.admin-occasion-logo-confetti{position:absolute;top:-12%;left:var(--x);width:25px;height:25px;object-fit:contain;animation:adminOccasionConfetti 4.5s linear var(--delay) forwards}@keyframes adminOccasionConfetti{to{transform:translate(var(--drift),120vh) rotate(var(--spin));opacity:.12}}@keyframes adminOccasionLogo{0%{transform:scale(.2) rotate(-20deg);opacity:0}70%{transform:scale(1.12) rotate(4deg)}100%{transform:scale(1)}}@media(prefers-reduced-motion:reduce){.admin-occasion-preview,.admin-occasion-preview-logo,.admin-occasion-logo-confetti{animation:none!important;transition:none!important}}
