/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #5B8EF0;
  --blue-dk: #3b70d8;
  --dark:    #0f172a;
  --mid:     #1e293b;
  --slate:   #334155;
  --muted:   #64748b;
  --border:  #e2e8f0;
  --bg:      #f8fafc;
  --white:   #ffffff;
  --green:   #22c55e;
  --red:     #ef4444;
  --radius:  8px;
  --font-sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  background: var(--dark);
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  letter-spacing: -0.3px;
}
.brand span { color: var(--blue); }

.topbar-nav { display: flex; align-items: center; gap: 12px; }

/* ── Main layout ────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

/* ── Panels ─────────────────────────────────────────────────── */
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.panel-status {
  position: sticky;
  top: 72px;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--dark); }
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}

/* ── Mode panes ─────────────────────────────────────────────── */
.mode-pane { display: none; }
.mode-pane.active { display: block; }

/* ── Form fields ────────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--slate);
  margin-bottom: 6px;
}
.field-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.field-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}
.field-input,
.field-textarea,
.field-select {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--dark);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus,
.field-textarea:focus,
.field-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(91, 142, 240, 0.15);
}
.field-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}
.field-textarea--tall { min-height: 160px; }
.field-select { cursor: pointer; }

/* ── File drop ──────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--blue);
  background: rgba(91, 142, 240, 0.04);
}
.file-drop-icon {
  width: 36px;
  height: 36px;
  color: var(--muted);
  margin: 0 auto 10px;
  display: block;
}
.file-drop-label {
  font-size: 0.9rem;
  color: var(--slate);
  margin-bottom: 4px;
}
.file-drop-sub { font-size: 0.82rem; color: var(--muted); }
.file-hidden { display: none !important; }

.file-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--dark);
}
.file-selected svg {
  width: 18px;
  height: 18px;
  color: var(--blue);
  flex-shrink: 0;
}
.file-selected-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Section divider ────────────────────────────────────────── */
.section-divider {
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Checkboxes ─────────────────────────────────────────────── */
.outputs-field { border: none; }
.outputs-field legend { margin-bottom: 10px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 16px; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  cursor: pointer;
}
.checkbox-label input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ── Form rows ──────────────────────────────────────────────── */
.form-row { margin-top: 18px; }
.form-col { width: 100%; }
.form-actions { margin-top: 28px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 13px 24px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--blue-dk); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-block;
  background: none;
  color: var(--blue);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  padding: 9px 20px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 16px;
}
.btn-secondary:hover { background: rgba(91, 142, 240, 0.06); }

.btn-ghost {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,0.5); }

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.btn-link:hover { color: var(--blue-dk); }
.btn-remove { color: var(--muted); font-size: 0.82rem; margin-left: auto; }

/* ── Spinner (button) ───────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Status panel ───────────────────────────────────────────── */
.status-idle,
.status-working,
.status-success,
.status-error {
  text-align: center;
  padding: 16px 8px;
}

.status-icon {
  width: 52px;
  height: 52px;
  color: var(--border);
  margin: 0 auto 16px;
  display: block;
}

.status-idle-text {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Spinner ring */
.spinner-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

.status-step-label {
  font-size: 0.9rem;
  color: var(--slate);
  font-weight: 500;
  margin-bottom: 20px;
}

.status-steps {
  text-align: left;
  display: inline-flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.2s;
}
.step-active .step-dot  { background: var(--blue); box-shadow: 0 0 0 3px rgba(91,142,240,0.25); }
.step-done   .step-dot  { background: var(--green); }
.step-error  .step-dot  { background: var(--red); }
.step-active .step-text { color: var(--dark); font-weight: 600; }
.step-done   .step-text { color: var(--green); }

/* Success */
.status-check {
  width: 52px; height: 52px;
  color: var(--green);
  margin: 0 auto 12px;
  display: block;
}
.status-success-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
}
.status-success-sub {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Error */
.status-x {
  width: 52px; height: 52px;
  color: var(--red);
  margin: 0 auto 12px;
  display: block;
}
.status-error-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
}
.status-error-msg {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── kbd ────────────────────────────────────────────────────── */
kbd {
  display: inline-block;
  padding: 1px 6px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--slate);
}

/* ── Animation ──────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth / login page ──────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.auth-logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
  text-align: center;
}
.auth-logo span { color: var(--blue); }

.auth-tagline {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}

.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 20px;
  line-height: 1.4;
}

.auth-card .field {
  margin-bottom: 16px;
}
.auth-card .field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--slate);
  margin-bottom: 6px;
}
.auth-card .field input {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--dark);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-card .field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(91, 142, 240, 0.15);
}

.btn-primary.full-width {
  width: 100%;
  margin-top: 8px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 800px) {
  .main {
    grid-template-columns: 1fr;
    padding: 20px 14px 48px;
  }
  .panel-status { position: static; }
  .panel { padding: 20px; }
}

@media (max-width: 420px) {
  .auth-card { padding: 28px 20px; }
}
