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

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

html,
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-base);
  color: var(--color-text);
  background-color: var(--color-surface);
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------------------------------------
   Layout Architecture (KeepSimple UX Core & getdesign.md spec)
   ------------------------------------------------------------- */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  align-items: stretch;
  background-color: var(--color-surface);
}

/* Sidebar */
.sidebar {
  width: 280px;
  height: 100vh;
  background-color: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--motion-base) var(--motion-ease);
  z-index: 40;
}

.sidebar-header {
  height: 72px;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.logo-badge {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--color-accent) 0%, #1e40af 100%);
  color: var(--color-on-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
  letter-spacing: -0.02em;
}

.logo-text h1 {
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-text);
  letter-spacing: -0.025em;
}

.logo-text p {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  padding: var(--space-5) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-subtle);
  padding: 22px 14px 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all var(--motion-fast) ease;
  white-space: nowrap !important;
}

.nav-item > span:first-of-type,
.nav-item .nav-label {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

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

.nav-item.active {
  background-color: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: 600;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-pill {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
  font-weight: 600;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--color-border);
  font-size: 11.5px;
  color: var(--color-text-muted);
  background: #fafbfc;
  flex-shrink: 0;
}

.footer-title {
  font-weight: 600;
  color: var(--color-text-secondary);
}

.footer-sub {
  margin-top: 4px;
  line-height: 1.4;
  color: var(--color-text-subtle);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--color-surface);
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 72px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  flex-shrink: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
}

/* -------------------------------------------------------------
   Custom Popover Dropdowns (Zero OS bugs, Figma-grade precision)
   ------------------------------------------------------------- */
.custom-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 16px;
  background: #ffffff;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: all var(--motion-fast) ease;
  user-select: none;
}

.dropdown-trigger:hover {
  border-color: #94a3b8;
  background-color: #f8fafc;
}

.dropdown-trigger:focus-visible,
.custom-dropdown.open .dropdown-trigger {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  background-color: #ffffff;
}

.chevron-icon {
  color: #64748b;
  flex-shrink: 0;
  transition: transform var(--motion-fast) ease;
}

.custom-dropdown.open .chevron-icon {
  transform: rotate(180deg);
  color: var(--color-accent);
}

/* Warehouse Trigger Customization */
.warehouse-trigger {
  padding-left: 14px;
  padding-right: 14px;
}

.warehouse-trigger .trigger-icon {
  color: #64748b;
  display: flex;
  align-items: center;
}

.warehouse-trigger .trigger-label {
  font-weight: 600;
  color: #0f172a;
}

/* Profile Trigger Customization */
.profile-trigger {
  padding: 4px 14px 4px 6px;
  gap: 12px;
}

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--color-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

.profile-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.profile-role-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 2px;
  line-height: 1.3;
}

/* Floating Dropdown Menus */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 290px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  animation: dropdownPop 0.16s var(--motion-ease);
}

.dropdown-menu.dropdown-menu-right {
  left: auto;
  right: 0;
  min-width: 360px;
}

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

@keyframes dropdownPop {
  0% { opacity: 0; transform: translateY(-6px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-menu-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
  font-weight: 600;
  padding: 8px 12px 6px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 4px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--motion-fast) ease;
}

.dropdown-item:hover {
  background-color: var(--color-surface-hover);
}

.dropdown-item.active {
  background-color: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: 600;
}

/* Warehouse Dots & Badges */
.wh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wh-dot.all { background: var(--color-accent); }
.wh-dot.rc { background: #8b5cf6; }
.wh-dot.store { background: #10b981; }
.wh-dot.wb { background: #a855f7; }
.wh-dot.ozon { background: #0284c7; }

.wh-name {
  flex: 1;
}

.wh-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: #f1f5f9;
  color: #64748b;
  font-weight: 600;
}

/* Role Dropdown Items */
.role-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.role-icon-box.buyer { background: #eff6ff; color: #2563eb; }
.role-icon-box.analyst { background: #f5f3ff; color: #7c3aed; }
.role-icon-box.warehouse { background: #ecfdf5; color: #059669; }
.role-icon-box.admin { background: #fef2f2; color: #dc2626; }

.role-desc-box {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.role-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
}

.role-sub {
  font-size: 11.5px;
  color: var(--color-text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

.check-icon {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-accent);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}

/* Topbar Status Badge */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.engine-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-success-subtle);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* -------------------------------------------------------------
   Universal Form Controls & Inputs (Clean 44px Fitts's standard)
   ------------------------------------------------------------- */
select.input,
.select-input,
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 44px;
  line-height: 42px;
  padding: 0 42px 0 16px;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: all var(--motion-fast) ease;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select.input:hover,
select:hover {
  border-color: #94a3b8;
  background-color: #f8fafc;
}

select.input:focus,
select:focus {
  border-color: var(--color-accent);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.input,
input[type="text"],
input[type="number"] {
  height: 44px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 14px;
  color: var(--color-text);
  background: #ffffff;
  outline: none;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-xs);
  transition: all var(--motion-fast) ease;
}

.input:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.table-input {
  width: 96px;
  height: 38px;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  padding: 0 10px;
}

/* -------------------------------------------------------------
   Page Container & Spacing Rhythm (KeepSimple UX Core)
   ------------------------------------------------------------- */
#viewContainer {
  padding: 40px 48px 80px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  height: calc(100vh - 72px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 24px;
  flex-wrap: wrap;
}

.page-title h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.page-title p {
  font-size: 14.5px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Cards & Surface Containers */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  margin-bottom: 32px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Metric KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

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

.kpi-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  letter-spacing: -0.03em;
  margin: 6px 0;
}

.kpi-subtext {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-subtext.positive { color: var(--color-success); font-weight: 600; }
.kpi-subtext.negative { color: var(--color-danger); font-weight: 600; }
.kpi-subtext.neutral { color: var(--color-text-muted); }

/* -------------------------------------------------------------
   Spacious Table & DataGrid (getdesign.md & UX Core standard)
   ------------------------------------------------------------- */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-card);
}

.datagrid {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.datagrid th {
  background: #f8fafc;
  height: 50px;
  padding: 0 24px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Prevent wheel accidental increment on number inputs */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

.datagrid td {
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--color-text-secondary);
  vertical-align: middle;
  height: 56px;
}

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

.datagrid tr:hover td {
  background-color: #f8fafc;
}

.cell-mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
}

.cell-number {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  text-align: right;
  letter-spacing: -0.01em;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.badge-a { background: #dcfce7; color: #15803d; }
.badge-b { background: #fef9c3; color: #854d0e; }
.badge-c { background: #fee2e2; color: #b91c1c; }
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #ffedd5; color: #c2410c; }
.badge-ok { background: #ecfdf5; color: #047857; }
.badge-purple { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--motion-fast) ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
  border-color: var(--color-accent);
}

.btn-primary:hover {
  background-color: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--color-text-secondary);
  border-color: var(--color-border-input);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  color: var(--color-text);
}

.btn-success {
  background-color: var(--color-success);
  color: #ffffff;
  border-color: var(--color-success);
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background-color: #059669;
  border-color: #059669;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

/* 3x3 ABC-XYZ Matrix */
.matrix-grid {
  display: grid;
  grid-template-columns: 120px repeat(3, 1fr);
  gap: 16px;
  margin: var(--space-5) 0;
}

.matrix-header-col {
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 10px 4px;
}

.matrix-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-muted);
}

.matrix-cell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  cursor: pointer;
  transition: all var(--motion-fast) ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.matrix-cell:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.matrix-cell.selected {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.05);
  box-shadow: 0 0 0 2px var(--color-accent);
}

.matrix-cell-code {
  font-weight: 700;
  font-size: 18px;
  font-family: var(--font-mono);
}

.matrix-cell-count {
  font-size: 13px;
  color: var(--color-text-muted);
}

.matrix-cell.heat-green { border-left: 5px solid var(--color-success); }
.matrix-cell.heat-yellow { border-left: 5px solid var(--color-warning); }
.matrix-cell.heat-red { border-left: 5px solid var(--color-danger); }

/* Supplier Constraint Bar (S04) */
.constraint-bar {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 24px;
}

.constraint-metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.constraint-progress-track {
  width: 240px;
  height: 12px;
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.constraint-progress-fill {
  height: 100%;
  background: var(--color-warning);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.constraint-progress-fill.satisfied {
  background: var(--color-success);
}

/* Nav Item Restrictions */
.nav-item.nav-restricted {
  opacity: 0.55;
}

.nav-item.nav-restricted:hover {
  background-color: rgba(239, 68, 68, 0.05);
  color: var(--color-danger);
}

/* RBAC Denied Screen */
.rbac-denied-container {
  padding: 64px 40px;
  text-align: center;
  max-width: 640px;
  margin: 60px auto;
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-dropdown);
}

.rbac-denied-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.rbac-denied-icon svg {
  width: 34px;
  height: 34px;
}

/* Responsive */
@media (max-width: 1024px) {
  #viewContainer {
    padding: 24px;
  }
  .topbar {
    padding: 0 20px;
  }
  .sidebar {
    position: fixed;
    height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-menu-btn {
    display: block;
  }
}

/* -------------------------------------------------------------
   Interactive Modals & Overlays (UX Core & KeepSimple Standard)
   ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--motion-fast) ease, visibility var(--motion-fast) ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.96) translateY(8px);
  transition: transform var(--motion-fast) cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-box {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #f8fafc;
}

.modal-header-text h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 4px 0;
}

.modal-header-text p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: #ffffff;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--motion-fast) ease;
}

.modal-close-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

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

.modal-footer {
  padding: 20px 28px;
  border-top: 1px solid var(--color-border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* -------------------------------------------------------------
   Toast Notification System (UX Core Micro-Feedback)
   ------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 320px;
  max-width: 440px;
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateY(16px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.toast.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast.toast-warning {
  border-left: 4px solid var(--color-warning);
}

.toast.toast-info {
  border-left: 4px solid var(--color-accent);
}

.toast-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-accent); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.toast-desc {
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* -------------------------------------------------------------
   Filter Tabs (S02 Inventory Filter Bar)
   ------------------------------------------------------------- */
.filter-tabs {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  gap: 4px;
}

.filter-tab {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--motion-fast) ease;
  font-family: var(--font-sans);
}

.filter-tab:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.6);
}

.filter-tab.active {
  background: #ffffff;
  color: var(--color-accent);
  box-shadow: var(--shadow-xs);
}

.tab-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: #e2e8f0;
  color: #475569;
  font-family: var(--font-mono);
  font-weight: 700;
}

.filter-tab.active .tab-badge {
  background: #dbeafe;
  color: #1d4ed8;
}

.tab-badge.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.tab-badge.warning {
  background: #fef3c7;
  color: #b45309;
}

/* -------------------------------------------------------------
   Dead Stock & Expiry Visual Signals
   ------------------------------------------------------------- */
.badge-deadstock {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-weight: 600;
}

.badge-expiring {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  font-weight: 600;
}

.alert-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.alert-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.alert-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: #ffedd5;
  color: #ea580c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-banner-text h4 {
  font-size: 14.5px;
  font-weight: 600;
  color: #9a3412;
  margin: 0 0 2px 0;
}

.alert-banner-text p {
  font-size: 13px;
  color: #7c2d12;
  margin: 0;
}

/* -------------------------------------------------------------
   Promo Simulator Controls (S03 Demand Forecasting)
   ------------------------------------------------------------- */
.promo-simulator-card {
  background: linear-gradient(180deg, #fbf7ff 0%, #ffffff 100%);
  border: 1px solid #e9d5ff;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: 0 2px 8px rgba(147, 51, 234, 0.06);
}

.promo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.promo-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.promo-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #f3e8ff;
  color: #7e22ce;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.promo-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: #581c87;
  margin: 0 0 2px 0;
}

.promo-title-group p {
  font-size: 13px;
  color: #7e22ce;
  margin: 0;
}

.promo-switch-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}

.promo-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  padding-top: 16px;
  border-top: 1px solid #f3e8ff;
}

.promo-control-item label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b21a8;
  margin-bottom: 8px;
}

.promo-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.promo-chip {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid #d8b4fe;
  background: #ffffff;
  color: #7e22ce;
  cursor: pointer;
  transition: all var(--motion-fast) ease;
}

.promo-chip:hover {
  background: #f3e8ff;
}

.promo-chip.active {
  background: #7e22ce;
  color: #ffffff;
  border-color: #7e22ce;
  box-shadow: 0 2px 6px rgba(126, 34, 206, 0.25);
}

.promo-metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-top: 20px;
}

.promo-metric-sub {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.promo-metric-sub .lbl {
  font-size: 11.5px;
  color: #7e22ce;
  font-weight: 600;
}

.promo-metric-sub .val {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #4c1d95;
}

/* -------------------------------------------------------------
   Supplier Comparison Matrix & Savings Highlighting (S04)
   ------------------------------------------------------------- */
.savings-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.savings-banner {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.savings-banner .title {
  font-size: 14px;
  font-weight: 700;
  color: #065f46;
  margin-bottom: 2px;
}

.savings-banner .desc {
  font-size: 12.5px;
  color: #047857;
}

.supplier-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.supplier-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: all var(--motion-fast) ease;
}

.supplier-card.active {
  border-color: var(--color-accent);
  background: #f8faff;
}

.supplier-card.recommended {
  border-color: var(--color-success);
  background: #f0fdf4;
}

.supplier-card-badge {
  position: absolute;
  top: -12px;
  right: 18px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.supplier-card.active .supplier-card-badge {
  background: var(--color-accent);
  color: #ffffff;
}

.supplier-card.recommended .supplier-card-badge {
  background: var(--color-success);
  color: #ffffff;
}

.supplier-card-header h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 4px 0;
}

.supplier-card-header .type {
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.supplier-stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
}

.supplier-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 6px;
}

.supplier-stat-row:last-child {
  border-bottom: none;
}

.supplier-stat-label {
  color: var(--color-text-muted);
}

.supplier-stat-value {
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text);
}

.supplier-stat-value.highlight-green {
  color: var(--color-success);
}

/* -------------------------------------------------------------
   Connector Gateway Hub & Integration Modals (Screen S07)
   ------------------------------------------------------------- */
.connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.connector-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: transform var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
  position: relative;
  overflow: hidden;
}

.connector-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-dropdown);
}

.connector-card.wb { border-top: 4px solid #8b5cf6; }
.connector-card.ozon { border-top: 4px solid #0284c7; }
.connector-card.onec { border-top: 4px solid #d97706; }

.connector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.connector-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.connector-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #ffffff;
}

.connector-logo-badge.wb { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.connector-logo-badge.ozon { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.connector-logo-badge.onec { background: linear-gradient(135deg, #d97706, #f59e0b); }

.connector-title h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 2px 0;
}

.connector-title p {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0;
}

.connector-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.connector-status-badge.active {
  background: #dcfce7;
  color: #15803d;
}

.connector-status-badge.warning {
  background: #fef3c7;
  color: #b45309;
}

.connector-body {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.connector-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-text-muted);
}

.connector-detail-row strong {
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.connector-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}

.integration-guide-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
  margin-top: 24px;
}

.guide-step-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: all var(--motion-fast) ease;
}

.guide-step-card:hover {
  background: #f1f5f9;
}

.guide-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.guide-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.guide-step-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text);
  flex: 1;
}

.guide-step-content {
  margin-top: 12px;
  padding-left: 40px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.guide-step-content ol, .guide-step-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.guide-step-content li {
  margin-bottom: 6px;
}

.code-snippet {
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 8px 0;
  display: block;
  overflow-x: auto;
}

.test-result-box {
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13px;
  display: none;
}

.test-result-box.success {
  display: block;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.test-result-box.testing {
  display: block;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.test-result-box.error {
  display: block;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* -------------------------------------------------------------
   Warehouse Context Filter Banner (All Screens S01-S08)
   ------------------------------------------------------------- */
.warehouse-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.06) 0%, rgba(30, 41, 59, 0.03) 100%);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-left: 4px solid var(--color-primary, #0284c7);
  border-radius: var(--radius-md, 8px);
  padding: 12px 18px;
  margin-bottom: 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  animation: slideDownFade 0.2s ease-out;
}

.wh-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wh-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wh-banner-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.wh-banner-title strong {
  color: var(--color-primary, #0284c7);
  font-weight: 700;
}

.wh-banner-sub {
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
}

.wh-banner-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm, 6px);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.wh-banner-reset:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

/* -------------------------------------------------------------
   Custom Supplier Dropdown Popover (S05 Auto-Order)
   ------------------------------------------------------------- */
.supplier-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.supplier-trigger {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  min-width: 380px;
  max-width: 480px;
  padding: 0 16px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.supplier-trigger:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.supplier-dropdown-wrap.open .supplier-trigger {
  border-color: var(--color-primary, #0284c7);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
  background: #ffffff;
}

.supplier-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(2, 132, 199, 0.1);
  color: var(--color-primary, #0284c7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.supplier-trigger-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

.supplier-trigger-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.supplier-trigger-meta {
  font-size: 11.5px;
  color: var(--color-text-secondary, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.supplier-dropdown-menu {
  min-width: 440px;
  max-width: 520px;
  max-height: 440px;
  overflow-y: auto;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--color-border);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 8px;
  z-index: 200;
}

.supplier-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  width: 100%;
  text-align: left;
}

.supplier-item:hover {
  background: #f1f5f9;
}

.supplier-item.active {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.25);
}

.supplier-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.supplier-item.active .supplier-avatar {
  background: var(--color-primary, #0284c7);
  color: #ffffff;
}

.supplier-item-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.supplier-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.supplier-item-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sup-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

.sup-tag.moq {
  background: #fef3c7;
  color: #92400e;
}

.sup-tag.lead {
  background: #e0f2fe;
  color: #0369a1;
}

.sup-tag.delay {
  background: #f1f5f9;
  color: #475569;
}

.supplier-item .check-icon {
  color: var(--color-primary, #0284c7);
  font-weight: 700;
  font-size: 16px;
  margin-left: 8px;
}



