/* ═══════════════════════════════════════════════════════════════════════════════
   Supplier Quotation System — Styles
   Light/Dark mode via CSS custom properties + .dark on <html>
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:           #f5f7fa;
  --bg-card:      #ffffff;
  --bg-sidebar:   #1e2a3a;
  --bg-input:     #ffffff;
  --border:       #e2e8f0;
  --text:         #1a202c;
  --text-muted:   #718096;
  --text-sidebar: #c8d3e0;
  --text-sidebar-active: #ffffff;
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --success:      #10b981;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --accent-login:      #c2410c;
  --accent-login-dark: #9a3412;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --radius:       10px;
  --sidebar-w:    240px;
  --transition:   0.2s ease;
}

html.dark {
  --bg:           #0f172a;
  --bg-card:      #1e293b;
  --bg-sidebar:   #0f172a;
  --bg-input:     #1e293b;
  --border:       #334155;
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  --shadow:       0 1px 4px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.screen-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.screen-card h1 { font-size: 1.6rem; margin-bottom: .5rem; }
.screen-card p  { color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.screen-card pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem 1rem;
  font-size: .8rem;
  text-align: left;
  overflow-x: auto;
  margin-bottom: 1rem;
}

/* ── Login screen (single centered card) ───────────────────────────────────────
   Fixed warm cream palette regardless of the in-app light/dark theme toggle —
   this is branding shown before the app (and its theme preference) loads. */
.login-screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: #f4ede1;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fdfaf3;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(60,45,25,.06), 0 12px 32px rgba(60,45,25,.08);
  padding: 3rem 2.5rem;
}

.login-header    { text-align: center; margin-bottom: 2.25rem; }
.login-wordmark  {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  font-size: 1.75rem;
  font-weight: 400;
  color: #2a2118;
  margin-bottom: .6rem;
}
.login-subtitle {
  font-size: .72rem;
  font-weight: 600;
  color: #9a8f7d;
  text-transform: uppercase;
  letter-spacing: .16em;
}

.login-label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  color: #9a8f7d;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .5rem;
}
.login-input {
  width: 100%;
  padding: .7rem .9rem;
  border: 1px solid #e4dac8;
  border-radius: 8px;
  font-size: .95rem;
  color: #2a2118;
  background: #ffffff;
  margin-bottom: 1.25rem;
}
.login-input:focus {
  outline: none;
  border-color: var(--accent-login);
  box-shadow: 0 0 0 3px rgba(194,65,12,.15);
}
.login-btn {
  width: 100%;
  padding: .75rem;
  border: none;
  border-radius: 8px;
  background: var(--accent-login);
  color: #ffffff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.login-btn:hover { background: var(--accent-login-dark); }
.login-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin-top: 1.25rem;
  font-size: .78rem;
  color: #9a8f7d;
  text-align: center;
}
.login-ms-icon { width: 14px; height: 14px; flex-shrink: 0; }
.login-error {
  color: var(--danger);
  font-size: .85rem;
  margin-bottom: 1rem;
  text-align: center;
}

@media (max-width: 480px) {
  .login-card { padding: 2.25rem 1.5rem; }
}

/* ── App layout ─────────────────────────────────────────────────────────────── */
#screen-app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-logo {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo h2 {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.sidebar-logo span { color: var(--primary); }

.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1.4rem;
  color: var(--text-sidebar);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  position: relative;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(59,130,246,.18);
  color: var(--text-sidebar-active);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 1.05rem; flex-shrink: 0; }
.nav-badge {
  display: none;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

.sidebar-footer {
  padding: .75rem 1.2rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info {
  font-size: .8rem;
  color: var(--text-sidebar);
  margin-bottom: .5rem;
  word-break: break-all;
}

/* ── Main content ────────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.topbar-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: .45rem .75rem .45rem 2.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: .88rem;
  outline: none;
  transition: border-color var(--transition);
}
.topbar-search input:focus { border-color: var(--primary); }
.topbar-search::before {
  content: "🔍";
  position: absolute;
  left: .6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  pointer-events: none;
}

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

/* ── Section headers ──────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.section-header h2 { font-size: 1.25rem; font-weight: 700; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.stat-card-success { border-left: 3px solid var(--success); }
.stat-card-danger  { border-left: 3px solid var(--danger);  }
.stat-card-warning { border-left: 3px solid var(--warning); }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-sub   { font-size: .78rem; color: var(--text-muted); }

/* ── Comparison summary strip ─────────────────────────────────────────────────── */
.comparison-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.comparison-summary .stat-card { flex: 1; min-width: 140px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm  { padding: .3rem .75rem; font-size: .8rem; }
.btn-xs  { padding: .2rem .55rem; font-size: .75rem; }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  display: block;
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.form-grid .span2 { grid-column: span 2; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: rgba(59,130,246,.12);
  color: var(--primary);
  border: 1px solid rgba(59,130,246,.2);
}
.badge-success { background: rgba(16,185,129,.12); color: var(--success); border-color: rgba(16,185,129,.2); }
.badge-danger  { background: rgba(239,68,68,.12);  color: var(--danger);  border-color: rgba(239,68,68,.2);  }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); border-color: rgba(245,158,11,.2); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}
.data-table th {
  text-align: left;
  padding: .65rem .9rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(59,130,246,.04); }
.data-table tbody tr:last-child td { border-bottom: none; }
.row-best  { background: rgba(16,185,129,.06)  !important; }
.row-worst { background: rgba(239,68,68,.06)   !important; }

/* ── Pivot table (Comparison: Compare Multiple / Show All) ─────────────────────── */
.pivot-table th, .pivot-table td { white-space: nowrap; }
.pivot-cheapest {
  background: rgba(16,185,129,.12);
  font-weight: 700;
  color: var(--success);
  cursor: help;
}
.pivot-empty { color: var(--text-muted); text-align: center; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  gap: .75rem;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; flex: 1; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: .2rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body    { padding: 1.4rem; }
.modal-footer  {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
}

/* ── Drag-and-drop zone ──────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(59,130,246,.05);
}
.attachment-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem .5rem;
  border-radius: 6px;
  font-size: .85rem;
}
.attachment-item.pending { opacity: .7; }
.attachment-item a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Dashboard widgets grid ──────────────────────────────────────────────────── */
.widgets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.widget-full { grid-column: span 2; }
.widget-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .1rem;
  border-bottom: 1px solid var(--border);
  font-size: .87rem;
}
.widget-row:last-child { border-bottom: none; }
.widget-label { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-num { font-weight: 700; color: var(--text-muted); font-size: .85rem; min-width: 22px; }

/* ── Chart containers ────────────────────────────────────────────────────────── */
.chart-container { position: relative; min-height: 200px; }

/* ── Filters bar ─────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}
.filters-bar input, .filters-bar select {
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: .88rem;
  outline: none;
}
.filters-bar input:focus, .filters-bar select:focus { border-color: var(--primary); }

/* ── Reports grid ─────────────────────────────────────────────────────────────── */
/* ── Search ──────────────────────────────────────────────────────────────────── */
.search-input-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}
.search-input-wrap input {
  width: 100%;
  padding: .75rem 1rem .75rem 2.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.search-input-wrap input:focus { border-color: var(--primary); }
.search-input-wrap::before {
  content: "🔍";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}
.search-group { margin-bottom: 2rem; }
.search-product-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--primary);
}
.search-count { font-size: .88rem; color: var(--text-muted); margin-bottom: 1rem; }

/* ── Alerts filter bar ────────────────────────────────────────────────────────── */
.alert-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.alert-tab {
  padding: .4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.alert-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Reports type tabs ───────────────────────────────────────────────────────── */
.report-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.report-tab {
  padding: .4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.report-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Comparison checklist (Compare Multiple mode) ──────────────────────────────── */
.comparison-checklist {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .25rem;
}
.comparison-check-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border-radius: 6px;
  font-size: .88rem;
  cursor: pointer;
}
.comparison-check-item:hover { background: var(--bg); }
.comparison-check-item input { cursor: pointer; }

/* ── States ──────────────────────────────────────────────────────────────────── */
.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 2.5rem;
  font-size: .9rem;
}
.empty-state strong { color: var(--text); }
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-muted);
}
.error-state { color: var(--danger); padding: 1.5rem; font-size: .9rem; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Global loading overlay ──────────────────────────────────────────────────── */
#global-loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  color: #fff;
  font-size: .95rem;
}

/* ── Toast notifications ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  font-size: .88rem;
  min-width: 220px;
  max-width: 380px;
  animation: slideUp .25s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger);  }
.toast-warn    { border-left: 3px solid var(--warning);  }
.toast-info    { border-left: 3px solid var(--primary); }
.toast span    { flex: 1; }
.toast button  { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--text-muted); }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Text utilities ──────────────────────────────────────────────────────────── */
.text-success { color: var(--success); font-weight: 600; }
.text-danger  { color: var(--danger);  font-weight: 600; }
.text-muted   { color: var(--text-muted); }
.text-right   { text-align: right; }

/* ── Mobile hamburger ────────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: .25rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .widgets-grid { grid-template-columns: 1fr; }
  .widget-full  { grid-column: span 1; }
  .form-grid    { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
}

@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  .hamburger { display: inline-flex; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }

  /* Responsive table — card layout */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
  }
  .data-table tr {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: .75rem;
    padding: .25rem 0;
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    padding: .4rem .9rem;
    border-bottom: 1px solid var(--border);
  }
  .data-table td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    min-width: 90px;
  }

  /* Pivot table has a variable, often-wide set of supplier columns — keep it a
     real scrollable grid on mobile instead of the stacked-card conversion above. */
  .pivot-table, .pivot-table thead, .pivot-table tbody,
  .pivot-table tr, .pivot-table th, .pivot-table td {
    display: revert;
  }
  .pivot-table tr { border: none; margin-bottom: 0; }
  .pivot-table td {
    padding: .6rem .9rem;
    border-bottom: 1px solid var(--border);
  }
  .pivot-table td::before { content: none; }

  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar input, .filters-bar select { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .comparison-summary { flex-direction: column; }
  .topbar-search { display: none; }
  .modal-box { max-width: 100%; border-radius: 12px; }
  #toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { min-width: unset; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 1rem .75rem; }
}
