:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --accent: #0ea5e9;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-mute: #94a3b8;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 600px at 80% -10%, rgba(79,70,229,.15), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(14,165,233,.12), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 800; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(79,70,229,.35);
}
.brand-logo.sm { width: 34px; height: 34px; font-size: 18px; border-radius: 9px; }
.brand-name { font-weight: 800; font-size: 22px; letter-spacing: -.5px; }
.brand-tag { font-size: 12px; color: var(--ink-mute); }
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }
.login-card form label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 6px; }
.login-card form input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fbfcfe; transition: border .15s, box-shadow .15s;
}
.login-card form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 600; font-size: 14px;
  border-radius: 10px; padding: 11px 20px; transition: transform .1s, box-shadow .15s, background .15s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background: #e0e7ff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-block { width: 100%; margin-top: 10px; }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.login-demo { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--ink-mute); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.login-demo code { background: var(--bg); padding: 2px 8px; border-radius: 6px; font-size: 12px; color: var(--ink-soft); }

/* ============ APP SHELL ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-sep { color: var(--line); font-weight: 300; }
.topbar-sub { color: var(--ink-mute); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.usage-pill {
  background: var(--green-bg); color: var(--green); font-weight: 600; font-size: 13px;
  padding: 6px 14px; border-radius: 999px; border: 1px solid #d1fae5;
}
.user-chip { font-weight: 600; font-size: 14px; color: var(--ink); }
.content { max-width: 1200px; margin: 0 auto; padding: 24px 24px 80px; }

/* Tabs */
.tabbar { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab-btn {
  border: none; background: transparent; font-family: inherit; font-size: 15px; font-weight: 600;
  color: var(--ink-mute); padding: 12px 18px; cursor: pointer; border-bottom: 3px solid transparent; transition: color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; animation: fadeIn .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card h2 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.card-sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h2 { margin: 0; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fbfcfe; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }

/* JD output */
.jd-output {
  font-size: 14px; line-height: 1.7; color: var(--ink); white-space: pre-wrap; word-wrap: break-word;
  max-height: 560px; overflow-y: auto; padding: 4px;
}
.jd-output h1 { font-size: 22px; margin-bottom: 12px; }
.jd-output h2 { font-size: 16px; margin: 20px 0 8px; color: var(--primary); }
.jd-output table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.jd-output th, .jd-output td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.jd-output th { background: var(--primary-light); }
.jd-output strong { color: var(--ink); }

/* Status */
.status-line { margin-top: 16px; font-size: 14px; color: var(--ink-soft); }
.status-line.loading { color: var(--primary); font-weight: 600; }
.status-line.error { color: var(--red); font-weight: 600; }
.status-line.ok { color: var(--green); font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table#results-table { width: 100%; border-collapse: collapse; font-size: 14px; }
#results-table th {
  text-align: left; padding: 12px 14px; background: var(--bg); color: var(--ink-soft);
  font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
#results-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#results-table tbody tr { cursor: pointer; transition: background .12s; }
#results-table tbody tr:hover { background: var(--primary-light); }
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 13px;
}
.score-high { background: var(--green-bg); color: var(--green); }
.score-mid { background: var(--amber-bg); color: var(--amber); }
.score-low { background: var(--red-bg); color: var(--red); }
a.github-link { color: var(--primary); text-decoration: none; font-weight: 500; }
a.github-link:hover { text-decoration: underline; }
.skill-cell { font-weight: 700; text-align: center; }
.sk-high { color: var(--green); background: var(--green-bg); border-radius: 6px; }
.sk-mid { color: var(--amber); background: var(--amber-bg); border-radius: 6px; }
.sk-low { color: var(--red); background: var(--red-bg); border-radius: 6px; }
.score-legend { margin-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.legend-title { font-weight: 700; color: var(--ink-soft); }

/* Skill bars in resume */
.skill-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.skill-name { min-width: 130px; font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.skill-bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.skill-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .5s ease; }
.skill-val { min-width: 42px; text-align: right; font-weight: 700; font-size: 13px; color: var(--primary); }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-sub { display: none; }
}
