/* ==========================================================================
   PROTACH - Precision Manufacturing ERP & Production Tracking Design System
   ========================================================================== */

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

:root {
  /* Color Palette - Industrial Dark Core */
  --bg-base: #0b0f17;
  --bg-surface: #111827;
  --bg-surface-raised: #1a2234;
  --bg-surface-elevated: #242f48;
  --bg-glass: rgba(17, 24, 39, 0.92);
  
  --border-subtle: #1f293d;
  --border-medium: #2e3c54;
  --border-highlight: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b0f17;

  /* Accent Colors */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.2);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  --info: #06b6d4;
  --purple: #8b5cf6;
  --indigo: #6366f1;

  /* Status Colors */
  --status-available: #10b981;
  --status-running: #f59e0b;
  --status-maintenance: #ef4444;
  --status-idle: #64748b;

  /* Typography */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-neon: 0 0 15px var(--primary-glow);

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

  --header-height: 64px;
  --sidebar-width: 250px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-base: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f8fafc;
  --bg-surface-elevated: #e2e8f0;
  --bg-glass: rgba(255, 255, 255, 0.95);
  
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-highlight: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
}

/* Custom Global Theme-Aware Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #334155 var(--bg-base);
}

[data-theme="light"] * {
  scrollbar-color: #cbd5e1 var(--bg-base);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  box-sizing: border-box;
}

/* Navigation & Filter Tabs */
.filter-tabs,
.sub-tabs,
.tab-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 6px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

[data-theme="light"] .tab-btn.active {
  background: var(--primary) !important;
  color: #ffffff !important;
}

/* Layout Hierarchy */
.app-container,
.app-layout {
  display: flex;
  width: 100vw;
  max-width: 100vw;
  min-height: 100vh;
  background-color: var(--bg-base);
  overflow-x: hidden;
  position: relative;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: var(--transition);
}

.brand-section {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 64px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
  overflow: hidden;
  position: relative;
  transition: var(--transition);
}

.brand-logo.has-image {
  background: #ffffff !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
  padding: 3px !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.brand-logo img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  border-radius: 6px !important;
  display: block !important;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.2;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
}

[data-theme="light"] .brand-title {
  color: #0f172a;
}

.brand-subtitle {
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
}

/* Nav Menu */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-category {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 700;
  padding: 10px 10px 4px 10px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-size: 13px;
}

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

.nav-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.nav-item .icon {
  font-size: 16px;
  min-width: 18px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.nav-badge.alert {
  background: var(--danger);
  color: white;
}

.nav-badge.warning {
  background: var(--warning);
  color: #000;
}

/* Role Selector Footer */
.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-raised);
  flex-shrink: 0;
}

.role-badge-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.role-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}

.role-info {
  flex: 1;
  line-height: 1.2;
  overflow: hidden;
}

.role-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.role-select {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  width: 100%;
}

/* Main Content Area - Fully Constrained & Flex Resilient */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  width: calc(100vw - var(--sidebar-width));
  max-width: calc(100vw - var(--sidebar-width));
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-base);
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Top Header */
.app-header {
  height: var(--header-height);
  width: 100%;
  max-width: 100%;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-sizing: border-box;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.page-breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.quick-search {
  position: relative;
  width: 240px;
}

.quick-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: var(--transition);
}

.quick-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.quick-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
}

/* Control Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-warning {
  background: var(--warning);
  color: #111;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* App Body Views Container */
.app-content {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.view-section {
  display: none;
  animation: fadeIn 0.2s ease-out;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

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

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

/* Toolbar Bar */
.toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  width: 100%;
  box-sizing: border-box;
}

.toolbar-bar > div:first-child {
  min-width: 240px;
}

/* Metric / KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
  width: 100%;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-lg);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-footer {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.kpi-trend-up {
  color: var(--success);
  font-weight: 600;
}

.kpi-trend-down {
  color: var(--danger);
  font-weight: 600;
}

/* Glass Cards & Panels */
.card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(255, 255, 255, 0.01);
  box-sizing: border-box;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.card-body {
  padding: 20px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

/* Tables & Wrappers (Fluid & Internally Scrollable) */
.data-table-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-sizing: border-box;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
  background: var(--bg-surface);
}

.data-table th {
  background: var(--bg-surface-raised);
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.data-table tr:last-child td {
  border-bottom: none;
}

/* Status Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-success .badge-dot { background: #10b981; }

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-warning .badge-dot { background: #f59e0b; }

.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-danger .badge-dot { background: #ef4444; }

.badge-info {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.badge-info .badge-dot { background: #06b6d4; }

.badge-neutral {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}
.badge-neutral .badge-dot { background: #94a3b8; }

.badge-purple {
  background: rgba(139, 92, 246, 0.12);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}
.badge-purple .badge-dot { background: #8b5cf6; }

/* Filter Tabs / Toolbar */
.filter-tabs {
  display: inline-flex;
  background: var(--bg-surface-raised);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 2px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  white-space: nowrap;
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Machine Shop Floor View */
.floors-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.floor-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  width: 100%;
  box-sizing: border-box;
}

.floor-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  width: 100%;
}

.machine-card {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
  transition: var(--transition);
  box-sizing: border-box;
}

.machine-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.machine-card.running { border-left: 4px solid var(--status-running); }
.machine-card.available { border-left: 4px solid var(--status-available); }
.machine-card.maintenance { border-left: 4px solid var(--status-maintenance); }
.machine-card.idle { border-left: 4px solid var(--status-idle); }

.machine-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 6px;
}

.machine-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.machine-type {
  font-size: 11px;
  color: var(--text-muted);
}

.machine-details {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.machine-job-badge {
  background: var(--bg-surface-elevated);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  display: inline-block;
  margin-top: 3px;
  word-break: break-all;
}

/* Order Visual Timeline / Stepper */
.timeline-container {
  padding: 20px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  width: 100%;
  box-sizing: border-box;
}

.stepper-horizontal {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  margin: 20px 0 10px 0;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 10px;
}

.stepper-horizontal::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--border-subtle);
  z-index: 1;
}

.step-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 80px;
  flex: 1;
}

.step-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-raised);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
  box-shadow: 0 0 0 4px var(--bg-surface);
}

.step-node.completed .step-icon-circle {
  background: var(--success);
  border-color: var(--success);
  color: white;
  box-shadow: 0 0 12px var(--success-glow), 0 0 0 4px var(--bg-surface);
}

.step-node.active .step-icon-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 15px var(--primary-glow), 0 0 0 4px var(--bg-surface);
  animation: pulse 2s infinite;
}

.step-title {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.step-node.completed .step-title,
.step-node.active .step-title {
  color: var(--text-primary);
}

.step-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

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

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 95%;
  max-width: 720px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  box-sizing: border-box;
  transform: translateY(0);
  will-change: transform, opacity;
}

.modal-dialog.modal-md {
  max-width: 860px;
  width: 92%;
}

.modal-dialog.modal-lg {
  max-width: 1100px;
  width: 95%;
}

.modal-dialog.modal-xl,
.modal-dialog.modal-wide {
  max-width: 1280px;
  width: 96%;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

.modal-footer {
  padding: 14px 0 0 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: transparent;
  flex-shrink: 0;
  margin-top: 20px;
  width: 100%;
  box-sizing: border-box;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
}

.form-grid.col-3 {
  grid-template-columns: repeat(3, 1fr);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-control {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.form-control[readonly], .form-control:disabled {
  background: var(--bg-base);
  color: var(--text-muted);
  cursor: not-allowed;
}

.stock-check-result {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 12px;
}

.stock-check-result.ok {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.stock-check-result.deficit {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 12px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: slideUp 0.3s ease-out;
  min-width: 260px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }

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

/* ==========================================================================
   Printable Document Templates & Perfect A4 Print Styling
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 8mm 8mm 8mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Completely hide all background ERP layout, navigation, cards, tables */
  .app-sidebar,
  .app-header,
  .app-main > .content-view,
  .content-view,
  .toolbar-bar,
  .kpi-grid,
  .card-panel,
  .filter-tabs,
  .data-table-wrapper,
  .modal-header,
  .modal-footer,
  .btn,
  .no-print,
  #toast-container {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .app-layout,
  .app-main {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  /* Clean Modal & Voucher Box for 1-Page A4 Printing */
  #modal-container,
  .modal-overlay {
    display: block !important;
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    opacity: 1 !important;
    overflow: visible !important;
  }

  .modal-dialog {
    display: block !important;
    position: static !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    transform: none !important;
    overflow: visible !important;
  }

  .modal-body {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    max-height: none !important;
  }

  .voucher-box {
    display: block !important;
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1.5px solid #0f172a !important;
    border-radius: 4px !important;
    padding: 16px 20px !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
  }

  .voucher-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .voucher-table th,
  .voucher-table td {
    border: 1px solid #0f172a !important;
    color: #000000 !important;
  }

  .shipping-label-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    page-break-inside: avoid !important;
  }

  .shipping-label {
    border: 1.5px dashed #000000 !important;
    padding: 10px !important;
    background: #ffffff !important;
    color: #000000 !important;
    page-break-inside: avoid !important;
  }
}

.voucher-box {
  background: #ffffff;
  color: #1e293b;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1;
  font-family: var(--font-sans);
}

.voucher-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.voucher-company-name {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
}

.voucher-doc-title {
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  color: #2563eb;
  text-align: right;
}

.voucher-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.voucher-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.voucher-table th {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}

.voucher-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  font-size: 11px;
  color: #1e293b;
}

/* Box Shipping Label Template */
.shipping-label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.shipping-label {
  background: #fff;
  color: #000;
  border: 2px dashed #000;
  padding: 14px;
  border-radius: 8px;
  position: relative;
}

.shipping-label-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #000;
  padding-bottom: 6px;
  font-weight: 800;
}

.barcode-strip {
  height: 36px;
  background: repeating-linear-gradient(
    90deg,
    #000 0px,
    #000 3px,
    #fff 3px,
    #fff 6px,
    #000 6px,
    #000 8px,
    #fff 8px,
    #fff 11px
  );
  margin: 10px 0 4px 0;
  border-radius: 2px;
}

/* Responsive adjustments */
@media (max-width: 1180px) {
  .form-grid.col-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 64px;
  }
  
  .app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }
  .app-sidebar .brand-title, .app-sidebar .brand-subtitle, .app-sidebar .nav-text, .app-sidebar .nav-category, .app-sidebar .role-info, .app-sidebar .nav-badge {
    display: none;
  }
  .app-sidebar .brand-section {
    padding: 12px 10px;
    justify-content: center;
  }
  .app-sidebar .nav-item {
    justify-content: center;
    padding: 10px;
  }
  .app-sidebar .sidebar-footer {
    padding: 8px 4px;
  }
  .app-sidebar .role-badge-box {
    justify-content: center;
    padding: 4px;
    border: none;
    background: transparent;
  }
  .app-main {
    margin-left: var(--sidebar-width);
    width: calc(100vw - var(--sidebar-width));
    max-width: calc(100vw - var(--sidebar-width));
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Full-Screen Universal Login Portal
   ========================================================================== */
.login-fullscreen-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #090d16 60%, #030712 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

.login-glass-card {
  width: 100%;
  max-width: 480px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 40px rgba(59, 130, 246, 0.15);
  padding: 32px;
  box-sizing: border-box;
}

.login-brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: 14px;
  font-size: 30px;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
  margin-bottom: 12px;
  overflow: hidden;
  position: relative;
  transition: var(--transition);
}

.login-brand-logo.has-image {
  background: #ffffff !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
  padding: 4px !important;
  border: 1.5px solid rgba(255, 255, 255, 0.3) !important;
}

.login-brand-logo img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  border-radius: 10px !important;
  display: block !important;
}

.login-brand-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  margin-bottom: 4px;
}

.login-brand-subtitle {
  font-size: 12px;
  color: #94a3b8;
}

.login-role-chips {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

