/* =============================================
   BEAM EVENT TRACKING SYSTEM
   Design System — Dark Mode Premium
   ============================================= */

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

/* ── CSS Custom Properties ── */
:root {
  /* Backgrounds */
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-tertiary:   #21262d;
  --surface:       #1c2128;
  --surface-hover: #262c36;
  --surface-active:#2d333b;

  /* Borders */
  --border:        rgba(240,246,252,0.10);
  --border-subtle: rgba(240,246,252,0.06);
  --border-focus:  rgba(47,129,247,0.60);

  /* Text */
  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;

  /* Semantic Colors */
  --accent:        #2f81f7;
  --accent-hover:  #388bfd;
  --success:       #3fb950;
  --success-bg:    rgba(63,185,80,0.12);
  --warning:       #d29922;
  --warning-bg:    rgba(210,153,34,0.12);
  --danger:        #f85149;
  --danger-bg:     rgba(248,81,73,0.12);
  --purple:        #bc8cff;
  --purple-bg:     rgba(188,140,255,0.12);
  --info:          #58a6ff;
  --info-bg:       rgba(88,166,255,0.12);

  /* Status Colors */
  --status-pending:    var(--text-muted);
  --status-active:     var(--accent);
  --status-transport:  var(--warning);
  --status-warehouse:  var(--purple);
  --status-mall:       var(--info);
  --status-done:       var(--success);
  --status-late:       var(--danger);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
  --shadow-xl:   0 20px 60px rgba(0,0,0,0.6);
  --glow-accent: 0 0 20px rgba(47,129,247,0.25);

  /* Spacing */
  --sp-1: 4px;   --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px;  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Radius */
  --r-sm:  6px;  --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-full: 9999px;

  /* Transitions */
  --t-fast:   0.12s ease;
  --t-normal: 0.20s ease;
  --t-slow:   0.35s ease;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  60px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Sarabun', 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Typography Scale ── */
.text-display { font-size: 2.5rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.text-h1 { font-size: 1.875rem; font-weight: 700; line-height: 1.2; }
.text-h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.text-h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
.text-h4 { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; }
.text-body { font-size: 0.9375rem; font-weight: 400; line-height: 1.6; }
.text-sm   { font-size: 0.8125rem; font-weight: 400; line-height: 1.5; }
.text-xs   { font-size: 0.75rem;   font-weight: 400; line-height: 1.4; }
.text-label{ font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--surface-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================
   KEYFRAME ANIMATIONS
   ========================================== */
@keyframes fadeIn    { from{opacity:0} to{opacity:1} }
@keyframes fadeUp    { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeDown  { from{opacity:0;transform:translateY(-16px)} to{opacity:1;transform:translateY(0)} }
@keyframes scaleIn   { from{opacity:0;transform:scale(0.94)} to{opacity:1;transform:scale(1)} }
@keyframes slideLeft { from{opacity:0;transform:translateX(24px)} to{opacity:1;transform:translateX(0)} }
@keyframes slideRight{ from{opacity:0;transform:translateX(-24px)} to{opacity:1;transform:translateX(0)} }
@keyframes pulse     { 0%,100%{opacity:1} 50%{opacity:0.4} }
@keyframes spin      { to{transform:rotate(360deg)} }
@keyframes shimmer   { from{background-position:-200% 0} to{background-position:200% 0} }
@keyframes countUp   { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes ping      { 75%,100%{transform:scale(2);opacity:0} }
@keyframes shake     {
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-8px)}
  40%{transform:translateX(8px)}
  60%{transform:translateX(-6px)}
  80%{transform:translateX(6px)}
}
@keyframes glow-pulse {
  0%,100%{box-shadow:0 0 20px rgba(47,129,247,0.2)}
  50%{box-shadow:0 0 40px rgba(47,129,247,0.5)}
}

/* Stagger animation delays */
.stagger-1{animation-delay:0ms}
.stagger-2{animation-delay:80ms}
.stagger-3{animation-delay:160ms}
.stagger-4{animation-delay:240ms}
.stagger-5{animation-delay:320ms}

/* ==========================================
   GLASSMORPHISM SYSTEM
   ========================================== */
.glass {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.glass-strong {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-lg);
}
.gradient-border {
  border: 1px solid transparent;
  background: linear-gradient(var(--surface),var(--surface)) padding-box,
              linear-gradient(135deg,#2f81f7,#bc8cff) border-box;
}

/* ==========================================
   LAYOUT SYSTEM
   ========================================== */
/* App wrapper after login */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  animation: slideRight 0.3s ease;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg,var(--accent),var(--purple));
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff; font-weight: 700;
  box-shadow: var(--glow-accent);
}
.sidebar-logo-text { font-size: 1.0625rem; font-weight: 700; color: var(--text-primary); }
.sidebar-logo-sub  { font-size: 0.6875rem; color: var(--text-muted); font-weight: 400; }

.sidebar-nav { flex: 1; padding: var(--sp-4) var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 0.9rem; font-weight: 500;
  transition: all var(--t-normal);
  position: relative;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover  { background: var(--surface-hover); color: var(--text-primary); }
.nav-item.active {
  background: rgba(47,129,247,0.12);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--accent);
  border-radius: 0 var(--r-full) var(--r-full) 0;
}
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 0.6875rem; font-weight: 600;
  padding: 1px 7px; border-radius: var(--r-full);
  min-width: 20px; text-align: center;
  animation: pulse 2s infinite;
}

.sidebar-bottom {
  padding: var(--sp-4); border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2); border-radius: var(--r-md);
  transition: background var(--t-normal); cursor: pointer;
}
.sidebar-user:hover { background: var(--surface-hover); }
.user-avatar {
  width: 34px; height: 34px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.user-name  { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.user-role  { font-size: 0.75rem; color: var(--text-muted); }

/* ── Topbar ── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.0625rem; font-weight: 600; color: var(--text-primary); flex: 1; }
.topbar-search {
  position: relative; display: flex; align-items: center;
}
.topbar-search input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) 36px;
  color: var(--text-primary);
  font-size: 0.875rem; width: 240px;
  transition: all var(--t-normal);
}
.topbar-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,129,247,0.15);
  width: 280px;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.search-icon { position: absolute; left: 12px; color: var(--text-muted); font-size: 0.9rem; }

/* ── Main Content ── */
.main-content {
  padding: var(--sp-6);
  overflow-y: auto;
  height: calc(100vh - var(--topbar-h));
  animation: fadeIn 0.25s ease;
}
.page-header {
  margin-bottom: var(--sp-6);
  animation: fadeUp 0.3s ease;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p  { color: var(--text-secondary); margin-top: 4px; font-size: 0.9rem; }

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md); font-weight: 600; font-size: 0.875rem;
  border: 1px solid transparent; transition: all var(--t-normal);
  cursor: pointer; white-space: nowrap; user-select: none; line-height: 1.4;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 0 16px rgba(47,129,247,0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover); box-shadow: 0 0 24px rgba(47,129,247,0.40);
}
.btn-secondary {
  background: var(--surface); color: var(--text-primary); border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-success { background: var(--success-bg); color: var(--success); border-color: rgba(63,185,80,0.25); }
.btn-success:hover:not(:disabled) { background: rgba(63,185,80,0.20); }
.btn-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(248,81,73,0.25); }
.btn-danger:hover:not(:disabled)  { background: rgba(248,81,73,0.22); }
.btn-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(210,153,34,0.25); }
.btn-warning:hover:not(:disabled) { background: rgba(210,153,34,0.20); }
.btn-ghost {
  background: transparent; color: var(--text-secondary); border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text-primary); }

.btn-sm { padding: 5px 12px; font-size: 0.8125rem; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-icon { padding: var(--sp-2); border-radius: var(--r-md); aspect-ratio: 1; }

/* ==========================================
   CARDS
   ========================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--t-normal), box-shadow var(--t-normal), border-color var(--t-normal);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-hoverable:hover { border-color: rgba(47,129,247,0.30); }

.card-header {
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-body   { padding: var(--sp-6); }
.card-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-2);
}

/* KPI Card */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  transition: all var(--t-normal);
  animation: fadeUp 0.4s ease both;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(255,255,255,0.12); }
.kpi-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--sp-2); }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--text-primary); letter-spacing: -0.02em; }
.kpi-value.animating { animation: countUp 0.5s ease; }
.kpi-meta  { font-size: 0.8rem; color: var(--text-muted); margin-top: var(--sp-2); }
.kpi-icon  {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: var(--sp-4);
}
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; }
.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* ==========================================
   FORMS & INPUTS
   ========================================== */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block; margin-bottom: var(--sp-2);
  font-size: 0.875rem; font-weight: 600; color: var(--text-secondary);
}
.form-label .required { color: var(--danger); margin-left: 3px; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: var(--sp-1); }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: var(--sp-1); display: none; }
.form-error.visible { display: block; animation: fadeIn 0.2s ease; }

.input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text-primary); font-size: 0.9375rem;
  transition: all var(--t-normal); line-height: 1.5;
}
.input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,129,247,0.15);
  background: var(--surface);
}
.input::placeholder { color: var(--text-muted); }
.input.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(248,81,73,0.15); }
.input.success { border-color: var(--success); }

.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}
.input-group { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group .input { padding-left: 38px; }

/* PIN Input */
.pin-input-group { display: flex; gap: var(--sp-3); justify-content: center; }
.pin-digit {
  width: 56px; height: 64px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 1.5rem; font-weight: 700;
  text-align: center; color: var(--text-primary);
  transition: all var(--t-normal); letter-spacing: 0.1em;
}
.pin-digit:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,129,247,0.20); }
.pin-digit.filled { border-color: rgba(47,129,247,0.40); background: rgba(47,129,247,0.06); }

/* ==========================================
   BADGES & STATUS
   ========================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge-dot.pulse { animation: pulse 2s infinite; }

.badge-default  { background: var(--surface-active); color: var(--text-secondary); }
.badge-accent   { background: var(--info-bg);    color: var(--info);    }
.badge-success  { background: var(--success-bg); color: var(--success); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger);  }
.badge-purple   { background: var(--purple-bg);  color: var(--purple);  }

/* Live dot */
.live-dot {
  position: relative; display: inline-block;
  width: 10px; height: 10px;
}
.live-dot::before, .live-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
}
.live-dot::before { background: var(--success); }
.live-dot::after  { background: var(--success); animation: ping 1.5s infinite; }

/* ==========================================
   STEP PIPELINE (Workflow Tracker)
   ========================================== */
.pipeline {
  display: flex; align-items: flex-start;
  gap: 0; padding: var(--sp-4) 0;
}
.pipeline-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; position: relative; gap: var(--sp-2);
}
.pipeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 20px; left: calc(50% + 24px);
  right: calc(-50% + 24px);
  height: 2px;
  background: var(--border);
  z-index: 0;
  transition: background var(--t-slow);
}
.pipeline-step.done:not(:last-child)::after { background: var(--success); }
.pipeline-step.active:not(:last-child)::after { background: var(--border); }
.pipeline-step.late:not(:last-child)::after { background: var(--danger); }

.step-circle {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; border: 2px solid; z-index: 1;
  transition: all var(--t-slow);
  background: var(--bg-secondary);
}
.pipeline-step.pending .step-circle { border-color: var(--border); color: var(--text-muted); }
.pipeline-step.active  .step-circle { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px rgba(47,129,247,0.15); animation: glow-pulse 2s infinite; }
.pipeline-step.done    .step-circle { border-color: var(--success); background: var(--success); color: #fff; }
.pipeline-step.late    .step-circle { border-color: var(--danger);  color: var(--danger);  box-shadow: 0 0 0 4px rgba(248,81,73,0.15); }

.step-label { font-size: 0.75rem; font-weight: 600; text-align: center; color: var(--text-muted); max-width: 80px; }
.pipeline-step.active .step-label { color: var(--accent); }
.pipeline-step.done   .step-label { color: var(--success); }
.pipeline-step.late   .step-label { color: var(--danger); }
.step-time  { font-size: 0.65rem; color: var(--text-muted); text-align: center; }

/* ==========================================
   TABLE
   ========================================== */
.table-wrapper {
  width: 100%; overflow-x: auto; border-radius: var(--r-lg);
  border: 1px solid var(--border);
}
.table {
  width: 100%; border-collapse: collapse;
  font-size: 0.875rem;
}
.table thead tr {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}
.table thead th {
  padding: 12px 16px; text-align: left;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted); white-space: nowrap;
  user-select: none;
}
.table thead th.sortable { cursor: pointer; }
.table thead th.sortable:hover { color: var(--text-primary); }
.table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--t-fast);
  cursor: pointer;
}
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.selected { background: rgba(47,129,247,0.07); }
.table tbody td { padding: 12px 16px; color: var(--text-primary); vertical-align: middle; }

/* ==========================================
   MODALS & DRAWERS
   ========================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: var(--sp-4);
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.25s ease;
}
.modal-header {
  padding: var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-body   { padding: var(--sp-6); }
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--sp-3);
}
.modal-close {
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--t-normal);
}
.modal-close:hover { background: var(--surface-hover); color: var(--text-primary); }

/* Side Drawer */
.drawer {
  position: fixed; top: 0; right: 0;
  width: 480px; height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 200; overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--t-slow);
}
.drawer.open { transform: translateX(0); }
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199; opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

/* ==========================================
   ALERTS SYSTEM
   ========================================== */
.alert-bar {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.alert-item {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--t-fast); cursor: pointer;
  animation: slideLeft 0.3s ease both;
}
.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: var(--surface-hover); }
.alert-icon {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0;
}
.alert-item.danger  .alert-icon { background: var(--danger-bg);  color: var(--danger);  }
.alert-item.warning .alert-icon { background: var(--warning-bg); color: var(--warning); }
.alert-item.info    .alert-icon { background: var(--info-bg);    color: var(--info);    }
.alert-text  { flex: 1; }
.alert-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.alert-desc  { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.alert-time  { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* Toast notification */
.toast-container {
  position: fixed; top: var(--sp-6); right: var(--sp-6);
  z-index: 9999; display: flex; flex-direction: column; gap: var(--sp-2);
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  font-size: 0.875rem; font-weight: 500; color: var(--text-primary);
  animation: slideLeft 0.3s ease;
  min-width: 280px;
}
.toast.success { border-color: rgba(63,185,80,0.30); }
.toast.error   { border-color: rgba(248,81,73,0.30); }
.toast.warning { border-color: rgba(210,153,34,0.30); }

/* ==========================================
   CALENDAR
   ========================================== */
.calendar-grid {
  display: grid; grid-template-columns: repeat(7,1fr);
  border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--border);
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-6); margin-bottom: var(--sp-4);
}
.cal-month-year { font-size: 1.2rem; font-weight: 700; }
.cal-nav { display: flex; gap: var(--sp-2); }
.cal-day-name {
  background: var(--bg-tertiary);
  text-align: center; padding: var(--sp-2);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.cal-day-name.weekend { color: var(--danger); opacity: 0.7; }
.cal-day {
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 100px; padding: var(--sp-2);
  transition: background var(--t-fast); cursor: pointer;
  position: relative;
}
.cal-day:hover { background: var(--surface-hover); }
.cal-day.other-month .cal-day-num { opacity: 0.3; }
.cal-day.today { background: rgba(47,129,247,0.06); }
.cal-day.today .cal-day-num {
  background: var(--accent); color: #fff;
  border-radius: 50%; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}
.cal-day-num { font-size: 0.85rem; font-weight: 600; margin-bottom: var(--sp-1); color: var(--text-secondary); }
.cal-event {
  font-size: 0.7rem; font-weight: 600; padding: 2px 6px;
  border-radius: var(--r-sm); margin-bottom: 2px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity var(--t-fast);
}
.cal-event:hover { opacity: 0.8; }
.cal-event.active  { background: rgba(47,129,247,0.20); color: var(--accent); }
.cal-event.done    { background: rgba(63,185,80,0.20);  color: var(--success); }
.cal-event.late    { background: rgba(248,81,73,0.20);  color: var(--danger); }
.cal-event.future  { background: rgba(188,140,255,0.20);color: var(--purple); }
.cal-event.pending { background: var(--bg-tertiary); color: var(--text-muted); }

/* ==========================================
   SKELETON LOADER
   ========================================== */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-text.w-50 { width: 50%; }
.skeleton-text.w-75 { width: 75%; }
.skeleton-card { height: 120px; border-radius: var(--r-lg); }

/* ==========================================
   EMPTY STATE
   ========================================== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: var(--sp-16) var(--sp-8);
  text-align: center; gap: var(--sp-4);
  animation: fadeUp 0.4s ease;
}
.empty-icon { font-size: 3rem; opacity: 0.25; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-desc  { font-size: 0.875rem; color: var(--text-muted); max-width: 320px; }

/* ==========================================
   DIVIDER & MISC
   ========================================== */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }
.divider-text {
  display: flex; align-items: center; gap: var(--sp-4); margin: var(--sp-4) 0;
  color: var(--text-muted); font-size: 0.8rem;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 0.7rem; font-weight: 600;
  background: var(--surface-active); color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-4); }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: var(--sp-4); }

/* Flex helpers */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col     { display: flex; flex-direction: column; }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }

/* Spacing */
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.p-4  { padding: var(--sp-4); }
.p-6  { padding: var(--sp-6); }

/* ==========================================
   LOGIN PAGE SPECIFIC
   ========================================== */
.login-page {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  pointer-events: none;
}
.login-bg-glow.blue  { width: 600px; height: 600px; background: var(--accent); top: -200px; right: -200px; }
.login-bg-glow.purple{ width: 500px; height: 500px; background: var(--purple); bottom: -150px; left: -150px; }
.login-card {
  width: 100%; max-width: 440px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-10);
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.4s ease;
  position: relative; z-index: 1;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-8);
}
.login-logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, #1a6ef5, #8b5cf6);
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff;
  box-shadow: 0 0 40px rgba(47,129,247,0.4);
  animation: glow-pulse 3s infinite;
}
.login-title { font-size: 1.5rem; font-weight: 700; text-align: center; }
.login-sub   { font-size: 0.875rem; color: var(--text-muted); text-align: center; }

.role-selector {
  display: grid; grid-template-columns: repeat(2,1fr); gap: var(--sp-3); margin-bottom: var(--sp-6);
}
.role-card {
  padding: var(--sp-4); border-radius: var(--r-lg);
  border: 1.5px solid var(--border); background: var(--bg-tertiary);
  cursor: pointer; text-align: center; transition: all var(--t-normal);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.role-card:hover { border-color: var(--accent); background: rgba(47,129,247,0.05); transform: translateY(-2px); }
.role-card.selected { border-color: var(--accent); background: rgba(47,129,247,0.10); }
.role-card.selected .role-card-icon { box-shadow: 0 0 16px rgba(47,129,247,0.4); }
.role-card-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.role-card-name { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.role-card-desc { font-size: 0.75rem; color: var(--text-muted); }

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; width: 280px; }
  .sidebar.mobile-open { display: flex; }
  .topbar-search input { width: 180px; }
  .grid-2, .grid-3, .grid-4, .grid-kpi { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
  .pipeline { overflow-x: auto; }
  .login-card { padding: var(--sp-6); margin: var(--sp-4); }
}
@media (max-width: 480px) {
  .main-content { padding: var(--sp-4); }
  .pin-digit { width: 48px; height: 56px; font-size: 1.25rem; }
  .role-selector { grid-template-columns: 1fr; }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.hidden   { display: none !important; }
.visible  { display: block !important; }
.sr-only  { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
  .sidebar, .topbar, .btn, .nav-item { display: none !important; }
  .main-content { height: auto; overflow: visible; }
  body { background: #fff; color: #000; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
