:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #6f8cff;
  --accent-2: #ff5fb0;
  --ok: #3ecf8e;
  --err: #ff6161;
  --warn: #ffb454;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

header .badge {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 20px;
}

.api-key-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-key-box input {
  width: 220px;
}

#health-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block;
}
#health-dot.ok { background: var(--ok); }
#health-dot.err { background: var(--err); }

nav.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
}

nav.tabs button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

nav.tabs button.active {
  background: var(--panel);
  color: var(--text);
}

main {
  padding: 20px 24px 60px;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

.card h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 14px;
}

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1; min-width: 260px; }

input[type=file], input[type=text], input[type=password], select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
}

button.btn {
  background: var(--accent);
  color: #0b0d12;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

.image-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-stage img { display: block; max-width: 100%; height: auto; }
.image-stage .box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  background: rgba(111,140,255,0.08);
}
.image-stage .box.selected { border-color: var(--accent-2); background: rgba(255,95,176,0.18); }
.image-stage .box .label {
  position: absolute; top: -20px; left: 0; font-size: 11px;
  background: var(--accent); color: #0b0d12; padding: 1px 6px; border-radius: 4px;
}
.image-stage .box.selected .label { background: var(--accent-2); }

.model-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.model-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 13px;
}
.model-item .meta { flex: 1; }
.model-item .name { font-weight: 600; }
.model-item .sub { color: var(--muted); font-size: 11.5px; }
.model-item .price { color: var(--warn); font-size: 11.5px; white-space: nowrap; }

.pricing-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.result-card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.result-card img { width: 100%; display: block; background: #000; aspect-ratio: 1; object-fit: contain; }
.result-card .body { padding: 10px; font-size: 12.5px; }
.result-card .body .model-name { font-weight: 600; margin-bottom: 4px; }
.result-card .body .row2 { display: flex; justify-content: space-between; color: var(--muted); }
.result-card .body .error { color: var(--err); }
.result-card .body a.dl { display: inline-block; margin-top: 8px; color: var(--accent); text-decoration: none; font-size: 12px; }

.status-line { font-size: 12.5px; color: var(--muted); margin-top: 8px; min-height: 18px; }
.status-line.err { color: var(--err); }
.status-line.ok { color: var(--ok); }

.small-select { max-width: 340px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
