:root {
  --bg: #111213;
  --surface: #1a1b1d;
  --surface-raised: #212224;
  --surface-hover: #28292b;

  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.10);

  --text-primary: #e4e5e9;
  --text-secondary: #8a8d98;
  --text-tertiary: #555861;

  --brand: #3c8240;

  --accent: #3c3f44;
  --accent-hover: #51555b;
  --accent-dim: rgba(60,63,68,0.10);

  --positive: #3c8240;
  --positive-dim: rgba(74,222,128,0.08);
  --negative: #f87171;
  --negative-dim: rgba(248,113,113,0.08);
  --warning: #fbbf24;
  --warning-dim: rgba(251,191,36,0.08);
  --info: #447bbe;
  --info-dim: rgba(96,165,250,0.08);

  --chart-1: #60a5fa;
  --chart-2: #66bb6a;
  --chart-3: #fbbf24;
  --chart-4: #a78bfa;

  --sidebar-width: 220px;
  --header-height: 52px;
  --radius: 8px;
  --radius-sm: 6px;
}

/* ---- Scrollbars ---- */
* {
  scrollbar-width: 8px;
  scrollbar-color: var(--accent) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

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

[x-cloak] { display: none !important; }

/* ---- Reports Secondary Sidebar ---- */
:root {
  --reports-subnav-width: 180px;
  --sidebar-collapsed-width: 52px;
}

.reports-subnav {
  width: var(--reports-subnav-width);
  height: 100vh;
  position: fixed;
  left: var(--sidebar-width);
  top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 99;
  transition: left 0.2s ease;
}

body.sidebar-collapsed .reports-subnav {
  left: var(--sidebar-collapsed-width);
}

.reports-subnav-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.reports-subnav-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.reports-subnav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
  white-space: nowrap;
}

.reports-subnav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.reports-subnav-item.active {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.reports-subnav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.45;
}

.reports-subnav-item:hover .reports-subnav-icon { opacity: 0.65; }
.reports-subnav-item.active .reports-subnav-icon { opacity: 0.85; }

.main.has-reports-subnav {
  margin-left: calc(var(--sidebar-width) + var(--reports-subnav-width));
}

body.sidebar-collapsed .main.has-reports-subnav {
  margin-left: calc(var(--sidebar-collapsed-width) + var(--reports-subnav-width));
}

body.sidebar-no-transition .sidebar,
body.sidebar-no-transition .main,
body.sidebar-no-transition .reports-subnav {
  transition: none !important;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.2s ease;
  overflow: hidden;
}

/* Collapsed sidebar state */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .nav-group-label {
  display: none;
}

body.sidebar-collapsed .nav-group + .nav-group {
  border-top: 3px solid rgba(255,255,255,0.07);
  margin-top: 6px;
  padding-top: 6px;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 8px;
  gap: 0;
  position: relative;
}

body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .nav-item .nav-label {
  display: none;
}

body.sidebar-collapsed .nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.75;
  flex-shrink: 0;
}

body.sidebar-collapsed .nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  margin-left: 0;
  padding: 0 4px;
  min-width: 14px;
  font-size: 9px;
}

body.sidebar-collapsed .nav-badge-info {
  right: 2px;
}

body.sidebar-collapsed .nav-badge-warning {
  right: 2px;
  top: 16px;
  margin-left: 0;
}

body.sidebar-collapsed .sidebar-footer {
  padding: 8px 6px 10px;
}

body.sidebar-collapsed .user-pill {
  padding: 6px;
  justify-content: center;
}

body.sidebar-collapsed .user-pill-info {
  display: none;
}

.user-pill-icon {
  display: none;
  flex-shrink: 0;
}

body.sidebar-collapsed .user-pill-icon {
  display: block;
}

body.sidebar-collapsed .logout-btn {
  display: none;
}

body.sidebar-collapsed .main {
  margin-left: var(--sidebar-collapsed-width);
}

/* Sidebar toggle button */
.sidebar-toggle {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  padding: 0;
  margin-bottom: 4px;
}

.sidebar-toggle-icon {
  transition: transform 0.2s ease;
}

body.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

/* Mobile hamburger button — hidden on desktop, shown at 768px */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--surface-hover); }

.sidebar-logo {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo a {
  display: flex;
  align-items: center;
}

.sidebar-logo-img-wrap {
  overflow: hidden;
  /* Matches image natural width at 40px tall (500/150 * 40) */
  width: 133px;
  height: 40px;
  transition: width 0.2s ease;
  flex-shrink: 0;
}

body.sidebar-no-transition .sidebar-logo-img-wrap {
  transition: none !important;
}

body.sidebar-collapsed .sidebar-logo {
  padding: 0;
  justify-content: center;
}

/* Collapsed: crop to just the symbol (~28px wide at 40px tall) */
body.sidebar-collapsed .sidebar-logo-img-wrap {
  width: 20px;
}

.sidebar-logo-img {
  height: 40px;
  width: auto;
  display: block;
}

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

.sidebar-footer {
  padding: 8px 10px 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group { margin-bottom: 2px; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.45;
}

.nav-item:hover .nav-icon { opacity: 0.65; }
.nav-item.active .nav-icon { opacity: 0.85; }

.nav-badge {
  margin-left: auto;
  background: var(--negative);
  color: #111;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.nav-badge-info {
  background: var(--info);
  color: #fff;
  margin-left: auto;
}

.nav-badge-warning {
  background: var(--warning);
  color: #111;
  margin-left: 4px;
}

.nav-badge-brand {
  background: var(--brand);
  color: #fff;
}


.sidebar-footer-user {
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 2px;
  margin-left: -10px;
  margin-right: -10px;
  padding-left: 10px;
  padding-right: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}

.user-pill:hover { background: var(--surface-hover); }

.user-avatar { display: none; }

.user-name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 10px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-pill-info { min-width: 0; flex: 1; }

.logout-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: all 0.12s;
}
.logout-btn:hover {
  background: var(--surface-raised);
  color: var(--negative);
}

/* ---- Main ---- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.topbar {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  padding: 20px 24px;
  flex: 1;
}

.content:has(.page-with-sidebar) {
  padding-top: 0;
}

/* ---- Common Controls ---- */
select option {
  background: var(--surface);
  color: var(--text-primary);
}

.ctrl-select {
  appearance: none;
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555861' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
}

.filter-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
}
.filter-button:hover { background: var(--surface-hover); }
.filter-popup {
  position: absolute;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
}
.filter-list { max-height: 280px; overflow-y: auto; padding: 4px 0; }
.filter-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: left;
}
.filter-item input[type="checkbox"] {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin: 0 8px 0 0;
  cursor: pointer;
  accent-color: var(--brand);
}
.filter-item label {
  cursor: pointer;
  flex: 1;
  margin: 0;
  text-align: left;
}
.filter-item:hover { background: var(--surface-hover); color: var(--text-primary); }

.ctrl-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.ctrl-input:focus {
  border-color: var(--accent);
}

.ctrl-input::placeholder {
  color: var(--text-tertiary);
}

.ctrl-file {
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
}

.ctrl-file::file-selector-button {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-right: 8px;
  transition: background 0.15s;
}

.ctrl-file::file-selector-button:hover {
  background: var(--surface-hover);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-brand {
  background: var(--brand);
  color: #fff;
}

.btn-brand:hover {
  background: #43a047;
}

.btn-danger {
  background: var(--negative);
  color: #fff;
}

.btn-danger:hover {
  background: #ef5350;
}

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--positive);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-success:hover {
  background: #43a047;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-success:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ap-btn-cooldown { opacity: 0.5; pointer-events: none; }

/* ---- Metric Cards ---- */
.metric-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.m-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.15s;
}

.m-card:hover { border-color: var(--border-strong); }

.m-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.m-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.m-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.m-badge.up { color: var(--positive); background: var(--positive-dim); }
.m-badge.down { color: var(--negative); background: var(--negative-dim); }

.m-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.m-sub {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 500;
}

.m-secondary .m-value { font-size: 17px; }

.progress-bar {
  height: 3px;
  background: rgba(255,255,255,0.04);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  opacity: 0.6;
}

/* ---- Chart Cards ---- */
.c-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

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

.c-title { font-size: 13px; font-weight: 600; }

.c-tabs {
  display: flex;
  gap: 1px;
  background: var(--bg);
  border-radius: 4px;
  padding: 2px;
}

.c-tab {
  padding: 3px 10px;
  border: none;
  background: transparent;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}

.c-tab:hover { color: var(--text-secondary); }
.c-tab.active { background: var(--surface-raised); color: var(--text-primary); }

.c-area { height: 220px; position: relative; }

/* ---- Dashboard Layout ---- */
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.metric-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.dash-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-mp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 300px;
  gap: 12px;
  margin-bottom: 16px;
}

/* ---- Tables ---- */
.t-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.t-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.t-header-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 8px 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.12);
}

.data-table td {
  padding: 8px 16px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table td:last-child, .data-table th:last-child { text-align: left; }
.data-table tr:hover td { background: var(--surface-hover); }

/* ---- Status Badges ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.open { color: var(--info); background: var(--info-dim); }
.status-badge.processing { color: var(--warning); background: var(--warning-dim); }
.status-badge.shipped { color: var(--positive); background: var(--positive-dim); }
.status-badge.completed { color: var(--positive); background: var(--positive-dim); }
.status-badge.cancelled { color: var(--negative); background: var(--negative-dim); }
.status-badge.pending { color: var(--warning); background: var(--warning-dim); }
.status-badge.live { color: var(--positive); background: var(--positive-dim); }
.status-badge.staged { color: var(--info); background: var(--info-dim); }
.status-badge.error { color: var(--negative); background: var(--negative-dim); }

/* Legacy badge aliases for JS compatibility */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.badge-success { color: var(--positive); background: var(--positive-dim); }
.badge-positive { color: var(--positive); background: var(--positive-dim); }
.badge-info { color: var(--info); background: var(--info-dim); }
.badge-warning { color: var(--warning); background: var(--warning-dim); }
.badge-danger { color: var(--negative); background: var(--negative-dim); }
.badge-negative { color: var(--negative); background: var(--negative-dim); }
.badge-secondary { color: var(--text-tertiary); background: var(--accent-dim); }
.badge-neutral { color: var(--text-secondary); background: var(--accent-dim); }
.badge-beta { font-size: 0.65em; font-weight: 600; background: var(--accent-color, #007bff); color: #fff; padding: 2px 6px; border-radius: 4px; margin-left: 4px; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-bar .filter-search {
  flex: 1;
  min-width: 200px;
}

/* ---- Time Pills ---- */
.time-pills {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.time-pill {
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
  letter-spacing: -0.01em;
}

.time-pill:hover { color: var(--text-secondary); }

.time-pill.active {
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ---- Form Sections (Settings) ---- */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.form-section-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.form-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.form-section-desc {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.form-section-body {
  padding: 16px 20px;
}

.form-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.form-row:last-child { margin-bottom: 0; }

.form-label {
  width: 180px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-top: 7px;
}

.form-field {
  flex: 1;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
}

.form-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555861' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 30px;
}

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

.form-hint {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3 { grid-template-columns: 1fr; }
}

/* ---- Inset box (raised panel inside a form-section-body) ---- */
.inset-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.inset-box-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.or-divider {
  text-align: center;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin: 20px 0;
}

/* ---- Marketplace Sync Cards ---- */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.mp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}

.mp-card:hover {
  border-color: var(--border-strong);
}

.mp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 0;
}

.mp-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.mp-card-body {
  padding: 12px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.mp-card-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  margin-top: 6px;
}

.mp-card-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-card-actions .btn-primary,
.mp-card-actions .btn-secondary,
.mp-card-actions .btn-danger {
  width: 100%;
  justify-content: center;
}

.inline-code {
  font-size: 0.85rem;
  background: var(--surface-raised);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 16px 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- Card Grid (Scanner, Editor) ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.grid-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
  cursor: pointer;
}

.grid-card:hover { border-color: var(--border-strong); }

.grid-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--bg);
}

.grid-card-body {
  padding: 16px;
}

.grid-card-icon {
  margin-bottom: 12px;
}

.grid-card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.grid-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 16px 0;
}

/* ---- Toast / Flash Messages ---- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
  max-width: 400px;
}

.toast.success { border-left: 3px solid var(--positive); }
.toast.error { border-left: 3px solid var(--negative); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  margin-left: auto;
  display: flex;
}

.toast-close:hover { color: var(--text-primary); }

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 360px;
  margin-bottom: 16px;
}

/* ---- Inventory Strip ---- */
.inv-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.inv-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.inv-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.inv-dot.b { background: var(--info-dim); }
.inv-dot.g { background: var(--positive-dim); }
.inv-dot.a { background: var(--warning-dim); }
.inv-dot.p { background: var(--accent-dim); }

.inv-lbl { font-size: 10.5px; color: var(--text-tertiary); font-weight: 500; }
.inv-val { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---- Marketplace Dot ---- */
.mp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

/* ---- Admin Bar (for admin users) ---- */
.admin-bar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 34px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 11px;
  gap: 12px;
}

.has-admin-bar .sidebar { top: 34px; height: calc(100vh - 34px); }
.has-admin-bar .topbar { top: 34px; }
.has-admin-bar .reports-subnav { top: 34px; height: calc(100vh - 34px); }

.admin-bar-label {
  color: var(--warning);
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-bar-label:hover {
  opacity: 0.8;
}

.admin-bar-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-bar-input {
  width: 200px;
  padding: 3px 8px;
  height: 24px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
}

.admin-bar-input:focus { border-color: var(--accent); }

.admin-bar-btn {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
}

.admin-bar-btn:hover { background: var(--accent-hover); }
.admin-bar-btn:disabled { background: var(--surface-hover); color: var(--text-tertiary); cursor: default; }

.admin-bar-btn-reset {
  background: transparent;
  color: var(--warning);
  border: 1px solid var(--warning);
}

.admin-bar-btn-reset:hover {
  background: var(--warning);
  color: var(--bg);
}

.admin-bar-current {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.admin-bar-current-user {
  color: var(--accent);
  font-weight: 600;
}

.admin-bar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  width: 280px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 210;
}

.admin-bar-dropdown.open { display: block; }

.admin-bar-option {
  padding: 5px 10px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-bar-option:hover,
.admin-bar-option.selected {
  background: var(--accent);
  color: #fff;
}

.admin-bar-option.hidden { display: none; }

/* ---- Settings Sub-Nav ---- */
.settings-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
  min-height: calc(100vh - var(--header-height));
}

.settings-sidebar {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 8px 20px 0;
  position: sticky;
  top: 0;
}

.settings-sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.settings-sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0 10px 6px;
}

.settings-sidebar-item {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s;
}

.settings-sidebar-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.settings-sidebar-item.active {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.settings-content {
  flex: 1;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

/* ---- Filter Sidebar ---- */
.page-with-sidebar {
  display: flex;
  flex: 1;
  overflow: hidden;
  margin: 0 -24px -20px;
  min-height: calc(100vh - var(--header-height));
}

.filter-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.filter-group {
  margin-bottom: 14px;
}

.filter-group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  display: block;
}

.filter-group-body {
  padding: 0;
}

.filter-group-body input,
.filter-group-body select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: 12px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.filter-group-body input::placeholder {
  color: var(--text-tertiary);
}

.filter-group-body input:focus,
.filter-group-body select:focus {
  border-color: var(--border-strong);
}

.page-main-content { flex: 1; min-width: 0; padding: 20px 24px; overflow-y: auto; }

/* Filter toggle: hidden on desktop */
.catalog-filter-toggle { display: none !important; }
.catalog-filter-backdrop { display: none; }

/* ---- Fullscreen Layout (Editor) ---- */
.fullscreen-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.fullscreen-layout .main {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.fullscreen-toolbar {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
}

.fullscreen-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ---- Order Index - expandable rows, bulk actions ---- */
.order-row { cursor: pointer; }
.order-row td:first-child { padding: 4px 16px; }
.order-mobile-meta { display: none; }
.expanded-order { display: none; }
.expanded-order.visible { display: table-row; }
.order-items {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 16px;
}
.order-detail-section { margin-bottom: 20px; }
.order-detail-section h5 {
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
}
.bulk-actions { display: none; }
.bulk-actions.active { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.totals-section { border-top: 1px solid var(--border); padding-top: 12px; text-align: right; }
.link-product { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--text-tertiary); }
.link-product:hover { color: var(--info); border-bottom-color: var(--info); }
.link-bin:hover { color: var(--info); border-bottom-color: var(--info); }
.d-none { display: none !important; }

/* ---- Order Create - search, line items ---- */
.search-results-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 100;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.search-result-item:hover { background: var(--surface-hover); }
.search-result-item:last-child { border-bottom: none; }
.search-result-image { width: 50px; height: 70px; object-fit: cover; border-radius: var(--radius-sm); margin-right: 12px; flex-shrink: 0; }
.item-row { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.item-row:last-child { border-bottom: none; margin-bottom: 0; }
.selected-product-display { display: flex; align-items: center; gap: 10px; }
.selected-product-display img { width: 35px; height: 49px; object-fit: cover; border-radius: var(--radius-sm); }

/* ---- Public Marketing Pages ---- */
.public-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.public-hero { position: relative; color: #fff; padding: 100px 24px; text-align: center; overflow: hidden; }
.public-hero-bg { position: absolute; inset: -10px; background-size: cover; background-position: center; filter: blur(2px); }
.public-hero-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); }
.public-hero-content { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; }
.public-hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin-bottom: 20px; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.public-hero-highlight { color: var(--brand); }
.public-lead { font-size: 1.2rem; margin-bottom: 24px; color: rgba(255,255,255,0.9); font-weight: 500; }
.public-section { padding: 60px 24px; }
.public-section-alt { background: var(--surface); }
.public-section-title { text-align: center; margin-bottom: 40px; font-size: clamp(1.5rem, 4vw, 2.5rem); color: var(--text-primary); font-weight: 700; }
.public-overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; max-width: 1000px; margin: 0 auto; }
.public-overview-item { text-align: center; padding: 28px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform 0.2s, border-color 0.2s; }
.public-overview-item:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.public-overview-item i { font-size: 2rem; color: var(--brand); margin-bottom: 12px; }
.public-overview-item h4 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.public-overview-item p { color: var(--text-secondary); font-size: 12.5px; line-height: 1.5; }
.public-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; max-width: 900px; margin: 0 auto; }
.public-stat-card { text-align: center; padding: 24px 20px; }
.public-stat-number { font-size: 2.5rem; font-weight: 800; color: var(--brand); margin-bottom: 8px; letter-spacing: -0.02em; }
.public-stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.public-game-badge { display: inline-flex; padding: 12px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.public-cta-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.public-btn-lg { padding: 12px 28px; font-size: 1rem; font-weight: 600; }
.public-profile-layout { display: flex; align-items: flex-start; gap: 40px; max-width: 900px; margin: 0 auto; }
.public-portrait { width: 200px; height: 200px; border-radius: var(--radius); border: 2px solid var(--border); object-fit: cover; flex-shrink: 0; }
.public-experience-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; max-width: 900px; margin: 0 auto; }
.public-experience-card { padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform 0.2s, border-color 0.2s; }
.public-experience-card:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.public-experience-icon { font-size: 2rem; color: var(--brand); margin-bottom: 16px; }
.public-feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; max-width: 1400px; margin: 0 auto; }
.public-feature-card { padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform 0.2s, border-color 0.2s; }
.public-feature-card:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.public-feature-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.public-feature-header i { font-size: 1.5rem; color: var(--brand); flex-shrink: 0; }
.public-service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; max-width: 1200px; margin: 0 auto; }
.public-service-card { padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform 0.2s, border-color 0.2s; display: flex; flex-direction: column; }
.public-service-card:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.public-service-icon { font-size: 2.5rem; color: var(--brand); margin-bottom: 16px; }
.public-service-details { list-style: none; padding: 0; margin: 0; }
.public-service-details li { padding: 6px 0; color: var(--text-secondary); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.public-service-details li i { color: var(--brand); flex-shrink: 0; }
.public-pricing-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.public-pricing-table th { background: var(--surface-raised); padding: 16px 24px; font-size: 12px; font-weight: 600; color: var(--text-primary); border-bottom: 1px solid var(--border); text-align: left; }
.public-pricing-table td { padding: 16px 24px; font-size: 12.5px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.public-pricing-table td strong { color: var(--brand); font-size: 1.1rem; }
.public-contact-method { display: flex; align-items: flex-start; gap: 20px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.public-contact-icon { font-size: 1.75rem; color: var(--brand); flex-shrink: 0; }
.public-contact-link { color: var(--brand); font-weight: 600; text-decoration: none; }
.public-contact-link:hover { text-decoration: underline; }
.public-included-banner { display: flex; align-items: flex-start; gap: 24px; max-width: 800px; margin: 0 auto; padding: 28px 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
@media (max-width: 768px) {
  .public-profile-layout { flex-direction: column; align-items: center; text-align: center; }
  .public-included-banner { flex-direction: column; align-items: center; text-align: center; }
}

/* ---- Print Layout ---- */
@media print {
  .sidebar, .topbar, .admin-bar { display: none !important; }
  .main { margin-left: 0 !important; }
  body { background: #fff; color: #000; font-size: 10pt; }
  html { zoom: 1; }
}

/* ---- Utility: Spinner Animation ---- */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* ---- Card Badges (rarity, foil) ---- */
.rarity-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rarity-common    { background: #4a4a4a; color: #ccc; }
.rarity-uncommon  { background: #1e3a5f; color: #7ab8f5; }
.rarity-rare      { background: #3d2a00; color: #f5c842; }
.rarity-mythic    { background: #4a1200; color: #ff8c42; }
.rarity-special, .rarity-bonus { background: #2a0a4a; color: #c084fc; }
.foil-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: linear-gradient(135deg, #7928ca, #ff0080);
  color: #fff;
  letter-spacing: 0.03em;
}

/* ---- Utility Badges & Labels ---- */
.set-code-badge {
  display: inline-block;
  font-family: monospace;
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 700;
  padding: 1px 5px;
  background: var(--surface-hover);
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.count-badge {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  background: var(--surface-hover);
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
}
.no-price { color: var(--text-tertiary); font-style: italic; }

/* ---- Pagination ---- */
.pg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}
.pg-bar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}
.pg-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pg-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}
.pg-btn.active {
  background: transparent;
  border-color: var(--text-primary);
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
  pointer-events: none;
}
.pg-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.pg-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 32px;
  color: var(--text-tertiary);
  font-size: 12px;
}
.pg-rows {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.pg-rows select {
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.pg-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.pg-jump input[type="number"] {
  width: 52px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  text-align: center;
  -moz-appearance: textfield;
}
.pg-jump input[type="number"]::-webkit-inner-spin-button,
.pg-jump input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pg-jump input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}
.pg-jump button {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.pg-jump button:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ---- Quick Scan Step Nav ---- */
.topbar:has(.qs-step-tabs) {
  justify-content: space-between;
}

.qs-step-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  padding: 0 16px;
}

.qs-step-tab {
  padding: 5px 13px;
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.8rem;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.qs-step-tab:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border);
}

.qs-step-tab.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

/* Full-bleed content area (no padding) for immersive layouts */
.main-fullbleed > .content {
  padding: 0;
  overflow: hidden;
}

/* ---- Scan Batch Mobile Cards ---- */
.batch-mobile { display: none; }
.batch-card-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.batch-card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.batch-card-item:last-child { border-bottom: none; }
.batch-card-item:active { background: var(--surface-hover); }
.batch-card-img {
  width: 48px;
  height: 67px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.batch-card-img-placeholder {
  width: 48px;
  height: 67px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.batch-card-info {
  flex: 1;
  min-width: 0;
}
.batch-card-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-card-set {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-card-details {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.batch-card-badges {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.batch-card-index {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  flex-shrink: 0;
}

/* ---- Orders Mobile Layout ---- */
@media (max-width: 768px) {
  /* Filter bar: stack vertically */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-bar select { width: 100% !important; }
  .filter-bar .filter-search { min-width: 0; width: 100%; }
  .filter-bar .btn-primary,
  .filter-bar .btn-secondary { flex: 1; text-align: center; }

  /* Bulk actions: stack */
  .bulk-actions.active {
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-actions.active form {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .bulk-actions.active form select,
  .bulk-actions.active form button { width: 100%; }

  /* Orders table → card layout */
  .orders-table { table-layout: auto !important; }
  .orders-table thead { display: none; }
  .orders-table tbody { display: flex; flex-direction: column; gap: 6px; }
  .orders-table .order-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 1px 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .orders-table .order-row td {
    border-bottom: none;
    padding: 0;
    font-size: 13px;
    background: none !important;
  }
  /* Checkbox */
  .orders-table .order-row td:nth-child(1) {
    grid-row: 1 / 4;
    grid-column: 1;
    display: flex;
    align-items: center;
  }
  /* Order ID */
  .orders-table .order-row td:nth-child(2) {
    grid-row: 1;
    grid-column: 2;
    font-weight: 600;
  }
  /* Marketplace */
  .orders-table .order-row td:nth-child(3) {
    grid-row: 1;
    grid-column: 2;
    display: none;
  }
  /* Date */
  .orders-table .order-row td:nth-child(4) {
    display: none;
  }
  /* Shipping To */
  .orders-table .order-row td:nth-child(5) {
    display: none;
  }
  /* Items */
  .orders-table .order-row td:nth-child(6) {
    display: none;
  }
  /* Ship Method */
  .orders-table .order-row td:nth-child(7) {
    display: none;
  }
  /* Total */
  .orders-table .order-row td:nth-child(8) {
    grid-row: 1;
    grid-column: 3;
    font-weight: 600;
    text-align: right;
  }
  /* Status */
  .orders-table .order-row td:nth-child(9) {
    grid-row: 2;
    grid-column: 3;
    text-align: right;
  }
  /* Mobile meta line (buyer · items · date) */
  .orders-table .order-row .order-mobile-meta {
    display: block;
    grid-row: 2;
    grid-column: 2;
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Expanded order row */
  .orders-table .expanded-order {
    display: none;
  }
  .orders-table .expanded-order.visible {
    display: block;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: -8px;
    margin-bottom: 8px;
  }
  .orders-table .expanded-order td {
    display: block;
    padding: 0;
    border-bottom: none;
  }
  .orders-table .expanded-order .order-items {
    padding: 12px;
  }
  .orders-table .expanded-order .order-items > div:first-child {
    flex-direction: column;
    gap: 16px;
  }

  /* Nested order items table inside expanded view */
  .expanded-order .data-table thead { display: table-header-group; }
  .expanded-order .data-table tbody { display: table-row-group; gap: 0; }
  .expanded-order .data-table tr { display: table-row; }
  .expanded-order .data-table td,
  .expanded-order .data-table th {
    display: table-cell;
    padding: 6px 8px;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
  }
  .expanded-order .data-table { overflow-x: auto; display: block; }
  .expanded-order .data-table thead,
  .expanded-order .data-table tbody { min-width: 500px; }

  /* Totals in expanded view */
  .totals-section .data-table { display: table; }
  .totals-section .data-table tr { display: table-row; }
  .totals-section .data-table td { display: table-cell; padding: 4px 8px; font-size: 12px; }
  .totals-section .data-table td[colspan] { display: none; }

  /* Don't horizontally scroll the card layout */
  .t-card > div[style*="overflow-x"] {
    overflow-x: visible !important;
  }

  /* Compact content padding */
  .content { padding: 12px; }
  .topbar { padding: 0 12px; }
  .topbar-right { gap: 4px; }
  .topbar-right .btn-secondary { font-size: 11px; padding: 4px 8px; }

  /* Pagination compact */
  .pg-bar-center { gap: 8px; }
  .pg-jump { display: none; }

  /* Scan batch: hide desktop table, show mobile cards */
  .batch-desktop { display: none; }
  .batch-mobile { display: block; }

  /* ---- Catalog / Filter Sidebar Mobile ---- */
  .catalog-filter-toggle { display: inline-flex !important; }

  .page-with-sidebar {
    flex-direction: column;
    margin: 0 -12px -12px;
  }

  .filter-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 150;
    padding: 16px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }

  .filter-sidebar.filter-sidebar-open {
    display: flex;
  }

  .catalog-filter-backdrop.active {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
  }

  .page-main-content {
    padding: 12px;
    min-height: auto;
  }

  /* ---- Dashboard Mobile ---- */

  /* Toolbar: stack time pills and marketplace filter */
  .dash-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .dash-toolbar .time-pills {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .dash-toolbar .time-pills::-webkit-scrollbar { display: none; }

  .dash-toolbar .dash-mp-dropdown { width: 100%; }
  .dash-toolbar .dash-mp-dropdown .filter-button { width: 100%; min-width: 0; }

  /* Primary metrics: 2 columns */
  .metric-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Secondary metrics & order rows: 2 columns */
  .metric-row-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Metric card compact */
  .m-card {
    padding: 10px 12px;
  }
  .m-value {
    font-size: 18px;
  }
  .m-secondary .m-value {
    font-size: 15px !important;
  }

  /* Charts: single column */
  .dash-chart-grid {
    grid-template-columns: 1fr;
  }
  .c-area {
    height: 180px;
  }

  /* Marketplace breakdown: single column */
  .dash-mp-grid {
    grid-template-columns: 1fr;
  }

  /* Inventory strip: 2 columns */
  .inv-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .inv-mini {
    padding: 10px 12px;
  }
  .inv-val {
    font-size: 15px;
  }

  /* ---- Settings: sidebar → horizontal scrollable tabs ---- */
  .settings-layout { flex-direction: column; gap: 0; }
  .settings-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 4px 8px;
    gap: 0;
  }
  .settings-sidebar::-webkit-scrollbar { display: none; }
  .settings-sidebar-group {
    flex-direction: row;
    align-items: center;
    gap: 2px;
    margin-bottom: 0;
  }
  .settings-sidebar-label { display: none; }
  .settings-sidebar-item {
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
  }
  .settings-content { padding: 0; }

  /* ---- Form rows: single column on mobile ---- */
  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .form-label { min-width: 0; }
  .form-field { flex: none; width: 100%; }

  /* Catalog table: horizontal scroll on mobile */
  .catalog-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .catalog-table-wrap table { min-width: 560px; }

  /* Inventory table: already has overflow-x inline; ensure it scrolls */
  .table-container { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }

  /* Pricing tables: horizontal scroll */
  .price-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .syntax-table { overflow-x: auto; -webkit-overflow-scrolling: touch; display: block; }

  /* Reports tables: horizontal scroll */
  .report-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Billing summary: stack summary grid */
  .billing-summary-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Distribution tables: tighter */
  .t-card .data-table th,
  .t-card .data-table td {
    padding: 6px 8px;
    font-size: 11px;
  }

  /* ---- Sidebar slide-out ---- */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    transition: transform 0.25s ease, width 0.2s ease;
  }
  body.sidebar-mobile-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0 !important; }
  .sidebar-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 190;
  }
  body.sidebar-mobile-open .sidebar-mobile-backdrop { display: block; }
  .sidebar-toggle { display: none; }
  .mobile-menu-btn { display: flex; }

  /* ---- Topbar compact ---- */
  .topbar { gap: 8px; }
  .topbar-title { font-size: 13px; }
  .topbar-subtitle { display: none; }

  /* ---- Admin bar compact ---- */
  .admin-bar { flex-wrap: wrap; gap: 4px; padding: 4px 8px; font-size: 11px; height: auto; min-height: 32px; }
  .admin-bar-selector { flex: 1; min-width: 0; }
  .admin-bar-current { width: 100%; font-size: 10px; }

  /* ---- Modal responsive ---- */
  .modal-panel {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* ---- Reports subnav → horizontal tab strip on mobile ---- */
@media (max-width: 768px) {
  .reports-subnav {
    position: sticky;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: 49;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .reports-subnav::-webkit-scrollbar { display: none; }
  .reports-subnav-header { display: none; }
  .reports-subnav-nav {
    display: flex;
    flex-direction: row;
    padding: 4px 8px;
    gap: 4px;
    white-space: nowrap;
    overflow: visible;
  }
  .main.has-reports-subnav,
  body.sidebar-collapsed .main.has-reports-subnav { margin-left: 0 !important; }
}

/* ---- Page-action Menu Dropdown ---- */
.menu-button {
    min-width: 90px;
    flex-shrink: 0;
}

.menu-dropdown {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.menu-dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    min-width: 200px;
    background-color: var(--surface-raised);
    border: 1px solid var(--border-strong);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1100;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.menu-dropdown-content a {
    display: block;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 12px;
    transition: background-color 0.15s;
}

.menu-dropdown-content a:hover {
    background-color: var(--surface-hover);
}

.menu-dropdown:hover .menu-dropdown-content { display: block; }

/* ---- Dashboard: Small phones ---- */
@media (max-width: 480px) {
  .inv-row {
    grid-template-columns: 1fr;
  }
  .time-pill {
    padding: 5px 8px;
    font-size: 10.5px;
  }
}

/* ── Booster expanded: simulation stats bar ─────────────── */
.ev-sim-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 24px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 38px;
}
.ev-sim-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ev-sim-label  { color: var(--text-tertiary); }
.ev-sim-val    { color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 500; }
.ev-sim-p10    { color: #ef4444; }
.ev-sim-p90    { color: #22c55e; }
.ev-sim-note  { margin-left: auto; font-size: 10px; color: var(--text-tertiary); font-style: italic; }
.ev-sim-cv-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ev-sim-cv-badge.cv-low  { background: rgba(34,197,94,0.15);  color: #22c55e; }
.ev-sim-cv-badge.cv-mid  { background: rgba(234,179,8,0.15);  color: #eab308; }
.ev-sim-cv-badge.cv-high { background: rgba(239,68,68,0.15);  color: #ef4444; }
.ev-impact-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 24px;
  padding: 8px 16px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 34px;
}
.ev-impact-label { font-weight: 600; color: var(--text-secondary); margin-right: 4px; }
.ev-impact-delta { font-size: 11px; font-weight: 600; }
.ev-impact-delta.positive { color: #22c55e; }
.ev-impact-delta.negative { color: #ef4444; }

/* ── Column tooltips (data-tip on <th>) ─────────────────── */
th[data-tip] { cursor: default; }

#ev-col-tip {
  position: fixed;
  z-index: 9999;
  max-width: 240px;
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  pointer-events: none;
  white-space: normal;
  text-align: left;
  display: none;
}
#ev-col-tip.visible { display: block; }

/* ---- Toggle Switch ---- */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--accent);
  border-radius: 10px;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--positive); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ---- Icon Button ---- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-icon.danger:hover { background: var(--negative-dim); color: var(--negative); }

/* ---- Full-width button ---- */
.btn-block { width: 100%; justify-content: center; }

/* ---- Inline Form ---- */
.form-inline {
  display: inline-flex;
  vertical-align: middle;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}
.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb svg { opacity: 0.4; }

/* ---- Text helpers ---- */
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.text-mono { font-family: 'Courier New', Courier, monospace; }
.font-medium { font-weight: 500; }

/* ---- Knowledge Base ---- */
.kb-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  max-width: 1100px;
}
@media (max-width: 768px) {
  .kb-layout { grid-template-columns: 1fr; }
}

.kb-categories {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kb-cat-link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.kb-cat-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.kb-cat-link.active { background: var(--accent-dim); color: var(--text-primary); font-weight: 600; }

.kb-cat-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-tertiary);
  padding: 0 12px 6px;
  margin-bottom: 2px;
}

.kb-articles {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kb-article-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color .15s, background .15s;
}
.kb-article-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}
.kb-article-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
}
.kb-article-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

.kb-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* KB Article Body (rendered HTML content) */
.kb-article-body {
  max-width: 800px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 400;
}
.kb-article-body h1 { font-size: 24px; font-weight: 800; margin: 28px 0 12px; color: var(--text-primary); letter-spacing: -0.02em; }
.kb-article-body h2 { font-size: 19px; font-weight: 700; margin: 28px 0 10px; color: var(--text-primary); letter-spacing: -0.01em; }
.kb-article-body h3 { font-size: 15px; font-weight: 700; margin: 22px 0 8px; color: var(--text-primary); }
.kb-article-body h4 { font-size: 13.5px; font-weight: 700; margin: 18px 0 6px; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.kb-article-body p { margin: 0 0 12px; }
.kb-article-body strong { color: var(--text-primary); font-weight: 600; }
.kb-article-body ul, .kb-article-body ol { margin: 0 0 12px; padding-left: 24px; }
.kb-article-body li { margin-bottom: 4px; }
.kb-article-body a { color: var(--info); text-decoration: underline; }
.kb-article-body a:hover { color: var(--text-primary); }
.kb-article-body code {
  background: var(--surface-raised);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.kb-article-body pre {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.kb-article-body pre code { background: none; padding: 0; }
.kb-article-body blockquote {
  border-left: 3px solid var(--brand);
  margin: 0 0 12px;
  padding: 8px 16px;
  color: var(--text-secondary);
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.kb-article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.kb-article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 13px;
}
.kb-article-body th, .kb-article-body td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.kb-article-body th {
  background: var(--surface-raised);
  font-weight: 600;
}
.kb-article-footer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* KB Admin */
.kb-admin-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 960px) {
  .kb-admin-grid { grid-template-columns: 1fr; }
}

.kb-cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kb-cat-row:last-child { border-bottom: none; }
.kb-cat-name { flex: 1; color: var(--text-primary); font-weight: 500; }
.kb-cat-meta { color: var(--text-tertiary); font-size: 12px; }
.kb-cat-actions { display: flex; gap: 4px; }

.kb-cat-edit-form {
  display: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}
.kb-cat-edit-form.active { display: block; }

.kb-inline-fields {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}
.kb-inline-fields .field { display: flex; flex-direction: column; gap: 4px; }
.kb-inline-fields .field-grow { flex: 1; }
.kb-inline-fields label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.kb-add-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.kb-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.kb-toolbar-count {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* KB Article link in data-table */
.kb-title-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}
.kb-title-link:hover { text-decoration: underline; }

/* KB Editor */
.kb-editor-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
  max-width: 1100px;
}
@media (max-width: 960px) {
  .kb-editor-layout { grid-template-columns: 1fr; }
}

.kb-editor-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.kb-editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kb-sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.kb-sidebar-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.kb-field { display: flex; flex-direction: column; gap: 6px; }
.kb-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.kb-field-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Quill WYSIWYG dark theme overrides */
.kb-quill-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.kb-quill-wrap .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
  padding: 6px 8px;
}
.kb-quill-wrap .ql-container.ql-snow {
  border: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}
.kb-quill-wrap .ql-editor {
  min-height: 420px;
  padding: 20px 24px;
  line-height: 1.7;
}
.kb-quill-wrap .ql-editor.ql-blank::before {
  color: var(--text-tertiary);
  font-style: normal;
}

/* Toolbar button colors */
.kb-quill-wrap .ql-snow .ql-stroke { stroke: var(--text-secondary); }
.kb-quill-wrap .ql-snow .ql-fill   { fill: var(--text-secondary); }
.kb-quill-wrap .ql-snow .ql-picker  { color: var(--text-secondary); }
.kb-quill-wrap .ql-snow .ql-picker-label { border-color: transparent; }
.kb-quill-wrap .ql-snow .ql-picker-label:hover,
.kb-quill-wrap .ql-snow button:hover { color: var(--text-primary); }
.kb-quill-wrap .ql-snow button:hover .ql-stroke { stroke: var(--text-primary); }
.kb-quill-wrap .ql-snow button:hover .ql-fill   { fill: var(--text-primary); }
.kb-quill-wrap .ql-snow button.ql-active .ql-stroke { stroke: var(--brand); }
.kb-quill-wrap .ql-snow button.ql-active .ql-fill   { fill: var(--brand); }
.kb-quill-wrap .ql-snow button.ql-active { color: var(--brand); }
.kb-quill-wrap .ql-snow .ql-picker.ql-expanded .ql-picker-label { border-color: var(--border); }

/* Toolbar dropdown menus */
.kb-quill-wrap .ql-snow .ql-picker-options {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  padding: 4px;
}
.kb-quill-wrap .ql-snow .ql-picker-item { color: var(--text-secondary); }
.kb-quill-wrap .ql-snow .ql-picker-item:hover { color: var(--text-primary); }

/* Quill tooltip (link editor) */
.kb-quill-wrap .ql-snow .ql-tooltip {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.kb-quill-wrap .ql-snow .ql-tooltip input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 4px 8px;
  font-size: 12px;
}
.kb-quill-wrap .ql-snow .ql-tooltip a { color: var(--info); }

/* Editor content element styles */
.kb-quill-wrap .ql-editor h1 { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.kb-quill-wrap .ql-editor h2 { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.kb-quill-wrap .ql-editor h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.kb-quill-wrap .ql-editor p  { margin-bottom: 10px; }
.kb-quill-wrap .ql-editor blockquote {
  border-left: 3px solid var(--brand);
  padding-left: 16px;
  color: var(--text-secondary);
}
.kb-quill-wrap .ql-editor pre.ql-syntax {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
}
.kb-quill-wrap .ql-editor code {
  background: var(--surface-raised);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.kb-quill-wrap .ql-editor a { color: var(--info); }
.kb-quill-wrap .ql-editor img { max-width: 100%; border-radius: var(--radius-sm); }

/* Hidden textarea for form submission */
.kb-html-source {
  display: none;
}
.kb-html-source.active {
  display: block;
  width: 100%;
  min-height: 420px;
  padding: 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text-primary);
  resize: vertical;
}
.kb-html-source.active:focus {
  outline: none;
  border-color: var(--brand);
}

/* Source toggle tab bar */
.kb-editor-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: -1px;
}
.kb-editor-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color .15s;
}
.kb-editor-tab:hover { color: var(--text-primary); }
.kb-editor-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--brand);
}

.kb-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-input-sm { width: 80px; }
.kb-input-md { width: 160px; }

/* KB Article view with images */
.kb-article-layout {
  max-width: 800px;
}
.kb-article-layout.kb-article-has-images {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  max-width: 1100px;
  align-items: start;
}
@media (max-width: 768px) {
  .kb-article-layout.kb-article-has-images {
    grid-template-columns: 1fr;
  }
}

.kb-article-images {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 72px;
}
.kb-article-figure {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kb-article-figure {
  cursor: pointer;
}
.kb-article-figure img {
  width: 100%;
  display: block;
}
.kb-article-figure figcaption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* KB Admin: image management */
.kb-images-section {
  margin-top: 24px;
  max-width: 1100px;
}
.kb-image-list {
  display: flex;
  flex-direction: column;
}
.kb-image-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.kb-image-row:last-child { border-bottom: none; }
.kb-image-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.kb-image-info {
  flex: 1;
  min-width: 0;
}
.kb-image-caption {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-image-edit-form {
  display: flex;
  align-items: center;
  gap: 6px;
}
.kb-image-edit-form .ctrl-input {
  height: 28px;
  font-size: 12px;
}

/* KB Lightbox */
.kb-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 40px;
  cursor: pointer;
}
.kb-lightbox.active {
  display: flex;
}
.kb-lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius);
  cursor: default;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.kb-lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.kb-lightbox-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}
.kb-lightbox-caption {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 600px;
}

/* ---- Assisted Pull ---- */
.assisted-pull-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.assisted-pull-container .page {
  display: none;
  flex-grow: 1;
  overflow: hidden;
  padding: 20px;
  box-sizing: border-box;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

.assisted-pull-container.menu-top .page { padding-top: 70px; padding-bottom: 20px; }
.assisted-pull-container.menu-bottom .page { padding-top: 20px; padding-bottom: 70px; }

.assisted-pull-container .page.active,
.assisted-pull-container .page.slide-left-out,
.assisted-pull-container .page.slide-right-out,
.assisted-pull-container .page.slide-left-in,
.assisted-pull-container .page.slide-right-in {
  display: flex;
  flex-direction: row;
  gap: 20px;
  justify-content: stretch;
}

/* Single column display */
.assisted-pull-container.column-display-one .page.active,
.assisted-pull-container.column-display-one .page.slide-left-out,
.assisted-pull-container.column-display-one .page.slide-right-out,
.assisted-pull-container.column-display-one .page.slide-left-in,
.assisted-pull-container.column-display-one .page.slide-right-in {
  justify-content: center;
}
.assisted-pull-container.column-display-one .ap-column { max-width: 1600px; width: 100%; margin: 0; }
.assisted-pull-container.column-display-one .ap-column:not(:first-child) { display: none; }

/* Slide animations */
.assisted-pull-container .page.slide-left-out  { animation: apSlideLeftOut 0.4s ease-in-out forwards; }
.assisted-pull-container .page.slide-right-out { animation: apSlideRightOut 0.4s ease-in-out forwards; }
.assisted-pull-container .page.slide-left-in   { animation: apSlideLeftIn 0.4s ease-in-out forwards; }
.assisted-pull-container .page.slide-right-in  { animation: apSlideRightIn 0.4s ease-in-out forwards; }

@keyframes apSlideLeftOut  { from { transform: translateX(0); }    to { transform: translateX(-100%); } }
@keyframes apSlideRightOut { from { transform: translateX(0); }    to { transform: translateX(100%); } }
@keyframes apSlideLeftIn   { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes apSlideRightIn  { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* Column */
.ap-column {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: calc(100vh - 40px - 70px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  min-width: 0;
  position: relative;
}

.ap-column.green-flash::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(38, 162, 67, 0.75);
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 1;
  animation: apGreenFlash 1s ease-in-out;
}

@keyframes apGreenFlash {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

.ap-column .bin-header {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-strong);
  text-align: left;
}

/* Card item */
.ap-card-item {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: clamp(4px, 0.3vw + 3px, 6px);
  margin-bottom: clamp(12px, 1vw + 8px, 18px);
  display: flex;
  gap: clamp(12px, 1vw + 8px, 18px);
  align-items: center;
  position: relative;
  transition: opacity 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
  overflow: hidden;
}

.ap-card-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-image);
  background-size: 155%;
  background-position: -50px -70px;
  background-repeat: no-repeat;
  filter: blur(25px) saturate(5.0);
  opacity: 0.25;
  z-index: 0;
  pointer-events: none;
}

.ap-card-item > * { position: relative; z-index: 1; }
.ap-card-item:hover { background: rgba(255, 255, 255, 0.02); }

/* Position display */
.ap-position-display {
  flex-shrink: 0;
  width: min(clamp(50px, 4vw + 25px, 70px), 8vh);
  height: min(clamp(140px, 11vw + 70px, 180px), 21vh);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  padding: 8px 4px;
  box-sizing: border-box;
}

.ap-position-number {
  font-size: clamp(1.9em, 1.7em + 0.5vw, 2.5em);
  font-weight: bold;
  color: white;
  line-height: 1;
  margin-bottom: 10px;
  position: relative;
}

.ap-position-number.has-similar-match  { border: 2px solid var(--text-secondary); border-radius: 4px; padding: 4px 8px; }
.ap-position-number.has-similar-mismatch { border: 2px solid var(--negative); border-radius: 4px; padding: 4px 8px; }

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

.ap-position-number.foil-position {
  background: linear-gradient(120deg, rgba(107,255,255,0.9) 15%, rgba(255,255,106,0.9) 50%, rgba(255,137,255,0.9) 85%);
  background-size: 200% 200%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: apRainbowFoil 4s infinite linear;
}

.ap-bin-label-small {
  font-size: clamp(0.75em, 0.65em + 0.3vw, 1.0em);
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1;
}

.ap-slot-number {
  margin-top: 5px;
  margin-bottom: 5px;
  text-align: center;
  font-size: clamp(1.3em, 1.1em + 0.4vw, 1.8em);
  color: white;
  font-weight: bold;
}

/* Position indicator bar */
.ap-position-container {
  position: relative;
  height: 12px;
  width: 80%;
  background: #444;
  border-radius: 3px;
  overflow: hidden;
}

.ap-position-line {
  width: 5px; height: 100%;
  background: #ccc;
  position: absolute; top: 0;
  transform: translateX(-50%);
  z-index: 2;
}

.ap-position-line-similar {
  width: 3px; height: 100%;
  background: #666;
  position: absolute; top: 0;
  transform: translateX(-50%);
  z-index: 1;
}

.ap-position-line-mismatch {
  width: 3px; height: 100%;
  background: var(--negative);
  position: absolute; top: 0;
  transform: translateX(-50%);
  z-index: 3;
}

/* Card image */
.ap-card-image {
  flex-shrink: 0;
  position: relative;
  width: min(clamp(100px, 8vw + 50px, 130px), 15vh);
  height: min(clamp(140px, 11vw + 70px, 180px), 21vh);
  overflow: hidden;
  border-radius: 5px;
}
.ap-card-image img { width: 100%; height: 100%; object-fit: cover; }

.ap-hover-image {
  display: none;
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.9);
  width: clamp(200px, 15vw + 100px, 280px);
  height: clamp(280px, 21vw + 140px, 390px);
  object-fit: contain;
}
.ap-card-image:hover + .ap-hover-image { display: block; }

/* Card details */
.ap-card-details {
  flex-grow: 1;
  font-size: clamp(0.65em, 0.5em + 0.4vw, 0.9em);
  height: min(clamp(140px, 11vw + 70px, 180px), 21vh);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ap-card-details .product-name { font-weight: bold; font-size: clamp(0.9em, 0.8em + 0.3vw, 1.2em); margin-bottom: 5px; }
.ap-card-details .set-name     { font-size: clamp(0.6em, 0.5em + 0.3vw, 0.8em); color: var(--text-secondary); margin-bottom: 8px; }
.ap-card-details .printing-condition { margin-bottom: 8px; font-size: clamp(0.85em, 0.75em + 0.2vw, 1em); }

.ap-similar-cards { font-size: clamp(0.85em, 0.75em + 0.2vw, 1em); color: var(--text-secondary); }
.ap-similar-cards .ap-warning-icon { color: #FFD700; font-size: 1.2em; }

@media (max-width: 768px)                        { .ap-card-details { font-size: 0.65em; } }
@media (min-width: 769px)  and (max-width: 1366px) { .ap-card-details { font-size: 0.75em; } }
@media (min-width: 1367px) and (max-width: 1920px) { .ap-card-details { font-size: 0.8em; } }
@media (min-width: 1921px)                        { .ap-card-details { font-size: 0.9em; } }

/* Similar-cards badges */
.ap-similar-cards .badge {
  display: inline-block;
  padding: 0.5em 0.4em;
  font-size: 75%;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.25rem;
  margin: 0 2px;
}
.ap-similar-cards .badge-current  { background: #444; color: #fff; border: 1px solid #444; }
.ap-similar-cards .badge-other    { background: transparent; border: 1px solid #444; color: var(--text-secondary); }
.ap-similar-cards .badge-mismatch { background: var(--negative); color: #fff; border: 1px solid var(--negative); }

/* Foil overlay on card images */
.ap-foil-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,0,255,0.2) 0%, rgba(0,255,255,0.3) 25%, rgba(255,255,0,0.2) 50%, rgba(0,255,0,0.3) 75%, rgba(255,0,255,0.2) 100%);
  background-size: 200% 200%;
  opacity: 0.9;
  mix-blend-mode: screen;
  animation: apRainbowFoil 4s infinite linear;
  border-radius: 5px;
}

/* Foil / language badges */
.ap-badge-foil {
  background: linear-gradient(120deg, rgba(107,255,255,0.69) 15%, rgba(255,255,106,0.60) 50%, rgba(255,137,255,0.66) 85%);
  background-size: 200% 200%;
  color: #1d1d1d;
  animation: apRainbowFoil 4s infinite linear;
  display: inline-block;
  padding: 0.25em 0.4em;
  font-size: 75%;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.25rem;
  margin-right: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ap-badge-language {
  background: #6c757d;
  color: #fff;
  display: inline-block;
  padding: 0.25em 0.4em;
  font-size: 75%;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.25rem;
  margin-right: 5px;
}

.ap-badge-info {
  display: inline-block;
  padding: 0.25em 0.5em;
  font-size: 0.85em;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--info);
  border-radius: 0.25rem;
  margin-left: 8px;
  vertical-align: middle;
}

/* Pagination controls */
.ap-pagination {
  position: fixed;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  z-index: 10;
}
.ap-pagination-top    { top: 0;    border-bottom: 1px solid var(--border-strong); }
.ap-pagination-bottom { bottom: 0; border-top: 1px solid var(--border-strong); }

.ap-pagination .ap-group { display: flex; align-items: center; gap: 8px; }

/* Uniform height for all pagination bar controls */
.ap-pagination .btn,
.ap-pagination .ctrl-select {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 36px;
  box-sizing: border-box;
}

.ap-pagination .ctrl-select { max-width: 200px; }

/* Next button - bolder to stand out */
.ap-btn-next { font-weight: 700; padding: 0 20px; }

.ap-btn-nearby { white-space: nowrap; min-width: 160px; }

/* Progress container */
.ap-progress {
  flex: 1;
  max-width: 300px;
  margin: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ap-progress-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ap-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-raised);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}

.ap-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #28a745, #20c997);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.ap-progress-text {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.ap-timer {
  font-size: 1.2em;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.3s ease;
  min-width: 40px;
  text-align: right;
}
.ap-timer.green  { color: #28a745; }
.ap-timer.yellow { color: var(--warning); }
.ap-timer.red    { color: var(--negative); }

/* Links */
.ap-bin-link,
.ap-product-link {
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}
.ap-bin-link:hover,
.ap-product-link:hover { text-decoration: underline; }

/* Modals */
.ap-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 999;
}

.ap-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
}

.ap-modal-sm { width: 80%; max-width: 800px; }
.ap-modal-lg { width: 90%; max-width: 900px; }

.ap-modal-header {
  background: var(--surface);
  padding: 10px 20px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.ap-modal-body {
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.ap-modal-close {
  color: var(--text-secondary);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  margin-right: 15px;
  margin-top: 5px;
  line-height: 0.7;
}
.ap-modal-close:hover { color: var(--text-primary); }

/* Oracle modal search bar */
.ap-modal-search {
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
}

.ap-modal-search .ap-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 140px;
  flex: 1;
}

.ap-modal-search label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.ap-modal-search input {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.ap-modal-search input:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: 0 0 0 2px rgba(68,123,190,0.2);
}

/* Oracle modal header flash messages */
.ap-header-flash {
  font-size: 0.9em;
  font-weight: normal;
  padding: 4px 10px;
  margin-left: 15px;
  border-radius: 4px;
  display: none;
}
.ap-header-flash.warning { display: inline-block; background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }
.ap-header-flash.danger  { display: inline-block; background: var(--negative-dim); color: var(--negative); border: 1px solid rgba(248,113,113,0.3); }
.ap-header-flash.success { display: inline-block; background: var(--positive-dim); color: var(--positive); border: 1px solid rgba(74,222,128,0.3); }

/* Oracle table */
.ap-oracle-table { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: var(--radius); overflow: hidden; }
.ap-oracle-table th, .ap-oracle-table td { text-align: left; padding: 8px 10px; vertical-align: middle; color: var(--text-primary); border-bottom: none; }
.ap-oracle-table thead { background: var(--surface-raised); }
.ap-oracle-table th { font-weight: 500; border-bottom: 2px solid var(--border-strong); }

.ap-oracle-table .col-bin       { width: 50px;  min-width: 50px;  max-width: 50px; }
.ap-oracle-table .col-pos       { width: 40px;  min-width: 40px;  max-width: 40px; }
.ap-oracle-table .col-name      { width: 150px; min-width: 150px; }
.ap-oracle-table .col-set       { width: 45px;  min-width: 45px;  max-width: 45px; }
.ap-oracle-table .col-condition { width: 45px;  min-width: 45px;  max-width: 45px; }
.ap-oracle-table .col-printing  { width: 60px;  min-width: 60px;  max-width: 60px; }
.ap-oracle-table .col-status    { width: 90px;  min-width: 90px;  max-width: 90px; }
.ap-oracle-table .col-action    { width: 120px; min-width: 120px; max-width: 120px; }

.ap-oracle-table tbody tr:nth-of-type(odd) td { background: rgba(255,255,255,0.05); }
.ap-oracle-table .highlight-row { background: rgba(68,123,190,0.2) !important; }
.ap-oracle-table .source-card-row { position: relative; outline: 2px solid var(--positive); outline-offset: -1px; }
.ap-oracle-table .source-card-row td { background: var(--positive-dim) !important; }

.ap-oracle-table .btn-replace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  height: 30px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.ap-oracle-table .btn-replace:hover { background: #43a047; }
.ap-oracle-table .btn-replace:active { transform: translateY(1px); }

.ap-oracle-table .status-select {
  width: 100%;
  padding: 4px 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ap-oracle-table .status-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(60,130,64,0.25); }

/* Status badges */
.ap-status-badge { padding: 0.25em 0.4em; font-size: 75%; font-weight: 700; border-radius: 0.25rem; }
.ap-status-1 { background: var(--surface-raised); color: #fff; }
.ap-status-4 { background: var(--info);    color: #fff; }
.ap-status-5 { background: var(--warning); color: #000; }
.ap-status-6 { background: var(--positive); color: #fff; }

/* Alert (used in modals) */
.ap-alert {
  position: relative;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
}
.ap-alert-info  { color: #0c5460; background: #d1ecf1; border-color: #bee5eb; }
.ap-alert-error { color: var(--negative); background: var(--negative-dim); border-color: var(--negative); }

/* Nearby cards */
.ap-nearby-container {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: none;
  align-items: center;
  width: clamp(340px, 25vw + 180px, 460px);
  z-index: 5;
  pointer-events: none;
}

.ap-nearby-card {
  position: relative;
  width: min(clamp(100px, 8vw + 50px, 130px), 15vh);
  height: min(clamp(140px, 11vw + 70px, 180px), 21vh);
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  transition: transform 0.2s ease;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  margin-left: -50px;
  pointer-events: auto;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
.ap-nearby-card:first-child { margin-left: 0; }
.ap-nearby-card:not(.target-card)::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: 5px;
}
.ap-nearby-card:hover { transform: translateY(-12px) scale(1.2); z-index: 10; }
.ap-nearby-card:hover::after { opacity: 0; }

/* Performance summary overlay */
.ap-perf-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  overflow-y: auto;
}

.ap-perf-content {
  max-width: 800px;
  margin: 50px auto;
  padding: 40px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.ap-perf-header { text-align: center; margin-bottom: 40px; }
.ap-perf-header h1 { font-size: 2.5em; margin-bottom: 10px; color: var(--text-primary); }

.ap-perf-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.ap-stat-card {
  background: var(--surface-raised);
  padding: 24px;
  border-radius: var(--radius);
  text-align: center;
}
.ap-stat-card .stat-label { font-size: 0.9em; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.ap-stat-card .stat-value { font-size: 2.5em; font-weight: bold; color: var(--text-primary); }
.ap-stat-card .stat-unit  { font-size: 0.9em; color: var(--text-secondary); }

.ap-perf-chart { margin-bottom: 40px; }
.ap-perf-chart h3 { margin-bottom: 20px; text-align: center; color: var(--text-primary); }

.ap-chart-bars {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  background: var(--surface-raised);
  border-radius: var(--radius);
}

.ap-chart-bar {
  display: flex;
  align-items: center;
  gap: 15px;
}

.ap-bar-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-primary);
  min-width: 80px;
  text-align: right;
}

.ap-bar-visual-container { flex: 1; display: flex; align-items: center; gap: 10px; }

.ap-bar-visual {
  height: 40px;
  border-radius: 0 6px 6px 0;
  position: relative;
  transition: width 0.5s ease;
  width: 0%;
  min-width: 0;
}

.ap-bar-count { font-size: 1.3em; font-weight: bold; color: var(--text-primary); min-width: 30px; }

.ap-chart-bar.bar-green  .ap-bar-visual { background: linear-gradient(to right, #28a745, #34ce57); }
.ap-chart-bar.bar-yellow .ap-bar-visual { background: linear-gradient(to right, var(--warning), #ffcd38); }
.ap-chart-bar.bar-red    .ap-bar-visual { background: linear-gradient(to right, var(--negative), #e4606d); }

.ap-perf-actions { display: flex; justify-content: center; gap: 20px; margin-top: 40px; }
.ap-perf-actions .btn-primary { padding: 10px 24px; font-size: 1em; }

/* Rows-2 mode (per-column: bins with 1-2 cards) */
.ap-column.rows-2 .ap-card-image {
  width: min(clamp(190px, 14.5vw + 95px, 247px), 30vh);
  height: min(clamp(265px, 22vw + 125px, 345px), 42vh);
  border-radius: 11px;
}
.ap-column.rows-2 .ap-position-display {
  width: min(clamp(100px, 8vw + 50px, 140px), 16vh);
  height: min(clamp(265px, 22vw + 125px, 345px), 42vh);
}
.ap-column.rows-2 .ap-position-number { font-size: clamp(3.8em, 3.4em + 1.0vw, 5.0em); }
.ap-column.rows-2 .ap-position-number.has-similar-match,
.ap-column.rows-2 .ap-position-number.has-similar-mismatch { border-width: 3px; padding: 6px 12px; }
.ap-column.rows-2 .ap-bin-label-small { font-size: clamp(1.5em, 1.3em + 0.6vw, 2.0em); }
.ap-column.rows-2 .ap-slot-number { font-size: clamp(2.6em, 2.2em + 0.8vw, 3.6em); }

.ap-column.rows-2 .ap-card-details { height: min(clamp(265px, 22vw + 125px, 345px), 42vh); }
.ap-column.rows-2 .ap-card-details .product-name        { font-size: clamp(1.8em, 1.6em + 0.6vw, 2.4em); }
.ap-column.rows-2 .ap-card-details .set-name             { font-size: clamp(1.2em, 1.0em + 0.6vw, 1.6em); }
.ap-column.rows-2 .ap-card-details .printing-condition   { font-size: clamp(1.7em, 1.5em + 0.4vw, 2.0em); }
.ap-column.rows-2 .ap-card-details .ap-similar-cards     { font-size: clamp(1.2em, 1.0em + 0.5vw, 1.5em); }

.ap-column.rows-2 .ap-hover-image {
  width: clamp(400px, 30vw + 200px, 560px);
  height: clamp(545px, 42vw + 265px, 765px);
}

.ap-column.rows-2 .ap-nearby-card {
  width: min(clamp(190px, 14.5vw + 95px, 247px), 30vh);
  height: min(clamp(265px, 22vw + 125px, 345px), 42vh);
  border-radius: 11px;
  margin-left: -95px;
}
.ap-column.rows-2 .ap-nearby-container { width: clamp(680px, 50vw + 350px, 920px); }
.ap-column.rows-2 .ap-nearby-card:hover { transform: translateY(-20px) scale(1.2); }

@media (max-width: 768px) {
  .ap-column.rows-2 .ap-card-details .product-name      { font-size: 1.6em; }
  .ap-column.rows-2 .ap-card-details .set-name           { font-size: 1.1em; }
  .ap-column.rows-2 .ap-card-details .printing-condition { font-size: 1.5em; }
  .ap-column.rows-2 .ap-card-details .ap-similar-cards   { font-size: 1.1em; }
}
@media (min-width: 769px) and (max-width: 1366px) {
  .ap-column.rows-2 .ap-card-details .product-name      { font-size: 1.9em; }
  .ap-column.rows-2 .ap-card-details .set-name           { font-size: 1.3em; }
  .ap-column.rows-2 .ap-card-details .printing-condition { font-size: 1.7em; }
  .ap-column.rows-2 .ap-card-details .ap-similar-cards   { font-size: 1.3em; }
}
@media (min-width: 1367px) and (max-width: 1920px) {
  .ap-column.rows-2 .ap-card-details .product-name      { font-size: 2.1em; }
  .ap-column.rows-2 .ap-card-details .set-name           { font-size: 1.4em; }
  .ap-column.rows-2 .ap-card-details .printing-condition { font-size: 1.85em; }
  .ap-column.rows-2 .ap-card-details .ap-similar-cards   { font-size: 1.4em; }
}
@media (min-width: 1921px) {
  .ap-column.rows-2 .ap-card-details .product-name      { font-size: 2.4em; }
  .ap-column.rows-2 .ap-card-details .set-name           { font-size: 1.6em; }
  .ap-column.rows-2 .ap-card-details .printing-condition { font-size: 2.0em; }
  .ap-column.rows-2 .ap-card-details .ap-similar-cards   { font-size: 1.5em; }
}

/* Rows-4 mode (per-column: bins with 3+ cards) */
.ap-column.rows-4 .ap-card-details .product-name        { font-size: clamp(1.4em, 1.3em + 0.3vw, 1.7em); }
.ap-column.rows-4 .ap-card-details .set-name             { font-size: clamp(1.1em, 1.0em + 0.3vw, 1.3em); }
.ap-column.rows-4 .ap-card-details .printing-condition   { font-size: clamp(1.35em, 1.25em + 0.2vw, 1.5em); }
.ap-column.rows-4 .ap-card-details .ap-similar-cards     { font-size: clamp(1.1em, 1.0em + 0.25vw, 1.25em); }

@media (max-width: 768px) {
  .ap-column.rows-4 .ap-card-details .product-name      { font-size: 1.35em; }
  .ap-column.rows-4 .ap-card-details .set-name           { font-size: 1.1em; }
  .ap-column.rows-4 .ap-card-details .printing-condition { font-size: 1.3em; }
  .ap-column.rows-4 .ap-card-details .ap-similar-cards   { font-size: 1.1em; }
}
@media (min-width: 769px) and (max-width: 1366px) {
  .ap-column.rows-4 .ap-card-details .product-name      { font-size: 1.45em; }
  .ap-column.rows-4 .ap-card-details .set-name           { font-size: 1.15em; }
  .ap-column.rows-4 .ap-card-details .printing-condition { font-size: 1.4em; }
  .ap-column.rows-4 .ap-card-details .ap-similar-cards   { font-size: 1.15em; }
}
@media (min-width: 1367px) and (max-width: 1920px) {
  .ap-column.rows-4 .ap-card-details .product-name      { font-size: 1.55em; }
  .ap-column.rows-4 .ap-card-details .set-name           { font-size: 1.2em; }
  .ap-column.rows-4 .ap-card-details .printing-condition { font-size: 1.45em; }
  .ap-column.rows-4 .ap-card-details .ap-similar-cards   { font-size: 1.2em; }
}
@media (min-width: 1921px) {
  .ap-column.rows-4 .ap-card-details .product-name      { font-size: 1.7em; }
  .ap-column.rows-4 .ap-card-details .set-name           { font-size: 1.3em; }
  .ap-column.rows-4 .ap-card-details .printing-condition { font-size: 1.5em; }
  .ap-column.rows-4 .ap-card-details .ap-similar-cards   { font-size: 1.25em; }
}
