:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: #151922;
  --ink: #eef1f6;
  --muted: #8b93a7;
  --line: #252b38;
  --line-2: #323a4d;
  --accent: #5eead4;
  --accent-2: #2dd4bf;
  --danger: #fb7185;
  --ok: #4ade80;
  --warn: #fbbf24;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --sidebar: 248px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(45, 212, 191, 0.08), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(99, 102, 241, 0.08), transparent 45%),
    var(--bg);
  line-height: 1.45;
}
button, input { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 0.8rem; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: rgba(8, 10, 14, 0.92);
  border-right: 1px solid var(--line);
  padding: 1.3rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.brand { display: flex; gap: 0.75rem; align-items: center; padding: 0 0.35rem; }
.mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  background: linear-gradient(145deg, #5eead4, #0f766e 70%);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.25), 0 8px 20px rgba(13, 148, 136, 0.35);
}
.brand-kicker {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 700;
}
.brand-name { margin: 0.05rem 0 0; font-weight: 650; }
.nav { display: grid; gap: 0.35rem; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 11px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  font-weight: 550;
}
.nav-btn svg { width: 1.1rem; height: 1.1rem; flex: none; }
.nav-btn:hover { background: #1a2030; color: var(--ink); }
.nav-btn.is-active { background: #1b2433; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.nav-count {
  margin-left: auto;
  font-size: 0.72rem;
  background: #0f141c;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  color: var(--muted);
}
.sidebar-foot {
  margin-top: auto;
  padding: 0.8rem 0.7rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
}
.sidebar-foot p { margin: 0.15rem 0; }

.shell { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.4rem 1.8rem 0.4rem;
}
h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.03em; }
.page-sub, .muted { color: var(--muted); }
.page-sub { margin: 0.3rem 0 0; }
.top-actions { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.project-switch {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.project-switch select {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 0.4rem 0.65rem;
  min-width: 16rem;
}
.live-pills { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.live i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #52525b;
  display: inline-block;
}
.live.ok { color: #bbf7d0; }
.live.ok i { background: var(--ok); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.12); }
.live.bad { color: #fecdd3; }
.live.bad i { background: var(--danger); }

main { padding: 1rem 1.8rem 3rem; max-width: 1120px; }
.view { display: none; }
.view.is-active { display: block; }
#view-overview.is-active, #view-test.is-active { display: flex; }
#view-overview, #view-test {
  flex-direction: column;
  gap: 1rem;
}
.stats, .settings-grid { display: grid; gap: 1rem; }
@media (min-width: 900px) {
  .stats, .settings-grid { grid-template-columns: 1fr 1fr; }
}
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 28%), var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.kicker {
  margin: 0 0 0.2rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}
h2 { margin: 0 0 0.4rem; font-size: 1.08rem; }
.badge, .pill {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.22rem 0.58rem;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 650;
}
.badge.ok, .pill.ok { color: var(--ok); border-color: #14532d; background: rgba(20, 83, 45, 0.25); }
.badge.bad, .pill.err { color: var(--danger); border-color: #7f1d1d; background: rgba(127, 29, 29, 0.2); }
.badge.run, .pill.run { color: var(--warn); border-color: #78350f; background: rgba(120, 53, 15, 0.25); }
.badge.run.is-loud {
  font-size: 0.86rem;
  letter-spacing: 0.16em;
  padding: 0.4rem 0.85rem;
  color: #fde68a;
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.2);
}
.pill.cancel { color: #c4b5fd; border-color: #5b21b6; }

#weights-card.is-running,
#test-image-card.is-running {
  border-color: #b45309;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.22), var(--shadow);
}
.running-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1.05rem 1.15rem;
  border-radius: 14px;
  border: 1px solid #f59e0b;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.2), rgba(120, 53, 15, 0.32));
}
.running-banner[hidden] { display: none !important; }
.running-banner-label {
  flex: none;
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #fbbf24;
  animation: running-pulse 1.35s ease-in-out infinite;
}
.running-banner p {
  margin: 0;
  color: #fde68a;
  font-size: 0.95rem;
  font-weight: 550;
}
@keyframes running-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.test-image-fields {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
#test-image-card.is-disabled .test-image-fields {
  opacity: 0.48;
}

dl {
  margin: 0.85rem 0 0;
  display: grid;
  grid-template-columns: 8.2rem 1fr;
  gap: 0.35rem 0.7rem;
  font-size: 0.92rem;
}
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }

.steps {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  gap: 0.7rem;
}
@media (min-width: 900px) { .steps { grid-template-columns: 1fr 1fr 1fr; } }
.steps li {
  display: flex;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
}
.steps span {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
}
.steps p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.86rem; }
.steps strong { font-size: 0.92rem; }

.job-progress {
  margin-top: 1.15rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--line);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.progress-head .kicker { margin-bottom: 0.15rem; }
.progress-detail {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.progress-pct {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 0;
  display: grid;
  gap: 0.6rem;
}
@media (min-width: 900px) { .progress-steps { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); } }
.progress-steps li {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: #0c1017;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  color: var(--muted);
  min-height: 4.4rem;
}
.progress-steps .step-mark {
  flex: none;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 550;
  color: var(--muted);
}
.progress-steps strong {
  display: block;
  color: inherit;
  font-size: 0.88rem;
}
.progress-steps p {
  margin: 0.18rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.progress-steps li.is-pending { opacity: 0.72; }
.progress-steps li.is-current {
  color: var(--ink);
  border-color: #134e4a;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.22);
  background: rgba(45, 212, 191, 0.05);
}
.progress-steps li.is-current .step-mark {
  color: #042f2e;
  background: linear-gradient(180deg, #5eead4, #2dd4bf);
  border-color: transparent;
}
.progress-steps li.is-done {
  color: var(--ink);
  border-color: #14532d;
  background: rgba(20, 83, 45, 0.18);
}
.progress-steps li.is-done .step-mark {
  color: #052e16;
  background: var(--ok);
  border-color: transparent;
}
.progress-steps li.is-error {
  color: var(--ink);
  border-color: #7f1d1d;
  background: rgba(127, 29, 29, 0.16);
}
.progress-steps li.is-error .step-mark {
  color: #fff1f2;
  background: var(--danger);
  border-color: transparent;
}
.progress-steps li.is-cancelled {
  color: #ddd6fe;
  border-color: #5b21b6;
  background: rgba(91, 33, 182, 0.16);
}
.progress-steps li.is-cancelled .step-mark {
  color: #ddd6fe;
  border-color: #5b21b6;
}
.progress-meter { margin-top: 0.8rem; }
.progress-bar {
  height: 0.45rem;
  background: #0c1017;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0f766e, #5eead4);
  border-radius: inherit;
}
.job-progress.is-live .progress-bar > span,
.download-progress.is-live .progress-bar > span {
  transition: width 0.35s ease;
}
.progress-bar.is-indeterminate > span {
  width: 38% !important;
  animation: progress-indet 1.15s ease-in-out infinite;
}
@keyframes progress-indet {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(280%); }
}
.download-progress {
  margin-top: 1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}
.download-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0.75rem 0 0;
  padding: 0;
}
.download-stats > div {
  background: #0c1017;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
.download-stats dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.download-stats dd {
  margin: 0.2rem 0 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--ink);
}

.job-mini {
  margin-top: 0.38rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 7.5rem;
}
.job-mini-bar {
  flex: 1;
  height: 0.28rem;
  background: #0c1017;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.job-mini-bar > span {
  display: block;
  height: 100%;
  background: #2dd4bf;
  border-radius: inherit;
}
.job-mini em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.row { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.controls {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.btn {
  border: 0;
  border-radius: 11px;
  padding: 0.62rem 1.05rem;
  font-weight: 650;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: linear-gradient(180deg, #5eead4, #2dd4bf); color: #042f2e; }
.primary:hover:not(:disabled) { filter: brightness(1.05); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-2); }
.danger { background: #9f1239; color: #fff1f2; }
label input, label textarea, label select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  background: #0c1017;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
label textarea { min-height: 6rem; resize: vertical; }
label { display: block; margin-top: 0.95rem; font-size: 0.86rem; color: var(--muted); }
.hint { color: var(--warn); font-size: 0.75rem; }
.hint.is-set { color: var(--ok); }
.error { color: var(--danger); margin: 0.7rem 0 0; }
pre {
  margin: 0.85rem 0 0;
  background: #090b10;
  color: #d6d3d1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.95rem 1rem;
  min-height: 18rem;
  max-height: 32rem;
  overflow: auto;
  font: 0.78rem/1.5 var(--mono);
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}
.log-links { display: flex; gap: 0.9rem; align-items: center; }
.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.table-wrap { overflow: auto; margin-top: 0.9rem; }
table.jobs { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.jobs th {
  text-align: left;
  color: var(--muted);
  font-weight: 550;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
}
table.jobs td { padding: 0.75rem 0.45rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.jobs tr.is-selected td { background: rgba(45, 212, 191, 0.06); }
table.jobs .empty { text-align: center; color: var(--muted); padding: 2rem 0.5rem; }
.job-id { font-family: var(--mono); font-size: 0.78rem; }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.project-list { display: grid; gap: 0.6rem; margin-top: 1rem; }
.project-item {
  width: 100%;
  text-align: left;
  background: #0c1017;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
}
.project-item:hover { border-color: var(--line-2); }
.project-item.is-active { border-color: #134e4a; background: rgba(45, 212, 191, 0.06); }
.project-item strong { display: block; }
.project-item span { color: var(--muted); font-size: 0.8rem; font-family: var(--mono); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  display: grid;
  place-items: center;
  z-index: 30;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(28rem, calc(100vw - 2rem));
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 1.3rem;
  box-shadow: var(--shadow);
}
#toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  background: #042f2e;
  color: #ccfbf1;
  border: 1px solid #134e4a;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  z-index: 40;
  box-shadow: var(--shadow);
}
#toast.bad { background: #4c0519; color: #ffe4e6; border-color: #9f1239; }

.empty-state { color: var(--muted); margin: 0.7rem 0 0; }
.pred-image {
  display: block;
  max-width: 100%;
  margin-top: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #090b10;
}
.pred-image[hidden],
img.pred-image:not([src]) {
  display: none !important;
}
.file-field input[type="file"] {
  padding: 0.4rem;
}
#weights-actions .btn { text-decoration: none; display: inline-flex; align-items: center; }
a.btn { color: inherit; }
a.btn:hover { text-decoration: none; filter: brightness(1.05); }

.api-docs h3 {
  margin: 1.05rem 0 0.35rem;
  font-size: 0.92rem;
}
.api-docs .api-sample {
  min-height: 0;
  max-height: 22rem;
}
.api-notes {
  margin: 0.7rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.api-notes li { margin: 0.35rem 0; }

@media (max-width: 820px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; }
  .shell { margin-left: 0; }
  .nav { display: flex; flex: 1; }
  .sidebar-foot { display: none; }
}
