:root {
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e7ecf3;
  --muted: #9aa8b8;
  --accent: #3d8bfd;
  --accent-hover: #5a9dff;
  --error-bg: #3a1f24;
  --error-text: #ffb4b4;
  --border: #2a3544;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body.centered {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #121820;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.actions a {
  color: var(--accent);
  text-decoration: none;
}

.actions a:hover {
  color: var(--accent-hover);
}

.card {
  max-width: 720px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.card.narrow {
  width: 100%;
  max-width: 420px;
  margin: 0;
}

.lead {
  color: var(--muted);
  line-height: 1.5;
}

.upload-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field span {
  font-weight: 600;
}

.field small {
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1419;
  color: var(--text);
}

.primary {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.primary:hover {
  background: var(--accent-hover);
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  color: var(--text);
}

.inline {
  display: inline;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #5c2a32;
}

.alert-ok {
  background: #1a2e24;
  color: #8fd19e;
  border: 1px solid #2a5c3a;
}

.secondary {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121820;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1rem;
}

.report-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 64px);
  border: none;
  background: white;
}

.hidden {
  display: none !important;
}

.job-card {
  max-width: 640px;
}

.progress-wrap {
  height: 10px;
  background: #0f1419;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 1rem 0 0.35rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6ea8fe);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-pct {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.progress-msg {
  margin: 0.25rem 0 1.25rem;
  color: var(--muted);
  min-height: 1.4em;
}

.upload-progress {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #121820;
}

.stage-label-inline {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.stage-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
}

.stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.stage-item.active {
  color: var(--text);
  font-weight: 600;
}

.stage-item.active .stage-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(61, 139, 253, 0.25);
}

.stage-item.done {
  color: #8fd19e;
}

.stage-item.done .stage-dot {
  background: #3ecf6a;
}

.stage-item.error {
  color: var(--error-text);
}

.stage-item.error .stage-dot {
  background: #ff6b6b;
}

.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.monitor-card {
  max-width: 960px;
}

.monitor-section {
  margin-top: 1.5rem;
}

.monitor-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.hint-inline {
  font-weight: normal;
  color: var(--muted);
  font-size: 0.85rem;
}

.monitor-pre {
  margin: 0;
  padding: 1rem;
  background: #0f1419;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre;
  max-height: 420px;
}

.monitor-pre-cpu {
  border-color: #3d5a80;
  background: #121a24;
  max-height: 220px;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .card {
    margin: 1rem;
  }
}
