:root {
    --bg: #080a0f;
    --bg-soft: #0b0d13;
    --surface: rgba(20, 23, 31, 0.86);
    --surface-2: rgba(25, 28, 37, 0.92);
    --surface-3: #10131b;
    --line: rgba(255, 255, 255, 0.095);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f7fb;
    --muted: #9ca3af;
    --muted-2: #737b8c;
    --brand: #7f56d9;
    --brand-2: #9e77ed;
    --brand-3: #53389e;
    --green: #12b76a;
    --green-bg: rgba(18, 183, 106, 0.12);
    --orange: #f79009;
    --orange-bg: rgba(247, 144, 9, 0.13);
    --red: #f04438;
    --red-bg: rgba(240, 68, 56, 0.12);
    --pink: #f63d68;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
    --radius-lg: 18px;
    --radius-xl: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 22% 0%, rgba(127, 86, 217, 0.24), transparent 28%),
        radial-gradient(circle at 88% 22%, rgba(83, 56, 158, 0.18), transparent 26%),
        linear-gradient(135deg, #07080c 0%, #0b0d13 45%, #090b10 100%);
    color: var(--text);
    min-height: 100vh;
}

button,
input,
textarea { font: inherit; }

button { cursor: pointer; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px 1fr;
}

.sidebar {
    border-right: 1px solid var(--line);
    background: rgba(8, 10, 15, 0.82);
    backdrop-filter: blur(24px);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand-row,
.usage-top,
.profile-card,
.topbar,
.top-actions,
.search-box,
.heading-pills,
.hero-badges,
.card-title,
.field-label-row,
.helper-toggle,
.metric-card,
.section-check,
.competency-row,
.signal-grid {
    display: flex;
    align-items: center;
}

.brand-row { gap: 12px; padding: 0 2px 12px; }
.brand-row strong { display: block; font-size: 16px; letter-spacing: -0.02em; }
.brand-row span,
.usage-top span,
.profile-card span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.brand-mark,
.spark-icon,
.metric-icon,
.card-title span,
.upload-icon {
    display: grid;
    place-items: center;
    color: var(--brand-2);
    background: linear-gradient(135deg, rgba(127, 86, 217, 0.22), rgba(127, 86, 217, 0.06));
    border: 1px solid rgba(158, 119, 237, 0.28);
    box-shadow: inset 0 0 18px rgba(127, 86, 217, 0.13);
}

.brand-mark { width: 42px; height: 42px; border-radius: 12px; }

.side-nav { display: grid; gap: 6px; }
.nav-item {
    color: #d0d5dd;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 650;
    font-size: 14px;
    position: relative;
}
.nav-item span { width: 22px; color: #c8cce0; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); }
.nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(127, 86, 217, 0.3), rgba(127, 86, 217, 0.12));
    box-shadow: inset 3px 0 0 var(--brand-2);
}
.nav-item.active span { color: var(--brand-2); }

.usage-card,
.profile-card,
.card,
.search-box,
.btn-secondary,
.icon-button {
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.usage-card {
    margin-top: auto;
    border-radius: 14px;
    padding: 16px;
}
.usage-top { gap: 10px; }
.spark-icon { width: 34px; height: 34px; border-radius: 10px; }
.usage-bar { margin: 16px 0 12px; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.usage-bar span { display: block; width: 72%; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: inherit; }
.usage-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.usage-meta strong { color: var(--text); }

.profile-card {
    border-radius: 14px;
    padding: 12px;
    gap: 10px;
    box-shadow: none;
}
.avatar,
.top-avatar {
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: linear-gradient(135deg, #f2f4f7, #d0d5dd);
    color: #344054;
    font-weight: 850;
}
.avatar { width: 38px; height: 38px; }
.top-avatar { width: 42px; height: 42px; }
.chevron { margin-left: auto; color: var(--muted); }

.main-shell { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 78px;
    padding: 14px 28px;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 10, 15, 0.78);
    backdrop-filter: blur(20px);
}
.search-box {
    width: min(560px, 48vw);
    height: 48px;
    border-radius: 12px;
    gap: 10px;
    padding: 0 12px;
    box-shadow: none;
}
.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}
.search-box input::placeholder,
textarea::placeholder,
.field-group input::placeholder { color: var(--muted-2); }
kbd {
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 12px;
    background: rgba(255,255,255,0.04);
}
.top-actions { gap: 12px; }

.btn,
.icon-button {
    border-radius: 10px;
    height: 46px;
    padding: 0 18px;
    font-weight: 800;
    color: var(--text);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.btn:hover,
.icon-button:hover { transform: translateY(-1px); }
.btn-primary {
    border: 1px solid rgba(158,119,237,0.55);
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 16px 34px rgba(127, 86, 217, 0.28);
}
.btn-secondary,
.icon-button { background: rgba(255,255,255,0.04); box-shadow: none; }
.icon-button { width: 46px; padding: 0; }
.btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.page-heading,
.input-card,
.empty-scorecard,
.results-stack {
    width: min(1560px, calc(100% - 44px));
    margin-left: auto;
    margin-right: auto;
}
.page-heading {
    padding: 24px 0 18px;
    display: flex;
    justify-content: space-between;
    gap: 22px;
    align-items: end;
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--brand-2);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 850;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.035em; }
h1 { font-size: clamp(30px, 4vw, 46px); line-height: 1.05; }
.page-heading p:not(.eyebrow) { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.heading-pills { gap: 8px; flex-wrap: wrap; justify-content: end; }
.heading-pills span,
.source-pill,
.recommendation,
.tags span,
.mini-score,
.section-check em {
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.045);
    color: #d0d5dd;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.card {
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(26, 29, 38, 0.92), rgba(15, 18, 26, 0.92));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.input-card { padding: 20px; }
.analysis-form {
    display: grid;
    grid-template-columns: 300px minmax(250px, 0.8fr) minmax(320px, 1.15fr) minmax(360px, 1.25fr);
    gap: 26px;
    align-items: stretch;
}
.upload-dropzone {
    min-height: 164px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    text-align: center;
    border: 1px dashed rgba(158,119,237,0.62);
    border-radius: 16px;
    background: rgba(127,86,217,0.07);
    color: var(--text);
    cursor: pointer;
    transition: all 0.18s ease;
}
.upload-dropzone.dragging,
.upload-dropzone:hover {
    border-color: var(--brand-2);
    background: rgba(127,86,217,0.13);
}
.upload-dropzone input { display: none; }
.upload-icon { width: 52px; height: 52px; border-radius: 15px; font-size: 25px; }
.upload-dropzone small { color: var(--muted); line-height: 1.55; }
.upload-dropzone small span { color: var(--green); }

.field-group { display: grid; align-content: start; gap: 10px; }
.field-group label,
.field-label-row label { font-weight: 750; color: var(--text); }
.field-label-row { justify-content: space-between; align-items: baseline; }
.field-label-row span,
.field-label-row small { color: var(--muted); font-weight: 650; }
.field-group input,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    outline: none;
    border-radius: 12px;
    background: rgba(8,10,15,0.5);
    color: var(--text);
    padding: 14px 16px;
}
.field-group input:focus,
textarea:focus {
    border-color: rgba(158,119,237,0.72);
    box-shadow: 0 0 0 4px rgba(127,86,217,0.15);
}
textarea { min-height: 106px; resize: vertical; }
.evidence-group textarea { min-height: 168px; font-size: 13px; line-height: 1.45; }
.jd-group textarea { min-height: 126px; }
.helper-toggle {
    margin-top: 34px;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.035);
    color: var(--muted);
    font-size: 13px;
}
.toggle-on {
    width: 38px; height: 22px; border-radius: 999px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); padding: 3px;
}
.toggle-on i { display: block; width: 16px; height: 16px; margin-left: auto; border-radius: 999px; background: #fff; }
.analyse-btn { width: 210px; margin-left: auto; margin-top: 2px; }
.evidence-group .analyse-btn { margin-top: 0; }
.status-text { margin: 14px 2px 0; color: var(--muted); min-height: 21px; font-size: 14px; }

.empty-scorecard {
    margin-top: 14px;
    min-height: 430px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    padding: 40px;
}
.empty-art {
    width: 92px;
    height: 116px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    background: rgba(127,86,217,0.12);
    border: 1px solid rgba(158,119,237,0.32);
    color: var(--brand-2);
    font-weight: 950;
    margin-bottom: 18px;
}
.empty-scorecard h2 { font-size: 26px; }
.empty-scorecard p { color: var(--muted); max-width: 520px; line-height: 1.6; }
.hidden { display: none !important; }
.results-stack { margin-top: 14px; padding-bottom: 46px; display: grid; gap: 14px; }

.score-hero {
    display: grid;
    grid-template-columns: 184px 1fr 1.2fr;
    gap: 28px;
    align-items: center;
    padding: 22px 28px;
}
.score-ring {
    width: 154px;
    height: 154px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    align-content: center;
    background: conic-gradient(var(--ring-color) 0deg var(--score-deg), rgba(255,255,255,0.08) var(--score-deg) 360deg);
    border: 12px solid rgba(10,12,18,0.88);
    box-shadow: inset 0 0 0 1px var(--line), 0 18px 44px rgba(0,0,0,0.32);
}
.score-ring.high { --ring-color: var(--green); }
.score-ring.medium { --ring-color: var(--orange); }
.score-ring.low { --ring-color: var(--red); }
.score-number { font-size: 38px; line-height: 1; font-weight: 950; letter-spacing: -0.06em; }
.score-number span { font-size: 20px; }
.score-ring small { margin-top: 5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; font-weight: 800; }
.score-main-copy h2 { font-size: clamp(34px, 4vw, 48px); }
.score-main-copy h2 span { color: var(--brand-2); }
.hero-badges { gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.recommendation.high { border-color: rgba(18,183,106,0.35); background: var(--green-bg); color: #75e0a7; }
.recommendation.medium { border-color: rgba(247,144,9,0.35); background: var(--orange-bg); color: #fec84b; }
.recommendation.low { border-color: rgba(240,68,56,0.35); background: var(--red-bg); color: #fda29b; }
.score-summary { border-left: 1px solid var(--line-strong); padding-left: 28px; }
.score-summary p { margin: 0; color: #d0d5dd; line-height: 1.65; }
.score-summary small { display: block; margin-top: 10px; color: var(--muted); line-height: 1.45; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.metric-card { min-height: 104px; padding: 16px; gap: 12px; align-content: start; flex-wrap: wrap; }
.metric-card > div:nth-child(2) { flex: 1; min-width: 120px; }
.metric-icon { width: 42px; height: 42px; border-radius: 12px; font-weight: 900; }
.metric-card p { margin: 0 0 3px; color: #d0d5dd; font-size: 13px; }
.metric-card strong { font-size: 24px; letter-spacing: -0.03em; }
.progress { width: 100%; height: 6px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

.insight-grid { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr 1.1fr; gap: 10px; }
.insight-card,
.suggestions-card,
.section-card,
.detail-card,
.competency-card { padding: 18px; }
.card-title { gap: 10px; margin-bottom: 14px; }
.card-title span { width: 28px; height: 28px; border-radius: 9px; font-size: 14px; }
.card-title h3,
.detail-card h3 { font-size: 16px; }
.positive .card-title span { color: #75e0a7; background: var(--green-bg); border-color: rgba(18,183,106,0.28); }
.warning .card-title span { color: #fec84b; background: var(--orange-bg); border-color: rgba(247,144,9,0.28); }

.clean-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.clean-list li {
    color: #cfd4df;
    line-height: 1.45;
    position: relative;
    padding-left: 18px;
    font-size: 13.5px;
}
.clean-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--brand-2);
}
.positive .clean-list li::before { background: var(--green); }
.warning .clean-list li::before { background: var(--orange); }
.muted { color: var(--muted); line-height: 1.5; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span { color: #d0d5dd; background: rgba(255,255,255,0.055); }
.tags.missing span { border-color: rgba(246,61,104,0.28); color: #fd6f8e; background: rgba(246,61,104,0.08); }
.tags.matched span { border-color: rgba(18,183,106,0.28); color: #75e0a7; background: var(--green-bg); }

.wide-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 10px; }
.section-check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.section-check {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,0.035);
    padding: 14px;
    gap: 8px;
    flex-wrap: wrap;
}
.section-check > span { color: var(--muted); }
.section-check strong { flex: 1; min-width: 80px; }
.section-check em { font-style: normal; padding: 5px 8px; }
.section-check em.good { color: #75e0a7; background: var(--green-bg); border-color: rgba(18,183,106,0.28); }
.section-check em.bad { color: #fda29b; background: var(--red-bg); border-color: rgba(240,68,56,0.28); }
.section-check small { width: 100%; color: var(--muted); line-height: 1.45; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-card p { color: #cfd4df; line-height: 1.65; margin: 12px 0 0; }
.signal-grid { gap: 10px; margin-top: 14px; align-items: stretch; }
.signal-grid > div {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px;
    background: rgba(255,255,255,0.035);
}
.signal-grid small { display: block; color: var(--muted); margin-bottom: 6px; }
.signal-grid strong { line-height: 1.45; display: block; }

.competency-table { display: grid; gap: 9px; }
.competency-row {
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: rgba(255,255,255,0.035);
}
.competency-row p { color: #cfd4df; margin: 6px 0 0; line-height: 1.45; }
.competency-row small { display: block; color: #fda29b; margin-top: 6px; line-height: 1.45; }
.mini-score.high { color: #75e0a7; background: var(--green-bg); border-color: rgba(18,183,106,0.28); }
.mini-score.medium { color: #fec84b; background: var(--orange-bg); border-color: rgba(247,144,9,0.28); }
.mini-score.low { color: #fda29b; background: var(--red-bg); border-color: rgba(240,68,56,0.28); }

@media (max-width: 1420px) {
    .analysis-form { grid-template-columns: 300px 1fr 1fr; }
    .evidence-group { grid-column: 2 / -1; }
}

@media (max-width: 1220px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .side-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .usage-card, .profile-card { display: none; }
    .analysis-form,
    .score-hero,
    .metric-grid,
    .insight-grid,
    .wide-grid,
    .detail-grid { grid-template-columns: 1fr; }
    .score-summary { border-left: 0; border-top: 1px solid var(--line-strong); padding-left: 0; padding-top: 18px; }
    .section-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-box { width: 100%; }
    .topbar { height: auto; flex-direction: column; align-items: stretch; }
    .top-actions { flex-wrap: wrap; }
}

@media (max-width: 720px) {
    .page-heading { flex-direction: column; align-items: start; }
    .page-heading, .input-card, .empty-scorecard, .results-stack { width: min(100% - 24px, 1560px); }
    .side-nav { grid-template-columns: 1fr; }
    .top-actions .btn { flex: 1; }
    .section-check-grid { grid-template-columns: 1fr; }
    .analyse-btn { width: 100%; }
}

@media print {
    body { background: #fff; color: #111827; }
    .sidebar,
    .topbar,
    .input-card,
    .empty-scorecard,
    .page-heading .heading-pills { display: none !important; }
    .app-shell { display: block; }
    .main-shell { width: 100%; }
    .page-heading,
    .results-stack { width: 100%; margin: 0; padding: 0; }
    .card { box-shadow: none; background: #fff; color: #111827; border-color: #d0d5dd; break-inside: avoid; }
    .score-summary p,
    .detail-card p,
    .competency-row p,
    .clean-list li { color: #344054; }
}

.resume-builder-cta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 22px;
    border-color: rgba(164,138,251,0.35);
    background:
        radial-gradient(circle at top left, rgba(164,138,251,0.18), transparent 36%),
        rgba(17, 24, 39, 0.82);
}
.resume-builder-cta h3 { margin: 4px 0 8px; font-size: 20px; letter-spacing: -0.02em; }
.resume-builder-cta p { color: var(--muted); margin: 0; line-height: 1.55; max-width: 760px; }
.builder-controls {
    min-width: 280px;
    display: grid;
    gap: 8px;
    align-items: start;
}
.builder-controls label {
    color: #f2f4f7;
    font-weight: 700;
    font-size: 13px;
}
.builder-controls small {
    color: var(--muted);
    line-height: 1.4;
}
.format-select {
    width: 100%;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(11,18,32,0.86);
    color: #f9fafb;
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
    font: inherit;
}
.format-select:focus {
    border-color: rgba(164,138,251,0.75);
    box-shadow: 0 0 0 4px rgba(164,138,251,0.14);
}
.format-pill {
    display: inline-flex;
    margin-top: 12px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(164,138,251,0.35);
    background: rgba(164,138,251,0.12);
    color: #d9d1ff;
    font-size: 12px;
    font-weight: 700;
}

.builder-output { display: grid; gap: 12px; }
.builder-output.hidden { display: none; }
.builder-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
}
.builder-hero h2 { margin: 6px 0 8px; font-size: 26px; letter-spacing: -0.03em; }
.builder-hero p { color: #d7dce6; margin: 0; line-height: 1.55; }
.builder-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.builder-grid .wide { grid-column: 1 / -1; }
.builder-card h3 { margin: 0 0 12px; font-size: 16px; }
.builder-card p { color: #d7dce6; line-height: 1.65; margin: 0; }
.warning-card { border-color: rgba(247,144,9,0.22); }
.rewrite-block {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255,255,255,0.035);
    padding: 14px;
    margin-top: 10px;
}
.rewrite-block:first-of-type { margin-top: 0; }
.rewrite-block strong { display: block; margin-bottom: 8px; }
.markdown-card pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(2, 6, 23, 0.56);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    color: #eef2ff;
    line-height: 1.65;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    max-height: 720px;
    overflow: auto;
}

@media (max-width: 1220px) {
    .resume-builder-cta,
    .builder-hero { flex-direction: column; align-items: stretch; }
    .builder-grid { grid-template-columns: 1fr; }
}

.inline-export {
    margin-top: 14px;
    width: fit-content;
}

.builder-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

/* Resume format selector fix */
.resume-format-panel {
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.035);
    border-radius: 16px;
    padding: 14px;
    display: grid;
    gap: 10px;
}

.resume-format-panel .format-helper {
    color: var(--muted);
    line-height: 1.5;
}

/* Resume PDF layout export selector */
.export-layout-actions {
    align-items: flex-end;
}
.pdf-layout-field {
    min-width: 190px;
    display: grid;
    gap: 6px;
    color: #f2f4f7;
    font-size: 12px;
    font-weight: 700;
}
.compact-select {
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 13px;
}
