@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #12141a;
  --bg-panel: #191c24;
  --bg-panel-raised: #20232c;
  --border: #2c303b;
  --border-light: #383d4a;
  --brass: #c69a5c;
  --brass-bright: #dab377;
  --text: #ede9e0;
  --text-muted: #8b90a0;
  --text-faint: #5c6072;
  --success: #5fa87d;
  --error: #d1685f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
}

a { color: inherit; }

/* ---------- Login / forgot / reset screens ---------- */

.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-brand { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; margin-bottom: 28px; letter-spacing: 0.02em; }
.login-brand span { color: var(--brass); }
.login-card { width: 100%; max-width: 360px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 32px 28px 28px; }
.login-card .panel-head { margin-bottom: 6px; }
.login-sub { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin: 0 0 22px; }
.login-links { margin-top: 16px; font-size: 12.5px; color: var(--text-faint); text-align: center; }
.login-links a { color: var(--brass); text-decoration: none; cursor: pointer; }
.login-links a:hover { color: var(--brass-bright); }

.field-wrap { position: relative; }
.field-wrap input { padding-right: 42px; }
.toggle-visibility {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 7px; cursor: pointer; color: var(--text-faint);
  display: flex; align-items: center; justify-content: center; border-radius: 6px;
}
.toggle-visibility:hover { color: var(--text-muted); background: var(--bg-panel-raised); }
.toggle-visibility svg { width: 17px; height: 17px; display: block; }

/* ---------- Shared form bits (used everywhere) ---------- */

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.panel-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); flex-shrink: 0; }
.panel-head h2 { font-family: 'Fraunces', serif; font-weight: 500; font-size: 17px; margin: 0; }

label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-muted); margin: 18px 0 7px; }
label:first-of-type { margin-top: 0; }

input[type="file"], input[type="text"], input[type="password"], input[type="email"], textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border-light); border-radius: 7px;
  padding: 11px 13px; font-size: 14px; font-family: 'Inter', sans-serif; color: var(--text);
}
input:disabled { color: var(--text-faint); cursor: not-allowed; }
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }

.run-btn {
  margin-top: 22px; width: 100%; background: var(--brass); color: #1a1508; border: none;
  padding: 12px 20px; border-radius: 7px; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.run-btn:hover { background: var(--brass-bright); }
.run-btn:disabled { background: var(--border-light); color: var(--text-faint); cursor: not-allowed; }
.run-btn.secondary { background: none; border: 1px solid var(--border-light); color: var(--text); }
.run-btn.secondary:hover { background: var(--bg-panel-raised); border-color: var(--border-light); }

.status { margin-top: 14px; font-size: 13px; padding: 10px 13px; border-radius: 7px; display: none; align-items: center; gap: 8px; }
.status.show { display: flex; }
.status.loading { background: rgba(198,154,92,0.1); color: var(--brass-bright); }
.status.success { background: rgba(95,168,125,0.1); color: var(--success); }
.status.error { background: rgba(209,104,95,0.1); color: var(--error); }

.spin { width: 12px; height: 12px; border: 1.5px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px 26px 26px; margin-bottom: 20px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 20px rgba(0,0,0,0.18); }

.stat-card, .step-card, .login-card, .profile-menu, .sidebar-item.active {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.045);
}

.run-btn { box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 2px 10px rgba(198,154,92,0.15); }
.run-btn:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 4px 14px rgba(198,154,92,0.22); }
.run-btn.secondary { box-shadow: none; }

input[type="file"]:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, textarea:focus {
  outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(198,154,92,0.14);
}

.login-card, .topbar { box-shadow: 0 10px 30px rgba(0,0,0,0.25); }

/* ---------- App shell: top bar + sidebar + content ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.wordmark { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; }
.wordmark span { color: var(--brass); }

.profile-menu-wrap { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--border);
  padding: 6px 10px 6px 14px; border-radius: 20px; color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif;
}
.profile-btn:hover { border-color: var(--border-light); }
.profile-btn svg { width: 14px; height: 14px; color: var(--text-faint); }
.profile-menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: var(--bg-panel-raised);
  border: 1px solid var(--border); border-radius: 10px; min-width: 170px; padding: 6px;
  display: none; z-index: 20; box-shadow: 0 12px 28px rgba(0,0,0,0.4);
}
.profile-menu.open { display: block; }
.profile-menu button {
  width: 100%; text-align: left; background: none; border: none; color: var(--text-muted);
  padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: 'Inter', sans-serif;
  display: flex; align-items: center; gap: 9px;
}
.profile-menu button:hover { background: var(--bg-panel); color: var(--text); }
.profile-menu button svg { width: 15px; height: 15px; flex-shrink: 0; }
.profile-menu hr { border: none; border-top: 1px solid var(--border); margin: 5px 2px; }

.app-body { flex: 1; display: flex; }

.sidebar { width: 216px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 20px 12px; }
.sidebar-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--text-muted); cursor: pointer; font-size: 13.5px; font-weight: 600; margin-bottom: 3px;
}
.sidebar-item:hover { background: var(--bg-panel); }
.sidebar-item.active { background: var(--bg-panel-raised); color: var(--text); }
.sidebar-item.active svg { color: var(--brass); }
.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-faint); }

.main-area { flex: 1; padding: 32px 32px 60px; max-width: 800px; }
.main-area .intro { margin-bottom: 28px; }
.main-area .intro h1 { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 500; margin: 0 0 8px; }
.main-area .intro p { color: var(--text-muted); font-size: 14px; margin: 0; }

.view { display: none; }
.view.active { display: block; }

/* ---------- Dashboard ---------- */

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 700; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; font-family: 'Fraunces', serif; }
.stat-value.accent { color: var(--brass-bright); }
.stat-value.success { color: var(--success); }
.stat-value.error { color: var(--error); }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--text-faint); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.running { background: rgba(198,154,92,0.15); color: var(--brass-bright); }
.badge.success { background: rgba(95,168,125,0.15); color: var(--success); }
.badge.failed { background: rgba(209,104,95,0.15); color: var(--error); }

/* ---------- Ranker / collect step tabs ---------- */

.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.step-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px 20px 18px; cursor: pointer; }
.step-card.selected { border-color: var(--brass); background: var(--bg-panel-raised); }
.step-num { font-family: 'Fraunces', serif; font-size: 12px; color: var(--text-faint); letter-spacing: 0.1em; display: block; margin-bottom: 10px; }
.step-card.selected .step-num { color: var(--brass); }
.step-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.step-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.footnote { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 30px; }

@media (max-width: 780px) {
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; display: flex; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 10px 12px; gap: 4px; }
  .sidebar-item { white-space: nowrap; margin-bottom: 0; }
  .main-area { padding: 24px 18px 50px; }
}

@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .main-area .intro h1 { font-size: 21px; }
}
