/*
 * MAKKOOK Decision Intelligence Platform
 * Component Library v2.0
 */

/* ============================================
   APP LAYOUT
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR — Enterprise Grade
   ============================================ */
.sidebar {
  width: 252px;
  background: #1a1a1a;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin-bottom: 0;
}

.sidebar-brand img {
  height: 22px;
  opacity: 0.9;
}

.sidebar-brand span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #E1541D, #FF6B35);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: #EFEFEF;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-title span {
  color: #E1541D;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section:first-child {
  margin-top: 4px;
}

.nav-label {
  padding: 12px 8px 6px;
  font-size: 10px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1;
}

.nav-section:not(:first-child) .nav-label {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 4px;
  padding-top: 16px;
}

.sidebar-section {
  padding: 12px 8px 6px;
  font-size: 10px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.04);
  margin: 4px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #9B9B9B;
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
  margin-bottom: 1px;
  letter-spacing: 0.01em;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #C6C6C6;
}

.nav-item.active {
  background: rgba(225, 84, 29, 0.1);
  color: #E1541D;
  font-weight: 550;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: #E1541D;
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.55;
}

.nav-item:hover .nav-icon {
  opacity: 0.75;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: #E1541D;
  background: rgba(225, 84, 29, 0.12);
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.4;
  letter-spacing: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(225, 84, 29, 0.12);
  color: #E1541D;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-details {
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #C6C6C6;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: #666;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  overflow-x: hidden;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.page-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-1);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.page-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-shrink: 0;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
  outline: none;
  height: 36px;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--color-bg-primary), 0 0 0 4px var(--color-primary);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-sm {
  height: 30px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  height: 44px;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
}

.btn-icon {
  width: 36px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 30px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color var(--duration-base) var(--ease-out);
}

.card:hover {
  border-color: var(--color-border-hover);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--duration-base) var(--ease-out);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--duration-base);
}

.kpi-card:hover {
  border-color: var(--color-border-accent);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-label {
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  font-family: var(--font-mono);
  color: var(--color-text-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.kpi-change {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.kpi-change.positive {
  color: var(--color-success);
}

.kpi-change.negative {
  color: var(--color-error);
}

.kpi-change.neutral {
  color: var(--color-text-tertiary);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}

.badge-success {
  background: var(--color-success-dim);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-dim);
  color: var(--color-warning);
}

.badge-error {
  background: var(--color-error-dim);
  color: var(--color-error);
}

.badge-info {
  background: var(--color-info-dim);
  color: var(--color-info);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-secondary);
}

.badge-primary {
  background: var(--color-primary-glow);
  color: var(--color-primary);
}

/* ============================================
   STATUS DOT
   ============================================ */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.live {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
  animation: pulse 2s var(--ease-in-out) infinite;
}

.status-dot.warning {
  background: var(--color-warning);
}

.status-dot.error {
  background: var(--color-error);
}

.status-dot.idle {
  background: var(--color-text-muted);
}

/* ============================================
   TABLES
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.data-table tbody tr {
  transition: background var(--duration-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress {
  width: 100%;
  height: 6px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  transition: width 1s var(--ease-out);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  animation: shimmer 2.5s infinite;
}

.progress-lg {
  height: 10px;
}

.progress-xl {
  height: 14px;
}

.progress-fill.success {
  background: var(--color-success);
}

.progress-fill.warning {
  background: var(--color-warning);
}

.progress-fill.error {
  background: var(--color-error);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border-left: 3px solid;
  font-size: var(--text-sm);
}

.alert-error {
  background: var(--color-error-dim);
  border-left-color: var(--color-error);
}

.alert-warning {
  background: var(--color-warning-dim);
  border-left-color: var(--color-warning);
}

.alert-success {
  background: var(--color-success-dim);
  border-left-color: var(--color-success);
}

.alert-info {
  background: var(--color-info-dim);
  border-left-color: var(--color-info);
}

.alert-icon {
  font-size: var(--text-base);
  flex-shrink: 0;
  line-height: 1;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  margin-bottom: 2px;
}

.alert-message {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin: 0;
}

.alert-action {
  flex-shrink: 0;
  align-self: center;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s var(--ease-out);
  padding: var(--space-6);
}

.modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: fadeInUp 0.3s var(--ease-out);
}

.modal-lg {
  max-width: 1000px;
}

.modal-sm {
  max-width: 500px;
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--color-text-tertiary);
  font-size: var(--text-2xl);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ============================================
   INDUSTRY CARDS (Landing)
   ============================================ */
.industry-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8) var(--space-6);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.industry-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-glow);
  opacity: 0;
  transition: opacity var(--duration-base);
}

.industry-card:hover {
  border-color: var(--color-border-accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
}

.industry-card:hover::after {
  opacity: 1;
}

.industry-card>* {
  position: relative;
  z-index: 1;
}

.industry-card-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  line-height: 1;
}

.industry-card-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
}

.industry-card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-5);
}

.industry-card-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-success);
  margin-bottom: var(--space-3);
}

.industry-card-metrics {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.industry-card-metrics .value {
  color: var(--color-primary);
}

/* ============================================
   GANTT CHART
   ============================================ */
.gantt-container {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-bg-secondary);
}

.gantt-header-row {
  display: grid;
  gap: 1px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.gantt-day-label {
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
}

.gantt-day-date {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  font-weight: var(--font-normal);
}

.gantt-body {
  padding: var(--space-3) var(--space-4);
}

.gantt-row {
  display: grid;
  gap: 2px;
  margin-bottom: var(--space-3);
  align-items: center;
  min-height: 52px;
}

.gantt-line-label {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  padding-right: var(--space-3);
}

.gantt-block {
  height: 44px;
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-2xs);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-weight: var(--font-medium);
  position: relative;
  overflow: hidden;
}

.gantt-block:hover {
  filter: brightness(1.2);
  transform: scaleY(1.08);
  z-index: 5;
}

.gantt-block.production {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563EB 100%);
}

.gantt-block.vip {
  background: var(--gradient-vip);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.3);
}

.gantt-block.changeover {
  background: var(--color-warning);
  min-width: 18px;
  flex: 0 0 auto;
  align-items: center;
}

.gantt-block.maintenance {
  background: repeating-linear-gradient(45deg, var(--color-bg-elevated), var(--color-bg-elevated) 8px, var(--color-bg-tertiary) 8px, var(--color-bg-tertiary) 16px);
  border: 1px dashed var(--color-border-hover);
}

.gantt-block.breakdown {
  background: linear-gradient(135deg, #991b1b 0%, #ef4444 100%);
}

.gantt-product {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
  font-size: var(--text-2xs);
}

.gantt-customer {
  font-size: 9px;
  opacity: 0.75;
}

/* ============================================
   CONSTRAINTS PANEL
   ============================================ */
.constraint-group {
  margin-bottom: var(--space-5);
}

.constraint-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.constraint-group-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.constraint-count {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.constraint-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.constraint-check {
  color: var(--color-success);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

/* ============================================
   OPTIMIZATION PROGRESS
   ============================================ */
.opt-progress {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-accent);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  text-align: center;
}

.opt-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-6);
}

.opt-bar-container {
  height: 12px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-8);
  position: relative;
}

.opt-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s var(--ease-out);
  position: relative;
}

.opt-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 1.5s infinite;
}

.opt-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-6);
}

.opt-stat-label {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.opt-stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
}

/* ============================================
   COMPARISON TABLE
   ============================================ */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
}

.comparison-table th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--color-border);
  text-align: center;
}

.comparison-table th:first-child {
  text-align: left;
}

.comparison-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  text-align: center;
}

.comparison-table td:first-child {
  text-align: left;
  color: var(--color-text-secondary);
}

.comparison-table .col-before {
  color: var(--color-text-muted);
}

.comparison-table .col-after {
  color: var(--color-text-primary);
  font-weight: var(--font-semibold);
}

.comparison-table .col-impact {
  font-weight: var(--font-bold);
  font-family: var(--font-mono);
}

.comparison-table .col-impact.positive {
  color: var(--color-success);
}

.comparison-table .col-impact.negative {
  color: var(--color-error);
}

/* ============================================
   TOOLTIP
   ============================================ */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  z-index: 100;
}

.tooltip:hover::after {
  opacity: 1;
}

/* ============================================
   SECTION DIVIDER
   ============================================ */
.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-6) 0;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: var(--space-1);
  background: var(--color-bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-lg);
  width: fit-content;
}

.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast);
  border: none;
  background: transparent;
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--color-text-secondary);
}

.tab.active {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-xs);
}

/* ============================================
   METRIC HIGHLIGHT
   ============================================ */
.metric-highlight {
  padding: var(--space-6);
  background: var(--color-primary-glow);
  border: 1px solid var(--color-border-accent);
  border-radius: var(--radius-xl);
  text-align: center;
}

.metric-highlight-label {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
}

.metric-highlight-value {
  font-size: var(--text-5xl);
  font-weight: var(--font-extrabold);
  font-family: var(--font-mono);
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.metric-highlight-sub {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: var(--text-5xl);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

/* ============================================
   MOBILE HAMBURGER TOGGLE
   ============================================ */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
}

/* ============================================
   RESPONSIVE — TABLET (≤1024px)
   ============================================ */
@media (max-width: 1024px) {
  .main-content {
    padding: var(--space-5) var(--space-6);
  }

  .page-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* ============================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================ */
@media (max-width: 768px) {
  /* Show hamburger */
  .sidebar-toggle {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.active {
    pointer-events: all;
  }

  /* Sidebar off-canvas */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 150;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Main content full width */
  .main-content {
    padding: 60px var(--space-4) var(--space-4);
    width: 100%;
  }

  .page-header {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .page-title {
    font-size: var(--text-2xl);
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-actions .btn {
    flex: 1;
    min-width: 0;
    font-size: var(--text-xs);
  }

  /* KPI grid — 2 columns on mobile */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-3);
  }

  /* Cards — reduce padding */
  .card {
    border-radius: var(--radius-lg);
  }

  .card-body {
    padding: var(--space-4);
  }

  /* Tabs — scrollable */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Status bar inline items */
  .status-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* Override common inline grid layouts */
  [style*="grid-template-columns: repeat(5"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns: 280px 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Scrollable tables */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  thead, tbody, tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  /* Inline flex layouts — stack on mobile */
  .header-actions {
    flex-wrap: wrap;
    gap: var(--space-2) !important;
  }

  .content-scrollable {
    padding: 0 !important;
  }

  /* Large inline font sizes — scale down */
  [style*="font-size: 42px"] {
    font-size: 28px !important;
  }

  [style*="font-size: 28px"] {
    font-size: 22px !important;
  }

  [style*="font-size: 20px"] {
    font-size: 16px !important;
  }

  /* Inline flex space-between rows — allow wrapping */
  [style*="display: flex"][style*="justify-content: space-between"] {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  /* Page-specific grid classes (defined in <style> tags, not inline) */
  .opt-grid,
  .impact-grid,
  .promo-metrics,
  .summary-stats,
  .options-grid {
    grid-template-columns: 1fr !important;
  }

  .order-details-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .promo-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Status indicators */
  .status-indicator {
    font-size: 11px;
  }

  /* Notification toasts */
  .notification-container {
    left: 8px !important;
    right: 8px !important;
    max-width: 100% !important;
  }

  /* Modals */
  .opt-content,
  .optimization-modal .opt-content {
    max-width: 95vw !important;
    padding: 20px !important;
    border-radius: 16px !important;
  }
}

/* ============================================
   RESPONSIVE — SMALL MOBILE (≤480px)
   ============================================ */
@media (max-width: 480px) {
  .main-content {
    padding: 56px var(--space-3) var(--space-3);
  }

  .page-title {
    font-size: var(--text-xl);
  }

  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(2"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(5"] {
    grid-template-columns: 1fr !important;
  }

  .page-actions .btn {
    font-size: 11px;
    height: 32px;
    padding: var(--space-1) var(--space-2);
  }

  .solver-gauge {
    width: 140px !important;
    height: 140px !important;
  }

  .gauge-value {
    font-size: 28px !important;
  }

  [style*="font-size: 42px"] {
    font-size: 24px !important;
  }

  [style*="font-size: 28px"] {
    font-size: 18px !important;
  }

  /* Promo grids */
  .promo-grid {
    grid-template-columns: 1fr !important;
  }

  /* Scenario cards */
  .scenario-cards {
    grid-template-columns: 1fr !important;
  }

  /* Metric grid in optimization */
  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}