*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Labotte Brand Palette ── */
  --cream:    #f5f0e8;
  --cream2:   #ede7d9;
  --sand:     #ddd6c8;
  --brown:    #3d2e1e;
  --brown2:   #5c4535;
  --warm-gray:#8a7d6a;

  --bg:       #f5f0e8;
  --bg2:      #ede7d9;
  --card:     #ffffff;
  --surface:  rgba(255, 255, 255, 0.97);
  --surface2: rgba(255, 252, 248, 0.97);
  --surface3: rgba(250, 246, 240, 0.95);
  --border:   rgba(61, 46, 30, 0.16);
  --border2:  rgba(61, 46, 30, 0.26);
  --border-bright: rgba(184, 134, 11, 0.55);

  --text:     #3d2e1e;
  --text1:    #3d2e1e;
  --text2:    #5c4535;
  --text3:    #8a7d6a;
  --white:    #3d2e1e;

  --accent:   #b8860b;
  --accent2:  #9a6f08;
  --gold:     #b8860b;
  --gold2:    #c8a96e;
  --green:    #1a7a4a;
  --red:      #c0392b;

  --ta:       #c06010;
  --tb:       #2563a0;

  --blue-50:  #faf7f2;
  --blue-100: #f0e8d8;
  --blue-200: #ddd0b8;
  --blue-400: #c8a96e;
  --blue-500: #b8860b;
  --blue-600: #9a6f08;
  --blue-700: #7a5806;
  --blue-900: #3d2e1e;

  --radius:   14px;
  --radius-sm: 9px;
  --font:     'Syne', sans-serif;
  --serif:    'Cormorant Garamond', Georgia, serif;
  --mono:     'DM Mono', monospace;

  --shadow:   0 2px 8px rgba(61,46,30,0.10), 0 1px 3px rgba(61,46,30,0.07);
  --shadow-blue: 0 0 24px rgba(200,169,110,0.15);
  --blur: blur(20px);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  overflow-x: hidden;
}

*, *::before, *::after {
  font-family: inherit;
}

/* ═══════════════════════════════
   AMBIENT BACKGROUND
═══════════════════════════════ */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
}

.orb-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, #e8d5b0, transparent 70%);
  top: -200px; left: -150px;
  animation: orbFloat1 20s ease-in-out infinite;
}

.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #d4b896, transparent 70%);
  bottom: -100px; right: -100px;
  animation: orbFloat2 25s ease-in-out infinite;
}

.orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #c8a96e, transparent 70%);
  top: 40%; right: 20%;
  opacity: 0.08;
  animation: orbFloat3 18s ease-in-out infinite;
}

.noise-overlay {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.025;
  mix-blend-mode: overlay;
}

@keyframes orbFloat1 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
}
@keyframes orbFloat2 {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(-40px, -60px); }
}
@keyframes orbFloat3 {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(30px, -30px); }
}

/* ═══════════════════════════════
   HEADER
═══════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 62px;
  background: rgba(245, 240, 232, 0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3d2e1e, #5c4535);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: 0 2px 12px rgba(61,46,30,0.25);
  overflow: hidden;
  padding: 4px;
}

.brand-mark-script {
  font-family: 'Dancing Script', cursive;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.brand-mark-serif {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  line-height: 1;
  letter-spacing: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--brown);
  line-height: 1;
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text3);
  font-weight: 500;
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  color: var(--text3);
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--text2);
  background: rgba(61,46,30,0.06);
  border-color: var(--border2);
}

.nav-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brown), var(--brown2));
  border-color: rgba(200,169,110,0.4);
  box-shadow: 0 2px 12px rgba(61,46,30,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
}

.nav-icon { font-size: 14px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 160px;
  justify-content: flex-end;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--green);
  padding: 4px 8px;
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 20px;
  background: rgba(16,185,129,0.08);
}

.live-dot {
  width: 5px;
  height: 5px;
  background: var(--green);
  border-radius: 50%;
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

.header-clock { text-align: right; }

.clock {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--brown2);
  letter-spacing: 1px;
  line-height: 1;
}

.clock-date {
  font-size: 14px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text3);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════
   PAGE & LAYOUT
═══════════════════════════════ */
.page { display: none; position: relative; z-index: 1; }
.page.active { display: block; }

.page-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ═══════════════════════════════
   PANELS
═══════════════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 2px 12px rgba(61,46,30,0.09), 0 1px 3px rgba(61,46,30,0.06);
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  font-size: 13px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text2);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: rgba(61,46,30,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-badge {
  font-size: 14px;
  font-weight: 500;
  color: var(--text3);
  text-transform: none;
  letter-spacing: 0;
}

.panel-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-desc {
  font-size: 14px;
  color: var(--text3);
}

/* ═══════════════════════════════
   SCAN PAGE
═══════════════════════════════ */
.scan-wrap {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.scan-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 78px;
}

.type-switcher {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: var(--blur);
  box-shadow: 0 2px 8px rgba(61,46,30,0.08);
}

.type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 10px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font);
}

.type-btn:hover { color: var(--text2); background: rgba(61,46,30,0.05); }
.type-btn.active {
  background: linear-gradient(135deg, rgba(184,134,11,0.18), rgba(200,169,110,0.10));
  color: var(--brown);
}

.type-icon { font-size: 22px; }
.type-label { font-size: 14px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.type-divider { width: 1px; background: var(--border); }

.scan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: var(--blur);
  box-shadow: 0 2px 8px rgba(61,46,30,0.08);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.scan-card:focus-within {
  border-color: var(--border-bright);
  box-shadow: 0 0 0 1px rgba(184,134,11,0.2), var(--shadow-blue);
}

.scan-card-header {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(61,46,30,0.04);
}

.scan-step-badge {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--brown2);
  background: rgba(184,134,11,0.12);
  border: 1px solid rgba(184,134,11,0.25);
  border-radius: 4px;
  padding: 1px 6px;
}

.scan-input {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--brown);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 400;
  padding: 16px;
  outline: none;
  letter-spacing: 1px;
  text-align: center;
}

.scan-input::placeholder { color: var(--text3); font-size: 14px; letter-spacing: 0; }

.scan-arrow {
  text-align: center;
  color: var(--text3);
  font-size: 20px;
  line-height: 1;
  margin: -4px 0;
}

.scan-feedback {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: var(--blur);
  animation: feedSlide 0.2s ease;
}
@keyframes feedSlide {
  from { opacity:0; transform: translateY(-6px); }
  to   { opacity:1; transform: translateY(0); }
}
.scan-feedback.success { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.scan-feedback.error   { background: rgba(239,68,68,0.1);  color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.scan-feedback.warning { background: rgba(212,168,67,0.12); color: var(--gold2); border: 1px solid rgba(212,168,67,0.35); }
.scan-feedback.hidden  { display: none; }

.mini-kpi-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  overflow: hidden;
  backdrop-filter: var(--blur);
}

.mini-kpi {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  gap: 3px;
}

.mini-kpi-val {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.mini-kpi-val.accent { color: var(--gold2); }
.mini-kpi-label { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text3); }
.mini-kpi-divider { width: 1px; height: 36px; background: var(--border); }

.emp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  margin: 1px;
  border-radius: 12px;
  overflow: hidden;
}

.emp-card {
  background: var(--surface2);
  padding: 12px 8px;
  text-align: center;
  transition: all 0.3s;
  position: relative;
}

.emp-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0.6;
}
.emp-card.ta::before { background: linear-gradient(90deg, var(--ta), transparent); }
.emp-card.tb::before { background: linear-gradient(90deg, var(--tb), transparent); }

.emp-card.flash {
  background: rgba(184,134,11,0.15) !important;
  transform: scale(0.95);
}

.emp-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.emp-count {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.emp-bonus {
  font-size: 12px;
  color: var(--gold);
  font-family: var(--mono);
  font-weight: 600;
  margin-top: 3px;
}

/* ═══════════════════════════════
   DASHBOARD
═══════════════════════════════ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--blur);
  box-shadow: 0 2px 12px rgba(61,46,30,0.09), 0 1px 3px rgba(61,46,30,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(61,46,30,0.13), 0 2px 6px rgba(61,46,30,0.08);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.kpi-primary::before { background: linear-gradient(90deg, var(--brown), var(--brown2)); }
.kpi-gold::before { background: linear-gradient(90deg, var(--gold), var(--gold2)); }
.kpi-split::before { background: linear-gradient(90deg, var(--ta) 50%, var(--tb) 50%); }

.kpi-glow {
  position: absolute;
  bottom: 0; right: 0;
  width: 120px; height: 120px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.12;
}
.kpi-primary .kpi-glow { background: var(--brown2); }
.kpi-gold .kpi-glow { background: var(--gold2); }

.kpi-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 52px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.kpi-gold .kpi-value { color: var(--gold2); }

.kpi-unit {
  font-size: 14px;
  color: var(--text3);
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.kpi-vs-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 6px 0;
}

.kpi-vs-a { font-family: var(--mono); font-size: 44px; font-weight: 500; color: var(--ta); }
.kpi-vs-b { font-family: var(--mono); font-size: 44px; font-weight: 500; color: var(--tb); }
.kpi-vs-sep { font-size: 14px; color: var(--text3); letter-spacing: 1px; }

.dash-row {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}

.ranking-panel { min-width: 0; }

.teams-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rank-row {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.rank-row:last-child { border-bottom: none; }
.rank-row:hover { background: rgba(61,46,30,0.04); }
.rank-row.rank-1 { background: rgba(212,168,67,0.05); }

.rank-medal { font-size: 18px; width: 28px; text-align: center; }
.rank-row.rank-1 .rank-medal { font-size: 22px; }

.rank-name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  width: 56px;
}
.rank-name.ta { color: var(--ta); }
.rank-name.tb { color: var(--tb); }
.rank-row.rank-1 .rank-name { font-size: 17px; }

.rank-bar-wrap {
  flex: 1;
  background: rgba(61,46,30,0.06);
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
}

.rank-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}
.rank-bar.ta { background: linear-gradient(90deg, var(--ta), #e8a020); }
.rank-bar.tb { background: linear-gradient(90deg, var(--tb), #60a5fa); }

.rank-val {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  width: 36px;
  text-align: right;
  color: var(--text);
}
.rank-row.rank-1 .rank-val { font-size: 22px; color: var(--gold2); }

.rank-bonus {
  font-size: 14px;
  color: var(--gold);
  width: 52px;
  text-align: right;
  font-family: var(--mono);
  font-weight: 600;
}

.team-a-hdr { color: var(--ta) !important; }
.team-b-hdr { color: var(--tb) !important; }

/* ═══════════════════════════════
   TABLES
═══════════════════════════════ */
.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
}

.data-table th {
  padding: 7px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: rgba(61,46,30,0.04);
  white-space: nowrap;
}

.data-table th:not(:first-child):not(:nth-child(2)) { text-align: center; }

.data-table td {
  padding: 8px 8px;
  border-bottom: 1px solid rgba(30,60,100,0.3);
  font-size: 12px;
  color: var(--text2);
  font-family: var(--mono);
  font-weight: 500;
}
.data-table td:not(:first-child):not(:nth-child(2)) { text-align: center; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(61,46,30,0.04); }
.data-table .total-row td { background: rgba(184,134,11,0.06); font-weight: 700; border-top: 1px solid var(--border); }

.sku-code { font-family: var(--mono); font-size: 14px; color: var(--accent2); }
.emp-id { font-family: var(--mono); font-size: 14px; }
.emp-id.ta { color: var(--ta); }
.emp-id.tb { color: var(--tb); }
.bonus-cell { color: var(--gold); font-weight: 500; font-family: var(--mono); }

/* ═══════════════════════════════
   FILTER BAR
═══════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-input:focus, .filter-select:focus { border-color: var(--accent); }
.filter-select option { background: #f5f0e8; color: #3d2e1e; }

.period-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  display: inline-block;
  letter-spacing: 0.5px;
}
.period-morning   { background: rgba(192,96,16,0.10);  color: var(--ta); }
.period-afternoon { background: rgba(37,99,160,0.10);  color: var(--tb); }
.period-ot        { background: rgba(192,57,43,0.10);  color: var(--red); }

.tab-pills {
  display: flex;
  gap: 4px;
}

.pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text3);
  transition: all 0.2s;
}

.pill:hover { color: var(--text2); }
.pill.active {
  background: linear-gradient(135deg, var(--brown), var(--brown2));
  border-color: rgba(200,169,110,0.4);
  color: #fff;
}

/* ═══════════════════════════════
   ADMIN
═══════════════════════════════ */
.admin-wrap { max-width: 900px !important; }

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bonus-rule {
  font-size: 14px;
  color: var(--text2);
  padding: 8px 12px;
  background: rgba(61,46,30,0.05);
  border-radius: 7px;
  border-left: 2px solid var(--gold);
}
.bonus-rule strong { color: var(--gold2); }

.emp-list-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.team-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.team-label-a { color: var(--ta); }
.team-label-b { color: var(--tb); }

.emp-tag {
  display: inline-flex;
  background: rgba(61,46,30,0.05);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text2);
  margin: 2px;
}

/* ═══════════════════════════════
   BUTTONS
═══════════════════════════════ */
.btn-toggle {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.3);
  color: var(--green);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-toggle:hover { background: rgba(16,185,129,0.15); }
.btn-toggle.active-test {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
}

.btn-danger {
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--red);
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.btn-danger:hover { background: rgba(239,68,68,0.15); }

.btn-outline {
  background: rgba(61,46,30,0.06);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: 7px;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent2); }

/* ═══════════════════════════════
   TOAST
═══════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brown);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
  z-index: 999;
  max-width: 300px;
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(16,185,129,0.4); color: var(--green); }
.toast.error { border-color: rgba(239,68,68,0.4); color: var(--red); }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   RECEIVING MODULE STYLES (ใหม่)
═══════════════════════════════════════════ */

/* PO List */
.btn-create-po {
  background: linear-gradient(135deg, rgba(184,134,11,0.15), rgba(200,169,110,0.08)) !important;
  border-color: rgba(184,134,11,0.4) !important;
  color: var(--brown2) !important;
  padding: 7px 14px !important;
  font-size: 14px !important;
}
.btn-create-po:hover {
  background: linear-gradient(135deg, rgba(184,134,11,0.28), rgba(200,169,110,0.18)) !important;
}

/* PO Status Badges */
.po-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font);
}
.status-pending  { background: rgba(100,116,139,0.12); color: #94a3b8; border: 1px solid rgba(100,116,139,0.2); }
.status-partial  { background: rgba(212,168,67,0.1);   color: var(--gold2); border: 1px solid rgba(212,168,67,0.3); }
.status-complete { background: rgba(16,185,129,0.1);   color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.status-over     { background: rgba(239,68,68,0.1);    color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }

/* Diff Badges */
.diff-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--mono);
  margin-left: 6px;
}
.diff-over  { background: rgba(212,168,67,0.12);  color: var(--gold2); border: 1px solid rgba(212,168,67,0.25); }
.diff-under { background: rgba(239,68,68,0.12);   color: var(--red);   border: 1px solid rgba(239,68,68,0.25); }

/* KPI diff colors */
.diff-over-kpi  { color: var(--gold2) !important; }
.diff-under-kpi { color: var(--red) !important; }
.color-green { color: var(--green) !important; }
.color-over  { color: var(--gold2) !important; }
.color-under { color: var(--red) !important; }

/* PO row actions */
.po-actions {
  display: flex;
  gap: 6px;
  padding: 6px 12px 10px;
  background: rgba(61,46,30,0.02);
  border-bottom: 1px solid var(--border);
}

/* Small buttons */
.btn-sm {
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border2);
  background: rgba(61,46,30,0.05);
  color: var(--text2);
}
.btn-sm:hover { background: rgba(61,46,30,0.08); color: var(--text); }
.btn-receive { border-color: rgba(184,134,11,0.35); color: var(--brown2); background: rgba(184,134,11,0.08); }
.btn-receive:hover { background: rgba(184,134,11,0.16); }
.btn-detail { border-color: rgba(212,168,67,0.25); color: var(--gold); background: rgba(212,168,67,0.06); }
.btn-detail:hover { background: rgba(212,168,67,0.14); }
.btn-del { border-color: rgba(239,68,68,0.2); color: var(--red); background: rgba(239,68,68,0.05); }
.btn-del:hover { background: rgba(239,68,68,0.14); }

/* ── Receiving active scan layout ── */
.recv-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.recv-left {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recv-info-panel { }

.recv-step-label {
  font-size: 14px;
  color: var(--text3);
  letter-spacing: 0.5px;
  font-family: var(--mono);
}

/* Progress bar */
.recv-progress-wrap {
  margin-top: 4px;
}

.recv-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text3);
  font-family: var(--mono);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.recv-progress-track {
  height: 6px;
  background: rgba(61,46,30,0.07);
  border-radius: 10px;
  overflow: hidden;
}

.recv-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brown), var(--gold2));
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 8px rgba(184,134,11,0.3);
}

/* Receiving KPIs */
.recv-kpi-row {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 4px;
}

.recv-kpi {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
}

.recv-kpi-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 4px;
}

.recv-kpi-val {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.recv-kpi-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* Finish button */
.btn-finish-recv {
  flex: 2;
  background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(16,185,129,0.08));
  border: 1px solid rgba(16,185,129,0.35);
  color: var(--green);
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.btn-finish-recv:hover {
  background: linear-gradient(135deg, rgba(16,185,129,0.3), rgba(16,185,129,0.14));
  box-shadow: 0 0 16px rgba(16,185,129,0.2);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,8,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: #ffffff;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(61,46,30,0.2), 0 0 0 1px rgba(184,134,11,0.1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  width: 560px;
}

.modal-large { width: min(860px, 95vw); }

.modal-header {
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(61,46,30,0.04);
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 5px;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: rgba(61,46,30,0.07); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
  background: rgba(61,46,30,0.02);
}

.modal-fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
}

.modal-section-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* PO Item Row */
.po-item-row {
  background: rgba(61,46,30,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.po-item-num {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent2);
  text-transform: uppercase;
}

.po-item-fields {
  display: flex;
  gap: 8px;
}

.po-sizes-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.po-size-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.po-size-cell label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 0.5px;
}

.po-size-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 5px 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  letter-spacing: 0;
}
.po-size-input:focus { border-color: var(--accent); }
.po-size-input::-webkit-inner-spin-button { display: none; }

/* Save PO button */
.btn-save-po {
  background: linear-gradient(135deg, var(--brown), var(--brown2));
  border: 1px solid rgba(200,169,110,0.4);
  color: #fff;
  border-radius: 8px;
  padding: 9px 20px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 12px rgba(61,46,30,0.2);
}
.btn-save-po:hover {
  background: linear-gradient(135deg, var(--brown2), #7a5a3a);
  box-shadow: 0 4px 18px rgba(61,46,30,0.3);
}

/* PO Detail */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-po-num {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--accent2);
}

.detail-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.detail-kpi {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}

.detail-kpi-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}

.detail-kpi-val {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

/* Import mode selector */
.import-mode-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.import-mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.import-mode-opt:has(input:checked) {
  border-color: var(--accent);
  background: rgba(184,134,11,0.06);
}

.import-mode-opt input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.import-mode-opt strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}

.import-mode-desc {
  font-size: 14px;
  color: var(--text3);
}

/* Import QC button */
.btn-import-qc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(212,168,67,0.08);
  border: 1px solid rgba(212,168,67,0.3);
  color: var(--gold2);
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.btn-import-qc:hover {
  background: rgba(212,168,67,0.16);
  box-shadow: 0 0 16px rgba(212,168,67,0.15);
}

/* Scan history section in PO Detail */
.scan-hist-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.scan-hist-header {
  padding: 0 0 10px;
  font-size: 14px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.8px;
  color: var(--text2);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scan-hist-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
}

.hist-warn {
  background: rgba(212,168,67,0.12);
  color: var(--gold2);
  border: 1px solid rgba(212,168,67,0.3);
}

.hist-over {
  background: rgba(239,68,68,0.1);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.25);
}

.scan-hist-anomaly-box {
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--red);
  margin-bottom: 10px;
}

.scan-hist-anomaly-box strong { color: var(--red); }

.scan-hist-ok-box {
  background: rgba(16,185,129,0.06);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--green);
  margin-bottom: 10px;
}

/* ═══════════════════════════════════════════
   SUMMARY MODULE STYLES (ใหม่)
═══════════════════════════════════════════ */

.summary-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* KPI Strip */
.summary-kpi-strip {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(184,134,11,0.04);
  gap: 0;
}

.sum-kpi {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.sum-kpi-val {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--brown);
  line-height: 1;
}

.sum-kpi-lbl {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
}

.sum-kpi-div {
  width: 1px;
  height: 36px;
  background: var(--border);
}

/* Day header rows */
.day-header-row td {
  background: rgba(184,134,11,0.06) !important;
  border-top: 1px solid var(--border) !important;
  border-bottom: none !important;
}

.day-label {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--brown);
  letter-spacing: 0.5px;
}

.day-total-badge {
  margin-left: 10px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text3);
  background: rgba(184,134,11,0.1);
  border: 1px solid rgba(184,134,11,0.2);
  border-radius: 10px;
  padding: 1px 8px;
}

/* Day subtotal row */
.day-subtotal-row td {
  background: rgba(61,46,30,0.02) !important;
  border-top: 1px solid rgba(184,134,11,0.15) !important;
}

/* ═══════════════════════════════
   RESPONSIVE
═══════════════════════════════ */
@media (max-width: 1100px) {
  .scan-wrap { grid-template-columns: 1fr; }
  .scan-left { position: static; }
  .dash-row { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .recv-layout { grid-template-columns: 1fr; }
  .recv-left { position: static; }
}

@media (max-width: 700px) {
  .header { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 7px 12px; font-size: 14px; flex-shrink: 0; }
  .nav-icon { font-size: 14px; }
  .brand-sub { display: none; }
  .header-right { display: none; }
  .page-wrap { padding: 12px 14px; }
  .kpi-row { grid-template-columns: 1fr; }
  .emp-grid { grid-template-columns: repeat(4, 1fr); }
  .live-badge { display: none; }
  .po-sizes-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-fields-row { grid-template-columns: 1fr; }
  .detail-kpi-row { grid-template-columns: 1fr; }
}

/* ── Edit Scan ── */
.scan-row-editable {
  cursor: pointer;
  transition: background 0.15s;
}
.scan-row-editable:hover {
  background: rgba(61,46,30,0.06);
}
.scan-row-editable:hover .edit-scan-btn {
  opacity: 1;
}
.edit-scan-btn {
  opacity: 0.25;
  font-size: 14px;
  transition: opacity 0.15s;
  pointer-events: none;
}
.edit-scan-info-row {
  background: rgba(61,46,30,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text2);
}
.edit-scan-admin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.edit-scan-lock-icon {
  font-size: 16px;
}
@keyframes inputShake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-6px); }
  40%,80%  { transform: translateX(6px); }
}
.input-shake {
  animation: inputShake 0.4s ease;
  border-color: var(--red) !important;
}

/* ═══════════════════════════════════════
   REAL-TIME COUNTER (Receiving)
═══════════════════════════════════════ */

/* Counter pulse animation */
@keyframes counterPulse {
  0%   { transform: scale(1); color: var(--text); }
  30%  { transform: scale(1.32); color: var(--brown2); text-shadow: 0 0 16px rgba(184,134,11,0.5); }
  100% { transform: scale(1); color: var(--text); }
}
.counter-pulse {
  animation: counterPulse 0.45s cubic-bezier(.4,0,.2,1);
  display: inline-block;
}

/* Last Scanned Strip */
.recv-last-scan {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(184,134,11,0.07);
  border: 1px solid rgba(184,134,11,0.2);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  transition: all 0.3s;
}
.recv-last-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}
.recv-last-item {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--brown2);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recv-last-count {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}
@keyframes lastScanFlash {
  0%   { background: rgba(184,134,11,0.2); border-color: rgba(200,169,110,0.6); }
  100% { background: rgba(184,134,11,0.07); border-color: rgba(184,134,11,0.2); }
}
.recv-last-scan-flash {
  animation: lastScanFlash 0.7s ease-out;
}

/* Comparison table row: last scanned */
@keyframes rowFlash {
  0%   { background: rgba(184,134,11,0.18); }
  100% { background: transparent; }
}
.recv-row-flash td {
  animation: rowFlash 1.2s ease-out forwards;
}

/* Comparison table row: complete */
.recv-row-complete td {
  background: rgba(16,185,129,0.04) !important;
}

/* Status badge per SKU group */
.recv-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.5;
}
.recv-status-badge.status-complete {
  background: rgba(16,185,129,0.12);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
}
.recv-status-badge.status-short {
  background: rgba(239,68,68,0.1);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.25);
}
.recv-status-badge.status-over {
  background: rgba(212,168,67,0.1);
  color: var(--gold2);
  border: 1px solid rgba(212,168,67,0.25);
}
.recv-status-badge.status-pending {
  background: rgba(61,46,30,0.06);
  color: var(--text3);
  border: 1px solid var(--border);
}

/* ═══════════════════════════════
   RECHECK PAGE
═══════════════════════════════ */
.recheck-wrap {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) {
  .recheck-wrap { grid-template-columns: 1fr; }
}
.recheck-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.recheck-title-icon { font-size: 32px; line-height: 1; }
.recheck-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: 0.5px; }
.recheck-subtitle { font-size: 14px; color: var(--text3); margin-top: 2px; }

.recheck-emp-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(184,134,11,0.08);
  border: 1px solid rgba(184,134,11,0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  animation: fadeSlideIn 0.2s ease;
}
.recheck-emp-badge {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--brown);
  letter-spacing: 2px;
}
.recheck-emp-label { font-size: 14px; color: var(--text3); }

.recheck-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.recheck-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 12px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  background: transparent;
}
.recheck-btn.pass {
  border-color: rgba(16,185,129,0.3);
  background: rgba(16,185,129,0.07);
  color: #10b981;
}
.recheck-btn.pass:hover { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.5); transform: translateY(-1px); }
.recheck-btn.pass:active { transform: scale(0.97); background: rgba(16,185,129,0.22); }
.recheck-btn.fail {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.07);
  color: #ef4444;
}
.recheck-btn.fail:hover { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.5); transform: translateY(-1px); }
.recheck-btn.fail:active { transform: scale(0.97); background: rgba(239,68,68,0.22); }
.recheck-btn-icon { font-size: 28px; line-height: 1; }
.recheck-btn-label { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }
.recheck-btn-sub { font-size: 14px; opacity: 0.6; }

.recheck-kpi-row {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 0;
  margin-top: 8px;
}
.recheck-kpi { flex: 1; text-align: center; }
.recheck-kpi-divider { width: 1px; height: 36px; background: var(--border); }
.recheck-kpi-val {
  display: block;
  font-size: 26px;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
  margin-bottom: 4px;
}
.recheck-kpi-val.green { color: var(--green); }
.recheck-kpi-val.red   { color: var(--red); }
.recheck-kpi-val.accent { color: var(--accent2); }
.recheck-kpi-label { font-size: 14px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

.recheck-log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  animation: fadeSlideIn 0.2s ease;
}
.recheck-log-item:last-child { border-bottom: none; }
.recheck-log-status { font-size: 16px; line-height: 1; flex-shrink: 0; }
.recheck-log-emp { font-family: var(--mono); font-weight: 600; color: var(--text); min-width: 50px; }
.recheck-log-result-pass { color: var(--green); font-weight: 600; }
.recheck-log-result-fail { color: var(--red); font-weight: 600; }
.recheck-log-time { margin-left: auto; color: var(--text3); font-size: 14px; font-family: var(--mono); }

.pass-rate-high { color: var(--green); font-weight: 600; }
.pass-rate-mid  { color: var(--gold2); font-weight: 600; }
.pass-rate-low  { color: var(--red); font-weight: 600; }

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

/* ─── Recheck Camera ─── */
.recheck-cam-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: rgba(184,134,11,0.1);
  border: 1px solid rgba(184,134,11,0.3);
  border-radius: var(--radius-sm);
  color: var(--brown2);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}
.recheck-cam-btn:hover {
  background: rgba(184,134,11,0.18);
  border-color: rgba(184,134,11,0.5);
}
.recheck-cam-btn.active {
  background: rgba(26,122,74,0.12);
  border-color: rgba(26,122,74,0.4);
  color: var(--green);
}

.recheck-cam-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 14px;
  aspect-ratio: 1 / 1;
}
.recheck-cam-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.recheck-cam-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.recheck-cam-frame {
  width: 55%;
  aspect-ratio: 1 / 1;
  border: 2.5px solid rgba(184,134,11,0.85);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  animation: camPulse 2s ease-in-out infinite;
}
@keyframes camPulse {
  0%,100% { border-color: rgba(184,134,11,0.85); }
  50%      { border-color: rgba(26,122,74,0.9); }
}
.recheck-cam-hint {
  margin-top: 14px;
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.recheck-cam-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  pointer-events: all;
}

/* ═══ PO Type Toggle ═══ */
.po-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text3);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s;
}
.po-type-btn.active {
  border-color: var(--brown2);
  color: var(--brown2);
  background: rgba(184,134,11,0.1);
  font-weight: 600;
}
.po-type-btn:hover:not(.active) {
  border-color: rgba(61,46,30,0.25);
  color: var(--text2);
}

/* ═══ PO Bag Qty Row ═══ */
.po-bag-qty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.po-bag-qty-label {
  font-size: 14px;
  color: var(--text3);
  white-space: nowrap;
}
.po-bag-qty-input {
  width: 90px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
}

/* ═══════════════════════════════════════
   GUIDE PAGE
═══════════════════════════════════════ */
.guide-panel .guide-body {
  padding: 20px 24px 4px;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.3s ease;
  max-height: 1200px;
}
.guide-panel .guide-body.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.guide-steps { display:flex; flex-direction:column; gap:0; }
.guide-step {
  display:flex; gap:16px; align-items:flex-start;
  padding:14px 0; border-bottom:1px solid rgba(61,46,30,0.08);
}
.guide-step:last-child { border-bottom:none; }
.guide-step-num {
  flex-shrink:0; width:32px; height:32px; border-radius:50%;
  background:rgba(61,46,30,0.08); border:1px solid rgba(61,46,30,0.15);
  display:flex; align-items:center; justify-content:center;
  font-size: 14px; font-weight:700; font-family:var(--mono); color:var(--text2);
}
.guide-step-content { flex:1; padding-top:4px; }
.guide-step-content strong { display:block; font-size:14px; font-weight:700; color:var(--text1); margin-bottom:4px; }
.guide-step-content p { font-size: 14px; color:var(--text3); line-height:1.65; margin:0; }
.guide-step-content code {
  background:rgba(61,46,30,0.06); border:1px solid rgba(61,46,30,0.14);
  border-radius:5px; padding:1px 7px; font-family:var(--mono); font-size: 14px; color:var(--text2);
}
.guide-tip {
  margin:12px 0 20px; padding:12px 16px;
  background:rgba(184,134,11,0.08); border:1px solid rgba(184,134,11,0.22);
  border-radius:10px; font-size:12.5px; color:var(--text2); line-height:1.6;
}

/* ═══════════════════════════════════════════════════
   MOBILE UI — ปรับให้กดง่าย มองชัด ไม่ซูมเมื่อแตะ 2 ครั้ง
═══════════════════════════════════════════════════ */

/* แก้ double-tap zoom ทุก element */
* {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ป้องกัน zoom เมื่อ focus input บน iOS */
input, select, textarea, button {
  font-size: 16px !important; /* iOS จะไม่ zoom ถ้า font-size >= 16px */
  touch-action: manipulation;
}

@media (max-width: 700px) {

  /* ── Global ── */
  body { font-size: 16px; }
  .page-wrap { padding: 12px; }

  /* ── Header & Nav ── */
  .header { padding: 8px 12px; gap: 6px; }
  .nav-btn {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px; /* touch target ขั้นต่ำ */
    border-radius: 10px;
  }
  .nav-icon { font-size: 14px; }

  /* ── PIN Keypad ── */
  #auth-pin-screen button {
    width: 76px !important;
    height: 76px !important;
    font-size: 24px !important;
    min-height: 76px;
  }
  #auth-dot-0, #auth-dot-1, #auth-dot-2, #auth-dot-3 {
    width: 18px !important;
    height: 18px !important;
  }

  /* ── Buttons ── */
  .btn-outline, .btn-danger, .btn-toggle {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px !important;
  }
  .btn-sm {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px !important;
  }
  .pill {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 14px !important;
  }

  /* ── Inputs ── */
  .scan-input {
    font-size: 16px !important;
    padding: 14px 16px;
    min-height: 52px;
  }
  .filter-input, .filter-select {
    font-size: 16px !important;
    padding: 10px 14px;
    min-height: 44px;
  }

  /* ── Tables ── */
  .data-table { font-size: 14px; }
  .data-table th { font-size: 14px; padding: 8px 6px; }
  .data-table td { padding: 10px 6px; }
  .table-scroll { -webkit-overflow-scrolling: touch; }

  /* ── KPI Cards ── */
  .kpi-row { gap: 8px; }

  /* ── Panels ── */
  .panel { border-radius: 12px; }
  .panel-header { padding: 12px 14px; font-size: 14px; }

  /* ── Scan Page ── */
  .scan-card { padding: 14px; border-radius: 12px; }
  .scan-card-header { font-size: 14px; margin-bottom: 10px; }

  /* ── Defect Entry ── */
  .de-size-input {
    width: 56px !important;
    height: 48px !important;
    font-size: 16px !important;
    border-radius: 8px;
  }

  /* ── Receiving Page ── */
  .btn-finish-recv {
    min-height: 56px;
    font-size: 16px !important;
    border-radius: 14px;
  }

  /* ── Packing Page ── */
  #page-packing .page-wrap { max-width: 100%; }

  /* ── Modal ── */
  .modal-box {
    margin: 12px;
    border-radius: 16px;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ── Topbar user label ── */
  #topbarUserLabel { font-size: 14px; }

  /* ── Logout button ── */
  #topbarUserLabel + button {
    padding: 4px 8px !important;
    font-size: 14px !important;
  }

  /* ── ซ่อน header-right บนมือถือเล็ก ── */
  .header-clock { display: none; }
  .live-badge { display: none; }
}

/* ── iPhone SE และมือถือเล็ก ── */
@media (max-width: 390px) {
  .nav-btn { padding: 8px 10px; font-size: 14px; }
  #auth-pin-screen button {
    width: 68px !important;
    height: 68px !important;
    font-size: 22px !important;
  }
}

/* ═══════════════════════════════════════════════════
   SAFE AREA — รองรับ Navigation Bar Android / iPhone notch
═══════════════════════════════════════════════════ */

/* รองรับ safe area ทุกด้าน */
body {
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Auth screen เลื่อน keypad ขึ้นพ้น nav bar */
#auth-pin-screen {
  padding-bottom: calc(env(safe-area-inset-bottom) + 24px) !important;
}

/* App wrapper padding ด้านล่าง */
#app-wrapper {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Zebra PDA / Android nav bar fallback */
@supports not (padding-bottom: env(safe-area-inset-bottom)) {
  #auth-pin-screen {
    padding-bottom: 60px !important;
  }
}

@media (max-width: 700px) {
  /* เพิ่ม padding ล่างให้ทุกหน้าพ้น nav bar */
  .page { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }
  
  /* keypad ใหญ่ขึ้นและไม่ถูกบัง */
  #auth-pin-screen {
    justify-content: center;
    padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 32px) !important;
  }
}

/* ═══════════════════════════════════════════════════
   PIN KEYPAD — Responsive ทุกขนาดหน้าจอ
═══════════════════════════════════════════════════ */
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 2.5vw, 14px);
  width: 100%;
  max-width: 300px;
}

.pin-btn {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--card);
  color: var(--text1);
  font-family: var(--mono);
  font-size: clamp(18px, 5vw, 26px);
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 60px;
}

.pin-btn:active {
  transform: scale(0.9);
  background: rgba(61,46,30,0.08);
}

.pin-btn-del {
  background: none;
  color: var(--text3);
  font-size: clamp(16px, 4vw, 22px);
}

/* dots ก็ responsive ด้วย */
#auth-pin-screen .pin-dots {
  display: flex;
  gap: clamp(12px, 4vw, 20px);
  margin-bottom: clamp(24px, 6vw, 40px);
}

#auth-dot-0, #auth-dot-1, #auth-dot-2, #auth-dot-3 {
  width: clamp(14px, 4vw, 20px) !important;
  height: clamp(14px, 4vw, 20px) !important;
  border-radius: 50%;
  border: 2px solid var(--border2);
  transition: all .15s;
}

/* Zebra PDA และมือถือเล็ก */
@media (max-width: 400px) {
  .pin-keypad { max-width: 260px; gap: 8px; }
  .pin-btn { min-height: 52px; font-size: 20px !important; }
}

/* Desktop และ Tablet */
@media (min-width: 900px) {
  .pin-keypad { max-width: 280px; gap: 12px; }
  .pin-btn { min-height: 72px; }
}

/* ═══════════════════════════════════════════════════
   DATE PICKER — แก้สีให้มองเห็นชัด
═══════════════════════════════════════════════════ */
input[type="date"],
input[type="month"] {
  color: var(--brown) !important;
  background: #ffffff !important;
  border: 1px solid var(--border2) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-family: var(--font) !important;
  font-size: 14px !important;
  cursor: pointer;
  color-scheme: light;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  filter: none !important;
  opacity: 0.6;
  cursor: pointer;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="month"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
}

input[type="date"]:focus,
input[type="month"]:focus {
  border-color: var(--accent) !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(184,134,11,0.15) !important;
}

@media (max-width: 700px) {
  input[type="date"],
  input[type="month"] {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
  }
}

/* ═══════════════════════════════════════════════════
   DROPDOWN NAV — Desktop
═══════════════════════════════════════════════════ */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-arrow {
  font-size: 14px;
  opacity: 0.6;
  transition: transform .2s;
}

.nav-dropdown.open .nav-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #ffffff;
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 6px;
  z-index: 9990;
  box-shadow: 0 8px 32px rgba(61,46,30,0.15);
  flex-direction: column;
  gap: 2px;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-item {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text2);
  font-family: var(--font);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
  touch-action: manipulation;
}

.nav-dropdown-item:hover,
.nav-dropdown-item.active {
  background: rgba(61,46,30,0.06);
  color: var(--brown);
}

/* ═══════════════════════════════════════════════════
   BOTTOM NAVIGATION — Mobile
═══════════════════════════════════════════════════ */
.bottom-nav {
  display: none; /* ซ่อนบน desktop */
}

@media (max-width: 900px) {
  /* ซ่อน top nav บนมือถือ */
  .nav { display: none !important; }

  /* แสดง bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9980;
    background: rgba(245, 240, 232, 0.98);
    border-top: 1px solid var(--border2);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px;
    border: none;
    background: none;
    color: var(--text3);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
    transition: color .15s;
    min-height: 56px;
  }

  .bottom-nav-btn span:first-child {
    font-size: 20px;
    line-height: 1;
  }

  .bottom-nav-btn.active {
    color: var(--accent2);
  }

  /* More menu */
  .bottom-nav-more {
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    z-index: 9979;
    background: rgba(245, 240, 232, 0.98);
    border-top: 1px solid var(--border2);
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(61,46,30,0.12);
  }

  /* เพิ่ม padding ด้านล่าง page ให้พ้น bottom nav */
  .page { padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important; }
}

/* ═══════════════════════════════════════════════════
   FIX BOTTOM NAV — กดติดทุกกรณี
═══════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* ให้ bottom nav อยู่เหนือทุกอย่าง */
  .bottom-nav {
    z-index: 99990 !important;
    box-shadow: 0 -2px 20px rgba(61,46,30,0.10);
  }

  .bottom-nav-more {
    z-index: 99989 !important;
  }

  /* ปุ่มใหญ่ขึ้น กดง่ายขึ้น */
  .bottom-nav-btn {
    min-height: 60px !important;
    padding: 8px 2px 10px !important;
    font-size: 14px !important;
    position: relative;
    z-index: 99991;
    /* เพิ่ม touch area */
    -webkit-tap-highlight-color: rgba(61,46,30,0.1);
  }

  .bottom-nav-btn span:first-child {
    font-size: 22px !important;
  }

  /* ป้องกัน content ทับ */
  #app-wrapper {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }

  /* ให้ page scroll ไม่ทับ bottom nav */
  .page.active {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    min-height: calc(100vh - 60px);
  }

  /* More menu อยู่เหนือสุด */
  #bnavMoreMenu {
    z-index: 99989 !important;
    bottom: calc(60px + env(safe-area-inset-bottom)) !important;
  }

  #bnavMoreMenu button {
    min-height: 52px !important;
  }
}

/* ═══════════════════════════════════════════════════
   CEO VIEW — Labotte Blue Pastel Theme
   ใช้เมื่อ login ด้วย ?token=ceo
═══════════════════════════════════════════════════ */
body.ceo-theme {
  --bg:       #08132a;
  --bg2:      #0d1d3d;
  --card:     #0f2347;
  --surface:  rgba(15, 35, 71, 0.9);
  --border:   rgba(126, 184, 247, 0.12);
  --border2:  rgba(126, 184, 247, 0.22);

  --text:     #e2eeff;
  --text1:    #e2eeff;
  --text2:    #a8c8f0;
  --text3:    #4a6fa8;

  --accent:   #7eb8f7;
  --accent2:  #a8d4ff;
  --gold:     #fcd34d;
  --green:    #6ee7b7;
  --red:      #fca5a5;
  --white:    #e2eeff;

  background: linear-gradient(135deg, #08132a 0%, #0d1d3d 50%, #0a1833 100%) !important;
}

/* Header */
body.ceo-theme .header {
  background: rgba(8, 19, 42, 0.95) !important;
  border-bottom: 1px solid rgba(126, 184, 247, 0.15) !important;
  backdrop-filter: blur(20px);
}

/* Brand */
body.ceo-theme .brand-name {
  background: linear-gradient(135deg, #7eb8f7, #a8d4ff) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

/* Nav */
body.ceo-theme .nav-btn {
  color: #7a98c4 !important;
  border-color: transparent !important;
}
body.ceo-theme .nav-btn:hover,
body.ceo-theme .nav-btn.active {
  background: rgba(126, 184, 247, 0.12) !important;
  color: #a8d4ff !important;
  border-color: rgba(126, 184, 247, 0.25) !important;
}

/* Dropdown */
body.ceo-theme .nav-dropdown-menu {
  background: #0d1d3d !important;
  border-color: rgba(126, 184, 247, 0.2) !important;
}
body.ceo-theme .nav-dropdown-item:hover {
  background: rgba(126, 184, 247, 0.1) !important;
  color: #a8d4ff !important;
}

/* KPI Cards */
body.ceo-theme .panel,
body.ceo-theme [style*="rgba(255,255,255,0.03)"],
body.ceo-theme [style*="rgba(255,255,255,0.04)"] {
  background: rgba(15, 35, 71, 0.6) !important;
  border-color: rgba(126, 184, 247, 0.15) !important;
}

/* Panels */
body.ceo-theme .panel-header {
  background: rgba(126, 184, 247, 0.06) !important;
  border-bottom-color: rgba(126, 184, 247, 0.12) !important;
  color: #a8d4ff !important;
}

body.ceo-theme .panel-badge {
  background: rgba(126, 184, 247, 0.15) !important;
  color: #7eb8f7 !important;
}

/* Tables */
body.ceo-theme .data-table th {
  background: rgba(126, 184, 247, 0.06) !important;
  color: #7eb8f7 !important;
  border-bottom-color: rgba(126, 184, 247, 0.15) !important;
}
body.ceo-theme .data-table tr:hover {
  background: rgba(126, 184, 247, 0.04) !important;
}
body.ceo-theme .data-table td {
  border-bottom-color: rgba(126, 184, 247, 0.08) !important;
}

/* Buttons */
body.ceo-theme .btn-outline {
  border-color: rgba(126, 184, 247, 0.3) !important;
  color: #7eb8f7 !important;
}
body.ceo-theme .btn-outline:hover {
  border-color: #7eb8f7 !important;
  background: rgba(126, 184, 247, 0.1) !important;
}

/* Select / Input */
body.ceo-theme select,
body.ceo-theme input[type="date"],
body.ceo-theme input[type="month"],
body.ceo-theme input[type="number"] {
  background: rgba(15, 35, 71, 0.8) !important;
  border-color: rgba(126, 184, 247, 0.25) !important;
  color: #e2eeff !important;
}

/* Pills */
body.ceo-theme .pill {
  border-color: rgba(126, 184, 247, 0.2) !important;
  color: #7a98c4 !important;
}
body.ceo-theme .pill.active {
  background: rgba(126, 184, 247, 0.15) !important;
  border-color: rgba(126, 184, 247, 0.4) !important;
  color: #a8d4ff !important;
}

/* Bottom Nav */
body.ceo-theme .bottom-nav {
  background: rgba(8, 19, 42, 0.98) !important;
  border-top-color: rgba(126, 184, 247, 0.15) !important;
}
body.ceo-theme .bottom-nav-btn.active {
  color: #7eb8f7 !important;
}
body.ceo-theme .bottom-nav-more {
  background: #0d1d3d !important;
  border-top-color: rgba(126, 184, 247, 0.2) !important;
}

/* CEO Back btn ใน nav bar — desktop */
#nav-ceo-back {
  background: rgba(184,134,11,0.12) !important;
  border-color: rgba(184,134,11,0.4) !important;
  color: #7a5806 !important;
  font-weight: 700 !important;
  margin-right: 6px;
}
#nav-ceo-back:hover {
  background: rgba(184,134,11,0.22) !important;
}

/* CEO Back btn ใน bottom nav — mobile */
#bnav-ceo-back {
  color: #7a5806;
  font-weight: 700;
  border-right: 1px solid rgba(184,134,11,0.2);
}

/* Scrollbar */
body.ceo-theme ::-webkit-scrollbar-track {
  background: #0d1d3d !important;
}
body.ceo-theme ::-webkit-scrollbar-thumb {
  background: rgba(126, 184, 247, 0.2) !important;
}
body.ceo-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(126, 184, 247, 0.35) !important;
}

/* CEO KPI Cards — ทำให้โดดเด่นขึ้น */
body.ceo-theme #ceoKpiGrid > div {
  background: linear-gradient(135deg, rgba(15,35,71,0.8), rgba(10,25,55,0.9)) !important;
  border-color: rgba(126, 184, 247, 0.2) !important;
  border-radius: 14px !important;
}

/* กล่องสีพิเศษตาม type */
body.ceo-theme #monthlyKpiGrid > div:nth-child(1),
body.ceo-theme #ceoKpiGrid > div:nth-child(1) {
  border-color: rgba(126, 184, 247, 0.35) !important;
  box-shadow: 0 0 20px rgba(126, 184, 247, 0.08) !important;
}

/* ═══════════════════════════════════════════════════
   TABLET / MOBILE BROWSER — 700-900px
   แสดง top nav แต่ลดขนาดลง
═══════════════════════════════════════════════════ */
@media (min-width: 701px) and (max-width: 900px) {
  .nav {
    display: flex !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 4px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
    flex-shrink: 0;
  }
  .nav-icon { font-size: 12px !important; }
  .bottom-nav { display: none !important; }
}

/* ═══════════════════════════════════════════════════
   SIDEBAR NAVIGATION — Desktop ≥ 901px
   ย้ายเมนูจากแนวนอน (top-nav) มาเป็นแถบข้าง
   จัดกลุ่มตามขั้นตอนงาน + ย่อเป็น icon ได้
═══════════════════════════════════════════════════ */

/* ── ค่าเริ่มต้น: ซ่อน sidebar (มือถือ/tablet) ── */
.sidebar { display: none; }

/* ── Desktop layout ── */
@media (min-width: 901px) {

  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 236px;
    z-index: 210;
    background: linear-gradient(180deg, #faf7f1, #f1ebdf);
    border-right: 1px solid var(--border);
    transition: width .28s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
  }

  /* ── ซ่อน brand + nav เดิมจาก header (sidebar แสดงแทน) ── */
  .header .brand  { display: none !important; }
  .header .nav    { display: none !important; }

  /* ── เลื่อน header + page ให้พ้น sidebar ── */
  .header       { margin-left: 236px; transition: margin-left .28s cubic-bezier(.4,0,.2,1); }
  .page         { margin-left: 236px; transition: margin-left .28s cubic-bezier(.4,0,.2,1); }
  .ambient-bg   { margin-left: 236px; transition: margin-left .28s cubic-bezier(.4,0,.2,1); }

  /* ── ซ่อน bottom-nav บน desktop ── */
  .bottom-nav       { display: none !important; }
  .bottom-nav-more  { display: none !important; }

  /* ═══ RAIL MODE (ย่อเป็นแถบ icon) ═══ */
  body.sidebar-rail .sidebar    { width: 66px; }
  body.sidebar-rail .header     { margin-left: 66px; }
  body.sidebar-rail .page       { margin-left: 66px; }
  body.sidebar-rail .ambient-bg { margin-left: 66px; }

  /* Brand */
  .sb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--border);
    min-height: 62px;
  }
  .sb-brand-txt {
    display: flex;
    flex-direction: column;
    gap: 1px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .2s;
  }
  body.sidebar-rail .sb-brand-txt { opacity: 0; width: 0; }
  body.sidebar-rail .sb-brand { justify-content: center; padding: 16px 0 14px; gap: 0; }

  /* Scroll area */
  .sb-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--sand) transparent;
  }
  .sb-scroll::-webkit-scrollbar { width: 5px; }
  .sb-scroll::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 4px; }

  /* Group */
  .sb-group { margin-top: 14px; }
  .sb-group:first-child { margin-top: 2px; }
  .sb-group-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text3);
    padding: 6px 12px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .2s;
  }
  body.sidebar-rail .sb-group-title {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }

  /* Menu item */
  .sb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid transparent;
    background: none;
    color: var(--text2);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all .16s;
    white-space: nowrap;
    text-align: left;
    position: relative;
    margin-bottom: 2px;
  }
  .sb-item:hover {
    background: rgba(61,46,30,.06);
    color: var(--brown);
  }
  .sb-item.active {
    background: linear-gradient(135deg, var(--brown), var(--brown2));
    color: #fff;
    box-shadow: 0 3px 12px rgba(61,46,30,.22);
    border-color: transparent;
  }
  .sb-item .sb-ic {
    font-size: 17px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
  }
  .sb-item .sb-lbl {
    overflow: hidden;
    transition: opacity .2s;
  }

  /* Rail mode items */
  body.sidebar-rail .sb-item {
    justify-content: center;
    padding: 11px 0;
    margin: 0 6px 2px;
  }
  body.sidebar-rail .sb-item .sb-lbl { opacity: 0; width: 0; overflow: hidden; }
  body.sidebar-rail .sb-item.active::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 18%;
    bottom: 18%;
    width: 3px;
    background: var(--gold2);
    border-radius: 0 3px 3px 0;
  }
  /* Tooltip on hover in rail */
  body.sidebar-rail .sb-item:hover .sb-lbl {
    display: block;
    opacity: 1;
    width: auto;
    position: absolute;
    left: 58px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--brown);
    color: #fff;
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 13px;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(61,46,30,.25);
    z-index: 220;
    pointer-events: none;
  }

  /* Footer */
  .sb-foot {
    border-top: 1px solid var(--border);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .sb-user {
    font-size: 11px;
    color: var(--text3);
    font-family: var(--mono);
    font-weight: 500;
    padding: 2px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity .2s;
  }
  body.sidebar-rail .sb-user { opacity: 0; height: 0; padding: 0; }

  .sb-collapse {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: rgba(61,46,30,.05);
    color: var(--text2);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 12px;
    border-radius: 9px;
    cursor: pointer;
    transition: all .16s;
  }
  .sb-collapse:hover { background: rgba(61,46,30,.1); }
  .sb-collapse-ic {
    font-size: 15px;
    display: inline-block;
    transition: transform .28s;
  }
  body.sidebar-rail .sb-collapse-ic { transform: rotate(180deg); }
  body.sidebar-rail .sb-collapse-lbl { display: none; }
  body.sidebar-rail .sb-collapse { justify-content: center; }

  .sb-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: 1px solid var(--border);
    background: none;
    color: var(--text3);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .16s;
    white-space: nowrap;
    overflow: hidden;
  }
  .sb-logout:hover { background: rgba(61,46,30,.06); color: var(--text2); }
  body.sidebar-rail .sb-logout { font-size: 0; padding: 8px; }
  body.sidebar-rail .sb-logout::before { content: "⏻"; font-size: 15px; }

  /* ═══ CEO Theme overrides ═══ */
  body.ceo-theme .sidebar {
    background: linear-gradient(180deg, #0a1628, #0d1f3a);
    border-right-color: rgba(126,184,247,.12);
  }
  body.ceo-theme .sb-brand { border-bottom-color: rgba(126,184,247,.12); }
  body.ceo-theme .sb-group-title { color: rgba(126,184,247,.45); }
  body.ceo-theme .sb-item { color: rgba(200,220,255,.6); }
  body.ceo-theme .sb-item:hover { background: rgba(126,184,247,.08); color: #a8d4ff; }
  body.ceo-theme .sb-item.active {
    background: linear-gradient(135deg, rgba(126,184,247,.18), rgba(126,184,247,.08));
    color: #a8d4ff;
    box-shadow: 0 2px 12px rgba(126,184,247,.12);
    border-color: rgba(126,184,247,.2);
  }
  body.ceo-theme .sb-foot { border-top-color: rgba(126,184,247,.12); }
  body.ceo-theme .sb-user { color: rgba(126,184,247,.4); }
  body.ceo-theme .sb-collapse { background: rgba(126,184,247,.06); color: rgba(200,220,255,.5); }
  body.ceo-theme .sb-collapse:hover { background: rgba(126,184,247,.12); }
  body.ceo-theme .sb-logout { border-color: rgba(126,184,247,.15); color: rgba(200,220,255,.4); }
  body.ceo-theme .sb-logout:hover { background: rgba(126,184,247,.08); }
  body.ceo-theme .sb-scroll::-webkit-scrollbar-thumb { background: rgba(126,184,247,.15); }
}

/* ═══ Override 701-900px: ใช้ bottom-nav แทน top-nav ═══ */
@media (min-width: 701px) and (max-width: 900px) {
  .nav { display: none !important; }
  .bottom-nav { display: flex !important; }
}

/* ═══ Diligence page — filter tabs (เสร็จแล้ว / ยังไม่เสร็จ / ทั้งหมด) ═══ */
.diligence-filter-tab {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all .15s ease;
}
.diligence-filter-tab:hover {
  background: var(--surface2);
}
.diligence-filter-tab.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
