/* ── Reset & Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Respect user's browser font-size preference; all rem values scale with it */
html { font-size: 100%; }

:root {
  /* Ruitenberg brand colors */
  --brand:        #3d4a5c;   /* charcoal from logo */
  --brand-hover:  #2d3748;
  --brand-light:  #f0f2f5;
  --brand-accent: #c4a882;   /* beige diamond from logo */

  /* Sidebar — clean white */
  --sidebar-bg:   #ffffff;
  --sidebar-text: #374151;
  --sidebar-muted:#4b5563;
  --sidebar-hover:#f3f4f6;
  --sidebar-active:#f3f4f6;
  --sidebar-border:1px solid #e5e7eb;

  /* Page — clean white */
  --bg:           #ffffff;
  --surface:      #ffffff;
  --border:       #e5e7eb;
  --border-light: #f9fafb;

  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #6b7280;

  /* Status */
  --green:        #166534;
  --green-bg:     #f0fdf4;
  --green-border: #bbf7d0;
  --orange:       #92400e;
  --orange-bg:    #fffbeb;
  --orange-border:#fde68a;
  --red:          #b91c1c;
  --red-bg:       #fef2f2;
  --red-border:   #fecaca;
  --blue:         #2563eb;
  --blue-bg:      #eff6ff;
  --blue-border:  #bfdbfe;
  --gray-bg:      #f3f4f6;
  --gray-border:  #d1d5db;

  /* Layout */
  --sidebar-w:      15rem;   /* 240px at 16px root — scales with user font prefs */
  --list-pane-w:    28%;     /* split-pane list width; overridden by JS from localStorage */

  /* Spacing scale — use these instead of hardcoded px/rem */
  --space-xs:   0.25rem;
  --space-sm:   0.5rem;
  --space-md:   0.75rem;
  --space-lg:   1rem;
  --space-xl:   1.5rem;
  --space-2xl:  2rem;

  /* Border radius */
  --radius-sm:    0.375rem;
  --radius:       0.5rem;
  --radius-lg:    0.75rem;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;   /* dynamic viewport height: accounts for mobile browser bars */
  min-width: 0;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  padding: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo-placeholder {
  width: 28px;
  height: 28px;
  background: var(--brand);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.brand-divider {
  color: var(--border);
  font-size: 1.125rem;
  font-weight: 300;
}

.brand-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.625rem;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0.5rem 0.625rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}

.nav-item:hover { background: var(--sidebar-hover); color: var(--brand); }
.nav-item.active { background: var(--sidebar-active); color: var(--brand); font-weight: 600; }

.nav-icon {
  width: 16px;
  height: 16px;
  opacity: .7;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0.75rem 0.625rem;
  border-top: 1px solid var(--border);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8125rem;
  color: var(--sidebar-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}

.logout-btn:hover { color: var(--text-primary); background: var(--sidebar-hover); }

/* ── Main content ────────────────────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;          /* prevent flex child from overflowing sidebar */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

.page-content {
  padding: 2rem;
  flex: 1;
}

/* ── Inline alerts (used in errors/login pages only) ─────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  border-left: 4px solid;
}
.alert-success { background: var(--green-bg); color: var(--green); border-left-color: var(--green); }
.alert-error   { background: var(--red-bg);   color: var(--red);   border-left-color: var(--red); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1.4;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--border-light); border-color: #d1d5db; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--border-light); color: var(--text-primary); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover { background: #fde8e8; }

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards / Panels ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 1.25rem; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-new       { background: var(--gray-bg);    color: var(--text-secondary); }
.badge-processing{ background: var(--blue-bg);    color: var(--blue); }
.badge-ready     { background: var(--orange-bg);  color: var(--orange); }
.badge-pushed    { background: var(--green-bg);   color: var(--green); }
.badge-error     { background: var(--red-bg);     color: var(--red); }
.badge-warning   { background: var(--orange-bg);  color: var(--orange); }
.badge-draft     { background: var(--gray-bg);    color: var(--text-secondary); }
.badge-cancelled { background: #f3f4f6;           color: #6b7280; }

.confidence-high   { color: var(--green);  font-size: 0.75rem; font-weight: 600; }
.confidence-medium { color: var(--orange); font-size: 0.75rem; font-weight: 600; }
.confidence-none   { color: var(--red);    font-size: 0.75rem; font-weight: 600; }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--border-light);
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--border-light); }

tbody td {
  padding: 0.75rem 0.875rem;
  color: var(--text-primary);
  vertical-align: middle;
}

.cell-muted { color: var(--text-muted); font-size: 0.8125rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"] {
  width: 100%;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

/* ── Search dropdowns ────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }

.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 300;
  max-height: 220px;
  overflow-y: auto;
}

.dropdown-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-primary);
  transition: background .1s;
  border-bottom: 1px solid var(--border-light);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item.focused { background: var(--brand-light); }
.dropdown-item small { color: var(--text-muted); }

/* ── Order list (index) ──────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sender-cell { font-size: 0.8125rem; color: var(--text-secondary); }
.subject-cell { font-weight: 500; }
.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 0.9375rem;
}

/* ── Order detail ────────────────────────────────────────────────────────────── */
.order-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.order-meta h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.odoo-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
  padding: 0.25rem 0.625rem;
  border-radius: 99px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.matched-product { color: var(--green); font-weight: 500; }
.unmatched-product { color: var(--text-muted); }

.qty-input, .price-input {
  width: 5rem;           /* ~80px at 16px root, scales with font preference */
  padding: 0.3125rem 0.5rem;
}

.product-search-input {
  width: 100%;           /* fill its cell — table column width controls size */
  min-width: 7rem;
  padding: 0.3125rem 0.5rem;
  font-size: 0.8125rem;
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  width: 100%;
}

.action-bar-left  { display: flex; align-items: center; gap: 0.75rem; }
.action-bar-right { display: flex; align-items: center; gap: 0.75rem; }

.pushed-notice {
  color: var(--green);
  font-size: 0.875rem;
  font-weight: 500;
}

.attachment-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.attachment-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.attachment-list a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}
.attachment-list a:hover { text-decoration: underline; }

.mime-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--border-light);
  border: 1px solid var(--border);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.25rem;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  background: var(--bg);
  margin-left: 0;
  box-sizing: border-box;
}

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

.login-error {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 2rem;
}
.login-error h2 { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-error p  { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

@media (max-width: 480px) {
  .login-page { padding: 1.25rem 1rem; align-items: flex-start; padding-top: max(2.5rem, env(safe-area-inset-top, 2.5rem)); }
  .login-card { padding: 1.75rem 1.25rem; border-radius: var(--radius); box-shadow: none; }
  /* 16px prevents iOS Safari from zooming into inputs */
  .login-card input[type="text"],
  .login-card input[type="password"],
  .login-card input[type="email"] { font-size: 1rem; min-height: 2.75rem; }
  .login-card .btn-full { min-height: 2.75rem; font-size: 1rem; }
  .login-brand { margin-bottom: 1.5rem; }
  .login-subtitle { margin-bottom: 1.25rem; }
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin-bottom: 2rem;
}

.login-brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.login-brand-placeholder {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.login-brand-divider {
  color: var(--border);
  font-size: 1.25rem;
  font-weight: 300;
}

.login-brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-microsoft {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-microsoft:hover { background: var(--border-light); }

/* ── Toast notifications ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  padding: 0.875rem 0.875rem 0.875rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  min-width: 280px;
  max-width: 380px;
  position: relative;
  overflow: hidden;
  animation: toast-in .25s cubic-bezier(.21,1.02,.73,1) forwards;
}

.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-error   .toast-icon { color: var(--red); }
.toast-warning { border-left-color: var(--orange); }
.toast-warning .toast-icon { color: var(--orange); }
.toast-default { border-left-color: var(--brand); }
.toast-default .toast-icon { color: var(--brand); }

.toast-icon { flex-shrink: 0; display: flex; }

.toast-msg {
  flex: 1;
  line-height: 1.4;
  font-weight: 500;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0.125rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.toast-close:hover { color: var(--text-primary); background: var(--border-light); }

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: currentColor;
  opacity: 0.2;
  border-radius: 0 0 0 4px;
}

.toast-exit {
  animation: toast-out .25s cubic-bezier(.06,.71,.55,1) forwards;
}

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

@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; max-height: 100px; margin-bottom: 0; }
  to   { transform: translateX(calc(100% + 1.5rem)); opacity: 0; max-height: 0; margin-bottom: -0.625rem; }
}

/* ── Tab bar ──────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }


/* ── Developer mode ──────────────────────────────────────────────────────────── */
.dev-mode-indicator {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  text-align: center;
  letter-spacing: 0.07em;
  margin: 0 0.625rem 0.25rem;
  cursor: default;
}
.dev-view-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(239, 68, 68, 0.88);
  color: #fff;
  font-size: 0.6rem;
  font-family: monospace;
  font-weight: 700;
  padding: 0.18rem 0.4rem;
  border-radius: 3px;
  z-index: 9000;
  cursor: pointer;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: all;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  user-select: none;
  transition: background .1s;
}
.dev-view-badge:hover { background: rgba(185, 28, 28, 0.95); }

/* ── Portal detail grid classes ──────────────────────────────────────────── */
.p-detail-row {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}
.p-detail-row-sidebar { grid-template-columns: minmax(300px, 380px) 1fr; }
.p-detail-row-half    { grid-template-columns: 1fr 1fr; }
.p-detail-row-full    { grid-template-columns: 1fr; }

@media (max-width: 960px) {
  .p-detail-row-sidebar { grid-template-columns: 1fr; }
}

/* ── Mobile topbar (hidden on desktop) ───────────────────────────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  z-index: 150;
}
.hamburger-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  flex-shrink: 0;
}
.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 250;
  cursor: pointer;
}
.sidebar-overlay.open { display: block; }

/* ── Mobile breakpoints ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { min-width: 0; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    z-index: 300;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0,0,0,.15);
  }

  /* Topbar: fixed at top — reliable on iOS Safari (sticky in flex fails there) */
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  /* Push content below the fixed topbar (topbar height ≈ 3rem = 48px) */
  .main-wrap {
    margin-left: 0;
    padding-top: 3rem;
  }

  .page-content  {
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .p-detail-row-sidebar,
  .p-detail-row-half { grid-template-columns: 1fr; }

  /* Safari: prevent content wider than viewport */
  .page-content, .main-wrap { max-width: 100vw; overflow-x: hidden; }

}

