/* ============================================================
   HEXON WAREHOUSE — PREMIUM DESIGN SYSTEM
   ============================================================ */

:root {
  --bg-primary: #07070b;
  --bg-secondary: #0f1017;
  --bg-card: #14151f;
  --bg-card-hover: #1a1b28;
  --bg-elevated: #1e1f2e;
  --bg-input: #12131c;
  --border: rgba(255,255,255,0.06);
  --border-focus: rgba(99,102,241,0.5);
  --text-primary: #f0f0f5;
  --text-secondary: #8b8d9e;
  --text-muted: #5c5e72;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99,102,241,0.15);
  --accent-soft: rgba(99,102,241,0.08);
  --success: #22c55e;
  --success-soft: rgba(34,197,94,0.1);
  --success-border: rgba(34,197,94,0.25);
  --warning: #f59e0b;
  --warning-soft: rgba(245,158,11,0.1);
  --warning-border: rgba(245,158,11,0.25);
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,0.1);
  --danger-border: rgba(239,68,68,0.25);
  --purple: #a855f7;
  --purple-soft: rgba(168,85,247,0.1);
  --nav-height: 68px;
  --topbar-height: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(168,85,247,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.login-logo svg { width: 28px; height: 28px; }

.login-box h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.login-box .sub {
  font-size: 13px;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-field {
  position: relative;
  margin-bottom: 14px;
}
.login-field input {
  display: block;
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.login-field input::placeholder { color: var(--text-muted); }
.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-field .field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 14px;
  display: none;
  padding: 10px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
}

.btn-login {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform var(--transition), box-shadow var(--transition);
  margin-top: 4px;
}
.btn-login:active { transform: scale(0.98); }
.btn-login:hover { box-shadow: 0 4px 20px rgba(99,102,241,0.4); }

/* ============================================================
   APP SHELL
   ============================================================ */

#appShell { display: none; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: var(--topbar-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-logo svg { width: 16px; height: 16px; }
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-user { font-size: 11px; color: var(--text-secondary); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.btn-refresh-top, .btn-settings-top {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-refresh-top:active, .btn-settings-top:active { background: var(--accent-soft); color: var(--accent); }
.btn-settings-top:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.btn-refresh-top.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Notification Preferences page (Phase 4D Item 2) === */
.np-subhead { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.np-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 12px; overflow: hidden; }
.np-cat-header { display: flex; align-items: center; padding: 14px 16px; cursor: pointer; user-select: none; gap: 12px; }
.np-cat-header:active { background: var(--bg-card-hover); }
.np-cat-icon { font-size: 20px; flex-shrink: 0; }
.np-cat-text { flex: 1; min-width: 0; }
.np-cat-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.np-cat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.np-chevron { font-size: 12px; color: var(--text-muted); transition: transform 0.15s; }
.np-card.open .np-chevron { transform: rotate(90deg); color: var(--accent); }
.np-toggle { width: 38px; height: 22px; appearance: none; -webkit-appearance: none; background: var(--border); border-radius: 11px; position: relative; cursor: pointer; transition: background 0.15s; flex-shrink: 0; outline: none; border: 0; margin: 0; }
.np-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.np-toggle:checked { background: var(--accent); }
.np-toggle:checked::after { left: 18px; }
.np-items { border-top: 1px solid var(--border); display: none; }
.np-card.open .np-items { display: block; }
.np-item { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 12px; }
.np-item:last-child { border-bottom: 0; }
.np-item-text { flex: 1; min-width: 0; }
.np-item-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.np-item-cap { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.np-saving { font-size: 12px; color: var(--text-muted); text-align: center; padding: 12px; }
.np-browser-card { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 16px; }

.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.logout-btn:active { border-color: var(--danger-border); color: var(--danger); }

/* ============================================================
   BOTTOM NAV
   ============================================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.nav-btn {
  flex: 1;
  text-align: center;
  padding: 10px 4px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
  position: relative;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.nav-btn.active { color: var(--accent); }
.nav-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  margin-bottom: 2px;
}
.nav-btn .nav-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  transition: all var(--transition);
}
.nav-btn.active .nav-icon svg { filter: drop-shadow(0 0 6px rgba(99,102,241,0.4)); }
.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  line-height: 1.4;
  display: none;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */

.content {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Pull-to-refresh indicator */
.ptr-indicator {
  text-align: center;
  padding: 0;
  height: 0;
  overflow: hidden;
  transition: height 0.3s, padding 0.3s;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ptr-indicator.active { height: 40px; padding: 8px 0; }
.ptr-indicator svg { animation: spin 0.8s linear infinite; width: 16px; height: 16px; }

/* Inline page refresh */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.btn-inline-refresh {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-inline-refresh:active { background: var(--accent-soft); color: var(--accent); }
.btn-inline-refresh.spinning svg { animation: spin 0.8s linear infinite; }

/* ============================================================
   STATS CARDS
   ============================================================ */

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at top right, var(--accent-soft), transparent);
  pointer-events: none;
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card.highlight { border-color: rgba(245,158,11,0.2); }
.stat-card.highlight::after { background: radial-gradient(circle at top right, var(--warning-soft), transparent); }
.stat-card.highlight .stat-value {
  background: linear-gradient(135deg, var(--warning), #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
}

/* ============================================================
   CARDS / LIST ITEMS
   ============================================================ */

.card-list { display: flex; flex-direction: column; gap: 10px; }

.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.order-card:active { background: var(--bg-card-hover); transform: scale(0.99); }
.order-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.order-card .product {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  padding-left: 2px;
}
.order-card .supplier {
  font-size: 13px;
  color: var(--accent-hover);
  font-weight: 500;
}
.order-card .customer {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.order-card .meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.order-card .tracking {
  font-size: 12px;
  color: var(--warning);
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.delivery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.delivery-card:active { background: var(--bg-card-hover); transform: scale(0.99); }
.delivery-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
}
.delivery-card.pending::before { background: var(--warning); }
.delivery-card.dispatched::before { background: var(--success); }
.delivery-card .invoice-num { font-weight: 700; font-size: 14px; }
.delivery-card .product { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.delivery-card .customer { font-size: 13px; margin-top: 4px; color: var(--text-secondary); }
.delivery-card .status-line {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.2px;
}
.badge-pending { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-dispatched { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }
.badge-good { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }
.badge-damaged { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-short { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-mixed { background: var(--purple-soft); color: var(--purple); border: 1px solid rgba(168,85,247,0.25); }

/* ============================================================
   SECTION HEADER
   ============================================================ */

.section-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   DETAIL PAGE
   ============================================================ */

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  margin-bottom: 16px;
  font-weight: 500;
  padding: 6px 0;
  transition: all var(--transition);
}
.detail-back:active { opacity: 0.7; }
.detail-back svg { width: 16px; height: 16px; }

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.detail-section h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: flex-start;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); flex-shrink: 0; }
.detail-row .val { font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }
.detail-row .val a { color: var(--accent); text-decoration: none; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  padding: 13px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: -0.1px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.25);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(99,102,241,0.35); }

.btn-success {
  background: linear-gradient(135deg, var(--success), #16a34a);
  color: #fff;
  box-shadow: 0 2px 12px rgba(34,197,94,0.25);
}

.btn-warning { background: linear-gradient(135deg, var(--warning), #d97706); color: #fff; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #dc2626); color: #fff; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:active { background: var(--bg-elevated); }

.btn-sm { padding: 8px 14px; font-size: 12px; width: auto; display: inline-flex; border-radius: var(--radius-sm); }
.btn-group { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group { margin-bottom: 16px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235c5e72' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-group select option { background: var(--bg-card); color: var(--text-primary); }
.form-group textarea { min-height: 80px; resize: vertical; }

/* ============================================================
   PHOTOS
   ============================================================ */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.photo-add {
  width: 100%;
  aspect-ratio: 1;
  border: 2px dashed rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 11px;
}
.photo-add svg { width: 24px; height: 24px; opacity: 0.5; }
.photo-add:active { border-color: var(--accent); background: var(--accent-soft); }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty .empty-icon {
  width: 56px;
  height: 56px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.empty .empty-icon svg { width: 24px; height: 24px; opacity: 0.4; }
.empty p { font-size: 13px; line-height: 1.5; }

/* ============================================================
   TOAST
   ============================================================ */

#toast {
  display: none;
  position: fixed;
  top: calc(var(--topbar-height) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  max-width: 90%;
  text-align: center;
  animation: toastIn 0.3s ease forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  justify-content: center;
  align-items: flex-end;
}
.modal-overlay.active { display: flex; }
.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-sheet h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}
.modal-close {
  float: right;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:active { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   FAB (Floating Action Button)
   ============================================================ */

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: all var(--transition);
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 24px; height: 24px; }

/* ============================================================
   WIZARD (Manual Receipt)
   ============================================================ */

.wizard-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.wizard-progress .step-bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.4s ease;
}
.wizard-progress .step-bar.active {
  background: linear-gradient(90deg, var(--accent), var(--purple));
}
.wizard-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.wizard-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.mr-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
  transition: all var(--transition);
}
.mr-item-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.mr-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.mr-item-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.mr-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
}
.mr-item-remove:active { color: var(--danger); background: var(--danger-soft); }
.mr-item-remove svg { width: 16px; height: 16px; }
.mr-item-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ============================================================
   LOADING SKELETON
   ============================================================ */

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 37%, var(--bg-card) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-card { height: 80px; border-radius: var(--radius-md); margin-bottom: 10px; }
.skeleton-stat { height: 70px; border-radius: var(--radius-md); }

/* ============================================================
   RESPONSIVE — DESKTOP
   ============================================================ */

@media (min-width: 768px) {
  .content { padding: 24px; padding-bottom: calc(var(--nav-height) + 40px); }
  .stats-row { gap: 14px; }
  .stat-card { padding: 20px; }
  .stat-card .stat-value { font-size: 32px; }
  .order-card, .delivery-card { padding: 18px; }
  .bottom-nav { left: 50%; transform: translateX(-50%); max-width: 400px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border: 1px solid var(--border); border-bottom: none; }
  .fab { right: calc(50% - 280px); }
}

/* ============================================================
   Phase 4B — Notification Bell + Dropdown + Inbox
   ============================================================ */

/* Bell — sized to match .btn-refresh-top in topbar-right */
.notif-bell { position: relative; width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); flex-shrink: 0; }
.notif-bell:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.notif-bell svg { width: 18px; height: 18px; pointer-events: none; }
.notif-bell .notif-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; pointer-events: none; }
.notif-bell .notif-badge.hidden { display: none; }

/* Dropdown */
.notif-dropdown { position: fixed; top: calc(var(--topbar-height) + 6px); right: 12px; width: min(380px, calc(100vw - 24px)); max-height: 540px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 1500; display: none; flex-direction: column; overflow: hidden; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.notif-dropdown.open { display: flex; animation: ndSlide 0.2s ease; }
@keyframes ndSlide { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.notif-dropdown .nd-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-dropdown .nd-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 0; }
.notif-dropdown .nd-header a { color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 500; }
.notif-dropdown .nd-header a:hover { color: var(--accent-hover); }
.notif-dropdown .nd-list { flex: 1; overflow-y: auto; max-height: 440px; }
.notif-dropdown .nd-empty { padding: 40px 20px; text-align: center; color: var(--text-secondary); font-size: 13px; }
.notif-dropdown .nd-footer { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; }
.notif-dropdown .nd-footer a { color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 500; }
.notif-dropdown .nd-footer a:hover { color: var(--accent-hover); }

/* Notification row (shared) */
.notif-row { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; cursor: pointer; transition: background var(--transition); position: relative; }
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { background: rgba(255,255,255,0.03); }
.notif-row.unread { background: rgba(99,102,241,0.06); }
.notif-row.unread::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.notif-row.escalation::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--danger); }
.notif-row .nr-icon { font-size: 18px; flex-shrink: 0; line-height: 1.2; width: 22px; text-align: center; }
.notif-row .nr-body { flex: 1; min-width: 0; }
.notif-row .nr-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.notif-row.unread .nr-title { font-weight: 700; }
.notif-row .nr-text { font-size: 12px; color: var(--text-secondary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.notif-row .nr-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-row .nr-kebab { width: 28px; height: 28px; border-radius: 6px; background: transparent; border: none; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; align-self: flex-start; font-size: 18px; line-height: 1; }
.notif-row .nr-kebab:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.notif-row .nr-menu { position: absolute; top: 36px; right: 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md); z-index: 10; min-width: 150px; overflow: hidden; }
.notif-row .nr-menu button { display: block; width: 100%; padding: 9px 12px; background: transparent; border: none; color: var(--text-primary); cursor: pointer; text-align: left; font-size: 13px; }
.notif-row .nr-menu button:hover { background: rgba(255,255,255,0.05); }

/* Dismiss inline expand */
.notif-row.dismissing { background: rgba(99,102,241,0.04); cursor: default; padding: 14px 16px; }
.notif-row.dismissing > .nr-icon, .notif-row.dismissing > .nr-body, .notif-row.dismissing > .nr-kebab { display: none; }
.notif-row .nr-reason { display: none; flex-direction: column; gap: 6px; width: 100%; }
.notif-row.dismissing .nr-reason { display: flex; }
.notif-row .nr-reason-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.notif-row .nr-reason-btns { display: flex; flex-direction: column; gap: 6px; }
.notif-row .nr-reason-btns button { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); cursor: pointer; font-size: 13px; font-weight: 500; text-align: left; transition: all var(--transition); }
.notif-row .nr-reason-btns button:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.notif-row .nr-reason-btns .reason-not_interested:hover { border-color: #94a3b8; }
.notif-row .nr-reason-btns .reason-will_call_later:hover { border-color: #3b82f6; }
.notif-row .nr-reason-btns .reason-order_lost:hover { border-color: var(--danger); }
.notif-row .nr-reason-back { color: var(--text-secondary); cursor: pointer; font-size: 11px; margin-top: 4px; align-self: flex-start; }
.notif-row .nr-reason-back:hover { color: var(--text-primary); }

@keyframes notifRowFadeOut { 0% { opacity: 1; max-height: 90px; } 100% { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; } }
.notif-row.removing { animation: notifRowFadeOut 0.4s ease forwards; }

/* Inbox page */
.notif-filters { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.notif-filters select { padding: 8px 10px; background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; }
.notif-filters label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.notif-filters input[type="checkbox"] { cursor: pointer; }
.notif-pagination { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 14px; }
.notif-pagination button { padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); cursor: pointer; font-size: 13px; }
.notif-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.notif-pagination span { font-size: 12px; color: var(--text-secondary); }
.notif-inbox-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }


/* ============================================================
   Tier 4d — Sharif Shipments page styles
   ============================================================ */
  /* Shipments page */
  #page-shipments { display: none; padding-bottom: 80px; }
  #page-shipments.active { display: block; }
  .shp-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-app); z-index: 5; }
  .shp-toolbar h2 { margin: 0; font-size: 17px; font-weight: 600; color: var(--text-primary); }
  .shp-toolbar .shp-count { font-size: 12px; color: var(--text-secondary); }
  .shp-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
  .shp-row { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; cursor: pointer; transition: all var(--transition); }
  .shp-row:hover, .shp-row.active { background: var(--bg-card-hover); border-color: var(--accent); }
  .shp-row-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .shp-row-tn { font-weight: 600; font-size: 14px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
  .shp-row-meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-secondary); }
  .shp-stage-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
  .shp-stage-shipped { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
  .shp-stage-in_transit { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
  .shp-stage-customs { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
  .shp-stage-at_warehouse { background: rgba(167, 139, 250, 0.18); color: #a78bfa; }
  .shp-stage-received { background: rgba(74, 222, 128, 0.18); color: #4ade80; }
  /* Detail */
  .shp-detail { padding: 16px; }
  .shp-back { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; font-size: 13px; margin-bottom: 12px; }
  .shp-back:hover { background: var(--bg-card-hover); color: var(--text-primary); }
  .shp-detail-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .shp-detail-h .shp-tn { font-size: 18px; font-weight: 700; color: var(--text-primary); }
  .shp-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 12px; }
  .shp-section h3 { margin: 0 0 8px 0; font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
  /* Timeline */
  .shp-timeline { display: flex; flex-direction: column; gap: 6px; }
  .shp-tl-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
  .shp-tl-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: var(--border); }
  .shp-tl-row.done .shp-tl-dot { background: var(--accent); }
  .shp-tl-row.current .shp-tl-dot { background: var(--warning); box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2); }
  .shp-tl-label { flex: 1; font-size: 13px; color: var(--text-secondary); }
  .shp-tl-row.done .shp-tl-label, .shp-tl-row.current .shp-tl-label { color: var(--text-primary); }
  .shp-tl-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--bg-elevated); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
  .shp-tl-badge.auto { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
  .shp-tl-badge.manual { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
  .shp-tl-badge.sharif { background: rgba(74, 222, 128, 0.18); color: #4ade80; }
  /* Promised vs ETA */
  .shp-pvse { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .shp-pvse-card { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
  .shp-pvse-card .lbl { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
  .shp-pvse-card .val { font-size: 14px; font-weight: 600; color: var(--text-primary); }
  .shp-pvse-card.tone-on-track { border: 1px solid #4ade80; }
  .shp-pvse-card.tone-at-risk { border: 1px solid #fbbf24; }
  .shp-pvse-card.tone-late { border: 1px solid var(--danger); }
  .shp-pvse-card.tone-on-track .val { color: #4ade80; }
  .shp-pvse-card.tone-at-risk .val { color: #fbbf24; }
  .shp-pvse-card.tone-late .val { color: var(--danger); }
  /* Linked POs */
  .shp-po-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .shp-po-row:last-child { border-bottom: none; }
  .shp-po-supplier { color: var(--text-primary); }
  .shp-po-meta { color: var(--text-secondary); font-size: 12px; }
  /* Events */
  .shp-event-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .shp-event-row:last-child { border-bottom: none; }
  .shp-event-h { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
  .shp-event-stage { font-weight: 600; font-size: 13px; color: var(--text-primary); text-transform: capitalize; }
  .shp-event-when { font-size: 11px; color: var(--text-tertiary, var(--text-secondary)); }
  .shp-event-actor { font-size: 11px; color: var(--text-secondary); }
  .shp-event-notes { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
  /* Actions */
  .shp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
  .shp-actions button { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-primary); font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--transition); }
  .shp-actions button:hover { background: var(--bg-card-hover); }
  .shp-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .shp-actions button.primary:hover { filter: brightness(1.1); }
  /* Empty + loading */
  .shp-empty { padding: 40px 16px; text-align: center; color: var(--text-secondary); font-size: 14px; }

/* ============================================================
   Tier 8a — Chrome harmonization (light theme + responsive nav)
   ============================================================ */
  /* === Variable overrides: switch to Sohail's light palette === */
  :root {
    --bg-primary:      #F6F7F9;
    --bg-secondary:    #FFFFFF;
    --bg-card:         #FFFFFF;
    --bg-card-hover:   #F1F3F6;
    --bg-elevated:     #FAFBFC;
    --bg-input:        #FFFFFF;
    --border:          #E5E7EB;
    --border-focus:    rgba(79, 70, 229, 0.45);
    --text-primary:    #0B1220;
    --text-secondary:  #6B7280;
    --text-muted:      #9CA3AF;
    --accent:          #4F46E5;
    --accent-hover:    #4338CA;
    --accent-glow:     rgba(79, 70, 229, 0.15);
    --accent-soft:     #EEF2FF;
    --success:         #16A34A;
    --success-soft:    #DCFCE7;
    --success-border:  rgba(22, 163, 74, 0.30);
    --warning:         #D97706;
    --warning-soft:    #FEF3C7;
    --warning-border:  rgba(217, 119, 6, 0.30);
    --danger:          #DC2626;
    --danger-soft:     #FEE2E2;
    --danger-border:   rgba(220, 38, 38, 0.30);
    --purple:          #7C3AED;
    --purple-soft:     #EDE9FE;
    --shadow-sm:       0 1px 2px rgba(15,23,42,0.04);
    --shadow-md:       0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-lg:       0 10px 24px -8px rgba(15,23,42,0.10), 0 4px 8px -4px rgba(15,23,42,0.04);
  }
  html, body { background: var(--bg-primary); color: var(--text-primary); }

  /* === Hard-coded dark accents that don't honor variables === */
  /* The original photo-add border used rgba(255,255,255,0.08) — invisible on light bg. */
  .photo-add { border-color: var(--border) !important; }
  /* Logout button border in topbar — was the same rgba(255,255,255,0.08). */
  .logout-btn { border-color: var(--border) !important; }
  /* Photo add dashed border specifically */
  .photo-add { border-style: dashed; }

  /* === Topbar: aligned with Sohail's app-header look === */
  .topbar {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm);
  }
  .topbar-title { color: var(--text-primary); }
  .topbar-logo {
    background: linear-gradient(135deg, var(--accent), #6366F1) !important;
  }
  /* Make space for a horizontal top-nav between the brand and the right-side icons (desktop only). */

  /* === Desktop top-nav (injected by Tier 8a script) === */
  .t8a-topnav {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: 24px;
  }
  .t8a-navbtn {
    background: none;
    border: 0;
    padding: 8px 14px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background 120ms, color 120ms;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .t8a-navbtn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
  .t8a-navbtn.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
  .t8a-navbtn .t8a-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
  }

  /* === Bottom-nav: themed for light bg === */
  .bottom-nav {
    background: var(--bg-card) !important;
    border-top: 1px solid var(--border) !important;
    box-shadow: 0 -1px 3px rgba(15,23,42,0.04);
  }
  .nav-btn { color: var(--text-secondary); }
  .nav-btn.active { color: var(--accent); }
  .nav-btn .nav-icon svg { stroke: currentColor; }
  /* Hide the Dashboard bottom-nav button entirely — folded into Shipments per D3. */
  .bottom-nav [data-page="dashboard"] { display: none !important; }

  /* === Responsive breakpoint === */
  @media (min-width: 769px) {
    .t8a-topnav { display: inline-flex !important; }
    .bottom-nav { display: none !important; }
    body { padding-bottom: 0 !important; }
    /* Widen the topbar container for desktop. */
    .topbar { padding: 0 32px !important; }
    /* Center content max-width on desktop, like Sohail. */
    .container, .main-content, #app, .page { max-width: 1440px; margin-left: auto; margin-right: auto; }
  }
  @media (max-width: 768px) {
    .t8a-topnav { display: none !important; }
  }

  /* === Cards, sections, headers === */
  .page-header, .section-header { color: var(--text-primary); }
  .section-header::after { background: var(--border); }
  /* Make stat cards / list cards explicitly light. */
  .stats-row > *, .card, .card-list > * {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }

  /* === Tier 4d Shipments page re-skin (was built using dark-theme vars) === */
  /* Most of it auto-re-themes via :root overrides; these are the few stage pills
     whose color values were chosen against a dark backdrop. Re-tune saturation. */
  .shp-stage-shipped   { background: rgba(2, 132, 199, 0.10); color: #0284C7; }
  .shp-stage-in_transit{ background: rgba(2, 132, 199, 0.10); color: #0284C7; }
  .shp-stage-customs   { background: rgba(217, 119, 6, 0.12); color: #B45309; }
  .shp-stage-at_warehouse { background: rgba(124, 58, 237, 0.12); color: #6D28D9; }
  .shp-stage-received  { background: rgba(22, 163, 74, 0.12); color: #15803D; }
  .shp-tl-row.done .shp-tl-dot { background: var(--accent); }
  .shp-tl-row.current .shp-tl-dot { background: var(--warning); box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.18); }
  .shp-tl-badge.auto    { background: rgba(2, 132, 199, 0.10); color: #0284C7; }
  .shp-tl-badge.manual  { background: rgba(124, 58, 237, 0.10); color: #6D28D9; }
  .shp-tl-badge.sharif  { background: rgba(22, 163, 74, 0.12); color: #15803D; }
  .shp-pvse-card.tone-on-track { border-color: var(--success); }
  .shp-pvse-card.tone-on-track .val { color: var(--success); }
  .shp-pvse-card.tone-at-risk  { border-color: var(--warning); }
  .shp-pvse-card.tone-at-risk  .val { color: var(--warning); }
  .shp-pvse-card.tone-late     { border-color: var(--danger); }
  .shp-pvse-card.tone-late     .val { color: var(--danger); }

  /* === Form inputs / textareas re-skin === */
  .form-group input, .form-group select, .form-group textarea {
    background-color: var(--bg-input);   /* LONGHAND — shorthand `background:` was resetting repeat/position */
    color: var(--text-primary);
    border-color: var(--border);
  }
  .form-group select {
    /* Re-tint the chevron arrow for light bg. !important on every background-*
       longhand so the chevron sits ONCE at the right (was tiling along the
       bottom because the shorthand above reset background-repeat to default). */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    padding-right: 32px !important;
  }

  /* === Notification dropdown / popovers === */
  .notif-dropdown, .notif-popover {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
  }

  /* === Buttons === */
  .btn-outline { color: var(--text-primary); border-color: var(--border); }
  .btn-outline:hover { background: var(--bg-card-hover); }

  /* === Toast === */
  #toast { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }

  /* === Bell pip color === */
  .notif-bell .notif-badge { box-shadow: 0 0 0 2px var(--bg-card); }

/* ============================================================
   Tier 8b — Filter chrome (Status Bar + chips + search)
   ============================================================ */
  /* === Filter chrome === */
  .t8b-filter-bar { margin: 0 0 14px 0; }
  .t8b-status-row {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
  }
  .t8b-stat-cell {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 10px 14px;
    cursor: pointer; min-width: 92px; transition: all 120ms;
    user-select: none;
  }
  .t8b-stat-cell:hover { border-color: var(--accent); }
  .t8b-stat-cell.active {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
  .t8b-stat-cell .t8b-stat-label {
    font-size: 10px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  }
  .t8b-stat-cell .t8b-stat-value {
    font-size: 20px; font-weight: 700; color: var(--text-primary);
    margin-top: 2px; font-variant-numeric: tabular-nums;
  }
  .t8b-stat-cell.active .t8b-stat-value { color: var(--accent); }

  .t8b-chip-row {
    display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
    align-items: center;
  }
  .t8b-chip {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 999px; padding: 6px 12px;
    font-size: 12px; font-weight: 500; color: var(--text-secondary);
    cursor: pointer; transition: all 120ms;
    display: inline-flex; align-items: center; gap: 6px;
    user-select: none;
  }
  .t8b-chip:hover { border-color: var(--accent); color: var(--accent); }
  .t8b-chip.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
  }
  .t8b-chip .t8b-chip-count {
    background: rgba(0,0,0,0.10); color: inherit;
    border-radius: 999px; padding: 1px 6px; font-size: 10px; font-weight: 700;
    margin-left: 2px;
  }
  .t8b-chip.active .t8b-chip-count { background: rgba(255,255,255,0.25); }

  .t8b-search-wrap {
    position: relative; max-width: 320px;
  }
  .t8b-search {
    width: 100%; padding: 8px 12px 8px 32px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-size: 13px; font-family: inherit;
  }
  .t8b-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
  .t8b-search-wrap svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; color: var(--text-muted); pointer-events: none;
  }

  .t8b-hidden { display: none !important; }

  .t8b-empty-msg {
    text-align: center; color: var(--text-muted); padding: 40px 16px;
    font-size: 13px;
  }

  /* Stock-table specifics — sortable column headers + filter row */
  .stock-table th.t8b-sortable {
    cursor: pointer; user-select: none; position: relative;
  }
  .stock-table th.t8b-sortable:hover { color: var(--accent); }
  .stock-table th.t8b-sortable .t8b-sort-arrow {
    display: inline-block; margin-left: 4px; opacity: 0.35;
    transition: opacity 120ms;
  }
  .stock-table th.t8b-sortable.t8b-sort-active .t8b-sort-arrow {
    opacity: 1; color: var(--accent);
  }

  /* Empty state when all rows filtered out */
  .t8b-empty-overlay {
    text-align: center; color: var(--text-muted); padding: 40px 16px;
    font-size: 13px;
  }

/* ============================================================
   Tier 8b layout addendum — widen content + per-page layouts
   ============================================================ */
  /* === Widen the content wrapper on desktop === */
  /* The original .content { max-width: 600px } was the mobile-first cap.
     T8a's 1440px max-width on .page was being overridden by this. */
  @media (min-width: 769px) {
    .content {
      max-width: 1600px !important;
      padding: 24px 32px !important;
      padding-bottom: 32px !important;
    }
  }
  /* Even narrower wrap on very wide monitors — 1800px caps for the rare
     ultra-wide case so cards don't stretch absurdly. */
  @media (min-width: 1920px) {
    .content { max-width: 1800px !important; }
  }

  /* === Settings page stays narrow for form readability === */
  @media (min-width: 769px) {
    #page-settings {
      max-width: 760px;
      margin-left: auto;
      margin-right: auto;
    }
  }

  /* === Receipts: multi-column card grid === */
  @media (min-width: 1024px) {
    #page-receipts #receiptsList {
      display: grid !important;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      flex-direction: initial !important;
    }
  }
  @media (min-width: 1440px) {
    #page-receipts #receiptsList {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  /* === Deliveries: multi-column card grid for both Pending and Dispatched === */
  @media (min-width: 1024px) {
    #page-deliveries #pendingDeliveries,
    #page-deliveries #dispatchedDeliveries {
      display: grid !important;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      flex-direction: initial !important;
    }
  }
  @media (min-width: 1440px) {
    #page-deliveries #pendingDeliveries,
    #page-deliveries #dispatchedDeliveries {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  /* === Shipments: side-by-side list+detail (sidecar pattern) === */
  /* Both #shpListView and #shpDetailView are direct children of #page-shipments.
     The Tier 4d JS toggles their inline display style — we override with
     !important so both stay visible at >=1024px. The grid auto-flow places
     the toolbar + filter bar across the full width on the first rows, then
     list + detail in the next row side-by-side. */
  @media (min-width: 1024px) {
    #page-shipments {
      display: grid;
      grid-template-columns: 400px 1fr;
      column-gap: 20px;
      row-gap: 16px;
      align-items: start;
    }
    /* Span the toolbar + filter bar across both columns */
    #page-shipments > .shp-toolbar,
    #page-shipments > #t8b-bar-shipments {
      grid-column: 1 / -1;
    }
    /* Force both panes visible (override JS inline display:none) */
    #page-shipments > #shpListView {
      display: block !important;
      max-height: calc(100vh - 280px);
      overflow-y: auto;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      position: sticky;
      top: calc(var(--topbar-height) + 24px);
    }
    #page-shipments > #shpDetailView {
      display: block !important;
      min-height: 400px;
    }
    /* Empty-state placeholder when no shipment is selected */
    #page-shipments > #shpDetailView:empty::before {
      content: 'Select a shipment to view its detail.';
      display: block;
      padding: 80px 24px;
      text-align: center;
      color: var(--text-muted);
      font-size: 14px;
      background: var(--bg-card);
      border: 1px dashed var(--border);
      border-radius: var(--radius-md);
    }
    /* Hide the back button — not needed when both panes are visible */
    #page-shipments .shp-back { display: none !important; }
    /* Tighten the list rows for the narrow column */
    #page-shipments .shp-list { padding: 8px; gap: 6px; }
    #page-shipments .shp-row { padding: 10px; }
    /* Active shipment in the list gets a highlight */
    #page-shipments .shp-row.t8b-active {
      background: var(--accent-soft);
      border-color: var(--accent);
    }
  }

  /* === Stock table: fill the widened content width naturally === */
  @media (min-width: 1024px) {
    #page-stock .stock-table-wrap {
      width: 100%;
    }
    #page-stock .stock-table {
      min-width: 100% !important;
    }
    /* Make the name column take more space when there's room */
    #page-stock .stock-table th:first-child,
    #page-stock .stock-table td:first-child {
      width: auto;
    }
  }

  /* === Make the topbar full-bleed but constrain its inner contents === */
  /* The topbar already spans full width; ensure it doesn't push content
     against the screen edges on ultra-wide. */
  @media (min-width: 1920px) {
    .topbar {
      padding-left: max(32px, calc((100vw - 1800px) / 2)) !important;
      padding-right: max(32px, calc((100vw - 1800px) / 2)) !important;
    }
  }

  /* === T8b filter chrome: tighten on desktop so cells/chips don't sprawl === */
  @media (min-width: 769px) {
    .t8b-stat-cell { min-width: 110px; }
  }

  /* === Detail pages (receiptDetail, deliveryDetail, etc.): keep them
     comfortable to read but allow them to use the wider space === */
  @media (min-width: 1024px) {
    #page-receiptDetail #receiptDetailContent,
    #page-deliveryDetail #deliveryDetailContent,
    #page-incomingDetail #incomingDetailContent {
      max-width: 1100px;
    }
  }

/* ============================================================
   Tier 8b delivery detail — Option A (hero + sidecar)
   ============================================================ */
  /* Delivery detail container — let it use the wider space */
  @media (min-width: 1024px) {
    #page-deliveryDetail #deliveryDetailContent { max-width: none !important; }
  }

  /* === HERO === */
  .dlv-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
  }
  .dlv-hero-eyebrow {
    font-size: 10px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 6px;
  }
  .dlv-hero-title {
    display: flex; align-items: baseline; gap: 12px;
    flex-wrap: wrap; margin-bottom: 6px;
  }
  .dlv-hero-invoice {
    font-size: 22px; font-weight: 700; color: var(--text-primary);
    font-family: var(--font-mono, ui-monospace, monospace);
    letter-spacing: -0.01em;
  }
  .dlv-hero-product {
    font-size: 16px; color: var(--text-secondary);
    font-weight: 500;
  }
  .dlv-hero-customer {
    font-size: 14px; color: var(--text-secondary);
    display: flex; align-items: center; gap: 6px;
  }
  .dlv-hero-customer strong { color: var(--text-primary); font-weight: 600; }
  .dlv-hero-right {
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
  }
  .dlv-status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .dlv-status-pill.pending     { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-border); }
  .dlv-status-pill.dispatched  { background: var(--info-soft, rgba(2,132,199,0.10)); color: var(--info, #0284C7); border: 1px solid rgba(2,132,199,0.30); }
  .dlv-status-pill.delivered   { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }
  .dlv-hero-action {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    background: var(--accent); color: #fff;
    border: 0; font-weight: 600; font-size: 13px;
    cursor: pointer; font-family: inherit;
    display: inline-flex; align-items: center; gap: 6px;
    transition: filter 120ms;
  }
  .dlv-hero-action:hover { filter: brightness(1.08); }
  .dlv-hero-action.outline {
    background: transparent; color: var(--accent);
    border: 1px solid var(--accent);
  }
  .dlv-hero-action.outline:hover { background: var(--accent-soft); }
  .dlv-hero-action svg { width: 14px; height: 14px; }

  /* === 3-STAGE TIMELINE === */
  .dlv-timeline {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 16px;
  }
  .dlv-timeline-track {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: relative;
    gap: 0;
  }
  .dlv-tl-stage {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; position: relative; padding: 4px 12px;
  }
  /* Connector lines between dots */
  .dlv-tl-stage:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 50%; right: -50%; top: 13px;
    height: 2px; background: var(--border);
    z-index: 0;
  }
  .dlv-tl-stage.done:not(:last-child)::after { background: var(--success); }
  .dlv-tl-dot {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg-card); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1; margin-bottom: 8px;
    font-size: 14px; color: var(--text-muted);
  }
  .dlv-tl-stage.done .dlv-tl-dot {
    background: var(--success); border-color: var(--success); color: #fff;
  }
  .dlv-tl-stage.current .dlv-tl-dot {
    background: var(--bg-card); border-color: var(--accent); color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
  .dlv-tl-label {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
  }
  .dlv-tl-stage.done .dlv-tl-label,
  .dlv-tl-stage.current .dlv-tl-label { color: var(--text-primary); }
  .dlv-tl-meta {
    font-size: 11px; color: var(--text-muted); margin-top: 2px;
  }

  /* === 2-COL GRID === */
  .dlv-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }
  @media (min-width: 1024px) {
    .dlv-grid {
      grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    }
  }

  /* === CARDS === */
  .dlv-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
  }
  .dlv-card h4 {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin: 0 0 12px 0; padding: 0; border: 0;
  }
  .dlv-card h4 svg { width: 13px; height: 13px; }

  /* === DOCUMENTS GRID === */
  .dlv-doc-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  }
  .dlv-doc-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    background: var(--bg-elevated);
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 120ms;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    min-height: 110px; justify-content: center;
  }
  .dlv-doc-tile:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text, var(--accent));
  }
  .dlv-doc-tile.empty {
    border-style: dashed; color: var(--text-muted);
    background: transparent; cursor: pointer;
  }
  .dlv-doc-tile.empty.no-action { cursor: default; }
  .dlv-doc-tile.empty.no-action:hover {
    border-color: var(--border); background: transparent; color: var(--text-muted);
  }
  .dlv-doc-icon { font-size: 26px; line-height: 1; }
  .dlv-doc-label { font-size: 12px; font-weight: 600; line-height: 1.2; }
  .dlv-doc-state { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

  /* === ACTIVITY === */
  .dlv-activity-row {
    display: flex; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .dlv-activity-row:last-child { border-bottom: 0; }
  .dlv-activity-row:first-child { padding-top: 0; }
  .dlv-activity-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0;
    margin-top: 6px;
  }
  .dlv-activity-body { flex: 1; min-width: 0; }
  .dlv-activity-title { font-size: 13px; color: var(--text-primary); }
  .dlv-activity-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

  /* === SIDECAR ROWS === */
  .dlv-kv {
    display: flex; align-items: baseline; gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .dlv-kv:last-child { border-bottom: 0; }
  .dlv-kv-label {
    font-size: 11px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    flex-shrink: 0; min-width: 72px; font-weight: 600;
  }
  .dlv-kv-val {
    color: var(--text-primary); text-align: right; flex: 1; word-break: break-word;
    font-size: 13px;
  }
  .dlv-kv-val a { color: var(--accent); text-decoration: none; }
  .dlv-kv-val a:hover { text-decoration: underline; }
  .dlv-copyable { cursor: pointer; }
  .dlv-copyable:hover { color: var(--accent); }

  /* Compact phone link with WhatsApp action */
  .dlv-phone-link { display: inline-flex; align-items: center; gap: 4px; }
  .dlv-phone-link .wa-link { font-size: 10px; color: var(--success); text-decoration: none; }
  .dlv-phone-link .wa-link:hover { text-decoration: underline; }

  /* Address shown in a small text block */
  .dlv-address-block {
    background: var(--bg-elevated);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
    margin-top: 8px;
  }

/* ============================================================
   Tier 8c1 — Line-item Receive drawer + discrepancy chips
   ============================================================ */
  /* === Receive line-item drawer === */
  .t8c1-drawer-wide #t4dDrawer { width: min(880px, 100%) !important; }
  .t8c1-receive-wrap { padding: 24px; }
  .t8c1-receive-h {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 4px;
  }
  .t8c1-receive-h h2 { margin: 0; font-size: 18px; color: var(--text-primary); }
  .t8c1-receive-h .sub { font-size: 12px; color: var(--text-muted); }
  .t8c1-receive-eyebrow {
    font-size: 11px; color: var(--text-muted); margin: 12px 0 8px 0;
    text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
  }
  .t8c1-group {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 12px;
  }
  .t8c1-group-head {
    font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px;
  }
  .t8c1-group-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
  .t8c1-line-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    font-size: 12px;
  }
  .t8c1-line-table thead th {
    background: var(--bg-elevated);
    text-align: left; padding: 8px 10px;
    font-weight: 600; color: var(--text-muted);
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
  }
  .t8c1-line-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
  }
  .t8c1-line-table tbody tr:last-child td { border-bottom: 0; }
  .t8c1-line-table .col-qty { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
  .t8c1-line-table .col-actual { width: 110px; }
  .t8c1-line-table .col-cond { width: 130px; }
  .t8c1-line-table input[type=number],
  .t8c1-line-table select,
  .t8c1-line-table input[type=text] {
    width: 100%; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-app); color: var(--text-primary);
    font-size: 12px; font-family: inherit;
  }
  .t8c1-line-table input:focus, .t8c1-line-table select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow);
  }
  .t8c1-disc-flag {
    display: inline-block; padding: 1px 6px; border-radius: 999px;
    background: var(--warning-soft); color: var(--warning);
    font-size: 10px; font-weight: 700; margin-left: 6px;
  }
  .t8c1-disc-flag.over { background: rgba(2,132,199,0.10); color: var(--info, #0284C7); }

  /* Discrepancy chip on the Receipts list */
  .t8c1-disc-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 999px;
    background: var(--warning-soft); color: var(--warning);
    font-size: 10px; font-weight: 700;
    margin-left: 6px;
    border: 1px solid var(--warning-border);
  }

  /* Line-item breakdown on Receipt detail page */
  .t8c1-receipt-lines {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 16px;
    overflow: hidden;
  }
  .t8c1-receipt-lines h4 {
    margin: 0; padding: 12px 16px;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .t8c1-receipt-lines table {
    width: 100%; border-collapse: collapse; font-size: 13px;
  }
  .t8c1-receipt-lines th {
    text-align: left; padding: 8px 16px;
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .t8c1-receipt-lines td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
  }
  .t8c1-receipt-lines tr:last-child td { border-bottom: 0; }
  .t8c1-receipt-lines .col-num { text-align: right; font-variant-numeric: tabular-nums; }
  .t8c1-receipt-lines .ok    { color: var(--success); font-weight: 600; }
  .t8c1-receipt-lines .short { color: var(--warning); font-weight: 600; }
  .t8c1-receipt-lines .over  { color: var(--info, #0284C7); font-weight: 600; }

/* ============================================================
   Tier 8d polish bundle — manual receipt + receipt detail +
   incoming detail + notifications chips
   ============================================================ */
  /* ===== Manual receipt drawer ===== */
  .t8d-mr-wrap { padding: 24px; }
  .t8d-mr-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
  .t8d-mr-h h2 { margin: 0; font-size: 18px; color: var(--text-primary); }
  .t8d-mr-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
  .t8d-mr-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  }
  .t8d-mr-grid.full { grid-template-columns: 1fr; }
  .t8d-mr-label {
    display: block; font-size: 11px; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .t8d-mr-input, .t8d-mr-textarea, .t8d-mr-select {
    width: 100%; padding: 10px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 13px; font-family: inherit;
  }
  .t8d-mr-input:focus, .t8d-mr-textarea:focus, .t8d-mr-select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
  }
  .t8d-mr-textarea { resize: vertical; min-height: 70px; }
  .t8d-mr-section {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    padding: 14px;
  }
  .t8d-mr-section-h {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
  }
  .t8d-mr-section-h h4 {
    margin: 0; font-size: 11px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  }
  .t8d-mr-add {
    padding: 4px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--accent); font-size: 12px; font-weight: 600;
    cursor: pointer; font-family: inherit;
  }
  .t8d-mr-add:hover { background: var(--accent-soft); border-color: var(--accent); }
  .t8d-mr-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 2fr 90px 90px 1fr 28px;
    gap: 8px; align-items: center;
  }
  .t8d-mr-item:last-child { margin-bottom: 0; }
  .t8d-mr-item input, .t8d-mr-item select {
    padding: 6px 8px; font-size: 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-app); color: var(--text-primary); font-family: inherit;
  }
  .t8d-mr-item .t8d-mr-rm {
    background: none; border: 0; cursor: pointer;
    color: var(--text-muted); font-size: 18px; line-height: 1;
  }
  .t8d-mr-item .t8d-mr-rm:hover { color: var(--danger); }
  .t8d-photo-grid-mr {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }
  .t8d-photo-thumb-mr {
    aspect-ratio: 1; border-radius: var(--radius-sm);
    background: var(--bg-app); border: 1px solid var(--border);
    background-size: cover; background-position: center;
    position: relative;
  }
  .t8d-photo-thumb-mr .rm {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--danger); color: #fff;
    border: 0; cursor: pointer; font-size: 12px; line-height: 1;
  }
  .t8d-photo-add-tile {
    aspect-ratio: 1; border-radius: var(--radius-sm);
    background: var(--bg-app); border: 2px dashed var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); font-size: 11px;
    flex-direction: column; gap: 4px;
  }
  .t8d-photo-add-tile:hover { border-color: var(--accent); color: var(--accent); }

  /* ===== Receipt detail Sohail style ===== */
  .rcp-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px; margin-bottom: 16px;
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 24px; flex-wrap: wrap;
  }
  .rcp-hero-eyebrow {
    font-size: 10px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px;
  }
  .rcp-hero-title {
    font-size: 22px; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.01em; margin-bottom: 4px;
  }
  .rcp-hero-supplier { font-size: 14px; color: var(--text-secondary); }
  .rcp-hero-supplier strong { color: var(--text-primary); font-weight: 600; }
  .rcp-hero-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
  .rcp-cond-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .rcp-cond-pill.good     { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }
  .rcp-cond-pill.damaged  { background: var(--danger-soft);  color: var(--danger);  border: 1px solid var(--danger-border); }
  .rcp-cond-pill.short    { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-border); }
  .rcp-cond-pill.mixed    { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-border); }
  .rcp-disc-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 4px 10px; border-radius: 999px;
    background: var(--warning-soft); color: var(--warning);
    font-size: 11px; font-weight: 700;
    border: 1px solid var(--warning-border);
  }
  .rcp-hero-action {
    padding: 10px 16px; border-radius: var(--radius-md);
    background: var(--accent); color: #fff;
    border: 0; font-weight: 600; font-size: 13px;
    cursor: pointer; font-family: inherit;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .rcp-hero-action:hover { filter: brightness(1.08); }
  .rcp-hero-action.outline {
    background: transparent; color: var(--accent);
    border: 1px solid var(--accent);
  }
  .rcp-grid {
    display: grid; grid-template-columns: 1fr; gap: 16px;
  }
  @media (min-width: 1024px) {
    .rcp-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  }
  .rcp-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 16px 20px;
  }
  .rcp-card h4 {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin: 0 0 12px 0; padding: 0; border: 0;
  }
  .rcp-card h4 svg { width: 13px; height: 13px; }
  .rcp-kv { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .rcp-kv:last-child { border-bottom: 0; }
  .rcp-kv-label {
    font-size: 11px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    flex-shrink: 0; min-width: 80px; font-weight: 600;
  }
  .rcp-kv-val { color: var(--text-primary); text-align: right; flex: 1; word-break: break-word; font-size: 13px; }
  .rcp-photos {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  .rcp-photo-tile {
    aspect-ratio: 1; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-elevated);
    background-size: cover; background-position: center;
    cursor: zoom-in;
  }
  .rcp-photo-add {
    aspect-ratio: 1; border-radius: var(--radius-sm);
    border: 2px dashed var(--border); background: transparent;
    color: var(--text-muted); font-size: 11px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; cursor: pointer;
  }
  .rcp-photo-add:hover { border-color: var(--accent); color: var(--accent); }

  /* Line items table inside Receipt Sohail layout (reuses T8c1 style) */
  .rcp-line-table {
    width: 100%; border-collapse: collapse; font-size: 12px;
  }
  .rcp-line-table th {
    text-align: left; padding: 8px 10px;
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .rcp-line-table td {
    padding: 10px; border-bottom: 1px solid var(--border);
    color: var(--text-primary);
  }
  .rcp-line-table tr:last-child td { border-bottom: 0; }
  .rcp-line-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }

  /* ===== Incoming shipment detail Sohail style ===== */
  .inc-hero {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px; margin-bottom: 16px;
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 24px; flex-wrap: wrap;
  }
  .inc-status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .inc-status-pill.need_to_order { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }
  .inc-status-pill.ordered       { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
  .inc-status-pill.shipped       { background: rgba(2,132,199,0.10); color: var(--info, #0284C7); border: 1px solid rgba(2,132,199,0.30); }
  .inc-status-pill.in_transit    { background: rgba(2,132,199,0.10); color: var(--info, #0284C7); border: 1px solid rgba(2,132,199,0.30); }
  .inc-status-pill.received      { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }

  .inc-timeline {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px; margin-bottom: 16px;
  }
  .inc-tl-track {
    display: grid; grid-template-columns: repeat(3, 1fr); position: relative; gap: 0;
  }
  .inc-tl-stage {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    position: relative; padding: 4px 12px;
  }
  .inc-tl-stage:not(:last-child)::after {
    content: ''; position: absolute;
    left: 50%; right: -50%; top: 13px;
    height: 2px; background: var(--border); z-index: 0;
  }
  .inc-tl-stage.done:not(:last-child)::after { background: var(--success); }
  .inc-tl-dot {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg-card); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1; margin-bottom: 8px;
    font-size: 14px; color: var(--text-muted);
  }
  .inc-tl-stage.done .inc-tl-dot { background: var(--success); border-color: var(--success); color: #fff; }
  .inc-tl-stage.current .inc-tl-dot {
    background: var(--bg-card); border-color: var(--accent); color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
  .inc-tl-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
  .inc-tl-stage.done .inc-tl-label, .inc-tl-stage.current .inc-tl-label { color: var(--text-primary); }

  /* ===== Notifications inbox chips ===== */
  .nb-chips {
    display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px 0;
  }
  .nb-chip {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 999px; padding: 6px 12px;
    font-size: 12px; font-weight: 500; color: var(--text-secondary);
    cursor: pointer; transition: all 120ms;
    display: inline-flex; align-items: center; gap: 6px;
    user-select: none;
  }
  .nb-chip:hover { border-color: var(--accent); color: var(--accent); }
  .nb-chip.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
  }
  .nb-status-row {
    display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px 0;
  }
  .nb-stat-cell {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px; cursor: pointer; min-width: 92px;
    user-select: none; transition: all 120ms;
  }
  .nb-stat-cell:hover { border-color: var(--accent); }
  .nb-stat-cell.active { background: var(--accent-soft); border-color: var(--accent); }
  .nb-stat-cell .lbl {
    font-size: 10px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  }
  .nb-stat-cell .val {
    font-size: 20px; font-weight: 700; color: var(--text-primary);
    margin-top: 2px; font-variant-numeric: tabular-nums;
  }
  .nb-stat-cell.active .val { color: var(--accent); }
  /* Hide the old filter controls when we inject our chips */
  .notif-filters.t8d-hidden-orig { display: none !important; }
