/* ============================================================
   Salus Customer Portal - Main Stylesheet
   Premium Glassmorphism Design
   ============================================================ */

/* ---- CSS Variables (Light Theme) ---- */
:root {
  --primary: #F29D28;
  --primary-dark: #D9821A;
  --primary-light: #F7B45E;
  --primary-text: #A96A0C;
  --warning-text: #92590a;
  --success-text: #067A56;
  --danger-text: #B91C1C;
  --info-text: #0C6478;
  --secondary: #2B2929;
  --success: #00C896;
  --warning: #FFB547;
  --danger: #FF4757;
  --info: #17A2B8;
  
  --bg: #FAF7F1;
  --surface: rgba(255,255,255,0.85);
  --surface-solid: #ffffff;
  --surface-hover: rgba(255,255,255,0.95);
  --border: rgba(242,157,40,0.12);
  --border-solid: #e2e8f0;
  
  --text-primary: #211E1D;
  --text-secondary: #2F2B29;
  --text-muted: #3F3A36;
  --text-on-primary: #ffffff;
  
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #FAF5EC 100%);
  --sidebar-text: rgba(33,30,29,0.96);
  --sidebar-active: rgba(242,157,40,0.12);
  --sidebar-hover: rgba(242,157,40,0.07);
  
  --shadow-sm: 0 2px 8px rgba(242,157,40,0.08);
  --shadow-md: 0 4px 20px rgba(242,157,40,0.12);
  --shadow-lg: 0 8px 40px rgba(242,157,40,0.18);
  --shadow-xl: 0 20px 60px rgba(242,157,40,0.25);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  --font-primary: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* ---- Dark Theme ---- */
[data-theme="dark"] {
  --bg: #171412;
  --primary-text: #F7B45E;
  --warning-text: #FFB547;
  --success-text: #00C896;
  --danger-text: #FF4757;
  --info-text: #17A2B8;
  --surface: rgba(35,31,29,0.85);
  --surface-solid: #211E1D;
  --surface-hover: rgba(46,41,38,0.95);
  --border: rgba(242,157,40,0.20);
  --border-solid: #3A3431;
  
  --text-primary: #F5F1EB;
  --text-secondary: #EDE7DF;
  --text-muted: #DCD4C9;
  
  --sidebar-bg: linear-gradient(180deg, rgba(41,37,34,0.92) 0%, rgba(25,22,20,0.94) 100%);
  --sidebar-text: rgba(255,255,255,0.96);
  --sidebar-active: rgba(242,157,40,0.22);
  --sidebar-hover: rgba(242,157,40,0.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
}

/* ---- Base Styles ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 900px 600px at 15% -5%, rgba(242,157,40,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 800px 500px at 100% 15%, rgba(43,41,41,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 700px 700px at 50% 100%, rgba(23,162,184,0.06) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
}

body.sidebar-locked { overflow: hidden; }

/* ============================================================
   LOADING SCREEN
   ============================================================ */
.loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #211E1D 0%, #171412 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-logo {
  width: auto; height: auto;
  background: #ffffff;
  border: none;
  border-bottom: 4px solid #F29D28;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 26px;
  margin: 0 auto 22px;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 8px 30px rgba(242,157,40,0.25);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(242,157,40,0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(242,157,40,0); }
}

.loading-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #ffffff;
}
.loading-title .accent, .loading-title span { color: #F29D28; }

.loading-bar {
  width: 200px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  margin: 20px auto 10px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: var(--radius-full);
  animation: loadProgress 0.9s ease-in-out forwards;
}

@keyframes loadProgress {
  0% { width: 0%; }
  60% { width: 75%; }
  100% { width: 100%; }
}

.loading-text {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  margin-top: 8px;
}

/* ============================================================
   AUTH SECTION
   ============================================================ */
.auth-section {
  min-height: 100vh;
  background: linear-gradient(135deg, #211E1D 0%, #16213e 40%, #0f3460 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Animated particles */
.auth-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  background: radial-gradient(circle, rgba(242,157,40,0.3) 0%, transparent 70%);
  border-radius: 50%;
  animation: float var(--d) ease-in-out infinite alternate;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -30px) scale(1.1); }
}

.auth-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 920px;
  width: 100%;
  min-height: 580px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

/* Brand Panel */
.auth-brand-panel {
  background: linear-gradient(135deg, rgba(242,157,40,0.9), rgba(43,41,41,0.7));
  backdrop-filter: blur(20px);
  padding: 50px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-brand-panel::before {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  top: -100px; right: -100px;
}

.auth-brand-panel::after {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  bottom: -60px; left: -60px;
}

.brand-content { position: relative; z-index: 1; color: white; }

.brand-icon {
  width: 70px; height: 70px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  border: 1px solid rgba(255,255,255,0.2);
}

.brand-icon .material-icons-round { font-size: 36px; }

.brand-title {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
}

.brand-title span {
  background: linear-gradient(90deg, #FFD700, #FFA500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-desc {
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.6;
  margin-bottom: 32px;
}

.brand-features { display: flex; flex-direction: column; gap: 12px; }

.brand-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  opacity: 0.9;
}

.brand-feature .material-icons-round { font-size: 18px; }

/* Form Panel */
.auth-form-panel {
  background: rgba(255,255,255,0.97);
  padding: 40px 45px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

[data-theme="dark"] .auth-form-panel {
  background: rgba(33,30,29,0.97);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-full);
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 9px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(242,157,40,0.35);
}

.form-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.form-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Role Selector */
.role-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.role-btn {
  flex: 1;
  padding: 8px 6px;
  border: 2px solid var(--border-solid);
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.role-btn .material-icons-round { font-size: 20px; }

.role-btn.active {
  border-color: var(--primary);
  background: rgba(242,157,40,0.08);
  color: var(--primary-text);
}

/* Input Groups */
.input-group-custom {
  position: relative;
  margin-bottom: 14px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  z-index: 1;
  pointer-events: none;
}

.form-input {
  width: 100%;
  padding: 12px 42px 12px 44px;
  border: 2px solid var(--border-solid);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-primary);
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px rgba(242,157,40,0.12);
}

.form-input::placeholder { color: var(--text-muted); }

.toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 4px;
}

.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
}

.forgot-link {
  color: var(--primary-text);
  text-decoration: none;
  font-weight: 600;
}

.forgot-link:hover { text-decoration: underline; }

/* Primary Button */
.btn-primary-custom {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(242,157,40,0.4);
  margin-bottom: 16px;
}

.btn-primary-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(242,157,40,0.5);
}

.btn-primary-custom:active { transform: translateY(0); }

.btn-primary-custom:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a { color: var(--primary-text); font-weight: 600; text-decoration: none; }

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Password Strength */
.password-strength {
  height: 4px;
  border-radius: var(--radius-full);
  margin-top: -8px;
  margin-bottom: 12px;
  transition: var(--transition);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 80px;
}

.sidebar.collapsed .sidebar-header {
  padding: 16px 8px 12px;
  flex-direction: column;
  gap: 14px;
  min-height: auto;
  border-bottom: 1px solid var(--border);
}

.sidebar.collapsed .sidebar-toggle {
  margin-left: 0;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  min-height: 70px;
  cursor: pointer;
  user-select: none;
}

.sidebar-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(242,157,40,0.4);
}

.sidebar-logo .material-icons-round { color: white; font-size: 22px; }

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition-slow);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-label { 
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--sidebar-text);
  white-space: nowrap;
}

.brand-portal {
  font-size: 11px;
  color: var(--sidebar-text);
  opacity: 0.55;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--sidebar-text);
  opacity: 0.6;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sidebar-toggle:hover { 
  background: var(--sidebar-hover);
  opacity: 1;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: rgba(242,157,40,0.06); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(242,157,40,0.35); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(242,157,40,0.55); }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(242,157,40,0.35) rgba(242,157,40,0.06); }

[data-theme="dark"] .sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); }
[data-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
[data-theme="dark"] .sidebar-nav { scrollbar-color: rgba(255,255,255,0.25) rgba(255,255,255,0.04); }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-text);
  opacity: 0.4;
  padding: 12px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
  position: relative;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

/* Sidebar icon tooltip — built in JS and appended to document.body
   (see App.showSidebarTooltip), so it renders fixed-positioned and
   escapes the sidebar's own scroll clipping entirely. */
.sidebar-tooltip {
  position: fixed;
  transform: translate(0, -50%) translateX(-6px);
  background: linear-gradient(135deg, #211E1D, #232048);
  color: #fff;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-primary);
  white-space: nowrap;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 20px rgba(242,157,40,0.25), 0 2px 6px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.08);
  z-index: 9000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.sidebar-tooltip.visible {
  opacity: 1;
  transform: translate(0, -50%) translateX(0);
}

/* Small triangular arrow pointing back at the icon it describes */
.sidebar-tooltip::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: #211E1D;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--primary-text);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--primary-text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item .material-icons-round {
  font-size: 20px;
  flex-shrink: 0;
}

.nav-label { font-size: 13px; font-weight: 600; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar.collapsed .nav-item .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin-left: 0;
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sidebar Footer */
/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed ~ .main-content { margin-left: 80px; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: none;
  align-items: center;
  transition: var(--transition);
}

.sidebar-toggle-btn:hover { background: var(--border); }

.page-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  transition: var(--transition);
}

.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(242,157,40,0.1);
}

.search-bar .material-icons-round { color: var(--text-muted); font-size: 18px; }

.search-bar input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  width: 200px;
  outline: none;
}

.notif-btn {
  position: relative;
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}

.notif-btn:hover { border-color: var(--primary); color: var(--primary-text); }

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface-solid);
}

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  transition: var(--transition);
}

.topbar-profile:hover { border-color: var(--primary); }

.topbar-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
}

/* Topbar icon buttons (Dark Mode toggle, Logout) — separate,
   self-contained actions sitting alongside the profile, rather than
   bundled into a dropdown menu. */
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.topbar-icon-btn .material-icons-round { font-size: 20px; }

.topbar-icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary-text);
  transform: translateY(-1px);
}

.topbar-icon-btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger-text);
  background: rgba(255,71,87,0.06);
}

/* Notification Panel */
.notif-panel {
  position: fixed;
  top: calc(var(--topbar-height) + 8px);
  right: 16px;
  width: 360px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}

.notif-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.notif-header button {
  background: none;
  border: none;
  color: var(--primary-text);
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.notif-list { max-height: 380px; overflow-y: auto; }

.notif-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  gap: 12px;
}

.notif-item:hover { background: var(--bg); }

.notif-item.unread { background: rgba(242,157,40,0.04); }

.notif-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.notif-icon.success { background: rgba(0,200,150,0.15); color: var(--success-text); }
.notif-icon.info { background: rgba(23,162,184,0.15); color: var(--info-text); }
.notif-icon.warning { background: rgba(255,181,71,0.15); color: var(--warning); }
.notif-icon.danger { background: rgba(255,71,87,0.15); color: var(--danger-text); }
.notif-icon.update { background: rgba(242,157,40,0.15); color: var(--primary-text); }
.notif-icon.chat { background: rgba(242,157,40,0.15); color: var(--primary-text); }

.notif-text { flex: 1; }
.notif-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.notif-message { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Search Results */
.search-results {
  position: fixed;
  top: calc(var(--topbar-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  max-height: 400px;
  overflow-y: auto;
}

/* ============================================================
   PAGE CONTAINER
   ============================================================ */
.page-container {
  flex: 1;
  padding: 24px;
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton-container { padding: 8px 0; }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(200,200,220,0.3) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-title { height: 32px; width: 40%; margin-bottom: 20px; }
.skeleton-card { height: 120px; margin-bottom: 16px; }
.skeleton-table { height: 280px; margin-top: 16px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 0 0 80px;
  opacity: 0.08;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  cursor: pointer;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.stat-icon .material-icons-round { font-size: 24px; color: white; }

.stat-icon.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-icon.success { background: linear-gradient(135deg, var(--success), #00a87a); }
.stat-icon.warning { background: linear-gradient(135deg, var(--warning), #e09000); }
.stat-icon.danger { background: linear-gradient(135deg, var(--danger), #cc0011); }
.stat-icon.info { background: linear-gradient(135deg, var(--info), #0e7a8a); }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-trend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.stat-trend.up { background: rgba(0,200,150,0.15); color: var(--success-text); }
.stat-trend.down { background: rgba(255,71,87,0.15); color: var(--danger-text); }

/* ============================================================
   GLASS CARDS (Tables, Forms, etc.)
   ============================================================ */
.glass-card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header-custom {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-custom h5 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.card-body-custom { padding: 22px; }

/* ============================================================
   DATA TABLES
   ============================================================ */
.custom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.custom-table thead th {
  background: var(--bg);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.custom-table tbody tr {
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
}

.custom-table tbody tr:hover { background: rgba(242,157,40,0.03); }
.custom-table tbody tr:last-child { border-bottom: none; }

.custom-table tbody td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  vertical-align: middle;
}

.table-container {
  overflow-x: auto;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-pending { background: rgba(255,181,71,0.15); color: var(--warning-text); }
.badge-received { background: rgba(23,162,184,0.15); color: var(--info-text); }
.badge-checking { background: rgba(242,157,40,0.15); color: var(--primary-text); }
.badge-investigation { background: rgba(242,157,40,0.15); color: var(--primary-text); }
.badge-manufacturing { background: rgba(255,181,71,0.15); color: var(--warning); }
.badge-packing { background: rgba(255,181,71,0.15); color: var(--warning); }
.badge-dispatch { background: rgba(23,162,184,0.15); color: var(--info-text); }
.badge-delivered { background: rgba(0,200,150,0.15); color: var(--success-text); }
.badge-completed, .badge-closed { background: rgba(0,200,150,0.15); color: var(--success-text); }
.badge-rejected { background: rgba(255,71,87,0.15); color: var(--danger-text); }
.badge-capa { background: rgba(255,181,71,0.15); color: var(--warning); }
.badge-under-review { background: rgba(242,157,40,0.15); color: var(--primary-text); }
.badge-active { background: rgba(0,200,150,0.15); color: var(--success-text); }
.badge-inactive { background: rgba(113,128,150,0.15); color: var(--text-muted); }
.badge-approved { background: rgba(0,200,150,0.15); color: var(--success-text); }
.badge-dispatched { background: rgba(23,162,184,0.15); color: var(--info-text); }
.badge-paid { background: rgba(0,200,150,0.15); color: var(--success-text); }
.badge-quoted { background: rgba(242,157,40,0.18); color: var(--warning-text); }
.badge-customer { background: rgba(242,157,40,0.15); color: var(--primary-text); }
.badge-crm { background: rgba(23,162,184,0.15); color: var(--info-text); }
.badge-admin { background: rgba(255,71,87,0.15); color: var(--danger-text); }

/* Priority Badges */
.priority-critical { background: rgba(255,71,87,0.15); color: var(--danger-text); font-size: 11px; padding: 3px 8px; border-radius: 4px; font-weight: 700; }
.priority-high { background: rgba(255,181,71,0.15); color: var(--warning); font-size: 11px; padding: 3px 8px; border-radius: 4px; font-weight: 700; }
.priority-medium { background: rgba(242,157,40,0.15); color: var(--primary-text); font-size: 11px; padding: 3px 8px; border-radius: 4px; font-weight: 700; }
.priority-low { background: rgba(0,200,150,0.15); color: var(--success-text); font-size: 11px; padding: 3px 8px; border-radius: 4px; font-weight: 700; }

/* ============================================================
   FORMS
   ============================================================ */
.form-section {
  max-width: 800px;
  margin: 0 auto;
}

.form-group-custom { margin-bottom: 20px; }

.form-label-custom {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

.form-control-custom {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border-solid);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-primary);
  transition: var(--transition);
  outline: none;
}

.form-control-custom:focus {
  border-color: var(--primary);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px rgba(242,157,40,0.1);
}

/* Flags a required field (e.g. cart line Rate) left empty at
   submit time — clearly visible border + soft red tint rather than
   a subtle colour shift, since this is meant to actually get noticed. */
.form-control-custom.is-invalid {
  border-color: var(--danger-text);
  background: rgba(255,71,87,0.06);
}
.form-control-custom.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(255,71,87,0.15);
}

.form-select-custom {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23718096'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea-custom { resize: vertical; min-height: 100px; }

/* ============================================================
   IMAGE UPLOAD / DROPZONE
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border-solid);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(242,157,40,0.04);
}

.dropzone .material-icons-round {
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.dropzone p { font-size: 13px; color: var(--text-muted); }

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.preview-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  border: 2px solid var(--border);
}

.preview-item img { width: 100%; height: 100%; object-fit: cover; }

.preview-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(255,71,87,0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-custom:hover { transform: translateY(-1px); }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 12px rgba(242,157,40,0.35); }
.btn-success { background: linear-gradient(135deg, var(--success), #00a87a); color: white; box-shadow: 0 4px 12px rgba(0,200,150,0.35); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #cc0011); color: white; box-shadow: 0 4px 12px rgba(255,71,87,0.35); }
.btn-warning { background: linear-gradient(135deg, var(--warning), #e09000); color: white; box-shadow: 0 4px 12px rgba(255,181,71,0.35); }
.btn-outline { background: transparent; border: 2px solid var(--border-solid); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-text); }

[data-theme="dark"] .btn-primary:hover { box-shadow: 0 4px 24px rgba(242,157,40,0.6); }
[data-theme="dark"] .btn-success:hover { box-shadow: 0 4px 24px rgba(0,200,150,0.55); }
[data-theme="dark"] .btn-danger:hover { box-shadow: 0 4px 24px rgba(255,71,87,0.55); }
[data-theme="dark"] .btn-warning:hover { box-shadow: 0 4px 24px rgba(255,181,71,0.55); }

/* ============================================================
   CHAT / TIMELINE
   ============================================================ */
.chat-container { max-height: 400px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideInChat 0.2s ease;
}

@keyframes slideInChat {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.sent { flex-direction: row-reverse; }

.chat-message-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 75%;
  flex: 0 1 auto;
}

.chat-message.sent .chat-message-content {
  align-items: flex-end;
}

.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.chat-avatar.customer { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.chat-avatar.crm { background: linear-gradient(135deg, var(--success), #00a87a); }
.chat-avatar.admin { background: linear-gradient(135deg, #2B2929, #c44569); }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
}

.chat-message.received .chat-bubble { background: var(--bg); border: 1px solid var(--border); border-radius: 4px 16px 16px 16px; }
.chat-message.sent .chat-bubble { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-radius: 16px 4px 16px 16px; }

.chat-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.chat-message.sent .chat-meta { text-align: right; }

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  border: 2px solid var(--border-solid);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  max-height: 100px;
  font-family: var(--font-primary);
}

.chat-input-area textarea:focus { border-color: var(--primary); }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }

.timeline-item {
  position: relative;
  padding-bottom: 20px;
  padding-left: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface-solid);
  box-shadow: 0 0 0 3px rgba(242,157,40,0.2);
}

.timeline-date { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.timeline-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.timeline-desc { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   PROGRESS & SLA
   ============================================================ */
.progress-custom {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.6s ease;
}

.sla-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.sla-ok { background: rgba(0,200,150,0.15); color: var(--success-text); }
.sla-warning { background: rgba(255,181,71,0.15); color: var(--warning-text); }
.sla-breach { background: rgba(255,71,87,0.15); color: var(--danger-text); }

/* ============================================================
   GLOBAL BUSY INDICATOR
   ============================================================ */
.global-busy-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.global-busy-bar.active {
  opacity: 1;
  width: 70%;
  transition: width 8s cubic-bezier(0.1, 0.6, 0.2, 1), opacity 0.2s ease;
}

.global-busy-bar.done {
  width: 100%;
  transition: width 0.25s ease;
}

.global-busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: transparent;
  cursor: wait;
}

/* A short delay before the cursor visibly changes / clicks start
   being blocked, so a near-instant response never flickers the
   overlay on screen for a fraction of a second. */
.global-busy-overlay.active {
  display: block;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-custom {
  background: var(--surface-solid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  pointer-events: all;
  border-left: 4px solid var(--primary);
  animation: slideInToast 0.3s ease;
  cursor: pointer;
}

@keyframes slideInToast {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-custom.fade-out { animation: slideOutToast 0.3s ease forwards; }

@keyframes slideOutToast {
  to { transform: translateX(120%); opacity: 0; }
}

.toast-icon { font-size: 22px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.toast-message { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.toast-success { border-color: var(--success); }
.toast-success .toast-icon { color: var(--success-text); }
.toast-error { border-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger-text); }
.toast-warning { border-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning-text); }
.toast-info { border-color: var(--info); }
.toast-info .toast-icon { color: var(--info-text); }

/* ============================================================
   SUCCESS OVERLAY
   ============================================================ */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.success-box {
  background: var(--surface-solid);
  border-radius: var(--radius-xl);
  padding: 50px 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-icon {
  width: 80px; height: 80px;
  background: rgba(0,200,150,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes bounceIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.success-icon .material-icons-round {
  font-size: 42px;
  color: var(--success-text);
}

.success-box h3 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.success-box p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.success-details {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
  text-align: left;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================================
   MODAL
   ============================================================ */
.glass-modal {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.glass-modal .modal-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}

.glass-modal .modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.glass-modal .modal-body { padding: 24px; }
.glass-modal .modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-select {
  padding: 8px 14px;
  border: 2px solid var(--border-solid);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-primary);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus { border-color: var(--primary); }

/* Order-by-Box / Order-by-Tablet toggle on the PO catalogue grid */
.order-mode-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-md);
  padding: 2px;
  margin-bottom: 6px;
  width: 190px;
}

.order-mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.order-mode-btn.active {
  background: var(--primary);
  color: #fff;
}

.order-mode-btn:not(.active):hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

/* PO catalogue row states */
.po-row-pending {
  background: rgba(255,181,71,0.07);
  transition: background 0.2s ease;
}

.po-row-in-cart {
  background: rgba(0,200,150,0.06);
}

/* +/- quantity stepper (Amazon-cart style) — each click moves by one
   whole MOQ multiple, so there's no way to land on an invalid
   quantity with this control. */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  width: 190px;
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.qty-stepper-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  background: var(--surface-hover);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}

.qty-stepper-btn:hover {
  background: var(--primary);
  color: #fff;
}

.qty-stepper-btn:active {
  transform: scale(0.92);
}

.qty-stepper-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 4px;
  min-width: 0;
}

.qty-stepper-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  text-align: center;
}

.qty-stepper-label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

/* ============================================================
   DASHBOARD QUICK ACTIONS
   ============================================================ */
.quick-action-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.quick-action-btn:hover {
  border-color: var(--primary);
  background: rgba(242,157,40,0.05);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.quick-action-btn .material-icons-round {
  font-size: 30px;
  color: var(--primary);
}

.quick-action-btn span:last-child {
  font-size: 13px;
  font-weight: 700;
}

/* ============================================================
   PURCHASE ORDER — TREE NAVIGATION
   ============================================================ */
.tree-root {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.tree-node {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
}

.tree-node-root {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  box-shadow: var(--shadow-md);
}

.tree-node-root .material-icons-round { color: white; font-size: 26px; }

.tree-node-branch {
  cursor: pointer;
  position: relative;
}

.tree-node-branch:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tree-node-branch.active {
  border-color: var(--primary);
  background: rgba(242,157,40,0.06);
}

.tree-node-branch .material-icons-round:first-child {
  font-size: 26px;
  color: var(--primary);
}

.tree-node-oncology .material-icons-round:first-child { color: var(--warning); }
.tree-node-oncology.active { border-color: var(--warning); background: rgba(255,181,71,0.08); }

.tree-chevron {
  margin-left: auto;
  color: var(--text-muted) !important;
  font-size: 20px !important;
}

.tree-node-leaf {
  cursor: pointer;
  justify-content: center;
  text-align: left;
  flex-direction: row;
  gap: 8px;
  padding: 8px 12px;
}

.tree-node-leaf .material-icons-round { font-size: 16px; color: var(--primary); }
.tree-node-leaf strong { font-size: 13px; }
.tree-node-leaf:hover { border-color: var(--primary); }
.tree-node-leaf.active { border-color: var(--success); background: rgba(0,200,150,0.06); }

/* Custom category dropdown (replaces native <select> so the open
   list can actually be styled compactly — browsers render a native
   select's option list themselves and ignore most CSS on it). */
.custom-dropdown {
  position: relative;
  min-width: 220px;
}

.custom-dropdown-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid var(--border-solid);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: var(--transition);
}

.custom-dropdown-toggle:hover,
.custom-dropdown.open .custom-dropdown-toggle {
  border-color: var(--primary);
}

.custom-dropdown-toggle .material-icons-round {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.custom-dropdown.open .custom-dropdown-toggle .material-icons-round {
  transform: rotate(180deg);
}

.custom-dropdown-toggle span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-dropdown-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 100%;
  max-width: 280px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: 4px;
}

.custom-dropdown.open .custom-dropdown-list {
  display: block;
}

.custom-dropdown-item {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.custom-dropdown-item:hover {
  background: var(--sidebar-hover);
}

.custom-dropdown-item.active {
  background: rgba(242,157,40,0.12);
  color: var(--primary-text);
  font-weight: 700;
}

.custom-dropdown-list::-webkit-scrollbar { width: 6px; }
.custom-dropdown-list::-webkit-scrollbar-track { background: rgba(242,157,40,0.06); border-radius: 3px; }
.custom-dropdown-list::-webkit-scrollbar-thumb { background: rgba(242,157,40,0.35); border-radius: 3px; }

.priority-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--warning), #e09000);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ============================================================
   PURCHASE ORDER — CART
   ============================================================ */
.cart-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cart-line:last-child { border-bottom: none; }

/* ============================================================
   PURCHASE ORDER — STATUS TRACK
   ============================================================ */
.po-status-track {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.po-status-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  padding-left: 14px;
  margin-left: 10px;
}

.po-status-step .material-icons-round {
  font-size: 18px;
}

.po-status-step.done {
  color: var(--success-text);
  border-left-color: var(--success);
  font-weight: 700;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ---- Tablets / small laptops: keep sidebar but narrower, tighten topbar ---- */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }

  .search-bar input { width: 140px; }

  .sidebar.collapsed ~ .main-content { margin-left: 70px; }
}

/* ---- Tablets in portrait / large phones: sidebar becomes an off-canvas drawer ---- */
@media (max-width: 900px) {
  :root { --sidebar-width: 260px; }

  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed { width: var(--sidebar-width); }
  .sidebar.collapsed .sidebar-header { flex-direction: row; padding: 20px 16px; }
  .sidebar.collapsed .sidebar-brand,
  .sidebar.collapsed .nav-label {
    opacity: 1;
    width: auto;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    flex-direction: row;
  }

  .main-content { margin-left: 0 !important; }

  .sidebar-toggle-btn { display: flex; }
  .sidebar-toggle { display: none; }

  .auth-container { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 30px 24px; }

  .topbar { padding: 0 16px; }
  .search-bar { display: none; }

  .page-container { padding: 16px; }

  .notif-panel { right: 8px; left: 8px; width: auto; top: calc(var(--topbar-height) + 6px); }
  .search-results { left: 8px; right: 8px; width: auto; transform: none; }

  /* Mobile overlay for sidebar */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
    display: none;
  }

  .sidebar-overlay.active { display: block; }

  /* Tables: tighter padding + smaller text so columns fit better before scrolling kicks in */
  .custom-table thead th { padding: 9px 10px; font-size: 10px; }
  .custom-table tbody td { padding: 10px 10px; font-size: 12px; }

  .glass-modal { margin: 12px; }
  .glass-modal .modal-body { padding: 18px; }
  .glass-modal .modal-header { padding: 16px 18px; }
  .glass-modal .modal-footer { padding: 14px 18px; flex-wrap: wrap; }

  /* Bulk action bar: drop the auto-margin trick on the clear button —
     it looks disconnected once the bar wraps onto multiple lines on
     a narrow screen — and let every control take the full row width. */
  #bulkActionBar { flex-direction: column; align-items: stretch !important; }
  #bulkActionBar > * { margin-left: 0 !important; width: 100%; }
}

@media (max-width: 576px) {
  .stat-card { padding: 16px; }
  .stat-value { font-size: 24px; }
  .form-section { max-width: 100%; }
  .filters-bar { gap: 6px; }
  .chat-bubble { max-width: 80%; }

  .card-header-custom { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .card-body-custom { padding: 16px; }

  .auth-form-panel { padding: 26px 18px; }
  .role-selector { gap: 6px; }
  .role-btn { font-size: 10px; padding: 8px 4px; }

  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast-custom { min-width: 0; max-width: none; width: 100%; }

  .success-box { padding: 32px 22px; }

  .topbar { padding: 0 12px; }
  .page-title { font-size: 17px; }
  .topbar-profile span { display: none; }
}

@media (max-width: 380px) {
  .page-container { padding: 12px; }
  .stat-card { padding: 14px; }
  .stat-icon { width: 40px; height: 40px; }
  .quick-action-btn { padding: 14px 8px; }
  .card-body-custom .row.g-2 .col-4 > div { padding: 8px 2px !important; }
  .card-body-custom .row.g-2 .col-4 > div > div:first-child { font-size: 16px !important; }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-enter { animation: pageEnter 0.3s ease; }

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.d-none { display: none !important; }

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.chart-container {
  position: relative;
  height: 250px;
}

/* ============================================================
   ID BADGE
   ============================================================ */
.id-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--primary-text);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}


/* ============================================================
   SALUS BRAND LOGO (official logo image, added in rebrand)
   ============================================================ */
.brand-logo-img { display: block; max-width: 100%; height: auto; }
.loading-logo .brand-logo-img { width: 200px; margin: 0 auto 8px; }
.brand-icon { background: #ffffff !important; border-radius: var(--radius-lg); padding: 14px 18px; width: auto; height: auto; }
.brand-icon .brand-logo-img { width: 200px; }
.sidebar-logo { background: transparent !important; box-shadow: none !important; width: auto; height: auto; }
.sidebar-logo .brand-logo-img { width: 42px; background: #ffffff; border-radius: 10px; padding: 4px; }
.sidebar.collapsed .sidebar-logo .brand-logo-img { width: 40px; }



/* ============================================================
   PENDING PAYMENT — highlighted focus card + new stage badges
   ============================================================ */
.stat-card.focus-payment {
  background: linear-gradient(135deg, #F29D28 0%, #D9821A 100%);
  border: 2px solid #B36B0E;
  box-shadow: 0 6px 24px rgba(242,157,40,0.45);
  animation: payment-pulse 2.2s ease-in-out infinite;
}
.stat-card.focus-payment .stat-value,
.stat-card.focus-payment .stat-label { color: #ffffff !important; }
.stat-card.focus-payment .stat-label { font-weight: 800; letter-spacing: 0.4px; }
.stat-icon.focus-payment { background: rgba(255,255,255,0.25); }
.stat-icon.focus-payment .material-icons-round { color: #ffffff; }
@keyframes payment-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(242,157,40,0.45); transform: translateY(0); }
  50% { box-shadow: 0 10px 34px rgba(242,157,40,0.75); transform: translateY(-3px); }
}
[data-theme="dark"] .stat-card.focus-payment { border-color: #F7B45E; }

/* Badges for the new 7-stage order pipeline */
.badge-order-confirmed { background: rgba(6,122,86,0.15); color: #067A56; }
.badge-artwork { background: rgba(242,157,40,0.18); color: #A96A0C; }
.badge-full-kitting { background: rgba(23,100,120,0.15); color: #0C6478; }
.badge-testing { background: rgba(90,60,170,0.15); color: #5A3CAA; }
.badge-production { background: rgba(43,41,41,0.12); color: #2B2929; }
.badge-fg { background: rgba(6,122,86,0.2); color: #067A56; font-weight: 800; }
[data-theme="dark"] .badge-order-confirmed { background: rgba(0,200,150,0.2); color: #4ADEB8; }
[data-theme="dark"] .badge-artwork { background: rgba(242,157,40,0.25); color: #F7B45E; }
[data-theme="dark"] .badge-full-kitting { background: rgba(23,162,184,0.22); color: #6BD3E5; }
[data-theme="dark"] .badge-testing { background: rgba(140,110,220,0.25); color: #C4AEF5; }
[data-theme="dark"] .badge-production { background: rgba(255,255,255,0.12); color: #F5F1EB; }
[data-theme="dark"] .badge-fg { background: rgba(0,200,150,0.28); color: #4ADEB8; font-weight: 800; }


/* ============================================================
   V4.1 — NO HORIZONTAL PAGE SCROLL (all devices) + PERFORMANCE
   ============================================================ */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}
img, svg, video, canvas { max-width: 100%; height: auto; }
.page-enter, .glass-card, .card-body-custom { max-width: 100%; }
/* Long unbroken strings (emails, IDs) must wrap, never widen the page */
.custom-table td, .card-body-custom, .chat-bubble, .notification-item {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.id-badge { white-space: nowrap; }
/* Wide tables scroll INSIDE their own container only — the page itself
   never scrolls sideways */
.table-container {
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.filters-bar, .card-header-custom { flex-wrap: wrap; }

/* PERFORMANCE: backdrop blur is the single heaviest effect on low-end
   phones/laptops — halve it on desktop, remove it entirely on mobile.
   Surfaces keep a solid fallback color so nothing becomes unreadable. */
.glass-card, .sidebar, .topbar { backdrop-filter: blur(10px); }
@media (max-width: 768px) {
  .glass-card, .sidebar, .topbar, .stat-card, .auth-brand-panel {
    backdrop-filter: none !important;
  }
  .stat-card.focus-payment { animation: none; }
  * { transition-duration: 0.15s !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   v3 — Professional polish + speed
   (database edition). Appended last so it overrides above.
   ============================================================ */

/* Speed: blur effects are expensive to paint on every scroll.
   Solid surfaces look cleaner and keep scrolling smooth on all
   office PCs and phones. */
:root { --surface: #ffffff; --surface-hover: #FFFDF9; --border: #ECE4D8; }
[data-theme="dark"] { --surface: #211E1D; --surface-hover: #2A2624; --border: #3A3431; }
.glass-card, .sidebar, .topbar, .stat-card, .modal-content, .notif-panel, .auth-card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Calmer, sharper cards */
.glass-card, .stat-card {
  box-shadow: 0 1px 2px rgba(43,41,41,0.06), 0 1px 8px rgba(43,41,41,0.04);
  border: 1px solid var(--border);
}
.stat-card:hover { transform: none; box-shadow: 0 2px 12px rgba(43,41,41,0.10); }
.btn-custom:hover, .btn-primary-custom:hover { transform: none; }

/* Buttons: solid colours with readable (AA contrast) text */
.btn-primary { background: #E08A12; box-shadow: none; color: #fff; }
.btn-primary:hover { background: #C97A0C; }
.btn-success { background: #067A56; box-shadow: none; color: #fff; }
.btn-success:hover { background: #05664A; }
.btn-danger { background: #C81E2B; box-shadow: none; color: #fff; }
.btn-warning { background: #FFB547; box-shadow: none; color: #2B2929; }
.btn-outline { border: 1.5px solid #CFC6B9; color: var(--text-primary); font-weight: 600; }
[data-theme="dark"] .btn-outline { border-color: #5A524C; }

/* Keyboard users can always see where they are */
:focus-visible { outline: 3px solid rgba(224,138,18,0.55); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

/* Tables: clear rows, sticky header, no faded text */
table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-solid);
  color: var(--text-primary) !important;
  font-weight: 700;
}
table tbody tr:nth-child(even) td { background: rgba(43,41,41,0.025); }
[data-theme="dark"] table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.03); }
table td { color: var(--text-primary); }

/* Faster page transitions */
.page-enter { animation-duration: 0.18s; }

/* Data & Backup page */
.data-health-item { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); height: 100%; }
.data-health-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.data-health-value { font-size: 20px; font-weight: 800; color: var(--text-primary); margin-top: 4px; }
.data-health-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.data-health-link { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--primary-text); }
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.export-option {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-md);
  font-weight: 600; color: var(--text-primary); background: var(--surface-solid);
  transition: border-color 0.15s;
}
.export-option:hover { border-color: var(--primary); }
.export-option input { width: 18px; height: 18px; accent-color: #E08A12; flex-shrink: 0; }
.export-option .material-icons-round { color: var(--primary-text); font-size: 20px; }
.export-option small { color: var(--text-secondary); font-weight: 500; }
.export-option:has(input:checked) { border-color: #E08A12; background: rgba(242,157,40,0.08); }
