:root {
  --xr-brand: #1e3a8a;
  --xr-accent: #6366f1;
  --xr-surface: #ffffff;
  --xr-bg: #f4f6f9;
  --xr-border: #e2e8f0;
  --xr-muted: #64748b;
  --xr-radius: 10px;
  --xr-shadow: 0 1px 4px rgba(0,0,0,.08);
  --xr-shadow-md: 0 3px 14px rgba(0,0,0,.10);

  /* Typography scale */
  --xr-text-xs: .72rem;
  --xr-text-sm: .825rem;
  --xr-text-base: .925rem;
  --xr-text-lg: 1.1rem;

  /* Spacing scale */
  --xr-space-xs: .375rem;
  --xr-space-sm: .625rem;
  --xr-space-md: 1rem;
  --xr-space-lg: 1.5rem;
}

body {
  background: var(--xr-bg);
  color: #1a202c;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ─────────────────────────────────────── */
.xr-navbar {
  background: var(--xr-surface);
  border-bottom: 1px solid var(--xr-border);
  padding: .75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.xr-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--xr-brand);
  letter-spacing: -.01em;
}

.xr-brand-dot { color: #ef4444; }

/* ── Cards ──────────────────────────────────────── */
.xr-card {
  background: var(--xr-surface);
  border: 1px solid var(--xr-border) !important;
  border-radius: var(--xr-radius) !important;
  box-shadow: var(--xr-shadow) !important;
}

/* ── Filters bar ────────────────────────────────── */
.filters-bar {
  background: var(--xr-surface);
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  padding: .875rem 1rem;
  box-shadow: var(--xr-shadow);
  margin-bottom: 1rem;
}

/* ── Stat cards ─────────────────────────────────── */
.stat-card {
  background: var(--xr-surface);
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  padding: 1rem .75rem;
  text-align: center;
  box-shadow: var(--xr-shadow);
  height: 100%;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: .15rem;
}

.stat-card .stat-label {
  font-size: .7rem;
  color: var(--xr-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ── Item rows ──────────────────────────────────── */
.item-row {
  display: flex;
  align-items: center;
  gap: .875rem;
  background: var(--xr-surface);
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  padding: .875rem 1rem;
  margin-bottom: .5rem;
  text-decoration: none;
  color: #1a202c;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

.item-row:hover {
  box-shadow: var(--xr-shadow-md);
  border-color: #a5b4fc;
  background: #fafaff;
  color: #1a202c;
}

/* ── Thumbnails ─────────────────────────────────── */
.item-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--xr-border);
}

.no-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  border: 1px solid var(--xr-border);
}

/* ── Status badges ──────────────────────────────── */
.xr-badge {
  font-size: .68rem;
  font-weight: 600;
  padding: .3em .75em;
  border-radius: 99px;
  letter-spacing: .03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-captured      { background: #dbeafe; color: #1e40af; }
.badge-needs_review  { background: #fef3c7; color: #92400e; }
.badge-approved      { background: #d1fae5; color: #065f46; }
.badge-ready_to_post { background: #bbf7d0; color: #14532d; }
.badge-rejected      { background: #fee2e2; color: #991b1b; }
.badge-posted        { background: #ede9fe; color: #5b21b6; }
.badge-sold          { background: #fce7f3; color: #9d174d; }
.badge-storage       { background: #f1f5f9; color: #475569; }
.badge-warehouse     { background: #f1f5f9; color: #475569; }

/* ── Section label ──────────────────────────────── */
.section-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--xr-muted);
}

/* ── Item photo (detail page) ───────────────────── */
.item-photo-wrap {
  border-radius: var(--xr-radius);
  overflow: hidden;
  box-shadow: var(--xr-shadow-md);
  background: #f1f5f9;
  margin-bottom: 1.25rem;
}

.item-photo {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

/* ── Detail fields ──────────────────────────────── */
.field-label { font-size: .75rem; color: var(--xr-muted); margin-bottom: .15rem; }
.field-value { font-weight: 600; font-size: .925rem; }

/* ── Form polish ────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ── Empty state ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--xr-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  opacity: .35;
  margin-bottom: .75rem;
}

/* ── Pending queue badge ────────────────────────── */
.xr-badge-pending {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: .7rem;
  font-weight: 700;
  padding: .25em .65em;
  border-radius: 99px;
  white-space: nowrap;
}

/* ── Cache badge ────────────────────────────────── */
.xr-badge-cached {
  background: #e0f2fe;
  color: #0369a1;
  font-size: .68rem;
  font-weight: 600;
  padding: .3em .75em;
  border-radius: 99px;
  letter-spacing: .03em;
  white-space: nowrap;
}

/* ── Offline banner ─────────────────────────────── */
.xr-offline-banner {
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  color: #92400e;
  font-size: .825rem;
  font-weight: 600;
  padding: .45rem 1.25rem;
  text-align: center;
}

/* ── Print ──────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }
  #qrSection { display: block !important; }
  body { background: white; }
  .xr-sidebar { display: none !important; }
  .xr-main { margin-left: 0 !important; }
}

/* ── Admin layout (sidebar) ─────────────────────── */
.xr-sidebar.loading { visibility: hidden; }

.xr-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 216px;
  height: 100vh;
  background: var(--xr-surface);
  border-right: 1px solid var(--xr-border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  padding: 1.25rem 0 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.xr-sidebar-brand {
  padding: 0 1.25rem 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--xr-brand);
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--xr-border);
  margin-bottom: .5rem;
}

.xr-sidebar-label {
  padding: .75rem 1.25rem .25rem;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
}

.xr-nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .55rem 1rem;
  margin: .1rem .625rem;
  font-size: .845rem;
  font-weight: 500;
  color: var(--xr-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: background .12s, color .12s;
}

.xr-nav-item:hover {
  background: #f1f5f9;
  color: #1a202c;
}

.xr-sidebar-footer {
  margin-top: auto;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--xr-border);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.xr-powered-logo {
  height: 18px;
  width: auto;
  opacity: .75;
  flex-shrink: 0;
}

.xr-powered-text {
  font-size: .62rem;
  color: #94a3b8;
  font-weight: 500;
  letter-spacing: .01em;
}

.xr-nav-item.active {
  background: #ede9fe;
  color: var(--xr-accent);
  font-weight: 600;
}

.xr-nav-icon {
  width: 16px;
  text-align: center;
  font-size: .85rem;
  flex-shrink: 0;
}

.xr-main {
  margin-left: 216px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.xr-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--xr-surface);
  border-bottom: 1px solid var(--xr-border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.xr-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Metric cards ───────────────────────────────── */
.xr-metric-card {
  background: var(--xr-surface);
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  padding: 1.25rem 1.125rem;
  box-shadow: var(--xr-shadow);
  height: 100%;
}

.xr-metric-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: .2rem;
  letter-spacing: -.02em;
}

.xr-metric-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--xr-muted);
  margin-bottom: .75rem;
}

/* ── Status bar chart ───────────────────────────── */
.xr-chart-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: .625rem;
}

.xr-chart-bar-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.xr-chart-bar-label {
  width: 100px;
  flex-shrink: 0;
  font-size: .775rem;
  color: #475569;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xr-chart-bar-track {
  flex: 1;
  height: 22px;
  background: #f1f5f9;
  border-radius: 5px;
  overflow: hidden;
}

.xr-chart-bar-fill {
  height: 100%;
  border-radius: 5px;
  min-width: 2px;
}

.xr-chart-bar-val {
  width: 30px;
  font-size: .775rem;
  font-weight: 600;
  color: #1a202c;
  text-align: right;
  flex-shrink: 0;
}

/* ── Activity feed ──────────────────────────────── */
.xr-activity-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .625rem 0;
  border-bottom: 1px solid var(--xr-border);
}

.xr-activity-item:last-child { border-bottom: none; }

.xr-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--xr-accent);
  flex-shrink: 0;
  margin-top: 4px;
}

/* ── Quick action buttons ───────────────────────── */
.xr-action-btn {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .625rem 1rem;
  background: var(--xr-surface);
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  font-size: .845rem;
  font-weight: 500;
  color: #1a202c;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: box-shadow .12s, border-color .12s, background .12s;
  font-family: inherit;
}

.xr-action-btn:hover {
  box-shadow: var(--xr-shadow-md);
  border-color: #a5b4fc;
  background: #fafaff;
  color: #1a202c;
}

.xr-action-icon {
  font-size: .9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: .65;
}

/* ── Mobile responsive ───────────────────────────── */
@media (max-width: 767px) {
  .xr-sidebar { display: none !important; }
  .xr-main { margin-left: 0 !important; }
  .xr-content { padding: 1rem; }
  .xr-header { padding: .625rem 1rem; }
}

/* ── Page header block ──────────────────────────── */
.xr-page-header {
  margin-bottom: 1.25rem;
}

.xr-page-header .xr-page-title {
  font-size: var(--xr-text-lg);
  font-weight: 700;
  color: #1a202c;
  line-height: 1.2;
}

.xr-page-header .xr-page-subtitle {
  font-size: var(--xr-text-sm);
  color: var(--xr-muted);
  margin-top: .2rem;
}

/* ── Header user context ─────────────────────────── */
.xr-header-ctx {
  font-size: var(--xr-text-sm);
  color: var(--xr-muted);
}

/* ── Form group helper ──────────────────────────── */
.xr-form-label {
  font-size: var(--xr-text-xs);
  font-weight: 600;
  color: var(--xr-muted);
  margin-bottom: .3rem;
  display: block;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.xr-helper-text {
  font-size: var(--xr-text-xs);
  color: var(--xr-muted);
  margin-top: .25rem;
}

/* ── Login page ─────────────────────────────────── */
.xr-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--xr-bg);
  padding: 1.5rem;
}

.xr-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--xr-surface);
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  box-shadow: var(--xr-shadow-md);
  padding: 2.5rem 2rem 2rem;
}

.xr-login-brand {
  font-weight: 800;
  font-size: 1.45rem;
  color: var(--xr-brand);
  letter-spacing: -.02em;
}

/* ── SaaS top-right toast ───────────────────────── */
#xr-toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  pointer-events: none;
}

.xr-toast {
  min-width: 260px;
  max-width: 360px;
  padding: .85rem 1.1rem;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,.13);
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.4;
  pointer-events: all;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .22s ease, transform .22s ease;
  display: flex;
  align-items: flex-start;
  gap: .65rem;
}

.xr-toast.xr-toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.xr-toast--success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.xr-toast--warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.xr-toast--error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

.xr-toast__icon { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }
.xr-toast__body { flex: 1; }
.xr-toast__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
  opacity: .5;
  padding: 0;
  flex-shrink: 0;
  color: inherit;
}
.xr-toast__close:hover { opacity: 1; }

@media (max-width: 480px) {
  #xr-toast-container { top: .75rem; right: .75rem; left: .75rem; }
  .xr-toast { max-width: 100%; }
}

/* info toast variant */
.xr-toast--info { background: #f0f4ff; border: 1px solid #a5b4fc; color: #3730a3; }

/* ── Topbar bell + profile (TASK-79) ─────────── */
.xr-topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.xr-dropdown-wrap {
  position: relative;
}

.xr-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--xr-border);
  background: var(--xr-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.xr-icon-btn:hover { background: #f1f5f9; border-color: #a5b4fc; }

.xr-bell-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--xr-border);
  background: var(--xr-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #475569;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
  padding: 0;
}
.xr-bell-btn:hover { background: #f1f5f9; border-color: #a5b4fc; }

.xr-unread-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1.5px solid #fff;
}

.xr-profile-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--xr-accent);
  background: #eef2ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--xr-accent);
  transition: background .15s;
  flex-shrink: 0;
  padding: 0;
}
.xr-profile-btn:hover { background: #e0e7ff; }

/* Dark variants for intake PWA header */
.xr-bell-btn--dark {
  border-color: rgba(255,255,255,.35);
  background: transparent;
  color: #fff;
}
.xr-bell-btn--dark:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.6);
}
.xr-profile-btn--dark {
  border-color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.15);
  color: #fff;
}
.xr-profile-btn--dark:hover { background: rgba(255,255,255,.25); }

.xr-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--xr-border);
  border-radius: var(--xr-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 600;
  overflow: hidden;
}

.xr-dropdown-wrap.is-open .xr-dropdown-panel { display: block; }

.xr-dropdown-panel--right { right: 0; left: auto; }

.xr-dropdown-header {
  padding: .55rem .875rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--xr-muted);
  border-bottom: 1px solid var(--xr-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xr-dropdown-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .575rem .875rem;
  font-size: .845rem;
  color: #1a202c;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  line-height: 1.4;
}
.xr-dropdown-item:hover { background: #f8fafc; color: #1a202c; text-decoration: none; }

.xr-dropdown-icon { font-size: .85rem; width: 18px; text-align: center; flex-shrink: 0; }

.xr-dropdown-divider { border-top: 1px solid var(--xr-border); margin: .25rem 0; }

.xr-dropdown-item--logout {
  background: #fafafa;
  color: #ef4444;
}
.xr-dropdown-item--logout:hover { background: #fef2f2; color: #dc2626; }

.xr-dropdown-empty {
  padding: .875rem;
  font-size: .82rem;
  color: var(--xr-muted);
  text-align: center;
}

@media (max-width: 767px) {
  .xr-dropdown-panel { min-width: 190px; }
  .xr-topbar-actions { gap: .375rem; }
}
