/* ═══════════════════════════════════════════
   ASOSIY O'ZGARUVCHILAR VA RESET
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #06090f;
  --bg1:      #0b1020;
  --bg2:      #111827;
  --bg3:      #1a2235;
  --chegara:  #1e2d47;
  --chegara2: #253550;
  --asosiy:   #00d4ff;
  --asosiy2:  #f59e0b;
  --asosiy3:  #4ade80;
  --xavf:     #f87171;
  --matn:     #cdd6f4;
  --matn2:    #8ba0c4;
  --matn3:    #4a5f82;
  --mono:     'IBM Plex Mono', monospace;
  --sarlavha: 'Syne', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--matn);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════
   FON CANVAS + SKANLAR
═══════════════════════════════════════════ */
#bgCanvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; opacity: 0.07; pointer-events: none;
}
.scanlines {
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px);
  z-index: 1; pointer-events: none;
}

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(6,9,15,0.93);
  border-bottom: 1px solid var(--chegara);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1500px; margin: 0 auto;
  padding: 0 2rem; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
}
.logo { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.logo-bracket { font-family: var(--mono); font-size: 1.2rem; color: var(--asosiy); font-weight: 600; }
.logo-text { font-family: var(--sarlavha); font-size: 1.05rem; font-weight: 800; letter-spacing: 0.08em; }
.logo-accent { color: var(--asosiy); }
.logo-sub { font-size: 0.68rem; color: var(--matn3); letter-spacing: 0.05em; margin-left: 0.5rem; }

.tabs { display: flex; border: 1px solid var(--chegara); border-radius: 4px; overflow: hidden; }
.tab {
  background: transparent; border: none;
  color: var(--matn3); font-family: var(--mono);
  font-size: 0.68rem; letter-spacing: 0.05em;
  padding: 0.5rem 0.9rem; cursor: pointer; transition: all 0.2s;
  border-right: 1px solid var(--chegara);
}
.tab:last-child { border-right: none; }
.tab:hover { color: var(--asosiy); background: rgba(0,212,255,0.04); }
.tab.active { color: var(--asosiy); background: rgba(0,212,255,0.09); }

/* ═══════════════════════════════════════════
   TAB CONTENT
═══════════════════════════════════════════ */
.tab-content { display: none; position: relative; z-index: 2; min-height: calc(100vh - 56px); }
.tab-content.active { display: block; }

.sidebar-label {
  font-size: 0.63rem; letter-spacing: 0.12em;
  color: var(--asosiy); text-transform: uppercase;
  margin-bottom: 1rem; font-weight: 500;
}

/* ═══════════════════════════════════════════
   TAB 00: LOYIHA MAQSADI
═══════════════════════════════════════════ */
.maqsad-layout {
  max-width: 1200px; margin: 0 auto;
  padding: 3rem 2.5rem;
}

.maqsad-hero {
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--chegara);
  padding-bottom: 2.5rem;
}

.hero-badge {
  font-size: 0.65rem; letter-spacing: 0.14em;
  color: var(--asosiy); margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--sarlavha); font-size: 3rem;
  font-weight: 800; line-height: 1.1;
  color: var(--matn); margin-bottom: 1.25rem;
}

.hero-accent { color: var(--asosiy); }

.hero-desc {
  font-size: 0.92rem; color: var(--matn2);
  max-width: 680px; line-height: 1.8;
}

.maqsad-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.maqsad-card {
  background: var(--bg1);
  border: 1px solid var(--chegara);
  border-radius: 10px;
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
  animation: fadeSlide 0.5s ease both;
}
.maqsad-card:hover {
  border-color: var(--chegara2);
  transform: translateY(-2px);
}
.maqsad-card.primary {
  border-color: var(--asosiy);
  background: rgba(0,212,255,0.04);
}

.maqsad-card:nth-child(1) { animation-delay: 0.05s; }
.maqsad-card:nth-child(2) { animation-delay: 0.10s; }
.maqsad-card:nth-child(3) { animation-delay: 0.15s; }
.maqsad-card:nth-child(4) { animation-delay: 0.20s; }
.maqsad-card:nth-child(5) { animation-delay: 0.25s; }
.maqsad-card:nth-child(6) { animation-delay: 0.30s; }

.mcard-icon { font-size: 1.6rem; margin-bottom: 0.75rem; }
.mcard-title {
  font-family: var(--sarlavha); font-size: 0.95rem;
  font-weight: 700; color: var(--matn); margin-bottom: 0.6rem;
}
.mcard-body { font-size: 0.8rem; color: var(--matn2); line-height: 1.7; }

.maqsad-flow {
  background: var(--bg1);
  border: 1px solid var(--chegara);
  border-radius: 10px;
  padding: 2rem;
}

.flow-steps {
  display: flex; align-items: center;
  gap: 1rem; flex-wrap: wrap; margin-top: 1rem;
}

.flow-step {
  flex: 1; min-width: 200px;
  background: var(--bg2);
  border: 1px solid var(--chegara);
  border-radius: 8px; padding: 1.25rem;
}

.flow-num {
  font-family: var(--sarlavha); font-size: 1.4rem;
  font-weight: 800; color: var(--asosiy);
  margin-bottom: 0.5rem;
}

.flow-text {
  font-size: 0.8rem; color: var(--matn2); line-height: 1.65;
}
.flow-text strong { color: var(--matn); display: block; margin-bottom: 0.3rem; }

.flow-arrow {
  font-size: 1.5rem; color: var(--matn3); flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   TAB 01: HUJJATLAR
═══════════════════════════════════════════ */
.docs-layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 56px); }

.docs-sidebar {
  border-right: 1px solid var(--chegara);
  padding: 2rem 1.5rem; background: var(--bg1);
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}

.problem-nav { display: flex; flex-direction: column; gap: 0.5rem; }

.prob-btn {
  background: transparent; border: 1px solid var(--chegara);
  border-radius: 4px; padding: 0.75rem 1rem;
  cursor: pointer; text-align: left; transition: all 0.2s;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.prob-btn:hover { border-color: var(--asosiy); background: rgba(0,212,255,0.04); }
.prob-btn.active { border-color: var(--asosiy); background: rgba(0,212,255,0.08); }
.prob-id { font-size: 0.88rem; font-weight: 600; color: var(--asosiy); letter-spacing: 0.08em; }
.prob-name { font-size: 0.68rem; color: var(--matn2); line-height: 1.3; }

.docs-main { padding: 2.5rem 3rem; max-width: 920px; }
.docs-loading { color: var(--matn3); font-style: italic; }

.prob-title {
  font-family: var(--sarlavha); font-size: 1.85rem;
  font-weight: 800; color: var(--matn); margin-bottom: 0.5rem;
}
.prob-formal {
  font-family: var(--mono); font-size: 0.82rem; color: var(--asosiy2);
  background: rgba(245,158,11,0.07); border-left: 3px solid var(--asosiy2);
  padding: 0.75rem 1rem; border-radius: 0 4px 4px 0;
  margin: 1rem 0; letter-spacing: 0.03em;
}
.prob-tavsif { color: var(--matn2); font-size: 0.87rem; line-height: 1.75; margin-bottom: 1rem; }
.prob-qiyinlik {
  color: var(--matn2); font-size: 0.84rem; line-height: 1.7;
  padding: 1rem; background: var(--bg2);
  border: 1px solid var(--chegara); border-radius: 6px; margin-bottom: 1.5rem;
}
.prob-qiyinlik strong { color: var(--asosiy3); }

.used-in-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.used-pill {
  font-size: 0.7rem; letter-spacing: 0.06em;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--chegara2); border-radius: 100px;
  color: var(--matn2); background: var(--bg2);
}

.algos-section-title {
  font-family: var(--sarlavha); font-size: 1rem; font-weight: 700; color: var(--matn);
  letter-spacing: 0.06em; margin-bottom: 1rem;
  border-bottom: 1px solid var(--chegara); padding-bottom: 0.5rem;
}

.algo-cards { display: flex; flex-direction: column; gap: 1rem; }

.algo-card {
  background: var(--bg2); border: 1px solid var(--chegara);
  border-radius: 8px; padding: 1.25rem 1.5rem;
  transition: border-color 0.2s; animation: fadeSlide 0.4s ease both;
}
.algo-card:hover { border-color: var(--chegara2); }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.algo-card:nth-child(1) { animation-delay: 0.05s; }
.algo-card:nth-child(2) { animation-delay: 0.10s; }
.algo-card:nth-child(3) { animation-delay: 0.15s; }
.algo-card:nth-child(4) { animation-delay: 0.20s; }
.algo-card:nth-child(5) { animation-delay: 0.25s; }

.algo-card-header {
  display: flex; align-items: baseline;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 0.5rem; flex-wrap: wrap;
}
.algo-nomi { font-family: var(--sarlavha); font-size: 1rem; font-weight: 700; color: var(--matn); }
.algo-murakkablik {
  font-size: 0.72rem; font-family: var(--mono); color: var(--asosiy2);
  background: rgba(245,158,11,0.08); padding: 0.2rem 0.55rem;
  border-radius: 4px; border: 1px solid rgba(245,158,11,0.2); white-space: nowrap;
}
.algo-tavsif { font-size: 0.82rem; color: var(--matn2); line-height: 1.7; margin-bottom: 0.6rem; }
.algo-ishlatiladi { font-size: 0.72rem; color: var(--asosiy3); }
.algo-ishlatiladi::before { content: "↳ Ishlatiladi: "; color: var(--matn3); }

/* ═══════════════════════════════════════════
   UMUMIY BOSHQARUV ELEMENTLARI
═══════════════════════════════════════════ */
.bench-layout { display: grid; grid-template-columns: 270px 1fr; min-height: calc(100vh - 56px); }

.bench-controls {
  border-right: 1px solid var(--chegara);
  padding: 2rem 1.5rem; background: var(--bg1);
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}

.control-group { margin-bottom: 1.75rem; }
.ctrl-label { display: block; font-size: 0.63rem; letter-spacing: 0.12em; color: var(--matn3); margin-bottom: 0.6rem; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾'; position: absolute; right: 0.75rem;
  top: 50%; transform: translateY(-50%);
  color: var(--asosiy); pointer-events: none; font-size: 0.8rem;
}
select {
  width: 100%; background: var(--bg2); border: 1px solid var(--chegara);
  border-radius: 4px; color: var(--matn); font-family: var(--mono);
  font-size: 0.78rem; padding: 0.6rem 2rem 0.6rem 0.75rem;
  cursor: pointer; appearance: none; outline: none; transition: border-color 0.2s;
}
select:focus { border-color: var(--asosiy); }

.slider-row { display: flex; align-items: center; gap: 0.75rem; }
input[type=range] { flex: 1; -webkit-appearance: none; background: transparent; height: 4px; }
input[type=range]::-webkit-slider-runnable-track { background: var(--chegara); height: 4px; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--asosiy); margin-top: -5px; cursor: pointer;
  border: 2px solid var(--bg); box-shadow: 0 0 8px rgba(0,212,255,0.5);
}
.bit-val { font-size: 1rem; font-weight: 600; color: var(--asosiy); min-width: 2.5rem; text-align: right; }
.slider-ticks { display: flex; justify-content: space-between; font-size: 0.6rem; color: var(--matn3); margin-top: 0.25rem; }

.round-btns { display: flex; gap: 0.5rem; }
.round-btn {
  flex: 1; background: var(--bg2); border: 1px solid var(--chegara);
  border-radius: 4px; color: var(--matn2); font-family: var(--mono);
  font-size: 0.85rem; padding: 0.45rem; cursor: pointer; transition: all 0.2s;
}
.round-btn.active { background: rgba(0,212,255,0.1); border-color: var(--asosiy); color: var(--asosiy); }
.round-btn:hover { border-color: var(--asosiy); color: var(--asosiy); }

.algo-checks { display: flex; flex-direction: column; gap: 0.5rem; }
.algo-check-label {
  display: flex; align-items: center; gap: 0.6rem; cursor: pointer;
  padding: 0.5rem 0.6rem; border: 1px solid var(--chegara); border-radius: 4px;
  transition: all 0.15s; font-size: 0.78rem; color: var(--matn2);
}
.algo-check-label:hover { border-color: var(--asosiy); color: var(--matn); background: rgba(0,212,255,0.03); }
.algo-check-label input[type=checkbox] { accent-color: var(--asosiy); width: 13px; height: 13px; cursor: pointer; }

.run-btn {
  width: 100%; background: var(--asosiy); color: var(--bg); border: none;
  border-radius: 4px; font-family: var(--mono); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.1em; padding: 0.8rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; transition: all 0.2s; margin-top: 0.5rem;
}
.run-btn:hover { background: #33deff; box-shadow: 0 0 20px rgba(0,212,255,0.3); }
.run-btn:disabled { background: var(--chegara); color: var(--matn3); cursor: not-allowed; box-shadow: none; }

.bench-status { margin-top: 0.75rem; font-size: 0.72rem; color: var(--matn3); min-height: 1.2em; text-align: center; }
.bench-status.loading { color: var(--asosiy); animation: blink 1s infinite; }
.bench-status.xato   { color: var(--xavf); }
@keyframes blink { 50% { opacity: 0.4; } }

.bench-results { padding: 2rem 2.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.results-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.input-info { font-size: 0.72rem; color: var(--matn3); letter-spacing: 0.04em; }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.chart-card { background: var(--bg1); border: 1px solid var(--chegara); border-radius: 8px; padding: 1.25rem 1.5rem; }
.chart-title { font-size: 0.68rem; letter-spacing: 0.1em; color: var(--matn3); margin-bottom: 1rem; text-transform: uppercase; }

.table-wrap { overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.results-table th {
  text-align: left; padding: 0.6rem 1rem;
  font-size: 0.63rem; letter-spacing: 0.08em;
  color: var(--matn3); background: var(--bg1);
  border-bottom: 1px solid var(--chegara); white-space: nowrap;
}
.results-table td {
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--chegara);
  color: var(--matn); font-family: var(--mono);
}
.results-table tr:hover td { background: rgba(0,212,255,0.02); }
.results-table td:first-child { color: var(--asosiy); font-weight: 500; }
.results-table td.num { color: var(--asosiy2); text-align: right; }
.empty-row { text-align: center !important; color: var(--matn3) !important; padding: 2rem !important; }
.cell-yaxshi { color: var(--asosiy3) !important; }

/* ═══════════════════════════════════════════
   TAB 03: REAL VAQT SINOVI
═══════════════════════════════════════════ */
.realtime-layout {
  max-width: 1100px; margin: 0 auto; padding: 2.5rem;
}

.realtime-header { margin-bottom: 2rem; }
.realtime-desc {
  font-size: 0.85rem; color: var(--matn2); line-height: 1.75;
  max-width: 700px; margin-top: 0.5rem;
}
.realtime-desc strong { color: var(--asosiy); }

.realtime-controls {
  background: var(--bg1); border: 1px solid var(--chegara);
  border-radius: 10px; padding: 2rem; margin-bottom: 2rem;
}

.rt-row { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.input-row { display: flex; gap: 0.75rem; align-items: stretch; flex-wrap: wrap; }

.rt-input {
  flex: 1; min-width: 220px;
  background: var(--bg2); border: 1px solid var(--chegara);
  border-radius: 4px; color: var(--matn); font-family: var(--mono);
  font-size: 1rem; font-weight: 500; padding: 0.65rem 1rem;
  outline: none; transition: border-color 0.2s;
  letter-spacing: 0.03em;
}
.rt-input:focus { border-color: var(--asosiy); box-shadow: 0 0 0 2px rgba(0,212,255,0.1); }
.rt-input::placeholder { color: var(--matn3); font-size: 0.8rem; }

.rt-hints { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.hint-btn {
  background: var(--bg2); border: 1px solid var(--chegara2);
  border-radius: 4px; color: var(--matn2); font-family: var(--mono);
  font-size: 0.75rem; padding: 0.4rem 0.75rem; cursor: pointer;
  transition: all 0.15s;
}
.hint-btn:hover { border-color: var(--asosiy2); color: var(--asosiy2); }

.rt-note {
  font-size: 0.72rem; color: var(--matn3);
  margin-top: 0.5rem; line-height: 1.5;
}

.rt-run-btn { background: var(--asosiy3); color: var(--bg); }
.rt-run-btn:hover { background: #6aee9a; box-shadow: 0 0 20px rgba(74,222,128,0.3); }

/* Kirish paneli */
.rt-kirish-panel {
  background: var(--bg1); border: 1px solid var(--chegara);
  border-left: 3px solid var(--asosiy2);
  border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 2rem;
}
.rt-kirish-info {
  display: flex; flex-wrap: wrap; gap: 1rem;
  font-size: 0.78rem; font-family: var(--mono);
}
.rt-kirish-kalit { color: var(--matn3); }
.rt-kirish-qiymat { color: var(--asosiy2); font-weight: 500; }

/* Xulosa paneli */
.rt-xulosa {
  background: var(--bg1); border: 1px solid var(--chegara);
  border-left: 3px solid var(--asosiy3);
  border-radius: 8px; padding: 1.25rem 1.5rem; margin-top: 1.5rem;
  font-size: 0.82rem; color: var(--matn2); line-height: 1.7;
}
.rt-xulosa strong { color: var(--asosiy3); }

/* Holat badge */
.badge-eng-tez { color: var(--asosiy3); font-weight: 600; }
.badge-eng-sekin { color: var(--xavf); font-weight: 600; }
.badge-oddiy { color: var(--matn3); }

/* ═══════════════════════════════════════════
   TAB 04: JONLI MONITOR
═══════════════════════════════════════════ */
.live-layout { max-width: 1000px; margin: 0 auto; padding: 2.5rem; }

.live-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.live-desc { font-size: 0.82rem; color: var(--matn2); max-width: 520px; line-height: 1.65; margin-top: 0.4rem; }
.live-controls { display: flex; gap: 0.75rem; align-items: center; flex-shrink: 0; padding-top: 1.6rem; }

.ws-btn {
  border-radius: 4px; font-family: var(--mono); font-size: 0.75rem;
  letter-spacing: 0.08em; padding: 0.6rem 1.1rem; cursor: pointer; transition: all 0.2s; border: none;
}
.ws-btn.start { background: var(--asosiy3); color: var(--bg); font-weight: 600; }
.ws-btn.start:hover { box-shadow: 0 0 16px rgba(74,222,128,0.35); }
.ws-btn.stop { background: var(--bg2); color: var(--xavf); border: 1px solid var(--xavf); }
.ws-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.live-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.metric-card { background: var(--bg1); border: 1px solid var(--chegara); border-radius: 8px; padding: 1rem; text-align: center; }
.metric-label { font-size: 0.58rem; letter-spacing: 0.12em; color: var(--matn3); margin-bottom: 0.35rem; }
.metric-val { font-family: var(--sarlavha); font-size: 1.5rem; font-weight: 800; color: var(--asosiy); line-height: 1; }
.metric-unit { font-size: 0.63rem; color: var(--matn3); margin-top: 0.2rem; }

.live-chart-wrap { background: var(--bg1); border: 1px solid var(--chegara); border-radius: 8px; padding: 1.25rem 1.5rem; }

.log-panel { margin-top: 1.5rem; background: var(--bg1); border: 1px solid var(--chegara); border-radius: 8px; padding: 1.25rem 1.5rem; }
.log-entries { max-height: 180px; overflow-y: auto; font-size: 0.72rem; display: flex; flex-direction: column-reverse; gap: 0.2rem; }
.log-entry { display: flex; gap: 1.5rem; padding: 0.15rem 0; border-bottom: 1px solid rgba(30,45,71,0.4); animation: logIn 0.3s ease; }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.log-ts { color: var(--matn3); white-space: nowrap; }
.log-vaqt { color: var(--asosiy); min-width: 5rem; }
.log-xotira { color: var(--asosiy2); min-width: 5rem; }
.log-bitlar { color: var(--matn2); }

/* ═══════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--chegara2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--asosiy); }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 1000px) {
  .docs-layout, .bench-layout { grid-template-columns: 1fr; }
  .docs-sidebar, .bench-controls { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--chegara); }
  .problem-nav { flex-direction: row; flex-wrap: wrap; }
  .charts-grid { grid-template-columns: 1fr; }
  .live-metrics { grid-template-columns: repeat(3, 1fr); }
  .maqsad-cards { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 2rem; }
  .logo-sub { display: none; }
  .tabs { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .maqsad-cards { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); }
  .live-metrics { grid-template-columns: repeat(2, 1fr); }
}