/* =========================================
   PROCESS LIFECYCLE VISUALIZER - STYLE.CSS
   Premium Dark UI with Glassmorphism
   ========================================= */

:root {
  --bg-base: #050813;
  --bg-surface: rgba(255, 255, 255, 0.04);
  --bg-surface-hover: rgba(255, 255, 255, 0.07);
  --bg-elevated: rgba(255, 255, 255, 0.08);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(124, 58, 237, 0.4);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;

  --accent-purple: #7C3AED;
  --accent-blue: #3B82F6;
  --accent-indigo: #4F8EF7;
  --accent-teal: #14b8a6;

  /* Process States */
  --state-new: #f59e0b;
  --state-ready: #3b82f6;
  --state-running: #22c55e;
  --state-waiting: #f97316;
  --state-terminated: #6b7280;

  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.15);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

/* =====================
   ANIMATED BACKGROUND
   ===================== */
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #7C3AED 0%, transparent 70%);
  top: -150px; left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #2563EB 0%, transparent 70%);
  top: 20%; right: -120px;
  animation-delay: -7s;
}

.orb-3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #0f766e 0%, transparent 70%);
  bottom: -100px; left: 40%;
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

.particle-field {
  position: absolute;
  inset: 0;
}

.particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.6);
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 0.5; }
  100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* =====================
   GLASS PANEL
   ===================== */
.glass-panel {
  background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  position: relative;
  z-index: 1;
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 50%);
  pointer-events: none;
}

/* =====================
   HEADER
   ===================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, rgba(5,8,19,0.95) 0%, rgba(20,14,50,0.92) 100%);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 30px rgba(0,0,0,0.4);
}

.header-inner {
  max-width: 1800px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

.brand-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(79,142,247,0.2));
  border: 1px solid rgba(124,58,237,0.4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.clock-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}

.clock-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-indigo);
  text-shadow: 0 0 20px rgba(79,142,247,0.5);
}

.cpu-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.cpu-badge.running {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.4);
  color: #4ade80;
}

.cpu-badge.switching {
  background: rgba(250,204,21,0.12);
  border-color: rgba(250,204,21,0.4);
  color: #fde047;
}

.cpu-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s ease;
}

.cpu-badge.running .cpu-dot {
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  animation: dotPulse 1s ease infinite;
}

.cpu-badge.switching .cpu-dot {
  background: #fde047;
  box-shadow: 0 0 8px #fde047;
  animation: dotPulse 0.5s ease infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

/* =====================
   MAIN LAYOUT
   ===================== */
.app-main {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 70px);
  align-items: start;
}

/* =====================
   SIDEBAR (LEFT)
   ===================== */
.sidebar-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar-panel::-webkit-scrollbar { width: 4px; }
.sidebar-panel::-webkit-scrollbar-track { background: transparent; }
.sidebar-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

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

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header h2 svg {
  color: var(--accent-purple);
  flex-shrink: 0;
}

.config-section {
  margin-bottom: 18px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Algorithm Selector */
.algo-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.algo-btn {
  padding: 10px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
}

.algo-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-purple);
  color: var(--text-primary);
}

.algo-btn.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.25), rgba(79,142,247,0.15));
  border-color: var(--accent-purple);
  color: #c4b5fd;
  box-shadow: 0 0 20px rgba(124,58,237,0.2);
}

.algo-short {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.algo-full {
  font-size: 10px;
  text-align: center;
  line-height: 1.3;
}

/* Sliders */
.slider-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent-purple) 0%, var(--accent-blue) 100%);
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(124,58,237,0.6);
  transition: transform 0.2s ease;
}

.range-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.range-value {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-indigo);
  min-width: 30px;
  text-align: right;
}

/* Input Groups */
.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.text-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.text-input:focus {
  border-color: var(--accent-purple);
  background: rgba(124,58,237,0.08);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.text-input::-webkit-inner-spin-button { opacity: 0.5; }

/* Buttons */
.btn-add {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(124,58,237,0.5);
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(79,142,247,0.1));
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
}

.btn-add:hover {
  background: linear-gradient(135deg, rgba(124,58,237,0.35), rgba(79,142,247,0.2));
  box-shadow: 0 0 20px rgba(124,58,237,0.3);
  transform: translateY(-1px);
}

.scenario-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-scenario {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.btn-scenario:hover {
  background: rgba(79,142,247,0.1);
  border-color: rgba(79,142,247,0.4);
  color: #93c5fd;
}

.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
  margin: 4px 0 16px;
}

.control-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-primary, .btn-secondary, .btn-step, .btn-danger {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #7C3AED, #4F8EF7);
  color: #fff;
  box-shadow: 0 4px 15px rgba(124,58,237,0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(124,58,237,0.5);
}

.btn-secondary {
  background: linear-gradient(135deg, #1e3a5f, #1e4d8c);
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,0.3);
}

.btn-secondary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1e4d8c, #2563eb);
  border-color: rgba(59,130,246,0.6);
}

.btn-step {
  background: linear-gradient(135deg, rgba(20,184,166,0.2), rgba(20,184,166,0.1));
  color: #5eead4;
  border: 1px solid rgba(20,184,166,0.3);
}

.btn-step:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(20,184,166,0.3), rgba(20,184,166,0.15));
  border-color: rgba(20,184,166,0.6);
}

.btn-danger {
  background: linear-gradient(135deg, rgba(239,68,68,0.2), rgba(239,68,68,0.1));
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(239,68,68,0.3), rgba(239,68,68,0.15));
  border-color: rgba(239,68,68,0.6);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-clear {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear:hover {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.3);
  color: #fca5a5;
}

/* =====================
   CENTER SECTION
   ===================== */
.center-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* PCB Table */
.process-table-panel {
  padding: 20px;
}

.table-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.new-dot { background: var(--state-new); }
.ready-dot { background: var(--state-ready); }
.running-dot { background: var(--state-running); }
.waiting-dot { background: var(--state-waiting); }
.terminated-dot { background: var(--state-terminated); }

.table-wrapper {
  overflow-x: auto;
  margin-top: 4px;
}

.pcb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pcb-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.pcb-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.2s ease;
}

.pcb-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

.pcb-table tr.row-running td {
  background: rgba(34,197,94,0.07);
}

.pcb-table tr.row-terminated td {
  opacity: 0.5;
}

.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-state p { font-size: 13px; }

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.badge-new { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-ready { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-running { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-waiting { background: rgba(249,115,22,0.15); color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.badge-terminated { background: rgba(107,114,128,0.15); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }

.pid-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #c4b5fd;
}

.mono-cell {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.delete-btn {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239,68,68,0.2);
  background: rgba(239,68,68,0.08);
  color: rgba(239,68,68,0.7);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.delete-btn:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.5);
  color: #fca5a5;
}

/* =====================
   MID ROW
   ===================== */
.mid-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  align-items: start;
}

/* State Diagram */
.state-diagram-panel {
  padding: 20px;
}

.state-diagram {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 16px;
  position: relative;
  padding-bottom: 60px;
  overflow: visible;
}

.state-node {
  flex-shrink: 0;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  transition: all 0.3s ease;
  border: 2px solid;
  cursor: default;
}

.state-node.active-node {
  transform: scale(1.12);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.1), var(--node-glow);
}

.node-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}

.node-count {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.new-node {
  background: radial-gradient(circle, rgba(245,158,11,0.2) 0%, transparent 70%);
  border-color: var(--state-new);
  color: var(--state-new);
  --node-glow: 0 0 30px rgba(245,158,11,0.4);
}

.ready-node {
  background: radial-gradient(circle, rgba(59,130,246,0.2) 0%, transparent 70%);
  border-color: var(--state-ready);
  color: var(--state-ready);
  --node-glow: 0 0 30px rgba(59,130,246,0.4);
}

.running-node {
  background: radial-gradient(circle, rgba(34,197,94,0.2) 0%, transparent 70%);
  border-color: var(--state-running);
  color: var(--state-running);
  --node-glow: 0 0 30px rgba(34,197,94,0.4);
}

.waiting-node {
  background: radial-gradient(circle, rgba(249,115,22,0.2) 0%, transparent 70%);
  border-color: var(--state-waiting);
  color: var(--state-waiting);
  --node-glow: 0 0 30px rgba(249,115,22,0.4);
}

.terminated-node {
  background: radial-gradient(circle, rgba(107,114,128,0.2) 0%, transparent 70%);
  border-color: var(--state-terminated);
  color: var(--state-terminated);
  --node-glow: 0 0 30px rgba(107,114,128,0.3);
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--state-running);
  animation: pulseRing 2s ease-out infinite;
  opacity: 0;
}

@keyframes pulseRing {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* Arrows between state nodes */
.arrow-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex: 1;
  min-width: 40px;
}

.arrow-line {
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, rgba(255,255,255,0.2), rgba(255,255,255,0.4), rgba(255,255,255,0.2));
  position: relative;
}

.arrow-line::after {
  content: '';
  position: absolute;
  right: -1px; top: -4px;
  border: 5px solid transparent;
  border-left: 8px solid rgba(255,255,255,0.5);
}

.arrow-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  font-style: italic;
}

/* Vertical arrow (Running → Waiting) */
.ag-run-wait {
  position: absolute;
  left: calc(90px * 2 + 40px * 2 + 45px);
  top: 90px;
  flex-direction: column;
  align-items: center;
  width: 2px;
}

.vert-arrow {
  width: 2px !important;
  height: 50px;
  background: linear-gradient(to bottom, rgba(249,115,22,0.4), rgba(249,115,22,0.2)) !important;
}

.vert-arrow::after {
  content: '';
  position: absolute;
  bottom: -1px; left: -4px;
  border: 5px solid transparent;
  border-top: 8px solid rgba(249,115,22,0.5);
  border-left: none;
}

.down-label {
  position: absolute;
  top: 55px;
  left: 8px;
  color: rgba(249,115,22,0.7) !important;
}

/* Return arrow (Waiting → Ready) */
.ag-wait-ready {
  position: absolute;
  bottom: 10px;
  left: 45px;
  width: calc(90px + 40px + 45px);
}

.top-return-arrow {
  width: 100% !important;
  height: 2px;
  background: linear-gradient(to left, rgba(59,130,246,0.4), rgba(59,130,246,0.2)) !important;
}

.top-return-arrow::after {
  content: '';
  position: absolute;
  left: -1px; top: -4px;
  border: 5px solid transparent;
  border-right: 8px solid rgba(59,130,246,0.5);
  border-left: none;
}

.top-return-label {
  position: absolute;
  top: 6px;
  left: 20px;
  color: rgba(59,130,246,0.7) !important;
}

/* Preempt arrow (Running → Ready, only in RR) */
.preempt-arrow {
  position: absolute;
  top: -18px;
  left: calc(90px + 40px);
  width: calc(90px + 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.preempt-arrow.visible { opacity: 1; }

.preempt-line {
  width: 100%;
  height: 2px;
  background: linear-gradient(to left, rgba(250,204,21,0.5), rgba(250,204,21,0.2));
  position: relative;
}

.preempt-line::after {
  content: '';
  position: absolute;
  left: -1px; top: -4px;
  border: 5px solid transparent;
  border-right: 8px solid rgba(250,204,21,0.5);
  border-left: none;
}

.preempt-label {
  font-size: 9px;
  color: rgba(250,204,21,0.7);
  margin-top: 3px;
  white-space: nowrap;
}

/* CPU Visualization */
.cpu-vis-panel {
  padding: 20px;
}

.cpu-display {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.cpu-chip {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cpu-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cpu-process-name {
  position: absolute;
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #c4b5fd;
  z-index: 2;
  text-shadow: 0 0 20px rgba(124,58,237,0.8);
  transition: all 0.3s ease;
  text-align: center;
}

.cpu-progress-ring {
  position: absolute;
  inset: 0;
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.cpu-remaining {
  position: absolute;
  bottom: 24px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  z-index: 2;
}

/* Context Switch Indicator */
.context-switch-indicator {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(250,204,21,0.06);
  border: 1px solid rgba(250,204,21,0.2);
  display: none;
  flex-direction: column;
  gap: 6px;
}

.context-switch-indicator.active { display: flex; }

.ctx-icon { font-size: 18px; text-align: center; }

.ctx-text {
  font-size: 12px;
  font-weight: 600;
  color: #fde047;
  text-align: center;
}

.ctx-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

.ctx-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #f59e0b, #fde047);
  transition: width 0.1s linear;
}

.cpu-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cpu-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.csi-label {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}

.csi-value {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  min-width: 60px;
  text-align: right;
}

.csi-bar {
  width: 60px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.csi-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent-purple), var(--accent-blue));
  transition: width 0.5s ease;
}

/* =====================
   QUEUES ROW
   ===================== */
.queues-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.queue-panel {
  padding: 16px;
}

.queue-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.ready-count {
  background: rgba(59,130,246,0.2);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.4);
}

.wait-count {
  background: rgba(249,115,22,0.2);
  color: #fb923c;
  border: 1px solid rgba(249,115,22,0.4);
}

.queue-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 50px;
  align-items: center;
  margin-top: 8px;
}

.queue-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.queue-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  animation: itemSlideIn 0.3s ease;
  position: relative;
  overflow: hidden;
}

.queue-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  opacity: 0.3;
}

.queue-item.ready-item {
  background: rgba(59,130,246,0.15);
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,0.3);
}

.queue-item.wait-item {
  background: rgba(249,115,22,0.15);
  color: #fdba74;
  border: 1px solid rgba(249,115,22,0.3);
}

.queue-order {
  font-size: 10px;
  opacity: 0.6;
  font-weight: 400;
}

@keyframes itemSlideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =====================
   GANTT CHART
   ===================== */
.gantt-panel {
  padding: 20px;
}

.gantt-wrapper {
  margin-top: 12px;
  overflow-x: auto;
}

.gantt-chart {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-height: 56px;
  position: relative;
}

.gantt-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  min-height: 56px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
}

.gantt-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 56px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  position: relative;
  transition: transform 0.2s ease;
  overflow: hidden;
  animation: ganttSlideIn 0.3s ease;
}

.gantt-block:hover { transform: scaleY(1.05); z-index: 2; }

.gantt-block.cpu-block {
  color: #fff;
}

.gantt-block.ctx-block {
  background: repeating-linear-gradient(45deg, rgba(250,204,21,0.1) 0px, rgba(250,204,21,0.1) 5px, transparent 5px, transparent 10px);
  border: 1px dashed rgba(250,204,21,0.4);
  color: rgba(250,204,21,0.8);
  font-size: 9px;
}

.gantt-block.io-block {
  background: rgba(249,115,22,0.15);
  border: 1px solid rgba(249,115,22,0.3);
  color: #fb923c;
  font-size: 9px;
}

.gantt-block.idle-block {
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.15);
  color: var(--text-muted);
  font-size: 10px;
}

.gantt-block-label {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 700;
}

.gantt-block-sub {
  font-size: 9px;
  opacity: 0.7;
  position: relative;
  z-index: 1;
}

.gantt-block-bg {
  position: absolute;
  inset: 0;
  opacity: 0.85;
}

@keyframes ganttSlideIn {
  from { transform: scaleX(0); transform-origin: left; opacity: 0; }
  to { transform: scaleX(1); transform-origin: left; opacity: 1; }
}

.gantt-timeline {
  display: flex;
  margin-top: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.gantt-tick {
  min-width: 36px;
  text-align: left;
  padding-left: 2px;
  border-left: 1px solid rgba(255,255,255,0.08);
}

/* =====================
   STATS PANEL
   ===================== */
.stats-panel {
  padding: 20px;
}

.algo-tag {
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(79,142,247,0.1));
  border: 1px solid rgba(124,58,237,0.4);
  color: #c4b5fd;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(124,58,237,0.3);
  transform: translateY(-2px);
}

.stat-icon { font-size: 20px; }

.stat-val {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
}

.stat-name {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
}

/* =====================
   LOG SIDEBAR
   ===================== */
.log-sidebar {
  padding: 20px;
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle-label input { display: none; }

.toggle-switch {
  width: 28px; height: 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border-color);
  position: relative;
  transition: all 0.2s ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s ease;
}

.toggle-label input:checked + .toggle-switch {
  background: rgba(124,58,237,0.3);
  border-color: var(--accent-purple);
}

.toggle-label input:checked + .toggle-switch::after {
  left: 14px;
  background: #c4b5fd;
}

.event-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding-right: 4px;
}

.event-log::-webkit-scrollbar { width: 4px; }
.event-log::-webkit-scrollbar-track { background: transparent; }
.event-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.log-entry {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  align-items: flex-start;
  animation: logSlide 0.25s ease;
  border-left: 2px solid;
}

@keyframes logSlide {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.log-time {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}

.log-msg { color: var(--text-secondary); line-height: 1.4; }

.log-info {
  background: rgba(59,130,246,0.06);
  border-color: rgba(59,130,246,0.3);
}
.log-info .log-time { color: #60a5fa; }

.log-success {
  background: rgba(34,197,94,0.06);
  border-color: rgba(34,197,94,0.3);
}
.log-success .log-time { color: #4ade80; }

.log-warn {
  background: rgba(250,204,21,0.06);
  border-color: rgba(250,204,21,0.3);
}
.log-warn .log-time { color: #fde047; }

.log-error {
  background: rgba(239,68,68,0.06);
  border-color: rgba(239,68,68,0.3);
}
.log-error .log-time { color: #fca5a5; }

.log-ctx {
  background: rgba(168,85,247,0.06);
  border-color: rgba(168,85,247,0.3);
}
.log-ctx .log-time { color: #c084fc; }

/* =====================
   CONTEXT SWITCH OVERLAY
   ===================== */
.ctx-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5,8,19,0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.ctx-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.ctx-overlay-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: overlayScale 0.3s ease;
}

@keyframes overlayScale {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.ctx-arrows {
  display: flex;
  align-items: center;
  gap: 24px;
}

.ctx-proc-out, .ctx-proc-in {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.ctx-proc-out {
  background: rgba(239,68,68,0.2);
  border: 2px solid rgba(239,68,68,0.5);
  color: #fca5a5;
  animation: procOut 0.5s ease forwards;
}

.ctx-proc-in {
  background: rgba(34,197,94,0.2);
  border: 2px solid rgba(34,197,94,0.5);
  color: #4ade80;
  animation: procIn 0.5s ease 0.3s both;
}

@keyframes procOut {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.9) translateX(-10px); opacity: 0.8; }
  100% { transform: scale(0.95); opacity: 0.9; }
}

@keyframes procIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.ctx-switch-icon { animation: spin 1s linear infinite; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ctx-overlay-text {
  font-size: 20px;
  font-weight: 700;
  color: #fde047;
}

.ctx-overlay-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

/* =====================
   RESPONSIVE SCALING
   ===================== */
@media (max-width: 1400px) {
  .app-main {
    grid-template-columns: 260px 1fr 260px;
  }
}

@media (max-width: 1100px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .sidebar-panel, .log-sidebar {
    position: static;
    max-height: none;
  }
  .mid-row {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* SVG Gradient for ring */
.ring-svg defs { display: block; }

/* Color palette for processes */
.proc-color-0 { background: linear-gradient(135deg, #7C3AED, #4F8EF7); }
.proc-color-1 { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.proc-color-2 { background: linear-gradient(135deg, #16a34a, #22c55e); }
.proc-color-3 { background: linear-gradient(135deg, #b45309, #f59e0b); }
.proc-color-4 { background: linear-gradient(135deg, #be185d, #ec4899); }
.proc-color-5 { background: linear-gradient(135deg, #7e22ce, #a855f7); }
.proc-color-6 { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.proc-color-7 { background: linear-gradient(135deg, #b91c1c, #ef4444); }

/* Inline SVG gradient injection */