/* ============================================================
   AgentOS Payload Lab — main.css
   Версия: 3.0.0
   Цветовая схема: светло-голубая
   ============================================================ */

:root {
  /* Фоны */
  --bg:        #eef2fc;
  --bg2:       #f6f8ff;
  --bg3:       #ffffff;
  --bg4:       #e2e8f6;

  /* Границы */
  --border:    rgba(30,60,160,.10);
  --border2:   rgba(30,60,160,.18);

  /* Текст */
  --text:      #111827;
  --text2:     #3d4f7c;
  --text3:     #8896b8;

  /* Акценты */
  --accent:    #2563eb;
  --accent2:   #7c3aed;

  /* Статусные цвета */
  --green:     #16a34a;
  --green-bg:  rgba(22,163,74,.10);
  --yellow:    #d97706;
  --yellow-bg: rgba(217,119,6,.10);
  --red:       #dc2626;
  --red-bg:    rgba(220,38,38,.10);
  --crit:      #be123c;
  --crit-bg:   rgba(190,18,60,.10);

  /* Типографика */
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Syne', sans-serif;
}

/* ── Тёмная тема ── */
[data-theme="dark"] {
  --bg:        #0f1117;
  --bg2:       #161b27;
  --bg3:       #1c2333;
  --bg4:       #252e40;
  --border:    rgba(100,130,200,.15);
  --border2:   rgba(100,130,200,.26);
  --text:      #e8ecf4;
  --text2:     #9aaac8;
  --text3:     #5a6a8a;
  --accent:    #3b82f6;
  --accent2:   #8b5cf6;
  --green:     #22c55e;
  --green-bg:  rgba(34,197,94,.13);
  --yellow:    #f59e0b;
  --yellow-bg: rgba(245,158,11,.13);
  --red:       #ef4444;
  --red-bg:    rgba(239,68,68,.13);
  --crit:      #fb7185;
  --crit-bg:   rgba(251,113,133,.13);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }

/* ── LAYOUT ── */
.app {
  display: grid;
  grid-template-rows: 44px 1fr;
  grid-template-columns: 200px 1fr;
  height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent2), var(--accent), transparent);
  opacity: .6;
}
.logo { font-weight: 700; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.logo span { color: var(--accent); }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(22,163,74,.5);
  animation: pulse 2.5s infinite;
}
.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px rgba(220,38,38,.5);
  animation: none;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.tb-stats { margin-left: auto; display: flex; gap: 24px; }
.tb-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.tb-stat-val { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--text); }
.tb-stat-val.danger { color: var(--red); }
.tb-stat-val.accent { color: var(--accent); }
.tb-stat-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--text3); }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--bg3);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-section {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text3);
  padding: 12px 16px 4px;
  font-weight: 600;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  cursor: pointer;
  color: var(--text2);
  transition: all .15s;
  border-left: 2px solid transparent;
  font-size: 12px;
}
.sb-item:hover { color: var(--text); background: var(--bg4); }
.sb-item.active {
  color: var(--accent);
  background: rgba(37,99,235,.07);
  border-left-color: var(--accent);
}
.sb-icon { width: 14px; height: 14px; flex-shrink: 0; opacity: .6; }
.sb-item.active .sb-icon { opacity: 1; }
.sb-badge {
  margin-left: auto;
  font-size: 9px;
  font-family: var(--mono);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--red-bg);
  color: var(--red);
}
.sb-badge.ok { background: var(--green-bg); color: var(--green); }

/* ── MAIN ── */
.main { display: flex; flex-direction: column; overflow: hidden; }

/* ── TABS ── */
.tabs {
  display: flex;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
}
.tab {
  padding: 0 16px;
  height: 40px;
  display: flex;
  align-items: center;
  font-size: 12px;
  cursor: pointer;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── CONTENT ── */
.content { flex: 1; overflow: hidden; background: var(--bg); }
.tab-pane { display: none; height: 100%; overflow-y: auto; padding: 16px 20px; }
.tab-pane.active { display: flex; gap: 12px; }

/* ── CARDS ── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(30,60,160,.06);
}
.card-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text3);
  margin-bottom: 10px;
  font-weight: 600;
}

/* ── FORM ELEMENTS ── */
.form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.form-row:last-child { margin-bottom: 0; }
.form-label { font-size: 11px; color: var(--text2); width: 82px; flex-shrink: 0; }

select,
input[type=text],
input[type=number] {
  height: 28px;
  font-size: 12px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
select:focus,
input[type=text]:focus,
input[type=number]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

textarea {
  font-size: 11px;
  padding: 8px 10px;
  line-height: 1.6;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  width: 100%;
  resize: none;
  outline: none;
  transition: border-color .15s;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── BUTTONS ── */
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  height: 28px;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  font-family: var(--sans);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.btn:hover { background: var(--bg4); color: var(--text); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,.3);
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── CHAOS TAGS ── */
.chaos-wrap { display: flex; gap: 6px; flex-wrap: wrap; }
.chaos-tag {
  padding: 4px 9px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border2);
  color: var(--text3);
  transition: all .15s;
  letter-spacing: .04em;
  user-select: none;
  background: var(--bg);
}
.chaos-tag:hover { color: var(--text2); border-color: var(--border2); }
.chaos-tag.on        { color: var(--yellow);  border-color: var(--yellow);  background: var(--yellow-bg); }
.chaos-tag.on.red    { color: var(--red);     border-color: var(--red);     background: var(--red-bg); }
.chaos-tag.on.blue   { color: var(--accent);  border-color: var(--accent);  background: rgba(37,99,235,.08); }
.chaos-tag.on.purple { color: var(--accent2); border-color: var(--accent2); background: rgba(124,58,237,.08); }

/* ── SCORE BAR ── */
.score-wrap { margin: 4px 0 10px; }
.score-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.score-label { font-size: 11px; color: var(--text2); }
.score-value { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.score-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg4);
  overflow: hidden;
}
.score-fill { height: 100%; border-radius: 4px; transition: width .4s ease, background .4s ease; }
.score-zones { display: flex; height: 4px; margin-top: 3px; border-radius: 2px; overflow: hidden; }
.zone { flex: 1; }
.z-g { background: var(--green); }
.z-y { background: var(--yellow); }
.z-r { background: var(--red); }
.z-c { background: var(--crit); }
.zone-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text3);
  margin-top: 3px;
  font-family: var(--mono);
}

/* ── STATUS PILLS ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .04em;
}
.pill.ok   { background: var(--green-bg);  color: var(--green); }
.pill.fail { background: var(--red-bg);    color: var(--red); }
.pill.warn { background: var(--yellow-bg); color: var(--yellow); }
.pill.crit { background: var(--crit-bg);   color: var(--crit); }
.pill.info { background: rgba(37,99,235,.10); color: var(--accent); }

/* ── RUN LIST ── */
.run-list { display: flex; flex-direction: column; gap: 1px; }
.run-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.run-row:last-child { border-bottom: none; }
.run-num    { font-family: var(--mono); font-size: 10px; color: var(--text3); width: 22px; flex-shrink: 0; }
.run-status { width: 64px; flex-shrink: 0; }
.run-bar    { flex: 1; margin: 0 6px; }
.mini-track { height: 4px; border-radius: 2px; background: var(--bg4); overflow: hidden; }
.mini-fill  { height: 100%; border-radius: 2px; }
.run-ms     { font-family: var(--mono); font-size: 10px; color: var(--text3); width: 40px; text-align: right; flex-shrink: 0; }

/* ── TIMELINE DOTS ── */
.timeline { display: flex; gap: 3px; flex-wrap: wrap; }
.tl-dot {
  width: 11px; height: 11px;
  border-radius: 3px;
  cursor: pointer;
  transition: transform .1s;
  flex-shrink: 0;
}
.tl-dot:hover { transform: scale(1.5); }

/* ── TRACE LOG ── */
.trace-log { display: flex; flex-direction: column; }
.trace-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
}
.trace-line:last-child { border-bottom: none; }
.tr-ts    { font-size: 10px; color: var(--text3); flex-shrink: 0; width: 38px; }
.tr-stage { font-size: 10px; color: var(--accent); flex-shrink: 0; min-width: 170px; }
.tr-val   { font-size: 10px; color: var(--text2); }
.tr-err  .tr-stage { color: var(--red); }
.tr-warn .tr-stage { color: var(--yellow); }

/* ── METRICS ── */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.metric-val { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1.2; color: var(--text); }
.metric-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--text3); margin-top: 3px; }

/* ── PROGRESS ── */
.progress-track  { flex: 1; height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.progress-fill   { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; }

/* ── COLUMNS ── */
.col-left  { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.col-right { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }

/* ── LOG VIEWER ── */
.log-filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.log-filter {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border2);
  color: var(--text3);
  background: var(--bg3);
  transition: all .15s;
}
.log-filter.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(37,99,235,.08);
}

.log-file-wrap {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(30,60,160,.05);
}
.log-file-header {
  padding: 7px 12px;
  background: var(--bg4);
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}
.log-entries { padding: 6px 12px; max-height: 240px; overflow-y: auto; }
.log-entry {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
}
.log-entry:last-child { border-bottom: none; }
.le-ts    { color: var(--text3); flex-shrink: 0; }
.le-stage { color: var(--accent); flex-shrink: 0; min-width: 140px; }
.le-val   { color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.le-err .le-stage { color: var(--red); }
.le-sec .le-stage { color: var(--yellow); }
.le-sys .le-stage { color: var(--accent2); }

/* ── SERIES STATS ── */
.series-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.ss-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(30,60,160,.05);
}
.ss-val { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text); }
.ss-lbl { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }

/* ── ANIMATIONS ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.card       { animation: fadeIn .2s ease; }
.run-row    { animation: fadeIn .15s ease; }
.trace-line { animation: fadeIn .1s ease; }
