/* ═══════════════════════════════════════════════════════════════
   SNG Logistics — Premium Design System v2
   ═══════════════════════════════════════════════════════════════ */

/* ══ Fonts are loaded via <link> in main.ejs (Noto Sans Thai + Lao + Prompt) ══ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-cyan:    #06b6d4;
  --brand-blue:    #3b82f6;
  --brand-purple:  #a855f7;

  /* Backgrounds */
  --bg-body:       #080b14;
  --bg-sidebar:    #0a0d18;
  --bg-topbar:     rgba(8,11,20,0.92);
  --bg-panel:      rgba(13,16,28,0.90);
  --bg-panel-hover:rgba(18,22,38,0.95);

  /* Borders */
  --border:        rgba(255,255,255,0.07);
  --border-active: rgba(6,182,212,0.30);

  /* Text */
  --text-primary:  rgba(255,255,255,0.92);
  --text-secondary:rgba(255,255,255,0.55);
  --text-muted:    rgba(255,255,255,0.28);

  /* Shadows */
  --shadow-panel:  0 4px 32px rgba(0,0,0,0.55);
  --shadow-card:   0 2px 16px rgba(0,0,0,0.40);

  /* Spacing / radius */
  --radius-sm:     0.625rem;
  --radius-md:     0.875rem;
  --radius-lg:     1.25rem;
  --radius-xl:     1.5rem;
}

/* ── Reset / Base — use !important to beat Tailwind preflight ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ── Native select/option fix — browser dropdowns use system colors ── */
/* Force dark background + light text so options are always readable    */
select {
  color-scheme: dark;           /* hint to OS to render native UI dark  */
}
select option {
  background-color: #1e293b !important;   /* slate-800 */
  color: #f1f5f9 !important;              /* slate-100 */
}
select option:hover,
select option:focus,
select option:checked {
  background-color: #0891b2 !important;   /* cyan-600  */
  color: #ffffff !important;
}
/* Webkit (Chrome/Edge) additional hint */
@media (prefers-color-scheme: dark) {
  select option {
    background-color: #1e293b;
    color: #f1f5f9;
  }
}

html {
  height: 100%;
}

body {
  /* Noto Sans Thai — covers Thai + Latin. Prompt as fallback for brand weight. */
  font-family: 'Noto Sans Thai', 'Prompt', sans-serif !important;
  font-size: 15px !important;
  line-height: 1.6 !important;
  background: radial-gradient(ellipse at 20% 0%, #0d1a2e 0%, #080b14 60%) !important;
  color: var(--text-primary) !important;
  min-height: 100vh !important;
  -webkit-font-smoothing: antialiased;
}

/* ── Lao script — Noto Sans Lao สำหรับอักษรลาวทุกตัว ────────────
   unicode-range ครอบคลุม U+0E80–U+0EFF (Lao Unicode block)
   Browser จะเลือก Noto Sans Lao อัตโนมัติเมื่อพบตัวอักษรลาว
   ไม่ว่าหน้าจะเป็น lang=th หรือ lang=lo ก็ตาม
─────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Noto Sans Lao';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/notosanslao/v36/bx6lNx2Ol_ixgdYWLm9BwxM3NW6BOkuf763Clj73CiQ_J1Djx9pidOt4ccbdf5MK3riB2w.woff2') format('woff2');
  unicode-range: U+0E80-0EFF; /* Lao */
}

/* ── เมื่อ lang=lo ให้ใช้ Noto Sans Lao เป็น font หลัก ── */
:lang(lo),
:lang(lo) * {
  font-family: 'Noto Sans Lao', 'Noto Sans Thai', sans-serif !important;
}

/* ── class helper ใช้บังคับ Lao font ได้โดยตรง ── */
.font-lao,
.font-lao * {
  font-family: 'Noto Sans Lao', sans-serif !important;
}


/* ── Typography helpers ────────────────────────────────────────── */
.label-xs {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-muted);
}
.mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }

/* ════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════ */
.sidebar {
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0; top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.sidebar-section-title {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  padding: 1.1rem 0.75rem 0.4rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.18s ease;
  margin-bottom: 0.125rem;
  border: 1px solid transparent;
}

.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.06);
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(6,182,212,0.14), rgba(59,130,246,0.10));
  color: #22d3ee;
  border-color: rgba(6,182,212,0.22);
  font-weight: 600;
}

.sidebar-link.active i { opacity: 1; }

/* ════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════ */
.main-content {
  margin-left: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════ */
.topbar {
  padding: 0.875rem 1.75rem;
  background: var(--bg-topbar);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

/* ════════════════════════════════════════════
   GLASS PANELS
   ════════════════════════════════════════════ */
.glass-panel-dark {
  background: var(--bg-panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.glass-panel {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ════════════════════════════════════════════
   KPI CARDS
   ════════════════════════════════════════════ */
.kpi-card-premium {
  background: var(--bg-panel);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.375rem 1.25rem 1.125rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  text-decoration: none;
  display: block;
}

/* Gradient accent bar on top */
.kpi-card-premium::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient, rgba(255,255,255,0.1));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: opacity 0.25s ease;
}

.kpi-card-premium:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 16px 40px rgba(0,0,0,0.50);
}

/* Color variants */
.kpi-card-premium.blue   { --gradient: linear-gradient(90deg, #3b82f6, #06b6d4); }
.kpi-card-premium.purple { --gradient: linear-gradient(90deg, #a855f7, #8b5cf6); }
.kpi-card-premium.green,
.kpi-card-premium.emerald{ --gradient: linear-gradient(90deg, #059669, #34d399); }
.kpi-card-premium.orange { --gradient: linear-gradient(90deg, #f97316, #fb923c); }
.kpi-card-premium.amber  { --gradient: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kpi-card-premium.cyan   { --gradient: linear-gradient(90deg, #06b6d4, #22d3ee); }
.kpi-card-premium.indigo { --gradient: linear-gradient(90deg, #6366f1, #818cf8); }
.kpi-card-premium.red    { --gradient: linear-gradient(90deg, #ef4444, #f87171); }

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

.kpi-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-family: 'Prompt', 'Sarabun', sans-serif;
}

.kpi-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 0.25rem;
}

/* ════════════════════════════════════════════
   STATUS PILLS
   ════════════════════════════════════════════ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-pill.new       { background:rgba(59,130,246,0.15);  color:#93c5fd; border:1px solid rgba(59,130,246,0.28); }
.status-pill.received  { background:rgba(249,115,22,0.15);  color:#fdba74; border:1px solid rgba(249,115,22,0.28); }
.status-pill.transit   { background:rgba(6,182,212,0.15);   color:#67e8f9; border:1px solid rgba(6,182,212,0.28);  }
.status-pill.crossing  { background:rgba(168,85,247,0.15);  color:#d8b4fe; border:1px solid rgba(168,85,247,0.28);}
.status-pill.warehouse { background:rgba(6,182,212,0.12);   color:#22d3ee; border:1px solid rgba(6,182,212,0.22);  }
.status-pill.delivery  { background:rgba(239,68,68,0.12);   color:#fca5a5; border:1px solid rgba(239,68,68,0.25);  }
.status-pill.completed { background:rgba(16,185,129,0.12);  color:#6ee7b7; border:1px solid rgba(16,185,129,0.25);}
.status-pill.customs   { background:rgba(245,158,11,0.15);  color:#fcd34d; border:1px solid rgba(245,158,11,0.28);}
.status-pill.failed    { background:rgba(239,68,68,0.12);   color:#fca5a5; border:1px solid rgba(239,68,68,0.25);  }
.status-pill.closed    { background:rgba(100,116,139,0.12); color:#94a3b8; border:1px solid rgba(100,116,139,0.2);}
.status-pill.default   { background:rgba(255,255,255,0.06); color:rgba(255,255,255,0.5); border:1px solid rgba(255,255,255,0.10); }

/* ════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════ */
.table-premium {
  width: 100%;
  border-collapse: collapse;
}

.table-premium th {
  padding: 0.875rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}

.table-premium td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.table-premium tbody tr {
  transition: background 0.15s ease;
}

.table-premium tbody tr:hover td {
  background: rgba(255,255,255,0.03);
}

.table-glass {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.375rem;
}

.table-glass th,
.table-glass td {
  background: var(--bg-panel);
  padding: 0.75rem 1rem;
}

.table-glass th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════ */
.btn-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  width: 100%;
  border: none;
  cursor: pointer;
}

.btn-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(6,182,212,0.35);
  filter: brightness(1.08);
}

.btn-danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.28);
  color: #fca5a5;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  width: 100%;
  cursor: pointer;
}

.btn-danger-action:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.45);
}

/* ════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════ */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.12);
  background: rgba(255,255,255,0.07);
}

.form-input::placeholder { color: var(--text-muted); }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

/* ════════════════════════════════════════════
   AUDIT TIMELINE
   ════════════════════════════════════════════ */
.audit-timeline {
  position: relative;
  padding-left: 1.75rem;
}

.timeline-item {
  position: relative;
  padding-bottom: 1.25rem;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: 0.3rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color, #06b6d4);
  box-shadow: 0 0 8px var(--dot-color, rgba(6,182,212,0.5));
  z-index: 1;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.25rem;
  top: 0.85rem;
  width: 2px;
  bottom: 0;
  background: rgba(255,255,255,0.06);
}

.timeline-item:last-child::before { display: none; }

.timeline-item.latest .timeline-dot {
  width: 12px;
  height: 12px;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 5px var(--dot-color, #06b6d4); }
  50%      { box-shadow: 0 0 14px var(--dot-color, #06b6d4); }
}

/* ════════════════════════════════════════════
   CAPACITY BAR
   ════════════════════════════════════════════ */
.capacity-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.capacity-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.capacity-bar-fill.low    { background: linear-gradient(90deg,#10b981,#34d399); }
.capacity-bar-fill.medium { background: linear-gradient(90deg,#f59e0b,#fb923c); }
.capacity-bar-fill.high   { background: linear-gradient(90deg,#ef4444,#f87171); }

/* ════════════════════════════════════════════
   SCANNER
   ════════════════════════════════════════════ */
.scan-input-large {
  font-size: 1.375rem;
  padding: 1.125rem 1.5rem;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(6,182,212,0.25);
  border-radius: var(--radius-md);
  color: white;
  width: 100%;
  letter-spacing: 0.06em;
  font-family: 'SF Mono', 'Consolas', monospace;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.scan-input-large:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6,182,212,0.12);
  outline: none;
}

.scan-input-large::placeholder { color: var(--text-muted); }

.scan-result-card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  animation: slideUp 0.25s ease;
}

.scan-result-card.success {
  border: 1.5px solid rgba(16,185,129,0.45);
  background: rgba(16,185,129,0.07);
}

.scan-result-card.error {
  border: 1.5px solid rgba(239,68,68,0.45);
  background: rgba(239,68,68,0.07);
}

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

/* ════════════════════════════════════════════
   PRICE PREVIEW / ALERTS
   ════════════════════════════════════════════ */
.price-preview-card {
  background: rgba(6,182,212,0.05);
  border: 1px solid rgba(6,182,212,0.20);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.price-preview-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: #22d3ee;
  letter-spacing: -0.02em;
  font-family: 'Prompt', sans-serif;
}

.price-preview-label {
  font-size: 0.725rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.alert-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-strip.warning {
  background: rgba(245,158,11,0.09);
  border: 1px solid rgba(245,158,11,0.22);
  color: #fcd34d;
}

.alert-strip.danger {
  background: rgba(239,68,68,0.09);
  border: 1px solid rgba(239,68,68,0.22);
  color: #fca5a5;
}

/* ════════════════════════════════════════════
   TAB BAR
   ════════════════════════════════════════════ */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  font-family: inherit;
}

.tab-btn.active {
  background: rgba(6,182,212,0.12);
  color: #22d3ee;
  border-color: rgba(6,182,212,0.20);
  font-weight: 600;
}

/* ════════════════════════════════════════════
   ACTION GROUPS
   ════════════════════════════════════════════ */
.action-group { display: flex; flex-direction: column; gap: 0.5rem; }
.action-group .action-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0.375rem 0;
}

/* ════════════════════════════════════════════
   MOBILE SIDEBAR TOGGLE
   ════════════════════════════════════════════ */
.sidebar-toggle { display: none; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }

  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 45;
    display: none;
    backdrop-filter: blur(4px);
  }
  .sidebar-overlay.open { display: block; }
}

/* ════════════════════════════════════════════
   MISC UTILITIES
   ════════════════════════════════════════════ */

/* Scrollbar styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 2px;
}

/* 2️⃣ ฟอนต์ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;600&family=Noto+Sans+Lao:wght@300;400;600&family=Sarabun:wght@400;600&display=swap');

@font-face {
  font-family: 'Noto Sans Lao Fallback';
  src: local('Noto Sans Lao');
  unicode-range: U+0E80-0EFF;
}

body {
  font-family: 'Noto Sans Lao Fallback', 'Sarabun', sans-serif;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: #e0e0e0;
}

/* 3️⃣ Sidebar */
.sidebar {
  width: 260px;
  background: var(--primary);
  height: 100vh;
  padding: 2rem 1rem;
  position: fixed;
  overflow-y: auto;
}
.sidebar a {
  color: #fff;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: .5rem;
  transition: background .2s;
}
.sidebar a:hover { background: var(--secondary); }

/* 4️⃣ Glassmorphism panels */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 30px rgba(0,0,0,.2);
}

/* 5️⃣ KPI cards */
.kpi-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.kpi-card {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border-radius: .75rem;
  padding: 1rem;
  text-align: center;
  transition: transform .2s;
}
.kpi-card:hover { transform: translateY(-4px); }

/* 6️⃣ Chart canvas */
#ordersChart {
  width: 100% !important;
  height: 300px;
  border-radius: .75rem;
}

/* 7️⃣ ตารางออเดอร์ล่าสุด */
.table-glass {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
}
.table-glass th,
.table-glass td {
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  padding: .75rem 1rem;
  border-radius: .5rem;
}
.table-glass th { color: var(--accent); }

/* ── Audit Timeline ───────────────────────────────── */
.audit-timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -1.75rem;
  top: 0.3rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot-color, #06b6d4);
  box-shadow: 0 0 8px var(--dot-color, rgba(6,182,212,0.5));
  z-index: 1;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.375rem;
  top: 0.9rem;
  width: 2px;
  bottom: 0;
  background: rgba(255,255,255,0.08);
}
.timeline-item:last-child::before { display: none; }
.timeline-item.latest .timeline-dot {
  width: 14px;
  height: 14px;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--dot-color, #06b6d4); }
  50%       { box-shadow: 0 0 16px var(--dot-color, #06b6d4); }
}

/* ── Capacity Bar ─────────────────────────────────── */
.capacity-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.capacity-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}
.capacity-bar-fill.low    { background: linear-gradient(90deg, #10b981, #34d399); }
.capacity-bar-fill.medium { background: linear-gradient(90deg, #f59e0b, #fb923c); }
.capacity-bar-fill.high   { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ── Scanner Input ────────────────────────────────── */
.scan-input-large {
  font-size: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(6,182,212,0.3);
  border-radius: 1rem;
  color: white;
  width: 100%;
  letter-spacing: 0.06em;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.scan-input-large:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6,182,212,0.15);
  outline: none;
}
.scan-input-large::placeholder { color: rgba(255,255,255,0.25); }

/* ── Scan Result Card ─────────────────────────────── */
.scan-result-card {
  border-radius: 1.25rem;
  padding: 1.5rem;
  animation: slideUp 0.3s ease;
}
.scan-result-card.success {
  border: 2px solid rgba(16,185,129,0.5);
  background: rgba(16,185,129,0.08);
}
.scan-result-card.error {
  border: 2px solid rgba(239,68,68,0.5);
  background: rgba(239,68,68,0.08);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Price Preview Card ───────────────────────────── */
.price-preview-card {
  background: rgba(6,182,212,0.06);
  border: 1px solid rgba(6,182,212,0.25);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.price-preview-value {
  font-size: 2rem;
  font-weight: 800;
  color: #22d3ee;
  letter-spacing: -0.02em;
}
.price-preview-label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Tab Bar ──────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.04);
  border-radius: 0.75rem;
  padding: 0.25rem;
}
.tab-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  transition: all 0.2s;
  text-align: center;
  cursor: pointer;
}
.tab-btn.active {
  background: rgba(6,182,212,0.15);
  color: #22d3ee;
  border: 1px solid rgba(6,182,212,0.2);
}

/* ── Alert Strip ──────────────────────────────────── */
.alert-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.alert-strip.warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  color: #fbbf24;
}
.alert-strip.danger {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #f87171;
}

/* ── Action Button Group ──────────────────────────── */
.action-group { display: flex; flex-direction: column; gap: 0.5rem; }
.action-group .action-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.5rem 0;
}
.btn-primary-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: white; font-weight: 600; font-size: 0.9rem;
  border-radius: 0.75rem;
  transition: all 0.25s;
  width: 100%;
}
.btn-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(6,182,212,0.35);
}
.btn-danger-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171; font-weight: 600; font-size: 0.9rem;
  border-radius: 0.75rem;
  transition: all 0.25s;
  width: 100%;
}
.btn-danger-action:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.5);
}


/* ════════════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE — พนักงานสแกนมือถือ
   ════════════════════════════════════════════════════════════════ */

/* ── Sidebar Overlay ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

/* ── Desktop: sidebar always visible ─────────────────── */
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0) !important; }
  .sidebar-toggle { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 260px; }
}

/* ── Tablet (768–1023px) ─────────────────────────────── */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .topbar {
    padding: 0.75rem 1rem;
  }
}

/* ── Mobile (< 768px) — Touch-optimized ──────────────── */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    width: 85vw;
    max-width: 320px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }

  /* Larger touch targets */
  .sidebar-link {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    gap: 0.875rem;
  }
  .sidebar-link i {
    font-size: 1rem;
    width: 22px;
  }

  /* Topbar compact */
  .topbar {
    padding: 0.625rem 0.75rem;
  }

  /* Main content breathing room */
  main.p-4 { padding: 0.75rem !important; }

  /* Glass panels tighter */
  .glass-panel-dark {
    border-radius: var(--radius-md);
  }

  /* KPI cards — stack to 2 col on narrow */
  .kpi-card-premium {
    padding: 1rem 0.875rem 0.75rem;
  }
  .kpi-value {
    font-size: 1.375rem !important;
  }

  /* Tables horizontal scroll wrapper */
  table {
    font-size: 0.8rem;
  }

  /* Scanner input bigger for thumb */
  .scanner-input,
  input[type="text"][x-ref="scanInput"] {
    font-size: 1.125rem !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  /* Bottom safe area for notch phones */
  body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ── Small phones (< 400px) ──────────────────────────── */
@media (max-width: 399px) {
  .sidebar {
    width: 100vw;
    max-width: 100vw;
  }
  .topbar h1 {
    font-size: 0.9rem;
  }
  main.p-4 { padding: 0.5rem !important; }

  .kpi-value {
    font-size: 1.125rem !important;
  }
}


/* ════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV — Quick access bar for scanner staff
   ════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 44;
  background: rgba(8,11,20,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 0.375rem 0.5rem;
  padding-bottom: calc(0.375rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 767px) {
  .mobile-bottom-nav { display: flex; }
  /* Add space at bottom for the nav */
  .main-content { padding-bottom: 4.5rem; }
}

.mobile-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.5rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
  text-align: center;
  line-height: 1.1;
}
.mobile-bottom-nav a i {
  font-size: 1.125rem;
  margin-bottom: 0.125rem;
}
.mobile-bottom-nav a:active {
  transform: scale(0.92);
}
.mobile-bottom-nav a.active,
.mobile-bottom-nav a:hover {
  color: var(--brand-cyan);
  background: rgba(6,182,212,0.08);
}


/* ════════════════════════════════════════════════════════
   TOUCH UTILITIES — Improve mobile tap/scroll UX
   ════════════════════════════════════════════════════════ */

/* Prevent accidental zoom on double-tap (iOS) */
button, a, input, select, textarea {
  touch-action: manipulation;
}

/* Smooth momentum scrolling on iOS */
.overflow-y-auto,
.overflow-x-auto,
.sidebar-nav {
  -webkit-overflow-scrolling: touch;
}

/* Remove tap highlight on mobile */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Focus ring for keyboard but not touch */
:focus-visible {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}


/* ════════════════════════════════════════════════════════
   SCANNER-SPECIFIC MOBILE — optimized for barcode workflow
   ════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Scanner input full width, bigger font */
  .scanner-scan-input {
    font-size: 1.25rem !important;
    padding: 1.125rem 3.5rem 1.125rem 3.25rem !important;
    border-radius: 1rem !important;
  }

  /* Scanner action buttons — full width stacked */
  .scanner-actions {
    flex-direction: column;
  }
  .scanner-actions > * {
    width: 100%;
  }

  /* Condition selector buttons bigger */
  .condition-btn {
    min-height: 3.5rem;
  }

  /* Weight input large & centered */
  .weight-input {
    font-size: 2rem !important;
    text-align: center;
    padding: 0.875rem !important;
  }

  /* Screening flag buttons — wrap nicely */
  .flag-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

/* ════════════════════════════════════════════════════════
   PRINT-HIDE — Hide nav elements when printing stickers
   ════════════════════════════════════════════════════════ */
@media print {
  .sidebar,
  .sidebar-overlay,
  .topbar,
  .mobile-bottom-nav { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  body { background: white !important; }
}