@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600&display=swap');

:root {
  /* Colors */
  --bg-darker: #090d16;
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.4);
  --bg-card-hover: rgba(30, 41, 59, 0.7);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.3);
  --secondary: #a855f7;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Branch Theme (default = สามชุก = Cyan) */
  --branch-primary: #38bdf8;
  --branch-primary-glow: rgba(56, 189, 248, 0.3);
  --branch-secondary: #a855f7;
  --branch-gradient: linear-gradient(135deg, #38bdf8, #a855f7);
  
  /* Fonts */
  --font-main: 'Outfit', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Layout */
  --sidebar-width: 260px;
  --bottom-nav-height: 68px;
  --mobile-header-height: 60px;
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --transition-speed: 0.3s;
}

/* Branch: เมืองสุพรรณบุรี = Amber/Orange */
body.branch-suphanburi {
  --branch-primary: #f59e0b;
  --branch-primary-glow: rgba(245, 158, 11, 0.3);
  --branch-secondary: #ef4444;
  --branch-gradient: linear-gradient(135deg, #f59e0b, #ef4444);
  --border-focus: #f59e0b;
}

/* Apply branch colors to key elements */
.mobile-logo-icon,
.logo-icon {
  background: var(--branch-gradient) !important;
}

.branch-pill {
  color: var(--branch-primary) !important;
  background: rgba(var(--branch-primary-rgb, 56, 189, 248), 0.1);
  border-color: rgba(var(--branch-primary-rgb, 56, 189, 248), 0.25) !important;
}

body.branch-suphanburi .branch-pill {
  background: rgba(245, 158, 11, 0.1) !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}

.mobile-header {
  border-bottom-color: rgba(var(--branch-primary-rgb, 56, 189, 248), 0.15) !important;
}

body.branch-suphanburi .mobile-header {
  border-bottom-color: rgba(245, 158, 11, 0.15) !important;
}

/* Branch accent strip at the very top */
body::before {
  content: '';
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--branch-gradient);
  z-index: 9999;
}


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-darker);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ==========================================
   MOBILE-FIRST APP LAYOUT (< 1024px)
   ========================================== */

.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

/* --- MOBILE HEADER --- */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-header-height);
  background: rgba(9, 13, 22, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 50;
}

.mobile-header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-logo-icon {
  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: 0.9rem;
  color: var(--bg-darker);
  flex-shrink: 0;
}

.mobile-logo-text {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.branch-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
  max-width: 160px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.branch-pill:active {
  background: rgba(56, 189, 248, 0.2);
  transform: scale(0.97);
}

.branch-pill i {
  flex-shrink: 0;
  font-size: 0.7rem;
}

.admin-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  flex-shrink: 0;
}

.admin-avatar-btn.admin-active {
  background: var(--success);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 12px var(--success-glow);
}

/* Legacy sidebar — hidden on mobile, shown on desktop */
.sidebar {
  display: none;
}

/* --- MAIN CONTENT AREA --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: var(--mobile-header-height);
  padding-bottom: var(--bottom-nav-height);
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.03) 0px, transparent 50%);
}

/* Legacy header-bar — hidden on mobile */
.header-bar {
  display: none;
}

/* --- VIEW PANELS --- */
.view-panel {
  display: none;
  padding: 1rem;
  animation: fadeIn 0.35s ease-out forwards;
  min-height: calc(100vh - var(--mobile-header-height) - var(--bottom-nav-height));
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- BOTTOM NAVIGATION BAR --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(9, 13, 22, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-glass);
  display: flex;
  align-items: stretch;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.5rem 0.25rem;
  transition: color 0.2s, transform 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
  font-size: 1.2rem;
  transition: transform 0.2s, color 0.2s;
}

.bottom-nav-item span {
  display: block;
  line-height: 1;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active i {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 0 0 4px 4px;
}

.bottom-nav-item:active {
  transform: scale(0.9);
}

/* --- FLOATING ACTION BUTTON (FAB) --- */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 1rem);
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg-darker);
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--primary-glow), 0 2px 8px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 10px var(--primary-glow);
}

.fab.fab-hidden {
  transform: scale(0) rotate(-45deg);
  opacity: 0;
  pointer-events: none;
}

/* ==========================================
   GLASSMORPHISM CARDS
   ========================================== */

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  margin-bottom: 1rem;
  transition: border-color var(--transition-speed) ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title i {
  color: var(--primary);
}

/* ==========================================
   JOB CARD ITEM (Mobile Card Component)
   ========================================== */

.job-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-lg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.job-card-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 3px 0 0 3px;
}

.job-card-item.status-completed::before {
  background: var(--success);
}

.job-card-item:active {
  background: var(--bg-card-hover);
}

.job-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}

.job-card-plate {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: monospace;
  letter-spacing: 1px;
  flex: 1;
}

.job-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.job-card-meta-item {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.job-card-meta-item i {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.job-card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-glass);
}

.job-card-job-no {
  font-size: 0.75rem;
  color: var(--primary);
  font-family: monospace;
  font-weight: 600;
}

/* ==========================================
   ROLL CARD ITEM (Mobile Card Component)
   ========================================== */

.roll-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-lg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
}

.roll-card-item:active {
  background: var(--bg-card-hover);
}

.roll-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.roll-card-id {
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.roll-card-spec {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.roll-card-variant {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.roll-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-glass);
}

.roll-card-footage {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.roll-card-actions {
  display: flex;
  gap: 0.4rem;
}

/* ==========================================
   LOG ENTRY CARD (Mobile Card Component)
   ========================================== */

.log-entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
}

.log-entry-card.log-extra {
  border-left: 3px solid var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}

.log-entry-roll-id {
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}

.log-entry-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.log-entry-spec {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.log-entry-details {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.log-entry-detail {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.log-entry-detail i {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.log-entry-footage {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Date Group Header for logs */
.log-date-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 0 0.4rem;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ==========================================
   STATS CARDS (2x2 on mobile)
   ========================================== */

.stats-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(56, 189, 248, 0.1); color: var(--primary); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.1); color: var(--secondary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.red { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stat-info p {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
  line-height: 1.3;
}

.stat-info h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ==========================================
   FORM STYLES
   ========================================== */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
  letter-spacing: 0.2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background-color: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 0.8rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 1rem; /* Larger for mobile touchability */
  outline: none;
  transition: all var(--transition-speed) ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background-color: rgba(15, 23, 42, 0.95);
}

.form-select option, select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-row .form-group {
  margin-bottom: 0;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-speed) ease;
  font-family: var(--font-main);
  min-height: 44px; /* Touch target */
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg-darker);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-secondary {
  background-color: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:active {
  background-color: var(--bg-card-hover);
}

.btn-success {
  background-color: var(--success);
  color: var(--bg-darker);
  box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:active {
  transform: scale(0.97);
}

.btn-danger {
  background-color: var(--danger);
  color: var(--text-primary);
  box-shadow: 0 4px 15px var(--danger-glow);
}

.btn-danger:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--border-radius-sm);
  min-height: 36px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-unregistered {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-registered {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-empty {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

/* ==========================================
   PROGRESS BAR
   ========================================== */

.progress-bar-container {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.06);
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ==========================================
   CIRCULAR GAUGE (Scan View)
   ========================================== */

.roll-meter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1rem 0;
}

.roll-gauge {
  position: relative;
  width: 120px;
  height: 120px;
}

.roll-gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.roll-gauge circle {
  fill: none;
  stroke-width: 10;
}

.roll-gauge-bg {
  stroke: rgba(255, 255, 255, 0.05);
}

.roll-gauge-fill {
  stroke: var(--primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
  filter: drop-shadow(0 0 6px var(--primary));
}

.roll-gauge-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.roll-gauge-num {
  font-size: 1.5rem;
  font-weight: 700;
}

.roll-gauge-unit {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* ==========================================
   MODALS & BOTTOM SHEETS
   ========================================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  padding: 0;
  align-items: flex-end; /* Bottom sheet by default */
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

/* Bottom Sheet style */
.modal-content {
  background: var(--bg-dark);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
  position: relative;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

/* Drag Handle indicator */
.modal-content::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--border-glass);
  border-radius: 2px;
  margin: 0 auto 1.25rem auto;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-card);
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

/* Create Job Bottom Sheet */
#create-job-sheet .modal-content {
  text-align: left;
}

/* ==========================================
   BOTTOM SHEET SPECIFIC - Create Job Form
   ========================================== */

.sheet-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding-top: 0.25rem;
}

.sheet-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.sheet-header i {
  color: var(--primary);
}

/* ==========================================
   QR SCAN VIEW (Mechanic Mode)
   ========================================== */

.scanner-sim-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-glass);
  margin-top: 1rem;
}

#reader {
  width: 100%;
  background-color: #000;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glass) !important;
}

#reader button {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: bold;
  margin: 0.5rem;
  transition: all 0.2s;
}

/* ==========================================
   PRINTABLE TAGS
   ========================================== */

.printable-tag-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #ffffff;
  color: #000000;
  padding: 2rem 1.5rem;
  border-radius: var(--border-radius-md);
  margin: 1rem auto;
  border: 2px solid #000000;
  width: 300px;
}

.tag-header {
  font-size: 1.1rem;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  letter-spacing: 1px;
}

.tag-subheader {
  font-size: 0.7rem;
  margin-bottom: 1rem;
  color: #555;
}

.tag-qrcode {
  padding: 10px;
  background: #fff;
  border: 1px solid #ddd;
  margin: 0.5rem auto 1rem auto;
  width: 172px;
  height: 172px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.tag-qrcode canvas, .tag-qrcode img {
  width: 150px !important;
  height: 150px !important;
  display: block;
  margin: 0 auto;
}

.tag-id {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: monospace;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  border: 1.5px solid #000;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}

.tag-footer {
  font-size: 0.65rem;
  color: #777;
  margin-top: 0.5rem;
  text-align: center;
  border-top: 1px dashed #ccc;
  padding-top: 0.5rem;
  width: 100%;
}

/* ==========================================
   CUSTOM CHECKBOX
   ========================================== */

.checkbox-container {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  margin: 0.5rem 0;
  line-height: 1.5;
}

.checkbox-container input {
  display: none;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--border-glass);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  background-color: rgba(15, 23, 42, 0.6);
  flex-shrink: 0;
  margin-top: 2px;
}

.checkbox-container input:checked + .checkbox-custom {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkbox-custom i {
  color: var(--bg-darker);
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.checkbox-container input:checked + .checkbox-custom i {
  opacity: 1;
}

/* ==========================================
   ADMIN PANEL TABS
   ========================================== */

.admin-tabs-nav {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 1.25rem;
  gap: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0;
}

.admin-tabs-nav::-webkit-scrollbar {
  display: none;
}

.admin-tab-btn {
  padding: 0.6rem 1rem;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.admin-tab-btn:hover {
  color: var(--text-primary);
}

.admin-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.admin-tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
}

.admin-tab-content.active {
  display: block;
}

/* ==========================================
   COLLAPSIBLE TREE (Admin Variants)
   ========================================== */

.brand-group-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
  border-left: 3px solid var(--primary);
  padding-left: 0.5rem;
}

.series-collapse-header {
  background-color: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  user-select: none;
}

.series-collapse-header:hover {
  background-color: rgba(30, 41, 59, 0.8);
}

.series-collapse-header i {
  transition: transform 0.2s;
  color: var(--text-secondary);
}

.series-collapse-header.collapsed i {
  transform: rotate(-90deg);
}

.series-collapse-content {
  padding-left: 0.25rem;
  margin-bottom: 0.75rem;
  display: block;
}

.series-collapse-content.collapsed {
  display: none;
}

/* ==========================================
   TABLE (Admin sub-views only, small tables)
   ========================================== */

.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  background: rgba(30, 41, 59, 0.2);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 320px;
}

.data-table th {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 0.85rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.row-extra-cutting {
  background: rgba(239, 68, 68, 0.05);
}

.row-extra-cutting td {
  border-left: 3px solid var(--danger);
}

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

.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 0.75rem);
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  border-left: 4px solid var(--primary);
  border-top: 1px solid var(--border-glass);
  border-right: 1px solid var(--border-glass);
  border-bottom: 1px solid var(--border-glass);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  transform: translateY(20px);
  opacity: 0;
  animation: toastIn 0.3s forwards;
  font-size: 0.9rem;
  pointer-events: auto;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

.toast.hide {
  animation: toastOut 0.3s forwards;
}

@keyframes toastIn {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(20px); opacity: 0; }
}

/* ==========================================
   UTILITY
   ========================================== */

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mt-3 { margin-top: 1.25rem; }
.mr-2 { margin-right: 0.5rem; }

.section-heading {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* Branch indicator (legacy alias kept for JS compat) */
.branch-indicator {
  transition: all 0.2s ease;
}

/* ==========================================
   MECHANIC MODE (Phone Scan URL Lockout)
   ========================================== */

body.mechanic-mode .mobile-header,
body.mechanic-mode .bottom-nav,
body.mechanic-mode .fab,
body.mechanic-mode .sidebar {
  display: none !important;
}

body.mechanic-mode .main-content {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

body.mechanic-mode .view-panel {
  display: block !important;
  padding: 1.25rem 1rem !important;
  min-height: 100vh;
}

body.mechanic-mode #panel-registered,
body.mechanic-mode #panel-unregistered,
body.mechanic-mode #panel-empty {
  margin: 0 auto !important;
  max-width: 100% !important;
}

/* ==========================================
   GRID HELPERS
   ========================================== */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.grid-1-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* ==========================================
   DESKTOP LAYOUT (≥ 1024px) — Sidebar Restored
   ========================================== */

@media (min-width: 1024px) {
  body {
    overflow: hidden;
  }

  .app-container {
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
  }

  /* Show desktop sidebar */
  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background: #0b0f19;
    border-right: 1px solid var(--border-glass);
    padding: 1.5rem 1rem;
    z-index: 10;
    height: 100vh;
    flex-shrink: 0;
  }

  .logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
  }

  .logo-icon i {
    color: var(--bg-darker);
    font-size: 1.1rem;
  }

  .logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
  }

  .nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
  }

  .nav-item.active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(168, 85, 247, 0.05));
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: var(--primary);
  }

  .nav-item i {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
  }

  /* Hide mobile-only elements */
  .mobile-header { display: none; }
  .bottom-nav { display: none; }
  .fab { display: none; }

  /* Show desktop header */
  .header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(9, 13, 22, 0.5);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
  }

  .header-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
  }

  .user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-lg);
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
  }

  /* Desktop main content */
  .main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* Desktop view panels */
  .view-panel {
    padding: 2rem;
    min-height: auto;
  }

  /* Desktop stats: 4 columns */
  .stats-container {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
  }

  .stat-card {
    padding: 1.25rem 1.5rem;
    gap: 1.25rem;
  }

  .stat-icon {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }

  .stat-info h3 {
    font-size: 1.5rem;
  }

  .stat-info p {
    font-size: 0.8rem;
  }

  /* Desktop: restore side-by-side grids */
  .grid-1-2 {
    grid-template-columns: 1.2fr 2fr;
  }

  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  /* Desktop: branch indicator in header */
  .branch-indicator {
    cursor: pointer;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--border-radius-md);
    font-size: 0.9rem;
    font-weight: 500;
  }

  .branch-indicator:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
    color: var(--primary) !important;
  }

  /* Desktop toast position */
  .toast-container {
    bottom: 2rem;
    left: auto;
    right: 2rem;
    width: 340px;
  }

  /* Desktop modal: center floating */
  .modal-overlay {
    align-items: center;
    padding: 2rem;
  }

  .modal-content {
    border-radius: var(--border-radius-lg);
    animation: fadeIn 0.25s ease;
    max-height: 85vh;
  }

  .modal-content::before {
    display: none;
  }

  /* Desktop admin tabs */
  .admin-tabs-nav {
    flex-wrap: nowrap;
    overflow-x: visible;
  }

  /* Desktop admin 2-col grid */
  #admin-tab-brands .grid-1-2,
  #admin-tab-series .grid-1-2,
  #admin-tab-variants .grid-1-2,
  #admin-tab-technicians .grid-1-2,
  #admin-tab-serviceAdvisors .grid-1-2 {
    grid-template-columns: 1.2fr 2fr;
  }

  /* Desktop roll gauge larger */
  .roll-gauge {
    width: 140px;
    height: 140px;
  }

  .roll-gauge-num {
    font-size: 1.8rem;
  }

  /* Desktop: scan view with grid */
  #panel-registered {
    max-width: 760px;
  }
  
  #panel-registered .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================
   PRINT CSS
   ========================================== */

@media print {
  @page {
    size: 100mm 150mm portrait;
    margin: 0;
  }

  html, body {
    color-scheme: light !important;
    background: #ffffff !important;
    color: #000000 !important;
    width: 100mm !important;
    height: 150mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body > *:not(#qr-modal) {
    display: none !important;
  }

  #qr-modal {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100mm !important;
    height: auto !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    animation: none !important;
    transform: none !important;
    transition: none !important;
  }

  #qr-modal .modal-content {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100mm !important;
    width: 100mm !important;
    height: auto !important;
    position: static !important;
    display: block !important;
    border-radius: 0 !important;
    overflow: visible !important;
    animation: none !important;
    transform: none !important;
    transition: none !important;
  }

  #qr-modal .modal-content::before {
    display: none !important;
  }

  #tags-print-container {
    display: block !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100mm !important;
    height: auto !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }

  .printable-tag-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: #ffffff !important;
    color: #000000 !important;
    padding: 8mm 6mm !important;
    margin: 8mm auto !important;
    border: none !important;
    width: 100mm !important;
    height: 125mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .printable-tag-container:not(:last-child) {
    page-break-after: always !important;
    break-after: page !important;
  }

  .printable-tag-container * {
    visibility: visible !important;
    color: #000000 !important;
  }

  .tag-qrcode {
    width: 172px !important;
    height: 172px !important;
    padding: 10px !important;
    background: #ffffff !important;
    border: 1px solid #000 !important;
    margin: 0.5rem auto !important;
  }

  .tag-qrcode img, .tag-qrcode canvas {
    width: 150px !important;
    height: 150px !important;
    margin: 0 auto !important;
  }

  .tag-footer {
    border-top: 1px dashed #000000 !important;
    font-size: 0.75rem !important;
    margin-top: 3mm !important;
    padding-top: 3mm !important;
  }

  #qr-modal .modal-close,
  #qr-modal .btn,
  #qr-modal .modal-title,
  #qr-modal #print-modal-description,
  #qr-modal p,
  .no-print {
    display: none !important;
  }
}

/* ==========================================
   2-STEP LOGIN MODAL STYLES
   ========================================== */

.login-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.login-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-glass);
  transition: all 0.3s;
}

.login-step-dot.active {
  width: 24px;
  border-radius: 4px;
  background: var(--branch-primary, var(--primary));
}

.login-step-dot.done {
  background: var(--success);
}

.login-step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.login-step.active {
  display: block;
}

/* Big branch choice buttons */
.branch-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.branch-choice-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-glass);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  font-family: var(--font-main);
  color: var(--text-primary);
  width: 100%;
}

.branch-choice-btn:hover, .branch-choice-btn:active {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.15);
}

.branch-choice-btn.suphanburi:hover, .branch-choice-btn.suphanburi:active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
}

.branch-choice-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.branch-choice-icon.cyan {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.branch-choice-icon.amber {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.branch-choice-info strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.branch-choice-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Employee pill grid */
.employee-role-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: rgba(255,255,255,0.04);
  border-radius: var(--border-radius-md);
  padding: 0.25rem;
}

.employee-role-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.employee-role-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.employee-pill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.employee-pill-grid::-webkit-scrollbar {
  width: 4px;
}

.employee-pill-grid::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 2px;
}

.employee-pill-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-glass);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-main);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.18s;
  width: 100%;
}

.employee-pill-btn:hover, .employee-pill-btn:active {
  border-color: var(--branch-primary, var(--primary));
  background: rgba(56, 189, 248, 0.08);
  transform: scale(1.02);
}

body.branch-suphanburi .employee-pill-btn:hover,
body.branch-suphanburi .employee-pill-btn:active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.employee-pill-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--branch-gradient, linear-gradient(135deg, var(--primary), var(--secondary)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--bg-darker);
  flex-shrink: 0;
}

.employee-pill-name {
  flex: 1;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Welcome-back card */
.welcome-back-card {
  background: var(--bg-card);
  border: 1.5px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

body.branch-suphanburi .welcome-back-card {
  border-color: rgba(245, 158, 11, 0.2);
}

.welcome-back-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--branch-gradient, linear-gradient(135deg, var(--primary), var(--secondary)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bg-darker);
  flex-shrink: 0;
}

.welcome-back-info strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.welcome-back-info span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.welcome-back-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Role badge in header */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 50px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 0.3rem;
}

.role-badge.role-sa {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.role-badge.role-tech {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

/* User identity in header */
.user-identity-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem 0.3rem 0.3rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}

.user-identity-pill:active {
  background: rgba(255,255,255,0.1);
}

.user-identity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--branch-gradient, linear-gradient(135deg, var(--primary), var(--secondary)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bg-darker);
  flex-shrink: 0;
}

.user-identity-name {
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================
   MY JOBS FILTER TABS (Jobs View)
   ========================================== */

.jobs-filter-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  background: rgba(255,255,255,0.04);
  border-radius: var(--border-radius-md);
  padding: 0.25rem;
}

.jobs-filter-tab {
  flex: 1;
  padding: 0.5rem 0.5rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
  background: transparent;
  font-family: var(--font-main);
}

.jobs-filter-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.jobs-filter-tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  border-radius: 50px;
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 0.3rem;
}

body.branch-suphanburi .jobs-filter-tab .tab-count {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

/* Session timeout banner */
.session-reminder {
  display: none;
  position: fixed;
  top: calc(var(--mobile-header-height) + 8px);
  left: 0.75rem;
  right: 0.75rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1rem;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  backdrop-filter: blur(10px);
}

.session-reminder.hidden {
  display: none !important;
}

.session-reminder i {
  color: var(--warning);
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .session-reminder {
    top: 80px;
    left: calc(var(--sidebar-width) + 1.5rem);
    right: 2rem;
    max-width: 500px;
  }
}

/* ==========================================
   ROLE-BASED VIEW RESTRICTIONS (Technician Mode)
   ========================================== */

body.role-tech #bottom-nav,
body.role-tech #app-sidebar .nav-links {
  display: none !important;
}

body.role-tech .main-content {
  padding-bottom: 0 !important;
}

body.role-tech #panel-scan-prompt .sa-only-message,
body.role-tech #panel-scan-prompt .sa-only-actions {
  display: none !important;
}

body.role-tech #panel-scan-prompt .tech-only-message {
  display: block !important;
}

#role-tab-tech {
  display: none !important;
}

/* ==========================================
   ANALYTICS DASHBOARD SYSTEM
   ========================================== */
.analytics-filter-bar {
  border-bottom: 1px solid var(--border-glass);
}

.analytics-stats-grid > div {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem;
  text-align: center;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

.analytics-stats-grid > div:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

.analytics-bar-row {
  margin-bottom: 0.5rem;
  transition: transform 0.2s;
}

.analytics-bar-row:hover {
  transform: translateX(4px);
}

.analytics-bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.analytics-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.analytics-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: analytics-shine 2s infinite linear;
}

@keyframes analytics-shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.brand-fill {
  background: linear-gradient(90deg, var(--primary) 0%, #06b6d4 100%);
}

.tech-fill {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.waste-fill {
  background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

/* Suphan Buri theme overrides */
body.branch-suphanburi .brand-fill {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}
body.branch-suphanburi .tech-fill {
  background: linear-gradient(90deg, #06b6d4 0%, var(--primary) 100%);
}



