/* ── Theme tokens ── */
:root,
[data-theme="light"] {
  --bg: #f8f9fc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f3f5f9;
  --surface-raised: #f0f2f7;
  --border: #e2e6ef;
  --border-subtle: #edf0f5;
  --accent: #76ABAE;
  --accent-hover: #5f9498;
  --accent-muted: rgba(118, 171, 174, 0.12);
  --accent-light: rgba(118, 171, 174, 0.2);
  --accent2: #76ABAE;
  --accent2-muted: rgba(118, 171, 174, 0.12);
  --danger: #e74c3c;
  --danger-muted: rgba(231, 76, 60, 0.08);
  --warning: #f39c12;
  --success: #00b894;
  --success-muted: rgba(0, 184, 148, 0.08);
  --text: #1a1d26;
  --text-secondary: #4a5068;
  --muted: #7c829d;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --header-h: 64px;
  --input-h: 2.5rem;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
  --transition: 0.2s ease;
  --focus-ring: 0 0 0 3px rgba(108, 92, 231, 0.25);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-elevated: #181b25;
  --surface: #1e2230;
  --surface-hover: #262b3a;
  --surface-raised: #2a3042;
  --border: #2d3348;
  --border-subtle: #232839;
  --accent: #76ABAE;
  --accent-hover: #8fc0c3;
  --accent-muted: rgba(118, 171, 174, 0.16);
  --accent-light: rgba(118, 171, 174, 0.22);
  --accent2: #76ABAE;
  --accent2-muted: rgba(118, 171, 174, 0.16);
  --danger: #f87171;
  --danger-muted: rgba(248, 113, 113, 0.1);
  --warning: #fbbf24;
  --success: #34d399;
  --success-muted: rgba(52, 211, 153, 0.1);
  --text: #f1f3f9;
  --text-secondary: #a3aabe;
  --muted: #6b7394;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --focus-ring: 0 0 0 3px rgba(167, 139, 250, 0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body.app-body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── App shell — topbar only layout ── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.app-topbar {
  height: 64px;
  min-height: 64px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  padding: 0 24px;
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

/* Brand */
.topbar-brand {
  display: flex !important;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-right: 24px;
  flex-shrink: 0;
}
.topbar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.topbar-brand-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #76ABAE;
}
.topbar-brand-text span {
  color: #76ABAE;
}

/* Navigation links */
.topbar-nav {
  display: flex !important;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.topbar-nav-item {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: -0.01em;
  border: 1.5px solid transparent;
}
.topbar-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}
.topbar-nav-item:hover {
  color: var(--accent);
  background: var(--accent-muted);
  border-color: rgba(108, 92, 231, 0.15);
  transform: translateY(-1px);
}
.topbar-nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, #76ABAE 0%, #5f9498 100%);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.35), 0 2px 6px rgba(108, 92, 231, 0.2);
  transform: translateY(-1px);
}

/* Right section */
.topbar-right {
  margin-left: auto;
  display: flex !important;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding: 6px 12px;
  background: var(--surface-hover);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

/* Theme toggle — plain ball slider */
.theme-toggle {
  width: 44px;
  height: 24px;
  display: inline-flex !important;
  align-items: center;
  border: none;
  border-radius: 50px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  flex-shrink: 0;
  padding: 0;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
[data-theme="dark"] .theme-toggle {
  background: #475569;
}
.theme-toggle:hover {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 0 3px rgba(118, 171, 174, 0.2);
}
.theme-toggle-track {
  width: 100%;
  height: 100%;
  position: relative;
}
.theme-toggle-track::before,
.theme-toggle-track::after { display: none; content: none; }
.theme-toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: absolute;
  left: 3px;
  top: 3px;
}
.theme-toggle-thumb::before,
.theme-toggle-thumb::after { display: none; content: none; }
[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(20px);
}

/* User pill */
.topbar-user {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 50px;
  background: var(--surface-hover);
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.topbar-user:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.12);
}
.topbar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #76ABAE, #5f9498);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.topbar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.topbar-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 50px;
  background: rgba(243, 156, 18, 0.12);
  color: #e67e22;
  border: 1px solid rgba(243, 156, 18, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Logout button */
.topbar-logout-btn {
  width: 36px;
  height: 36px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(238, 90, 36, 0.25);
}
.topbar-logout-btn:hover {
  transform: scale(1.12) rotate(-5deg);
  box-shadow: 0 6px 18px rgba(238, 90, 36, 0.4);
}
.topbar-logout-btn svg {
  width: 16px;
  height: 16px;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #76ABAE, #5f9498);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(108, 92, 231, 0.3);
}
.mobile-menu-btn:hover {
  transform: scale(1.05);
}
.mobile-menu-btn.is-active {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  box-shadow: 0 3px 10px rgba(231, 76, 60, 0.3);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .app-topbar {
    padding: 0 16px;
    gap: 6px;
  }
  .topbar-brand { margin-right: 8px; }
  .topbar-brand-text { display: none; }
  .topbar-nav {
    display: none !important;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    z-index: 100;
    gap: 4px;
  }
  .topbar-nav.is-open {
    display: flex !important;
  }
  .topbar-nav-item {
    padding: 12px 16px;
  }
  .topbar-user { display: none !important; }
  .topbar-time { display: none !important; }
  .mobile-menu-btn { display: flex !important; }
}

/* ── Main area ── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.app-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

body.app-body:not(.dashboard-page) .app-content {
  max-width: 1800px;
  margin: 0 auto;
}

/* ── Dashboard ── */
.dashboard-hero {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.dashboard-hero-compact { padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.dashboard-hero h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.3rem;
}
.dashboard-hero p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 34rem;
  line-height: 1.55;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--input-h);
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.25);
}
.btn-cta:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
  transform: translateY(-1px);
  color: #fff;
}
.btn-cta:active { transform: translateY(0) scale(0.98); }
.btn-cta:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-cta svg { width: 16px; height: 16px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  min-height: var(--input-h);
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }

.quick-scrape {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.quick-scrape .section-eyebrow {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.quick-scrape .quick-scrape-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.quick-scrape-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
}
.quick-scrape-form input[type="url"],
.quick-scrape-form input[type="text"] {
  flex: 1;
  min-height: var(--input-h);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 0.9rem;
  outline: none;
  transition: all var(--transition);
}
.quick-scrape-form input::placeholder { color: var(--muted); }
.quick-scrape-form input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.quick-scrape-form .btn-cta { flex-shrink: 0; min-width: 9rem; }
@media (max-width: 540px) {
  .quick-scrape-form { flex-wrap: wrap; }
  .quick-scrape-form input, .quick-scrape-form .btn-cta { width: 100%; flex: 1 1 100%; }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-card.highlight { border-left: 3px solid var(--accent); }
.stat-card .stat-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.3rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.stat-card .stat-value.accent { color: var(--accent); }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 0.92rem; font-weight: 700; }
.panel-head p { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table th, .data-table td { padding: 0.75rem 1.15rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table thead { background: var(--surface-raised); }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-hover); }
.data-table .cell-muted { color: var(--muted); }

.badge-mp { font-size: 0.68rem; padding: 0.2rem 0.5rem; border-radius: 99px; background: var(--accent-muted); color: var(--accent); font-weight: 500; }
.empty-state-box { text-align: center; padding: 3rem 1.5rem; color: var(--muted); font-size: 0.85rem; line-height: 1.7; }

.btn-sm {
  font-size: 0.78rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-muted); }
.actions-row { display: flex; gap: 0.4rem; flex-wrap: nowrap; justify-content: flex-end; }

/* ── Users & Forms ── */
.form-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  max-width: 26rem;
  box-shadow: var(--shadow-sm);
}
.form-card-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; }
.form-card label { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem; }
.form-card input[type="text"],
.form-card input[type="password"] {
  width: 100%; min-height: var(--input-h); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.85rem; padding: 0 0.85rem; margin-bottom: 0.85rem; outline: none; transition: all var(--transition);
}
.form-card input::placeholder { color: var(--muted); }
.form-card input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.form-msg { font-size: 0.8rem; margin-bottom: 0.75rem; min-height: 1.2rem; }
.form-msg.ok { color: var(--success); }
.form-msg.err { color: var(--danger); }
.badge-admin { font-size: 0.6rem; padding: 0.15rem 0.4rem; border-radius: 99px; background: rgba(243, 156, 18, 0.1); border: 1px solid rgba(243, 156, 18, 0.3); color: var(--warning); font-weight: 600; }
.badge-user { font-size: 0.6rem; padding: 0.15rem 0.4rem; border-radius: 99px; background: var(--surface-raised); border: 1px solid var(--border); color: var(--muted); }

.role-select {
  font-size: 0.8rem; padding: 0.38rem 0.55rem; border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; min-width: 6.5rem; transition: all var(--transition);
}
.role-select:hover:not(:disabled) { border-color: var(--accent); }
.role-select:disabled { opacity: 0.5; cursor: not-allowed; }

.user-name-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-name-input {
  min-width: 8rem;
  max-width: 14rem;
  font-size: 0.85rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.user-name-input[readonly] {
  background: transparent;
  border-color: transparent;
  padding-left: 0;
  cursor: default;
}

.user-name-input.is-editing {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  padding-left: 0.55rem;
  cursor: text;
}

.user-name-input:disabled {
  opacity: 0.65;
}

.user-name-edit-btn {
  flex-shrink: 0;
}

/* ── Modals ── */
.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(22rem, 100%); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--shadow-lg); }
.modal.modal-wide { width: min(56rem, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.modal h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.modal p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 1rem; }
.modal-input {
  width: 100%;
  min-height: var(--input-h);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 0.85rem;
  margin-bottom: 0.85rem;
  outline: none;
  transition: all var(--transition);
}
.modal-input::placeholder { color: var(--muted); }
.modal-input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.modal-combobox-wrap { position: relative; margin-bottom: 0.85rem; }
.modal-combobox { position: relative; display: flex; align-items: center; }
.modal-combobox-input {
  width: 100%;
  min-height: 2.6rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.62rem 2.1rem 0.62rem 0.9rem;
  outline: none;
  transition: all var(--transition);
}
.modal-combobox-input:focus {
  border-color: #6c5ce7;
  box-shadow: 0 0 0 4px rgba(108,92,231,0.14);
  background: #fff;
}
.modal-combobox-input::placeholder { color: var(--muted); }
.modal-combobox-chevron {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.modal-combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 210;
  margin-top: 3px;
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid #d7deea;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15,23,42,0.14);
  padding: 3px;
  list-style: none;
}
.modal-combobox-list[hidden] { display: none; }
.modal-combobox-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  list-style: none;
}
.modal-combobox-list li::marker { content: ""; }
.modal-combobox-list li:hover { background: rgba(108, 92, 231, 0.08); }
.modal-combobox-list li.active { background: rgba(108, 92, 231, 0.12); font-weight: 600; }
.modal-combobox-list li.highlighted { background: rgba(108, 92, 231, 0.14); }
.combobox-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
#dash-map-category-modal .modal {
  width: min(24rem, 96vw);
  border-radius: 14px;
  padding: 1.4rem 1.45rem 1.25rem;
}
#dash-map-category-modal .modal h2 {
  font-size: 1.05rem;
  margin-bottom: 0.45rem;
}
#dash-map-category-modal .modal p {
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}
#dash-map-category-modal .modal-combobox-wrap {
  margin-bottom: 1rem;
}
#dash-map-category-modal .modal-combobox-input {
  min-height: 2.75rem;
  font-size: 0.95rem;
}
#dash-map-category-modal .modal-combobox-chevron {
  pointer-events: auto;
  cursor: pointer;
}
#dash-map-category-modal .modal-combobox-list {
  max-height: 230px;
}
#dash-map-category-modal .modal-combobox-list li {
  font-size: 0.95rem;
  padding: 0.56rem 0.72rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.btn-modal { font-size: 0.8rem; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); cursor: pointer; transition: all var(--transition); font-weight: 500; }
.btn-modal:hover { border-color: var(--accent); color: var(--accent); }
.btn-modal-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-modal-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-modal-danger { border-color: var(--danger); color: var(--danger); }
.btn-modal-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-modal:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-modal.is-loading { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; }
.modal.is-busy .btn-modal:not(.is-loading) { pointer-events: none; }
.btn-spinner { display: inline-block; width: 0.85rem; height: 0.85rem; margin-right: 0.35rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; flex-shrink: 0; }
.btn-spinner[hidden] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-preview-body { flex: 1; min-height: 12rem; max-height: min(70vh, 560px); overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 1rem; padding: 0.75rem; display: flex; align-items: center; justify-content: center; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin-bottom: 0.8rem; }
.compare-pane h4 { margin: 0 0 0.35rem; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.compare-preview { min-height: 13rem; max-height: 50vh; margin-bottom: 0; }
.compare-sb-image { width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.compare-similarity { margin: 0.75rem 0 0.5rem; font-size: 0.85rem; font-weight: 700; color: var(--accent); }
.compare-code-wrap { display: flex; flex-direction: column; min-height: 0; }
.compare-code-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: 0.1rem 0 0.35rem; }
.compare-code-wrap h4 { margin: 0.1rem 0 0.35rem; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.compare-code-head h4 { margin: 0; }
.compare-copy-btn { flex-shrink: 0; }
.compare-copy-btn.is-success { border-color: var(--success); color: var(--success); background: var(--success-muted); }
.compare-copy-btn.is-error { border-color: var(--danger); color: var(--danger); background: var(--danger-muted); }
.compare-code { margin: 0 0 1rem; max-height: 9rem; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0.6rem; font-size: 0.72rem; line-height: 1.45; color: var(--text); white-space: pre; word-break: normal; overflow-wrap: normal; }
.compare-sb-actions { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; gap: 0.6rem; align-items: center; margin-bottom: 0.85rem; }
.compare-sb-label { font-size: 0.78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.compare-sb-input { min-height: 2.2rem; margin-bottom: 0; }
.compare-sb-action-buttons { display: inline-flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.compare-sb-code-stack { display: grid; gap: 0.8rem; margin-top: 0.35rem; }
.compare-sb-code-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; align-items: stretch; }
.compare-sb-code-pair .compare-code-wrap { min-height: 0; }
.compare-sb-code-pair .compare-code { flex: 0 0 auto; height: 40vh; min-height: 40vh; max-height: 40vh; overflow: auto; margin-bottom: 0; }
.compare-sb-explain { margin-bottom: 0.7rem; color: var(--text-secondary); font-size: 0.84rem; line-height: 1.45; background: var(--surface-hover); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 0.55rem 0.65rem; }
.compare-sb-debug-wrap { margin-top: -0.45rem; }
.compare-sb-debug-wrap summary { cursor: pointer; color: var(--muted); font-size: 0.74rem; margin-bottom: 0.35rem; }
.compare-sb-debug { max-height: min(24vh, 15rem); margin-top: 0.35rem; }

body.compare-sb-page .compare-sb-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  margin-bottom: 0;
}
body.compare-sb-page .compare-sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
body.compare-sb-page .compare-sb-head h3 { font-size: 1rem; }
body.compare-sb-page .compare-sb-head p { color: var(--muted); font-size: 0.82rem; }
body.compare-sb-page .compare-preview {
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: auto;
  display: block;
  width: 100%;
  height: 40vh;
  min-height: 40vh;
  max-height: 40vh;
  padding: 0;
  position: relative;
  cursor: grab;
  touch-action: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body.compare-sb-page .compare-preview::-webkit-scrollbar {
  display: none;
}
body.compare-sb-page .compare-pane {
  min-width: 0;
}
body.compare-sb-page .compare-sb-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  align-items: start;
}
body.compare-sb-page .compare-preview-wrap {
  position: relative;
  width: 100%;
}
body.compare-sb-page .compare-preview.is-dragging {
  cursor: grabbing;
}
body.compare-sb-page.compare-is-dragging,
body.compare-sb-page.compare-is-dragging * {
  user-select: none;
}
body.compare-sb-page .compare-preview-controls {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 3;
  display: inline-flex;
  gap: 0.35rem;
}
body.compare-sb-page .compare-preview-zoom-btn {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, #fff 8%);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}
body.compare-sb-page .compare-preview-zoom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
body.compare-sb-page .compare-preview .compare-preview-canvas {
  min-width: 100%;
  min-height: 100%;
  width: max-content;
  height: max-content;
  display: grid;
  place-items: center;
}
body.compare-sb-page .compare-preview .compare-preview-stage {
  flex: 0 0 auto;
}
body.compare-sb-page .compare-preview .compare-preview-stage > svg,
body.compare-sb-page .compare-preview .compare-preview-stage > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
body.compare-sb-page .compare-code {
  overflow: auto;
}

/* ── Scrape page layout ── */
body.app-body.scrape-page { display: block; height: 100%; min-height: 100vh; overflow: hidden; }
body.scrape-page .app-shell { min-height: 100vh; height: 100vh; }
body.scrape-page .app-main { flex: 1; min-height: 0; overflow: hidden; }
body.scrape-page .app-content {
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100% !important;
  max-width: none !important;
}
body.scrape-page .scrape-workspace { flex: 1; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
body.scrape-page .scrape-workspace > main {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
body.scrape-page .scrape-workspace > main > .preview-panel { min-height: 0; height: 100%; }
body.scrape-page .app-topbar { flex-shrink: 0; }

/* ── Login ── */
body.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--bg); }
.login-card { width: 100%; max-width: 22rem; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 1.75rem; box-shadow: var(--shadow-lg); }
.login-card .brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.5rem; }
.login-card h1 { font-size: 1.25rem; font-weight: 800; color: var(--accent); }
.login-card h1 span { color: var(--accent2); }
.login-card .sub { font-size: 0.82rem; color: var(--muted); margin-bottom: 1.5rem; }
.login-card label { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.3rem; }
.login-card input { width: 100%; min-height: var(--input-h); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.88rem; padding: 0 0.85rem; margin-bottom: 1rem; outline: none; transition: all var(--transition); }
.login-card input::placeholder { color: var(--muted); }
.login-card input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.login-card .err { font-size: 0.8rem; color: var(--danger); margin-bottom: 0.75rem; }
.login-card button[type="submit"] { width: 100%; font-weight: 600; font-size: 0.9rem; padding: 0.7rem; border: none; border-radius: var(--radius-sm); background: var(--accent); color: #fff; cursor: pointer; transition: all var(--transition); box-shadow: 0 2px 8px rgba(108, 92, 231, 0.25); }
.login-card button[type="submit"]:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3); transform: translateY(-1px); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
.table-scroll { overflow-x: auto; }

/* Accordion (marketplace) */
.marketplace-accordion { border-bottom: 1px solid var(--border); }
.marketplace-accordion:last-child { border-bottom: none; }
.marketplace-accordion > summary { list-style: none; display: flex; align-items: center; padding: 0.85rem 1.15rem; cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--text); background: var(--surface-raised); transition: background var(--transition); }
.marketplace-accordion > summary:hover { background: var(--surface-hover); }
.marketplace-accordion > summary::-webkit-details-marker { display: none; }
.marketplace-accordion[open] > summary { border-bottom: 1px solid var(--border); }
.marketplace-accordion-count { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 0.78rem; }

@media (max-width: 900px) {
  .app-content { padding: 1rem; }
  body.scrape-page .scrape-workspace > main { grid-template-columns: 1fr; }
}

/* ── Dashboard redesign (scoped, theme-aware) ── */

:root, [data-theme="light"] {
  --dash-bg-card: #ffffff;
  --dash-bg-card-end: #f6f9ff;
  --dash-bg-hero: linear-gradient(135deg, #f0fafa 0%, #ffffff 50%, #f4f7ff 100%);
  --dash-border: #d8e3f0;
  --dash-border-accent: rgba(118, 171, 174, 0.35);
  --dash-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --dash-shadow-hover: 0 12px 32px rgba(118, 171, 174, 0.18);
  --dash-glow: rgba(118, 171, 174, 0.12);
  --dash-thead: #f3f6fc;
  --dash-row-hover: #f6fafa;
  --dash-input-bg: #ffffff;
  --dash-input-border: #d0daea;
  --dash-badge-bg: #e8f4f4;
  --dash-badge-border: #c2dede;
  --dash-toggle-bg: #eaf3f3;
  --dash-toggle-border: #c6dede;
  --dash-btn-bg: #ffffff;
  --dash-btn-border: #d0daea;
  --dash-highlight-bg: linear-gradient(135deg, #e8f5f5 0%, #f0fafa 100%);
  --dash-stat-icon-bg: rgba(118, 171, 174, 0.1);
}

[data-theme="dark"] {
  --dash-bg-card: #1a1f2e;
  --dash-bg-card-end: #1e2333;
  --dash-bg-hero: linear-gradient(135deg, #141825 0%, #1a2030 50%, #161b28 100%);
  --dash-border: #2a3145;
  --dash-border-accent: rgba(118, 171, 174, 0.3);
  --dash-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --dash-shadow-hover: 0 12px 32px rgba(118, 171, 174, 0.12);
  --dash-glow: rgba(118, 171, 174, 0.08);
  --dash-thead: #1e2436;
  --dash-row-hover: #1f2638;
  --dash-input-bg: #151923;
  --dash-input-border: #2a3145;
  --dash-badge-bg: rgba(118, 171, 174, 0.12);
  --dash-badge-border: rgba(118, 171, 174, 0.25);
  --dash-toggle-bg: rgba(118, 171, 174, 0.1);
  --dash-toggle-border: rgba(118, 171, 174, 0.25);
  --dash-btn-bg: #1e2333;
  --dash-btn-border: #2a3145;
  --dash-highlight-bg: linear-gradient(135deg, rgba(118, 171, 174, 0.08) 0%, rgba(118, 171, 174, 0.04) 100%);
  --dash-stat-icon-bg: rgba(118, 171, 174, 0.08);
}

body.app-body.dashboard-page .app-content {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 1.65rem 2rem 2rem !important;
}

/* ── Hero ── */
body.dashboard-page .dashboard-hero {
  position: relative;
  overflow: hidden;
  background: var(--dash-bg-hero);
  border: 1px solid var(--dash-border);
  border-radius: 20px;
  box-shadow: var(--dash-shadow);
  padding: 2rem 1.75rem;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

body.dashboard-page .dashboard-hero::before {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--dash-glow) 0%, transparent 70%);
  pointer-events: none;
}

body.dashboard-page .dashboard-hero::after {
  content: "";
  position: absolute;
  left: -40px;
  bottom: -80px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--dash-glow) 0%, transparent 70%);
  pointer-events: none;
}

body.dashboard-page .dashboard-hero h2 {
  font-size: clamp(1.5rem, 2.6vw, 1.85rem);
  line-height: 1.2;
  margin-bottom: 0.5rem;
  color: var(--text);
}
body.dashboard-page .dashboard-hero h2 span {
  color: var(--accent);
}

body.dashboard-page h1,
body.dashboard-page h2,
body.dashboard-page h3,
body.dashboard-page .panel-head h3 {
  color: var(--text);
}

body.dashboard-page .dashboard-hero p {
  font-size: 0.9rem;
  max-width: 44rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── CTA Button ── */
body.dashboard-page .btn-cta {
  border-radius: 12px;
  min-height: 2.65rem;
  padding: 0 1.4rem;
  background: linear-gradient(135deg, #76ABAE 0%, #5a9a9e 100%);
  box-shadow: 0 6px 20px rgba(118, 171, 174, 0.3);
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dashboard-page .btn-cta:hover {
  background: linear-gradient(135deg, #6a9fa2 0%, #4e8e92 100%);
  box-shadow: 0 10px 28px rgba(118, 171, 174, 0.38);
  transform: translateY(-2px);
}

/* ── Stats Grid ── */
body.dashboard-page .stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.85rem;
}

body.dashboard-page .stat-card {
  border: 1px solid var(--dash-border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--dash-bg-card) 0%, var(--dash-bg-card-end) 100%);
  box-shadow: var(--dash-shadow);
  padding: 1.1rem 1.1rem 1rem;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dashboard-page .stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.3s ease;
}

body.dashboard-page .stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--dash-border-accent);
  box-shadow: var(--dash-shadow-hover);
}

body.dashboard-page .stat-card:hover::before {
  background: linear-gradient(90deg, var(--accent), transparent);
}

body.dashboard-page .stat-card.highlight {
  border-left: none;
  background: var(--dash-highlight-bg);
  box-shadow: var(--dash-shadow-hover);
}

body.dashboard-page .stat-card.highlight::before {
  background: linear-gradient(90deg, var(--accent), transparent);
}

body.dashboard-page .dashboard-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

body.dashboard-page .dashboard-hero-logos {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

body.dashboard-page .dashboard-hero-logo {
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

body.dashboard-page .dashboard-hero-logo--seatgpt {
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

body.dashboard-page .dashboard-hero-logo--bext {
  height: 32px;
  width: auto;
}

body.dashboard-page .stat-card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

body.dashboard-page .stat-site-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

body.dashboard-page .stat-site-logo--wordmark {
  width: auto;
  max-width: 4.5rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

[data-theme="dark"] body.dashboard-page .stat-site-logo:not(.stat-site-logo--wordmark) {
  background: rgba(255, 255, 255, 0.08);
}

body.dashboard-page .stat-card .stat-label {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  margin-bottom: 0;
}

body.dashboard-page .stat-card .stat-value {
  font-size: 1.85rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text);
}

body.dashboard-page .stat-card .stat-value.accent {
  color: var(--accent);
}

/* ── Panels ── */
body.dashboard-page .panel {
  border-radius: 16px;
  border: 1px solid var(--dash-border);
  box-shadow: var(--dash-shadow);
  overflow: hidden;
  transition: border-color 0.3s ease;
}

body.dashboard-page .panel-head {
  padding: 1.15rem 1.3rem;
  background: linear-gradient(180deg, var(--dash-bg-card) 0%, var(--dash-bg-card-end) 100%);
  border-bottom: 1px solid var(--dash-border);
}

body.dashboard-page .panel-head h3 {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}

body.dashboard-page .panel-head p {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Accordion */
body.dashboard-page .panel-accordion-summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  border-bottom: none;
}
body.dashboard-page .panel-accordion[open] > .panel-accordion-summary {
  border-bottom: 1px solid var(--dash-border);
}
body.dashboard-page .panel-accordion-summary::-webkit-details-marker { display: none; }
body.dashboard-page .panel-accordion-summary::after { display: none; }

body.dashboard-page .panel-accordion-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

body.dashboard-page .panel-accordion-toggle {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--dash-toggle-bg);
  border: 1px solid var(--dash-toggle-border);
  color: var(--accent);
  transition: all 0.2s ease;
}
body.dashboard-page .panel-accordion-toggle svg {
  transition: transform 0.25s ease;
}
body.dashboard-page .panel-accordion-summary:hover .panel-accordion-toggle {
  background: var(--accent-muted);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(118, 171, 174, 0.2);
}
body.dashboard-page .panel-accordion[open] .panel-accordion-toggle svg {
  transform: rotate(180deg);
}

/* ── Buttons ── */
body.dashboard-page .btn-sm {
  border-radius: 10px;
  min-height: 2rem;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--dash-btn-border);
  background: var(--dash-btn-bg);
  color: var(--accent);
  font-weight: 600;
  transition: all 0.2s ease;
}

body.dashboard-page .btn-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(118, 171, 174, 0.15);
}

body.dashboard-page .btn-sm.danger {
  color: var(--danger);
}

body.dashboard-page .btn-sm.danger:hover {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
  box-shadow: 0 3px 10px rgba(231, 76, 60, 0.2);
}

/* ── Data Table ── */
body.dashboard-page .data-table {
  font-size: 0.85rem;
  table-layout: auto;
}

body.dashboard-page .data-table thead {
  background: var(--dash-thead);
}

body.dashboard-page .data-table th,
body.dashboard-page .data-table td {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--dash-border);
}

body.dashboard-page .data-table th {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
}

body.dashboard-page .data-table tbody tr {
  transition: background 0.15s ease;
}

body.dashboard-page .data-table tbody tr:hover td {
  background: var(--dash-row-hover);
}

body.dashboard-page .data-table th:nth-child(2),
body.dashboard-page .data-table td:nth-child(2) {
  min-width: 220px;
}

body.dashboard-page .data-table th:last-child,
body.dashboard-page .data-table td:last-child {
  width: 240px;
  min-width: 240px;
  text-align: right;
}

/* ── Badges ── */
body.dashboard-page .badge-mp {
  background: var(--dash-badge-bg);
  color: var(--accent);
  border: 1px solid var(--dash-badge-border);
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
}

body.dashboard-page .data-table th:nth-child(3),
body.dashboard-page .cell-marketplace {
  min-width: 9.5rem;
  text-align: left;
  vertical-align: middle;
}

body.dashboard-page .mp-table-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

body.dashboard-page .mp-table-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

body.dashboard-page .mp-table-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0.15rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

body.dashboard-page .mp-table-icon img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

body.dashboard-page .mp-table-icon--wordmark {
  min-width: 3.5rem;
  padding: 0.2rem 0.35rem;
  background: transparent;
  box-shadow: none;
}

body.dashboard-page .mp-table-icon--wordmark img {
  width: auto;
  max-width: 3.75rem;
  height: 1.15rem;
}

[data-theme="dark"] body.dashboard-page .mp-table-icon:not(.mp-table-icon--wordmark) {
  background: rgba(255, 255, 255, 0.08);
}

body.dashboard-page .actions-row {
  gap: 0.35rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

body.dashboard-page .btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: unset;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--dash-btn-border);
  background: var(--dash-btn-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

body.dashboard-page .btn-icon-only:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(118,171,174,0.15);
}

body.dashboard-page .btn-icon-only.danger:hover {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
  box-shadow: 0 3px 10px rgba(231,76,60,0.2);
}

body.dashboard-page .btn-icon-only.copied {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-muted);
}

body.dashboard-page .btn-icon-only svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

body.dashboard-page .maps-count-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid rgba(118,171,174,0.25);
  margin-left: 0.4rem;
  vertical-align: middle;
}

body.dashboard-page .maps-panel-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body.dashboard-page .map-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
}

body.dashboard-page .map-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dashboard-page .sb-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--dash-badge-border);
  background: var(--dash-badge-bg);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.dashboard-page .sb-inline-btn:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
  transform: translateY(-1px);
}

body.dashboard-page .sb-inline-btn.is-synced {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}

body.dashboard-page .sb-inline-btn.is-unsynced {
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: color-mix(in srgb, var(--warning) 78%, var(--text));
}

body.dashboard-page .sb-sync-state {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0 0.42rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  border: 1px solid var(--border-subtle);
}

body.dashboard-page .sb-sync-state.is-synced {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 11%, transparent);
  border-color: color-mix(in srgb, var(--success) 30%, var(--border-subtle));
}

body.dashboard-page .sb-sync-state.is-unsynced {
  color: color-mix(in srgb, var(--warning) 80%, var(--text));
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border-subtle));
}

body.dashboard-page .empty-state-box {
  padding: 3.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

body.dashboard-page .maps-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1rem 0.2rem;
}

body.dashboard-page .maps-page-size {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

body.dashboard-page .maps-page-size select {
  min-height: 2rem;
  border-radius: 9px;
  border: 1px solid var(--dash-btn-border);
  background: var(--dash-btn-bg);
  color: var(--text);
  padding: 0.2rem 0.45rem;
}

body.dashboard-page .maps-pagination .btn-sm {
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
}

body.dashboard-page .maps-pagination-indicator {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 7rem;
  text-align: center;
}

/* ── Marketplace accordion dark fix ── */
body.dashboard-page .marketplace-accordion > summary {
  background: var(--dash-thead);
  color: var(--text);
  border-bottom: 1px solid var(--dash-border);
}
body.dashboard-page .marketplace-accordion > summary:hover {
  background: var(--dash-row-hover);
}
body.dashboard-page .marketplace-accordion[open] > summary {
  border-bottom: 1px solid var(--dash-border);
}

/* ── Filter bar v2 (dropdown + search) ── */
body.dashboard-page .filter-bar-v2 {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

body.dashboard-page .filter-bar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

body.dashboard-page .filter-dropdown-wrap {
  position: relative;
  flex-shrink: 0;
}

body.dashboard-page .filter-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.65rem;
  padding: 0 1.1rem;
  border-radius: 12px;
  border: 1.5px solid var(--dash-border);
  background: linear-gradient(180deg, var(--dash-bg-card) 0%, var(--dash-bg-card-end) 100%);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: var(--dash-shadow);
}

body.dashboard-page .filter-dropdown-btn:hover,
body.dashboard-page .filter-dropdown-btn.open {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(118,171,174,0.18);
}

body.dashboard-page .filter-dropdown-btn .filter-chevron {
  transition: transform 0.25s ease;
  opacity: 0.5;
}

body.dashboard-page .filter-dropdown-btn.open .filter-chevron {
  transform: rotate(180deg);
  opacity: 1;
  color: var(--accent);
}

body.dashboard-page .filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  max-height: 340px;
  background: var(--dash-bg-card);
  border: 1.5px solid var(--dash-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.dashboard-page .filter-dropdown-menu[hidden] { display: none; }

body.dashboard-page .filter-dropdown-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--dash-border);
}

body.dashboard-page .filter-dropdown-search svg {
  flex-shrink: 0;
  color: var(--muted);
}

body.dashboard-page .filter-dropdown-search input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  min-width: 0;
}

body.dashboard-page .filter-dropdown-search input::placeholder {
  color: var(--muted);
}

body.dashboard-page .filter-dropdown-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem;
}

body.dashboard-page .filter-dropdown-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--dash-border);
}

body.dashboard-page .filter-dd-action {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--dash-border);
  background: var(--dash-btn-bg);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s ease;
}

body.dashboard-page .filter-dd-action:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
}

body.dashboard-page .filter-dropdown-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

body.dashboard-page .filter-dropdown-check:hover {
  background: var(--accent-muted);
}

body.dashboard-page .filter-dropdown-check.checked {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
}

body.dashboard-page .filter-dropdown-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

body.dashboard-page .filter-check-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dashboard-page .filter-selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

body.dashboard-page .filter-selected-tags:empty {
  display: none;
}

body.dashboard-page .filter-sel-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid rgba(118,171,174,0.25);
}

body.dashboard-page .filter-sel-tag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

body.dashboard-page .filter-sel-tag-x:hover {
  background: var(--accent);
  color: #fff;
}

body.dashboard-page .filter-sel-tag-mp {
  background: rgba(108, 92, 231, 0.1);
  color: #6c5ce7;
  border-color: rgba(108, 92, 231, 0.25);
}

[data-theme="dark"] body.dashboard-page .filter-sel-tag-mp {
  background: rgba(167, 139, 250, 0.12);
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.25);
}

body.dashboard-page .filter-sel-tag-mp .filter-sel-tag-x:hover {
  background: #6c5ce7;
}

[data-theme="dark"] body.dashboard-page .filter-sel-tag-mp .filter-sel-tag-x:hover {
  background: #a78bfa;
}

body.dashboard-page .filter-dropdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

body.dashboard-page .filter-dropdown-count {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-raised);
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  min-width: 1.4rem;
  text-align: center;
}

body.dashboard-page .filter-dropdown-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

body.dashboard-page .filter-search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.65rem;
  padding: 0 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--dash-border);
  background: linear-gradient(180deg, var(--dash-bg-card) 0%, var(--dash-bg-card-end) 100%);
  box-shadow: var(--dash-shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.dashboard-page .filter-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(118,171,174,0.15);
}

body.dashboard-page .filter-search-box svg {
  flex-shrink: 0;
  color: var(--muted);
}

body.dashboard-page .filter-search-box input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  min-width: 0;
}

body.dashboard-page .filter-search-box input::placeholder {
  color: var(--muted);
}

@media (max-width: 640px) {
  body.dashboard-page .filter-bar-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  body.dashboard-page .filter-dropdown-wrap {
    width: 100%;
  }
  body.dashboard-page .filter-dropdown-btn {
    width: 100%;
    justify-content: space-between;
  }
  body.dashboard-page .filter-dropdown-menu {
    width: 100%;
  }
  body.dashboard-page .filter-search-box {
    width: 100%;
    flex: unset;
  }
}

/* ── Category config page ── */
body.category-config-page .app-content {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 1.65rem 2rem 2rem !important;
}

body.category-config-page .category-config-panel {
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--dash-border) 75%, transparent);
  box-shadow: 0 16px 32px rgba(7, 15, 30, 0.12);
  overflow: hidden;
}

body.category-config-page .cc-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) repeat(3, minmax(150px, 1fr)) auto;
  gap: 0.9rem;
  padding: 1.1rem 1.25rem 1rem;
  border-bottom: 1px solid var(--dash-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated) 92%, #6bb5b8 8%), var(--bg-elevated));
}

body.category-config-page .cc-search-box {
  min-height: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.85rem;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--dash-border) 70%);
  background: color-mix(in srgb, var(--dash-input-bg) 86%, #ffffff 14%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 8px 20px rgba(22, 61, 93, 0.08);
}

body.category-config-page .cc-search-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 72%, #ffffff 28%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), 0 10px 24px rgba(14, 42, 68, 0.16);
}

body.category-config-page .cc-search-box svg {
  width: 18px;
  height: 18px;
  color: color-mix(in srgb, var(--text) 55%, var(--accent) 45%);
}

body.category-config-page .cc-search-box input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

body.category-config-page .cc-search-box input::placeholder {
  color: color-mix(in srgb, var(--muted) 75%, #a7c9cc 25%);
  font-weight: 500;
}

body.category-config-page .cc-select {
  min-height: 3rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--dash-border) 80%, #8ec8cd 20%);
  background: color-mix(in srgb, var(--dash-btn-bg) 88%, #ffffff 12%);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
}

body.category-config-page .cc-create-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.9rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--dash-border);
  background: color-mix(in srgb, var(--dash-input-bg) 76%, transparent);
}

body.category-config-page .cc-create-row .modal-input {
  margin-bottom: 0;
}

body.category-config-page .cc-name-input {
  width: 100%;
  min-height: 2rem;
  border: 1px solid var(--dash-border);
  border-radius: 8px;
  background: var(--dash-input-bg);
  color: var(--text);
  padding: 0 0.55rem;
  transition: border-color .18s ease, box-shadow .18s ease;
}

body.category-config-page .cc-name-input[readonly] {
  opacity: 0.82;
  cursor: default;
}

body.category-config-page .cc-name-input.is-editing {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 62%, #ffffff 38%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

body.category-config-page .cc-color-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

body.category-config-page .cc-color-picker {
  width: 2.25rem;
  height: 2.05rem;
  border: 1px solid var(--dash-border);
  border-radius: 8px;
  background: var(--dash-btn-bg);
  cursor: pointer;
  padding: 2px;
}

body.category-config-page .cc-hex-input {
  width: 6.2rem;
  min-height: 2rem;
  border: 1px solid var(--dash-border);
  border-radius: 8px;
  background: var(--dash-input-bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0 0.55rem;
}

body.category-config-page .cc-color-status {
  min-width: 3.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

body.category-config-page .cc-usage-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.55rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}

body.category-config-page .cc-usage-pill.is-mapped {
  background: rgba(52, 211, 153, 0.12);
  color: #059669;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

body.category-config-page .cc-usage-pill.is-unmapped {
  background: rgba(148, 163, 184, 0.16);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

body.category-config-page .cc-usage-modal {
  width: min(36rem, 95vw);
}

body.category-config-page .cc-usage-list {
  max-height: 50vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.2rem;
}

body.category-config-page .cc-usage-map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--dash-border);
  border-radius: 10px;
  background: var(--dash-input-bg);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background var(--transition), border-color var(--transition);
}

body.category-config-page .cc-usage-map-row:hover:not(:disabled) {
  background: var(--surface-hover, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--dash-border));
}

body.category-config-page .cc-usage-map-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.category-config-page .cc-usage-map-row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

body.category-config-page .cc-usage-map-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.category-config-page .cc-usage-map-meta {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

body.category-config-page #cc-feedback {
  padding: 0.6rem 1.25rem 0;
  margin-bottom: 0;
}

body.categories-page .lc-name-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

body.categories-page .lc-name-wrap .cc-name-input[readonly] {
  display: none;
}

body.categories-page .lc-name-wrap .cc-name-input.is-editing {
  display: block;
  min-width: 10rem;
}

body.category-config-page #cc-table-wrap {
  border-radius: 0;
}

body.category-config-page .cc-page-size {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

body.category-config-page .cc-page-size select {
  min-height: 2rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.2rem 0.45rem;
}

body.category-config-page .cc-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem 1.1rem;
  border-radius: 0 0 18px 18px;
}

body.category-config-page .cc-pagination .btn-sm {
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
}

body.category-config-page .cc-pagination-indicator {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 10rem;
  text-align: center;
}

body.category-config-page .data-table thead th {
  background: color-mix(in srgb, var(--dash-card-bg) 90%, #2f95a0 10%);
  letter-spacing: .04em;
  font-size: .69rem;
  text-transform: uppercase;
}

body.category-config-page .data-table tbody tr {
  transition: background-color .16s ease;
}

body.category-config-page .data-table tbody tr:hover {
  background: color-mix(in srgb, var(--dash-input-bg) 88%, var(--accent) 12%);
}

@media (max-width: 980px) {
  body.category-config-page .cc-toolbar {
    grid-template-columns: 1fr;
  }
  body.category-config-page .cc-create-row {
    flex-wrap: wrap;
  }
}

/* ── Category button in topbar ── */
.topbar-cat-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}
button.topbar-nav-cat-btn {
  background: transparent;
  cursor: pointer;
  position: relative;
  font-family: inherit;
}
.topbar-cat-badge {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.05rem 0.35rem;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  min-width: 1rem;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
}

/* ── Category popup (anchored to topbar button) ── */
.cat-popup {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 340px;
  max-height: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: catPopupIn 0.18s ease;
}
.cat-popup[hidden] {
  display: none;
}
@keyframes catPopupIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cat-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.cat-popup-header h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.cat-popup-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.cat-popup-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.cat-popup-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.cat-popup-search svg {
  flex-shrink: 0;
  color: var(--muted);
}
.cat-popup-search input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.cat-popup-search input::placeholder {
  color: var(--muted);
}

.cat-popup-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.4rem 0;
  min-height: 60px;
  max-height: 320px;
}
.cat-popup-list::-webkit-scrollbar {
  width: 5px;
}
.cat-popup-list::-webkit-scrollbar-track {
  background: transparent;
}
.cat-popup-list::-webkit-scrollbar-thumb {
  background: rgba(118,171,174,0.25);
  border-radius: 99px;
}
.cat-popup-list::-webkit-scrollbar-thumb:hover {
  background: rgba(118,171,174,0.45);
}

.cat-popup-list .cat-chips-empty {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 1rem 0.85rem;
  margin: 0;
  text-align: center;
}

/* ── Category row inside popup ── */
.cat-popup-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  transition: background 0.12s ease;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  font-family: inherit;
}
.cat-popup-item:hover {
  background: var(--surface-hover);
}
.cat-popup-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}
.cat-popup-item-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-popup-item-count {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(0,0,0,0.05);
  color: var(--muted);
  min-width: 1rem;
  text-align: center;
}
[data-theme="dark"] .cat-popup-item-count {
  background: rgba(255,255,255,0.06);
}
.cat-popup-item:hover .cat-popup-item-count {
  background: rgba(118,171,174,0.15);
  color: var(--accent);
}
.cat-popup-item-edit {
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  color: var(--muted);
  flex-shrink: 0;
}
.cat-popup-item:hover .cat-popup-item-edit {
  opacity: 1;
  color: var(--accent);
}

.cat-popup-footer {
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
}
.cat-popup-footer .cat-create-row {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
}
.cat-popup-add-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
  font-family: inherit;
}
.cat-popup-add-btn:hover {
  opacity: 0.8;
}

.btn-cta-sm {
  min-height: 2.15rem;
  padding: 0 1rem;
  font-size: 0.78rem;
  border-radius: 10px;
  gap: 0.35rem;
}

[data-theme="dark"] .cat-popup {
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.25);
}

/* ── Category badge pills (dashboard table) ── */
body.dashboard-page .data-table td.cell-category {
  vertical-align: middle;
}

body.dashboard-page .cat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, transform 0.15s ease;
  vertical-align: middle;
}

body.dashboard-page .cat-badge:hover {
  opacity: 0.88;
}

body.dashboard-page .cat-badge--editable {
  cursor: pointer;
  font: inherit;
}

body.dashboard-page button.cat-badge--editable {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  cursor: pointer;
}

body.dashboard-page .cat-badge--editable:hover,
body.dashboard-page button.cat-badge--editable:hover {
  opacity: 0.92;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

body.dashboard-page .cat-badge--editable:focus-visible,
body.dashboard-page button.cat-badge--editable:focus-visible,
body.dashboard-page .dash-cat-set-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.dashboard-page .dash-cat-cell {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  min-width: 8.5rem;
}

body.dashboard-page .dash-cat-view {
  display: inline-flex;
  align-items: center;
}

body.dashboard-page .dash-cat-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px dashed var(--dash-border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

body.dashboard-page .dash-cat-empty:hover {
  border-color: var(--accent);
  color: var(--text);
}

body.dashboard-page .dash-cat-edit {
  width: min(16rem, 100%);
}

body.dashboard-page .dash-cat-combobox {
  margin-bottom: 0;
}

body.dashboard-page .dash-cat-combobox .modal-combobox-input {
  min-height: 2.15rem;
  font-size: 0.82rem;
  padding-right: 1.75rem;
}

body.dashboard-page .dash-cat-list {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 40;
  width: min(16rem, 92vw);
  max-height: 220px;
  margin: 0;
}

body.dashboard-page .dash-cat-cell.is-editing .dash-cat-view {
  display: none;
}

body.dashboard-page .cat-badge--fifa-world-cup {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

body.dashboard-page .cat-badge--premier-league {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #e9d5ff;
}

body.dashboard-page .cat-badge--fa-cup {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

body.dashboard-page .cat-badge--champions-league {
  background: #1e3a5f;
  color: #ffffff;
  border-color: #1e40af;
}

body.dashboard-page .cat-badge--la-liga {
  background: #ffedd5;
  color: #c2410c;
  border-color: #fed7aa;
}

body.dashboard-page .cat-badge--default {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #e5e7eb;
}

body.dashboard-page .cat-badge--custom,
body.categories-page .cat-badge--custom {
  /* Colors come from inline styles (saved category hex). */
}

[data-theme="dark"] body.dashboard-page .cat-badge--fifa-world-cup {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}

[data-theme="dark"] body.dashboard-page .cat-badge--premier-league {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.35);
}

[data-theme="dark"] body.dashboard-page .cat-badge--fa-cup {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

[data-theme="dark"] body.dashboard-page .cat-badge--champions-league {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

[data-theme="dark"] body.dashboard-page .cat-badge--la-liga {
  background: rgba(249, 115, 22, 0.22);
  color: #fdba74;
  border-color: rgba(249, 115, 22, 0.35);
}

[data-theme="dark"] body.dashboard-page .cat-badge--default {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.28);
}

/* ── Category manager ── */
.cat-create-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--dash-border);
}
.cat-create-row[hidden] { display: none; }
.cat-create-row input[type="text"] {
  flex: 1;
  min-height: var(--input-h);
  background: var(--dash-input-bg);
  border: 1px solid var(--dash-input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  padding: 0 0.75rem;
  outline: none;
  transition: border-color 0.2s ease;
}
.cat-create-row input[type="text"]:focus { border-color: var(--accent); }
.cat-create-row input[type="color"] {
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--dash-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: var(--dash-btn-bg);
}
.cat-create-btn {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}


/* ── Responsive ── */
@media (max-width: 900px) {
  body.app-body.dashboard-page .app-content {
    padding: 1.25rem 1rem 1.5rem !important;
  }

  body.dashboard-page .dashboard-hero,
  body.dashboard-page .panel {
    border-radius: 14px;
  }

  body.dashboard-page .dashboard-hero {
    padding: 1.5rem 1.15rem;
  }


  body.dashboard-page .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.6rem;
  }

  body.dashboard-page .data-table th:last-child,
  body.dashboard-page .data-table td:last-child {
    width: auto;
    min-width: auto;
  }

  body.dashboard-page .actions-row {
    flex-wrap: wrap;
  }

  body.dashboard-page .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  body.dashboard-page .maps-panel-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

  .compare-sb-actions {
    grid-template-columns: 1fr;
  }

  .compare-sb-action-buttons {
    justify-content: flex-start;
  }

  .compare-sb-code-pair {
    grid-template-columns: 1fr;
  }

  .cat-popup {
    width: min(320px, calc(100vw - 1.5rem));
    left: 0;
  }
}