/* ============================================================
   IT Stock — UI/UX Pro Max
   Premium Design System
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Premium Color Palette */
  --bg: #f0f2f5;
  --surface: #ffffff;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --sky: #0ea5e9;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
  
  /* Glass Effects */
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-blur: blur(20px);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
  --gradient-sky: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
  --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #172554 100%);
  
  /* Typography */
  --font-sans: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.01em;
}

.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.td-mono { font-family: var(--font-mono); font-size: 13px; }
strong { font-weight: 600; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 24px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  cursor: pointer; transition: all var(--transition-normal);
  white-space: nowrap; position: relative; overflow: hidden;
}
.btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
  opacity: 0; transition: opacity var(--transition-fast);
}
.btn:hover::before { opacity: 1; }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--gradient-primary);
  color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.btn-primary:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}
.btn-success {
  background: var(--gradient-success);
  color: #fff; box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}
.btn-success:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}
.btn-danger {
  background: var(--gradient-danger);
  color: #fff; box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}
.btn-danger:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}
.btn-ghost { 
  background: var(--border-light); 
  color: var(--text); 
  border: 1px solid var(--border);
}
.btn-ghost:hover { 
  background: var(--surface); 
  border-color: var(--primary);
  color: var(--primary);
}
.btn-soft { 
  background: var(--primary-light); 
  color: var(--primary-dark); 
  border: 1px solid rgba(99, 102, 241, 0.2);
}
.btn-soft:hover { 
  background: rgba(99, 102, 241, 0.15); 
  border-color: var(--primary);
}
.btn-outline { 
  background: transparent; 
  color: var(--primary-dark); 
  border: 2px solid var(--primary-light);
}
.btn-outline:hover { 
  background: var(--primary-light); 
  border-color: var(--primary);
}
.btn-block { width: 100%; padding: 14px; font-size: 15px; }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: var(--radius-sm); 
  cursor: pointer; background: transparent; color: var(--muted); 
  transition: all var(--transition-fast); position: relative;
}
.btn-icon:hover { 
  background: var(--primary-light); 
  color: var(--primary); 
  transform: scale(1.1);
}
.btn-icon.danger:hover { 
  background: var(--danger-light); 
  color: var(--danger); 
}
.btn-side {
  width: 100%; justify-content: flex-start; padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05); color: #e2e8f0; 
  border-radius: var(--radius-sm); border: 1px solid transparent;
}
.btn-side:hover { 
  background: rgba(255, 255, 255, 0.1); 
  color: #fff; 
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field label { 
  font-size: 13px; font-weight: 600; color: var(--text-secondary); 
  letter-spacing: 0.02em; text-transform: uppercase;
}
.input {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border); 
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; 
  color: var(--text); background: var(--surface); transition: all var(--transition-fast); 
  outline: none; box-shadow: var(--shadow-xs);
}
.input:focus { 
  border-color: var(--primary); 
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), var(--shadow-sm);
  transform: translateY(-1px);
}
.input::placeholder { color: #94a3b8; }
textarea.input { resize: vertical; min-height: 60px; }
select.input {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 16px center;
  padding-right: 40px; cursor: pointer;
}
select.input option { padding: 10px 14px; font-size: 14px; }
.rx-suggest { 
  position: absolute; top: 100%; left: 0; right: 0; 
  background: var(--surface); border: 2px solid var(--primary); 
  border-radius: var(--radius-sm); max-height: 240px; overflow-y: auto; 
  z-index: 999; display: none; box-shadow: var(--shadow-xl); 
  margin-top: 4px; backdrop-filter: var(--glass-blur);
}
.rx-item { 
  padding: 12px 16px; cursor: pointer; font-size: 14px; 
  color: var(--text); transition: all var(--transition-fast); 
  border-bottom: 1px solid var(--border-light);
}
.rx-item:last-child { border-bottom: none; }
.rx-item:hover { 
  background: var(--primary-light); 
  color: var(--primary-dark); 
  padding-left: 20px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.row-actions { display: flex; gap: 12px; margin-top: 12px; }

.tx-row {
  display: grid; grid-template-columns: 1.6fr .55fr auto;
  gap: 12px; align-items: center; margin-bottom: 12px;
}
.tx-row.issue { grid-template-columns: 1.6fr .55fr auto; }
.tx-item-wrap { display: flex; gap: 8px; align-items: center; }
.tx-item-wrap select { flex: 1; }
.tx-item-wrap .tx-barcode { width: 150px; flex: none; font-size: 12px; }
.tx-row .tx-serial { display: none; }
.tx-row.tracked .tx-qty { display: none; }
.tx-row.tracked .tx-serial { display: block; }
.tx-row .tx-serial.input { min-height: 42px; }

.check {
  display: inline-flex; align-items: center; gap: 10px; 
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

.search-box { position: relative; }
.search-box .ic { 
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); 
  color: #94a3b8; transition: color var(--transition-fast);
}
.search-box input { padding-left: 42px; width: 280px; }
.search-box:focus-within .ic { color: var(--primary); }

/* ============ Login Page ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; 
  padding: 24px; position: relative; overflow: hidden;
  background: var(--gradient-dark);
}
.login-wrap::before {
  content: ''; position: absolute; top: -50%; left: -50%; 
  width: 200%; height: 200%; 
  background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.4) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(14, 165, 233, 0.3) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
  animation: aurora 20s ease-in-out infinite;
}
@keyframes aurora {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(2%, 1%) rotate(1deg); }
  50% { transform: translate(-1%, 2%) rotate(-1deg); }
  75% { transform: translate(1%, -1%) rotate(0.5deg); }
}
.login-card {
  width: 440px; max-width: 94vw; 
  background: rgba(255, 255, 255, 0.95); 
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-lg); padding: 48px 40px 36px; 
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4),
              0 0 0 1px rgba(255, 255, 255, 0.2);
  animation: loginFadeUp 0.6s var(--transition-spring) both;
  text-align: center; position: relative; z-index: 1;
}
@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: none; }
}
.login-logo {
  width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: var(--gradient-primary);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.5);
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.login-title { 
  font-size: 28px; font-weight: 700; 
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 32px; }
.login-card form { text-align: left; }
.login-card .btn-block { margin-top: 8px; }
.login-error {
  background: var(--danger-light); color: #b91c1c; 
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 12px 16px; border-radius: var(--radius-sm); 
  font-size: 13.5px; margin-bottom: 18px; text-align: center;
}
.demo-hint {
  margin-top: 28px; padding: 16px 18px; border-radius: var(--radius-sm); 
  text-align: left; background: var(--primary-light); 
  border: 1px dashed rgba(99, 102, 241, 0.3); 
  font-size: 13px; line-height: 2;
}
.demo-hint code {
  background: var(--surface); border: 1px solid var(--primary-light); 
  border-radius: 6px; padding: 2px 8px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--primary-dark);
}

/* ============ Main Layout ============ */
.app-layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 24px 18px 18px; color: #e2e8f0;
  background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}
.brand { 
  display: flex; align-items: center; gap: 14px; 
  padding: 0 10px 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-badge {
  width: 46px; height: 46px; border-radius: 14px; 
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient-primary); color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
  transition: transform var(--transition-normal);
}
.brand-badge:hover { transform: scale(1.1) rotate(5deg); }
.brand-name { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 0.02em; }
.brand-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }

.nav { flex: 1; margin-top: 20px; display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px; 
  border-radius: var(--radius-sm); color: #cbd5e1; text-decoration: none; 
  font-size: 14.5px; font-weight: 500; transition: all var(--transition-normal);
  position: relative; overflow: hidden;
}
.nav-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--gradient-primary); border-radius: 0 4px 4px 0;
  opacity: 0; transform: scaleY(0); transition: all var(--transition-fast);
}
.nav-item:hover { 
  background: rgba(255, 255, 255, 0.08); 
  color: #fff; 
  transform: translateX(4px);
}
.nav-item:hover::before { opacity: 0.5; transform: scaleY(1); }
.nav-item.active {
  background: var(--gradient-primary);
  color: #fff; font-weight: 600; 
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}
.nav-item.active::before { opacity: 1; transform: scaleY(1); }
.nav-badge {
  margin-left: auto; min-width: 24px; height: 24px; padding: 0 8px; 
  border-radius: var(--radius-full);
  background: var(--gradient-danger); color: #fff;
  font-size: 11.5px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
  animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.sidebar-foot { 
  border-top: 1px solid rgba(255, 255, 255, 0.08); 
  padding-top: 16px; display: flex; flex-direction: column; gap: 12px; 
}
.user-card { display: flex; align-items: center; gap: 12px; padding: 6px 8px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; 
  font-weight: 700; font-size: 16px; color: #fff;
  background: var(--gradient-warning);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  transition: transform var(--transition-fast);
}
.avatar:hover { transform: scale(1.1); }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }
.user-name { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.3; }
.user-role { font-size: 12px; color: #94a3b8; }
.link-reset {
  background: none; border: none; color: #64748b; font-size: 12px; 
  cursor: pointer; padding: 4px; transition: all var(--transition-fast);
}
.link-reset:hover { color: #cbd5e1; text-decoration: underline; }

/* Sync Indicator */
.sync-indicator {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px; color: #94a3b8; margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.sync-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #64748b; flex-shrink: 0;
  transition: all var(--transition-normal);
}
.sync-dot.connected {
  background: var(--success);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
  animation: syncGlow 2s ease-in-out infinite;
}
@keyframes syncGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(16, 185, 129, 0.6); }
  50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.8); }
}
.sync-dot.syncing {
  background: var(--warning);
  animation: pulse 1s infinite;
}
.sync-dot.error {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}
.sync-dot.offline {
  background: #64748b;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}
.sync-text {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync-text small { font-size: 11px; color: #64748b; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20; 
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px; display: flex; align-items: center; 
  justify-content: space-between; gap: 16px;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar-sub { font-size: 13px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.date-chip {
  background: var(--border-light); border: 1px solid var(--border); 
  color: var(--text-secondary); padding: 10px 16px; 
  border-radius: var(--radius-full); font-size: 13px; font-weight: 500;
  transition: all var(--transition-fast);
}
.date-chip:hover { 
  background: var(--primary-light); 
  border-color: var(--primary); 
  color: var(--primary-dark);
}

.page { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }

/* ============ Cards ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); 
  border-radius: var(--radius); box-shadow: var(--shadow-sm); 
  padding: 24px 28px; margin-bottom: 24px;
  transition: all var(--transition-normal);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-head { 
  display: flex; align-items: flex-start; justify-content: space-between; 
  gap: 16px; margin-bottom: 20px; 
}
.card-head h3 { font-size: 18px; font-weight: 700; }
.card-head p { margin-top: 4px; }

/* ============ Alert Banner ============ */
.alert-banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, #f59e0b 0%, #f43f5e 100%);
  color: #fff; border-radius: var(--radius); padding: 18px 24px; 
  margin-bottom: 24px; box-shadow: 0 12px 30px rgba(244, 63, 94, 0.3);
  animation: fadeUp 0.5s var(--transition-spring) both;
}
.alert-banner .spacer { flex: 1; }
.alert-banner .btn-light { 
  background: rgba(255, 255, 255, 0.95); color: #9a3412; 
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); 
  border: none; font-weight: 600;
}
.alert-banner .btn-light:hover { 
  background: #fff; transform: translateY(-2px); 
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* ============ Stats Cards ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card { 
  display: flex; align-items: center; gap: 16px; padding: 22px; 
  margin-bottom: 0; transition: all var(--transition-normal); 
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; right: 0; 
  width: 100px; height: 100px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
  transform: translate(30%, -30%);
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.15; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.icon-bubble {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  display: flex; align-items: center; justify-content: center; color: #fff;
  transition: transform var(--transition-normal);
}
.stat-card:hover .icon-bubble { transform: scale(1.1) rotate(5deg); }
.ib-indigo { 
  background: var(--gradient-primary); 
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4); 
}
.ib-emerald { 
  background: var(--gradient-success); 
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4); 
}
.ib-sky { 
  background: var(--gradient-sky); 
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.4); 
}
.ib-amber { 
  background: var(--gradient-warning); 
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4); 
}
.ib-rose { 
  background: var(--gradient-danger); 
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4); 
}

.dash-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 24px; }
.dash-grid .card { margin-bottom: 0; }

/* ============ Chart ============ */
.chart-wrap { padding-top: 8px; }
.chart-bars { 
  display: flex; align-items: flex-end; gap: 20px; height: 200px; 
  padding: 0 10px; border-bottom: 2px solid var(--border); 
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; }
.chart-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
.bar { 
  width: 18px; border-radius: 6px 6px 3px 3px; 
  transition: height 0.6s var(--transition-spring); 
  min-height: 4px; position: relative;
}
.bar:hover { filter: brightness(1.1); }
.bar-rcv { background: var(--gradient-primary); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4); }
.bar-iss { background: var(--gradient-danger); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4); }
.chart-label { font-size: 12px; color: var(--muted); padding-bottom: 8px; }
.chart-legend { 
  display: flex; gap: 20px; justify-content: center; 
  padding: 14px 0 4px; font-size: 13px; color: var(--text-secondary); 
}
.lg { display: inline-flex; align-items: center; gap: 8px; }
.lg::before { content: ''; width: 12px; height: 12px; border-radius: 4px; }
.lg-rcv::before { background: var(--gradient-primary); }
.lg-iss::before { background: var(--gradient-danger); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; font-weight: 600; 
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 14px 16px; 
  border-bottom: 2px solid var(--border); white-space: nowrap;
  background: var(--border-light);
}
table.list td { 
  padding: 14px 16px; border-bottom: 1px solid var(--border-light); 
  vertical-align: middle; transition: background var(--transition-fast); 
}
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr.clickable { cursor: pointer; }
table.list tbody tr.clickable:hover { 
  background: var(--primary-light); 
  transform: scale(1.01);
}
table.list .actions { text-align: right; white-space: nowrap; }
.empty {
  padding: 48px 24px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty .ic { opacity: 0.4; }

.mini-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.mini-table th { 
  text-align: left; font-size: 12px; color: var(--muted); 
  font-weight: 600; padding: 8px 12px; 
  border-bottom: 2px solid var(--border); 
  background: var(--border-light);
}
.mini-table td { 
  padding: 10px 12px; border-bottom: 1px solid var(--border-light); 
  font-size: 13.5px; 
}
.tx-detail-inner { 
  background: var(--border-light); border: 1px solid var(--border); 
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 6px 0; 
}
.tx-note { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 7px; 
  padding: 4px 14px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: all var(--transition-fast);
}
.badge:hover { transform: scale(1.05); }
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: #b91c1c; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-gray { background: var(--border-light); color: #475569; }
.badge-receive { background: #dbeafe; color: #1d4ed8; }
.badge-issue { background: #fce7f3; color: #be185d; }
.badge-dot { 
  width: 8px; height: 8px; border-radius: 50%; 
  display: inline-block; 
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}
.badge-dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }
.badge-dot.low { background: var(--warning); box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); }
.badge-dot.out { background: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }

.chip-cat {
  display: inline-block; background: var(--border-light); 
  color: #475569; border-radius: var(--radius-sm);
  padding: 4px 12px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}
.chip-cat:hover { 
  background: var(--primary-light); 
  border-color: var(--primary); 
  color: var(--primary-dark);
}

/* ============ Toolbar ============ */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar-summary { font-size: 13.5px; color: var(--muted); }

/* ============ Segmented Control ============ */
.seg { 
  display: inline-flex; background: var(--border-light); 
  border-radius: var(--radius-sm); padding: 5px; gap: 5px;
  border: 1px solid var(--border);
}
.seg-btn {
  border: none; background: transparent; padding: 10px 20px; 
  border-radius: 8px; font-family: inherit; font-size: 14px; 
  font-weight: 600; color: var(--muted); cursor: pointer; 
  transition: all var(--transition-fast);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { 
  background: var(--surface); 
  color: var(--primary-dark); 
  box-shadow: var(--shadow-sm);
  transform: scale(1.02);
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; 
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px); 
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 24px; overflow-y: auto;
  animation: overlayFadeIn 0.2s ease;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); 
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto; 
  animation: modalPop 0.3s var(--transition-spring) both;
  border: 1px solid var(--border);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: none; }
}
.modal-wide { width: min(900px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2; 
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-head h3 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px;
  border-top: 1px solid var(--border); position: sticky; bottom: 0; 
  background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.confirm-msg { color: var(--text-secondary); }

/* ============ Toast ============ */
#toast-root { 
  position: fixed; top: 24px; right: 24px; z-index: 200; 
  display: flex; flex-direction: column; gap: 12px; 
}
.toast {
  display: flex; align-items: center; gap: 12px; 
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 16px 20px; box-shadow: var(--shadow-xl); 
  font-size: 14px; font-weight: 500;
  border-left: 4px solid var(--success); 
  animation: toastSlideIn 0.4s var(--transition-spring) both; 
  max-width: 400px;
}
.toast.out { animation: toastSlideOut 0.3s ease both; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: none; }
}
@keyframes toastSlideOut {
  to { opacity: 0; transform: translateX(40px) scale(0.95); }
}
.toast-success { border-left-color: var(--success); color: #166534; }
.toast-error { border-left-color: var(--danger); color: #991b1b; }
.toast-info { border-left-color: var(--sky); color: #075985; }
.toast svg { flex: none; }

/* ============ Animations ============ */
@keyframes fadeUp { 
  from { opacity: 0; transform: translateY(20px); } 
  to { opacity: 1; transform: none; } 
}
@keyframes pop { 
  from { opacity: 0; transform: scale(0.96) translateY(12px); } 
  to { opacity: 1; transform: none; } 
}

/* ============ Report Preview ============ */
.rep-preview { overflow-x: auto; }
.rep-preview table { min-width: 740px; }

/* ============ QR Scanner ============ */
.qr-reader { 
  width: 100%; max-width: 400px; margin: 0 auto 14px; 
  border-radius: var(--radius); overflow: hidden; 
  background: #0f172a; box-shadow: var(--shadow-xl);
}
.qr-reader video { border-radius: var(--radius); width: 100% !important; }
.scanner-hint {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13.5px; color: var(--text-secondary); margin-bottom: 12px;
}
@keyframes rowFlash {
  0%, 100% { background: transparent; }
  30% { background: #fef08a; }
  70% { background: #fef08a; }
}
.row-flash { animation: rowFlash 1.6s ease; }

/* ============ Label Sheet ============ */
.label-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.label-sheet {
  display: grid; grid-template-columns: repeat(2, 90mm); gap: 4mm; justify-content: center;
}
.label {
  border: 2px solid #475569; border-radius: 6px; padding: 4mm 5mm;
  display: flex; align-items: center; gap: 4mm; background: #fff; 
  break-inside: avoid; transition: all var(--transition-fast);
}
.label:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.label-img { width: 24mm; height: 24mm; flex-shrink: 0; }
.label-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; display: block; }
.label-qr img { width: 24mm; height: 24mm; display: block; }
.label-qr .label-noqr {
  width: 24mm; height: 24mm; display: flex; align-items: center; justify-content: center;
  color: #94a3b8; border: 2px dashed #cbd5e1; border-radius: 4px;
}
.label-code { font-weight: 700; font-size: 13px; letter-spacing: 0.05em; }
.label-name { font-size: 11px; font-weight: 600; line-height: 1.4; }
.label-meta { font-size: 9.5px; color: #475569; margin-top: 3px; }

/* ============ Print Document ============ */
.doc { padding: 32px 36px; }
.doc-head { 
  display: flex; justify-content: space-between; align-items: flex-start; 
  gap: 16px; border-bottom: 3px solid #0f172a; 
  padding-bottom: 14px; margin-bottom: 8px; 
}
.doc-org { font-size: 13px; font-weight: 600; line-height: 1.6; }
.doc-org span { font-weight: 400; color: var(--muted); }
.doc-no { text-align: right; font-size: 13px; line-height: 1.7; }
.doc-no span { display: block; color: var(--muted); font-size: 12px; }
.doc-no strong { font-size: 16px; }
.doc-title { text-align: center; font-size: 22px; font-weight: 700; padding: 12px 0 6px; letter-spacing: 0.05em; }
.doc-info { width: 100%; border-collapse: collapse; margin: 12px 0 16px; font-size: 14px; }
.doc-info td { padding: 4px 6px; }
.doc-info-label { width: 200px; color: var(--text-secondary); font-weight: 500; }
.doc-items { margin-bottom: 14px; }
.doc-amount { margin: 6px 0 12px; font-size: 14px; }
.doc-amount-text { color: #475569; font-size: 13px; margin-top: 3px; }
.doc-note { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.doc-note-label { font-weight: 600; }
.doc-serial { font-size: 10px; color: #475569; font-weight: 400; }

/* ============ Print Sheet ============ */
.print-sheet { 
  background: #fff; border-radius: var(--radius-sm); 
  padding: 28px 32px; border: 1px solid var(--border); 
}
.print-head { 
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; 
  gap: 16px; border-bottom: 3px solid #0f172a; 
  padding-bottom: 14px; margin-bottom: 18px; 
}
.print-org { font-size: 13px; font-weight: 600; line-height: 1.6; }
.print-org span { font-weight: 400; color: var(--muted); }
.print-title { font-size: 18px; font-weight: 700; text-align: center; }
.print-meta { font-size: 12.5px; color: var(--muted); text-align: right; line-height: 1.7; }
.print-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-table th { 
  background: var(--border-light); border: 1px solid #cbd5e1; 
  padding: 10px 12px; font-size: 12px; text-align: left; 
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.print-table td { border: 1px solid #e2e8f0; padding: 8px 12px; }
.print-table .pr-num { text-align: right; font-variant-numeric: tabular-nums; }
.print-table tfoot td { 
  font-weight: 700; background: var(--border-light); 
  border-top: 2px solid #94a3b8; 
}
.print-sig { 
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; 
  margin-top: 72px; text-align: center; font-size: 14px; 
}
.sig-line { border-top: 2px solid #334155; margin-bottom: 10px; height: 40px; }
.print-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff !important; }
  #login-view, #app-view, #toast-root { display: none !important; }
  .modal-overlay { 
    position: static !important; display: block !important; 
    padding: 0 !important; background: #fff !important; 
    overflow: visible !important; backdrop-filter: none !important;
  }
  .modal { 
    width: 100% !important; max-width: 100% !important; 
    max-height: none !important; overflow: visible !important; 
    box-shadow: none !important; border: none !important; 
    border-radius: 0 !important; 
  }
  .modal-head, .print-actions { display: none !important; }
  .print-sheet { border: none !important; padding: 0 !important; }
  .modal-body { padding: 0 !important; }
  .label-sheet { grid-template-columns: repeat(2, 90mm); gap: 4mm; }
  .label { border-color: #000; }
  .print-table { font-size: 11px; }
  .print-table th, .print-table td { padding: 5px 8px; }
  .print-sig { margin-top: 56px; }
}

/* ============ Miscellaneous ============ */
.user-cell { display: flex; align-items: center; gap: 14px; }
.summary-strip { display: flex; gap: 28px; padding: 6px 0 4px; flex-wrap: wrap; }
.summary-item { font-size: 13.5px; color: var(--muted); }
.summary-item b { color: var(--text); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .page { padding: 20px 18px 36px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ============ Departments / Missions ============ */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.dept-card {
  display: block; text-decoration: none; color: inherit;
  padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); transition: all var(--transition-normal);
}
.dept-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  transform: translateY(-4px);
}
.dept-card-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 14px;
}
.dept-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  transition: transform var(--transition-normal);
}
.dept-card:hover .dept-icon { transform: scale(1.1) rotate(5deg); }
.dept-icon-muted { background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%); }
.dept-name { font-size: 18px; font-weight: 600; margin-bottom: 3px; }
.dept-card-body { padding-top: 10px; border-top: 1px solid var(--border); }
.dept-categories { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.dept-alert { color: var(--warning); font-size: 13px; font-weight: 500; }
.dept-card-muted { opacity: 0.7; }
.dept-filter-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--gradient-primary);
  color: #fff; border-radius: var(--radius-sm); 
  margin-bottom: 20px; font-size: 14px;
}
.dept-filter-banner strong { font-weight: 700; }
.dept-filter-banner .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.3); }
.dept-filter-banner .btn-ghost:hover { background: rgba(255,255,255,0.15); }
.dept-filter-banner .btn-soft { background: rgba(255,255,255,0.2); color: #fff; }
.dept-filter-banner .btn-soft:hover { background: rgba(255,255,255,0.3); }

.mission-card { margin-bottom: 24px; padding: 24px; }
.mission-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.mission-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  transition: transform var(--transition-normal);
}
.mission-header:hover .mission-icon { transform: scale(1.1); }
.mission-icon-muted { background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%); }
.mission-name { font-size: 20px; font-weight: 700; margin-bottom: 3px; }
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.group-card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 18px; transition: all var(--transition-normal);
  background: var(--border-light);
}
.group-card:hover {
  border-color: var(--primary); box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.group-card-inner { display: flex; justify-content: space-between; align-items: center; }
.group-name { font-weight: 600; font-size: 14px; }
.group-stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.text-warning { color: var(--warning); font-weight: 600; }
.card-muted { opacity: 0.7; }

/* Item Image */
.item-thumb {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: var(--radius-sm); margin-right: 10px;
  vertical-align: middle; border: 1px solid var(--border);
  flex-shrink: 0; transition: transform var(--transition-fast);
}
.item-thumb:hover { transform: scale(1.1); }
.td-item-name { display: flex; align-items: center; gap: 0; }
.item-image-wrap { display: flex; flex-direction: column; gap: 10px; }
.item-image-preview {
  position: relative; display: inline-block;
  width: 170px; height: 170px; border-radius: var(--radius-sm);
  overflow: hidden; border: 2px solid var(--border);
  background: var(--border-light);
  transition: all var(--transition-normal);
}
.item-image-preview:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.item-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.item-image-preview .btn-icon {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,0.9); border-radius: 50%;
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.item-image-actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   Conflict Resolution
   ============================================================ */
.conflict-modal { max-height: 82vh; display: flex; flex-direction: column; }
.conflict-banner {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 20px; background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24; border-radius: var(--radius-sm);
  margin-bottom: 18px; color: #92400e;
}
.conflict-banner .muted { color: #a16207; }
.conflict-banner svg { flex-shrink: 0; color: #d97706; margin-top: 3px; }

.conflict-autosave-info {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #f0fdf4;
  border: 1px solid #86efac; border-radius: var(--radius-sm);
  margin-bottom: 18px; font-size: 0.9rem; color: #166534;
}
.conflict-autosave-info svg { flex-shrink: 0; color: #22c55e; }

.conflict-list {
  flex: 1; overflow-y: auto; max-height: 58vh;
  display: flex; flex-direction: column; gap: 14px;
  padding: 6px 4px;
}
.conflict-item {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm); padding: 18px;
  transition: all var(--transition-normal);
}
.conflict-item:hover { box-shadow: var(--shadow-md); }
.conflict-item-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.conflict-badge {
  font-size: 0.8rem; font-weight: 600; padding: 4px 12px;
  border-radius: var(--radius-full); background: var(--border-light);
  color: #475569;
}
.conflict-item-id {
  font-size: 0.8rem; color: #94a3b8; margin-left: auto;
}
.conflict-detail-text {
  font-size: 0.92rem; color: var(--text-secondary); margin-bottom: 14px;
}
.conflict-detail-text strong { color: var(--text); }
.conflict-fields { display: flex; flex-direction: column; gap: 12px; }
.conflict-field-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 14px; background: var(--border-light);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.conflict-field-name {
  min-width: 100px; font-weight: 600; font-size: 0.85rem;
  color: #64748b; padding-top: 5px;
}
.conflict-field-options { display: flex; flex: 1; gap: 12px; flex-wrap: wrap; }
.conflict-radio {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  flex: 1; min-width: 160px; transition: all var(--transition-fast);
  font-size: 0.9rem;
}
.conflict-radio.wide { flex: unset; min-width: 220px; }
.conflict-radio:hover { border-color: #93c5fd; background: #eff6ff; }
.conflict-radio:has(input:checked) { border-color: #3b82f6; background: #eff6ff; }
.conflict-radio input[type=radio] {
  accent-color: #3b82f6; width: 18px; height: 18px; flex-shrink: 0;
}
.conflict-val {
  font-weight: 600; font-size: 0.92rem; color: var(--text);
  word-break: break-word;
}
.conflict-val.local { color: #1d4ed8; }
.conflict-val.remote { color: #7c3aed; }
.conflict-source {
  font-size: 0.75rem; color: #94a3b8; margin-left: auto;
  white-space: nowrap;
}
.conflict-actions {
  display: flex; justify-content: flex-end; gap: 12px;
  padding-top: 18px; margin-top: 10px; border-top: 1px solid #e5e7eb;
}

@media (max-width: 640px) {
  .conflict-field-row { flex-direction: column; gap: 8px; }
  .conflict-field-options { flex-direction: column; }
  .conflict-radio { min-width: 100%; }
  .conflict-banner { flex-direction: column; gap: 10px; }
}
