:root {
  --bg:        #111110;
  --surface-1: #1a1a19;   /* chart surface */
  --surface-2: #201f1d;
  --surface-3: #272623;
  --border:    #34332f;
  --border-2:  #45443f;
  --text:      #f2f1ea;
  --text-2:    #c3c2b7;
  --text-3:    #8a897f;
  --accent:    #f5d90a;   /* electric yellow */
  --accent-2:  #eda100;
  --blue:      #3987e5;
  --danger:    #e66767;
  --good:      #0ca30c;
  --radius:    12px;
  --shadow:    0 6px 24px rgba(0,0,0,.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 300px;
  min-width: 300px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #16150f 0%, var(--bg) 40%);
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand .bolt {
  font-size: 30px;
  filter: drop-shadow(0 0 10px rgba(245,217,10,.55));
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.brand p { margin: 0; font-size: 12px; color: var(--text-3); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 22px 14px;
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  background: var(--surface-1);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .05s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #1e1d16; }
.dz-icon { font-size: 22px; color: var(--accent); }
.dz-main { font-size: 13px; color: var(--text-2); }
.dz-main b { color: var(--text); }
.dz-sub { font-size: 11px; color: var(--text-3); }

.upload-list { margin-top: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.upload-item {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-item:hover { border-color: var(--border-2); background: var(--surface-2); }
.upload-item.active { border-color: var(--accent); background: #1d1c14; }
.upload-item .ui-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .ui-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 10px; padding: 1px 7px; border-radius: 999px; font-weight: 600; letter-spacing: .3px; }
.pill.done    { background: rgba(12,163,12,.16); color: #6fdc6f; }
.pill.running { background: rgba(57,135,229,.16); color: #7fb3f5; }
.pill.pending { background: rgba(237,161,0,.16); color: var(--accent-2); }
.pill.error   { background: rgba(230,103,103,.16); color: var(--danger); }
.side-foot { margin-top: 12px; font-size: 10px; color: var(--text-3); text-align: center; }

/* ---------- Main ---------- */
#main { flex: 1; height: 100vh; overflow-y: auto; }
.empty { height: 100%; display: grid; place-items: center; }
.empty-inner { max-width: 460px; text-align: center; padding: 30px; }
.empty-bolt { font-size: 60px; filter: drop-shadow(0 0 24px rgba(245,217,10,.4)); }
.empty-inner h2 { margin: 12px 0 8px; }
.empty-inner p { color: var(--text-2); }
.empty code, code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--accent-2); }

#workspace { padding: 22px 28px 60px; max-width: 1180px; }
#ws-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
#ws-head h2 { margin: 0; font-size: 24px; }
.ws-sub { color: var(--text-3); font-size: 12px; margin-top: 4px; }

.tabs { display: flex; gap: 4px; margin: 20px 0 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: none; border: none; color: var(--text-3);
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: #111; border-radius: 999px; padding: 0 6px; font-size: 10px; font-weight: 700; }

.status-banner {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; font-size: 13px;
}
.status-banner .spinner {
  width: 16px; height: 16px; border: 2px solid var(--border-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
.progress { flex: 1; height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .3s; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards & charts ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 4px; font-size: 15px; }
.hint { color: var(--text-3); font-size: 12px; margin: 0 0 10px; }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 380px; }
.chart.xl { height: 460px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.stat .val { font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat .lbl { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat .sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.interpretation { font-size: 13px; color: var(--text-2); }
.interpretation code { display: inline-block; margin: 2px 0; }
.interpretation .kv { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.interpretation .kv .k { color: var(--text-3); min-width: 150px; }

/* ---------- Controls ---------- */
.controls .control-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
select, input.text-input, textarea.text-input, .field input {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
}
select[multiple] { min-height: 92px; min-width: 130px; }
.field input[type="number"], .field input[type="text"] { width: 130px; }
textarea.text-input { width: 100%; resize: vertical; }

.metric-toggle, .seg { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 3px; border-radius: 9px; margin-bottom: 10px; }
.chip {
  background: none; border: none; color: var(--text-2);
  padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.chip.active { background: var(--accent); color: #111; }

.btn {
  border: 1px solid var(--border-2); background: var(--surface-3); color: var(--text);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { border-color: var(--border-2); background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.run-info { font-size: 12px; color: var(--text-3); margin-left: 10px; }

.attack-stat { display: flex; gap: 22px; align-items: baseline; margin-bottom: 10px; }
.attack-stat .big { font-size: 30px; font-weight: 700; color: var(--accent); }
.attack-stat .lbl { font-size: 12px; color: var(--text-3); }

/* ---------- Comments ---------- */
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.comment-form input { max-width: 260px; }
.comment-list { display: flex; flex-direction: column; gap: 10px; }
.comment {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2); border-radius: 9px; padding: 12px 14px;
}
.comment .c-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.comment .c-author { color: var(--accent-2); font-weight: 700; }
.comment .c-body { white-space: pre-wrap; color: var(--text); font-size: 13px; }
.comment .c-del { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 11px; }
.comment .c-del:hover { color: var(--danger); }
.empty-note { color: var(--text-3); font-size: 13px; font-style: italic; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-2);
  color: var(--text); padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 50; font-size: 13px; max-width: 80vw;
}
.toast.err { border-color: var(--danger); }
.toast.ok  { border-color: var(--good); }
