:root {
    --navy: #1a2744;
    --navy-dark: #0f1a2f;
    --navy-mid: #243159;
    --navy-light: #2e4480;
    --white: #ffffff;
    --accent: #c6a75a;
    --accent-light: rgba(198, 167, 90, 0.15);
    --accent-mid: rgba(198, 167, 90, 0.28);
    --text: #e8eaf2;
    --text-dim: rgba(232,234,242,0.55);
    --surface: #141e35;
    --surface-2: #1b2744;
    --surface-3: #212f50;
    --surface-4: #263258;
    --card: #1e2d4d;
    --line: rgba(255,255,255,0.08);
    --line-strong: rgba(255,255,255,0.13);
    --muted: rgba(200,208,230,0.6);
    --expand-bg: #192339;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: var(--surface);
    min-height: 100vh;
}

/* ── TOP BAR ── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 56px;
    height: 64px;
    background: var(--navy-dark);
    border-bottom: 1px solid var(--line-strong);
    box-shadow: 0 1px 0 rgba(198,167,90,0.15), 0 4px 20px rgba(0,0,0,0.4);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { display: flex; flex-direction: column; gap: 1px; }

.brand-mark {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--white);
}

.brand-x { color: var(--accent); }

.brand-sub {
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.top-nav { display: flex; gap: 4px; align-items: center; }

.top-nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 999px;
    transition: all 0.18s ease;
}

.top-nav a:hover,
.top-nav a.active {
    color: var(--white);
    background: rgba(255,255,255,0.09);
}

.logout {
    border: 1px solid rgba(255,255,255,0.18) !important;
    margin-left: 8px;
}

.logout:hover {
    border-color: rgba(255,255,255,0.35) !important;
}

/* ── NAV DROPDOWN ── */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    color: var(--text-dim);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-block;
    user-select: none;
}

.nav-dropdown:hover .nav-dropdown-trigger {
    color: var(--white);
    background: rgba(255,255,255,0.09);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid var(--line-strong);
    overflow: hidden;
    z-index: 50;
    min-width: 180px;
    animation: fadeUp 0.15s ease;
}

.nav-dropdown:hover .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text) !important;
    text-decoration: none;
    transition: background 0.12s;
    border-radius: 0 !important;
    background: none !important;
}

.nav-dropdown-menu a:hover {
    background: var(--surface-3) !important;
    color: var(--white) !important;
}

.nav-placeholder-tag {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.7;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(198,167,90,0.3);
}

/* ── LAYOUT ── */
.main-content { padding: 40px 56px 80px; }

.section-header { margin-bottom: 24px; }

.section-header h2 {
    margin: 0 0 5px;
    font-size: 22px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.02em;
}

.section-header p { margin: 0; color: var(--muted); font-size: 14px; }

.tabs { display: grid; gap: 32px; }
.tab-panel { display: none; animation: fadeUp 0.3s ease; }
.tab-panel.active { display: block; }

/* ── HISTORY TABLE ── */
.history-table {
    background: var(--card);
    border-radius: 14px;
    overflow: visible;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2), 0 16px 40px rgba(0,0,0,0.3);
    border: 1px solid var(--line-strong);
}

/* clip the rounded corners but allow dropdowns to overflow */
.history-table > :first-child { border-radius: 14px 14px 0 0; overflow: hidden; }

.history-row {
    display: grid;
    grid-template-columns: 32px 2.4fr 1.1fr 0.9fr 0.7fr 0.7fr 0.7fr 0.7fr;
    gap: 10px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.14s ease;
    align-items: center;
}

/* History row cells — consistent font size, no wrap */
.history-row .col-company {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #dc143c;
    font-weight: 600;
}
.history-row .col-role,
.history-row .col-date {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-row:last-of-type { border-bottom: none; }

.history-row:not(.history-head):hover { background: var(--surface-3); }

.history-head {
    background: var(--surface-4);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    cursor: default;
    border-bottom: 1px solid var(--line-strong) !important;
    border-radius: 14px 14px 0 0;
}

.row-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    opacity: 0.85;
}

.chevron-icon {
    transition: transform 0.2s ease;
}

.history-row.expanded .chevron-icon {
    transform: rotate(180deg);
}

/* ── DOC PILL ── */
.doc-pill { display: inline-block; }

.doc-pill-label {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 12.5px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 6px;
    background: var(--accent-light);
    border: 1px solid rgba(198,167,90,0.2);
    white-space: nowrap;
    transition: background 0.14s, border-color 0.14s;
}

.doc-pill-label a {
    color: var(--accent) !important;
    text-decoration: none;
    background: none !important;
    padding: 0 2px !important;
    border-radius: 3px !important;
    font-weight: 600;
    transition: color 0.12s;
}

.doc-pill-label a:hover {
    color: #e0c870 !important;
    background: none !important;
}

.pill-sep {
    color: rgba(198,167,90,0.4);
    font-weight: 400;
    padding: 0 1px;
}

/* ── EXPAND PANEL ── */
.history-expand {
    display: none;
    padding: 13px 20px 15px;
    background: var(--expand-bg);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
    border-left: 3px solid var(--accent);
    transition: all 0.2s ease;
}

.history-expand.active {
    display: block;
    animation: expandDown 0.18s ease;
}

.history-expand a { color: var(--accent); font-weight: 500; word-break: break-all; }
.history-expand a:hover { color: #d4b870; }

.url-text {
    font-size: 12px;
    color: var(--muted) !important;
    font-weight: 400;
    word-break: break-all;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(200,208,230,0.3);
}

.url-text:hover {
    color: var(--text) !important;
}

/* ── PLATFORM BADGES ── */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px 6px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none !important;
    transition: filter 0.15s, transform 0.15s;
    letter-spacing: 0.01em;
}

.platform-badge:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

.platform-badge.linkedin {
    background: #0a66c2;
    color: #ffffff !important;
}

.platform-badge.indeed {
    background: #003a9b;
    color: #ffffff !important;
}

.platform-badge.generic {
    background: var(--surface-3);
    color: var(--text) !important;
    border: 1px solid var(--line-strong);
}

/* ── CARDS ── */
.step-card {
    background: var(--card);
    border-radius: 14px;
    padding: 24px 28px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2), 0 12px 30px rgba(0,0,0,0.25);
    margin-bottom: 20px;
    border: 1px solid var(--line-strong);
}

.step-label {
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 16px;
}

.form-row { margin-bottom: 16px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

input, textarea, select {
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(198,167,90,0.12);
}

textarea { resize: vertical; }

button, .primary, .secondary {
    border: none;
    border-radius: 999px;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    letter-spacing: 0.01em;
}

.primary {
    background: linear-gradient(135deg, #b8922a 0%, #d4aa4e 100%);
    color: var(--navy-dark);
    box-shadow: 0 4px 14px rgba(198,167,90,0.3);
}

.primary:hover {
    background: linear-gradient(135deg, #c9a33c 0%, #e0bb60 100%);
    box-shadow: 0 6px 20px rgba(198,167,90,0.45);
    transform: translateY(-1px);
}

.secondary {
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--line-strong);
}

.secondary:hover { background: var(--surface-4); }

.btn-secondary {
    background: var(--surface-3);
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: all 0.15s;
}
.btn-secondary:hover { background: var(--surface-4); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

.input-row { display: flex; gap: 12px; align-items: center; }
.helper { margin-top: 8px; color: var(--muted); font-size: 13px; }

.toggle-group { display: flex; gap: 10px; }

.toggle {
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line-strong);
}

.toggle.active {
    background: var(--navy-light);
    color: var(--white);
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(26,39,68,0.3);
}

/* ── PROGRESS ── */
.progress { display: flex; flex-direction: column; gap: 12px; }
.progress-line { font-weight: 700; color: var(--accent); }
.status-list { display: grid; gap: 8px; color: var(--muted); }

/* ── PREVIEW ── */
.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.preview-card {
    background: var(--surface-2);
    border-radius: 14px;
    padding: 16px;
    border: 1px solid var(--line-strong);
}

.preview-header { display: flex; flex-direction: column; gap: 8px; }
.preview-header h3 { margin: 0; color: var(--white); font-size: 14px; }
.preview-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.preview-actions a, .preview-actions button { font-size: 11px; padding: 5px 10px; white-space: nowrap; }

.preview-body {
    height: 520px;
    overflow: hidden;
    background: var(--white);
    border-radius: 10px;
    padding: 0;
    margin-top: 12px;
    border: 1px solid var(--line);
    position: relative;
}

.preview-body iframe {
    width: 154%;
    height: 154%;
    border: none;
    transform: scale(0.65);
    transform-origin: top left;
    pointer-events: none;
}

.docx-note { margin-top: 12px; font-size: 12px; color: var(--muted); }

.review-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

/* ── HEADSHOTS ── */
.headshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.headshot-item {
    border: 2px solid transparent;
    background: var(--surface-3);
    border-radius: 12px;
    padding: 6px;
    cursor: pointer;
    min-height: 86px;
    transition: all 0.15s;
}

.headshot-item img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
}

.headshot-item.selected {
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(198,167,90,0.25);
}



/* ── MISC ── */
.thumb {
    width: 120px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
}

.empty-state {
    padding: 48px 28px;
    background: var(--card);
    border-radius: 14px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line-strong);
    font-size: 15px;
}

/* ── LOGIN ── */
.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 25% 20%, rgba(46,68,128,0.5) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(198,167,90,0.12) 0%, transparent 50%),
        var(--surface);
}

.login-card {
    background: var(--card);
    padding: 40px 36px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3), 0 30px 60px rgba(0,0,0,0.4);
    width: min(400px, 90vw);
    border: 1px solid var(--line-strong);
}

.login-card h1 {
    margin: 0 0 4px;
    color: var(--white);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card form { display: grid; gap: 14px; margin-top: 20px; }
.login-note { margin-top: 16px; font-size: 12px; color: var(--text-dim); }

/* ── FLASH ── */
.flash-zone { margin-bottom: 20px; }

.flash {
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(198,167,90,0.1);
    color: var(--accent);
    border-left: 3px solid var(--accent);
    font-size: 14px;
}

.flash.error {
    background: rgba(248,113,113,0.1);
    color: #fca5a5;
    border-left-color: #f87171;
}

/* ── MODAL ── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(8,14,28,0.7);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 20;
}

.modal-content {
    background: var(--card);
    border-radius: 16px;
    padding: 28px;
    width: min(520px, 94vw);
    display: grid;
    gap: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 1px solid var(--line-strong);
}

.modal-content.large { width: min(720px, 94vw); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-status { font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes expandDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .top-bar { flex-direction: column; align-items: flex-start; gap: 14px; padding: 16px 20px; height: auto; }
    .main-content { padding: 24px 20px 60px; }
    .history-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── GENERATION OVERLAY ── */
.gen-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gen-overlay.hidden { display: none; }

.gen-spinner-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.gen-globe {
    font-size: 64px;
    animation: spin-globe 2s linear infinite;
    filter: drop-shadow(0 0 20px rgba(198,167,90,0.5));
}

@keyframes spin-globe {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.gen-spinner-label {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.gen-spinner-sub {
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0.03em;
}

/* ── Mobile footer — hidden on desktop ── */
.mob-footer { display: none; }

/* ── Mobile doc pills — hidden on desktop ── */
.mobile-doc-pill { display: none; }
.mobile-pills-row { display: none; }

/* ── MOBILE — History browse only ── */
@media (max-width: 768px) {

    /* Mobile footer */
    .mob-footer {
        display: block;
        text-align: center;
        margin-top: 48px;
        padding: 14px 20px 32px;
        font-size: 11px;
        color: #f97316;
        border-top: 1px solid rgba(249, 115, 22, 0.3);
        line-height: 1.5;
    }

    /* Hide Generate tab — history only on mobile */
    .tab-link[data-tab="new"] { display: none; }

    /* Swap desktop pill for mobile pill */
    .doc-pill { display: none; }
    /* Show mobile pills row, hide desktop pill columns */
    .mobile-pills-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 8px;
    }
    .doc-pill { display: none; }
    /* Hide desktop grid columns (resume-pdf, cover-pdf, resume-docx, cover-docx) */
    .history-row > div:nth-child(6),
    .history-row > div:nth-child(7),
    .history-row > div:nth-child(8),
    .history-row > div:nth-child(9) { display: none; }

    .mobile-doc-btn {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 8px 14px;
        border-radius: 8px;
        background: var(--surface-3);
        color: var(--white);
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        border: 1px solid var(--line);
        white-space: nowrap;
    }
    .mobile-doc-btn:active { opacity: 0.75; }

    /* Tighten layout */
    .main-content { padding: 12px 12px 60px; }

    /* Compact header */
    .top-bar { padding: 10px 14px; height: auto; flex-wrap: wrap; gap: 8px; }
    .brand-sub { display: none; }
    .nav-dropdown { display: none; }

    /* History table → stacked cards */
    .history-row.history-head { display: none; }

    .history-row {
        display: flex;
        flex-direction: column;
        gap: 3px;
        padding: 14px 16px;
        border-radius: 10px;
        margin-bottom: 8px;
        border: 1px solid var(--line-strong);
        background: var(--surface-2);
        cursor: pointer;
    }

    /* Hide chevron, DOCX columns */
    .history-row .row-chevron { display: none; }


    /* Company — crimson, wraps — order 1 */
    .history-row .col-company {
        font-size: 15px;
        font-weight: 700;
        color: #dc143c;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        order: 1;
    }

    /* Role — muted */
    .history-row .col-role {
        font-size: 13px;
        color: var(--muted);
        white-space: normal;
        order: 2;
    }

    /* Date — small, muted */
    .history-row .col-date {
        font-size: 11px;
        color: var(--muted);
        order: 3;
        margin-bottom: 8px;
    }

    /* Mobile expand button — hidden on desktop */
    .mob-expand-btn { display: none; }

    /* Mobile expand toggle */
    .mob-expand-btn {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        order: 11;
        align-self: flex-start;
        margin-top: 6px;
        padding: 5px 10px;
        border-radius: 6px;
        background: transparent;
        color: var(--muted);
        font-size: 11px;
        font-weight: 500;
        border: 1px solid var(--line);
        cursor: pointer;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    .mob-expand-btn.expanded { color: var(--accent); border-color: var(--accent); }
    .mob-expand-btn.expanded .mob-chevron { transform: rotate(180deg); }
    .mob-chevron { transition: transform 0.2s; }

    /* Mobile pills row */
    .mobile-pills-row {
        order: 10;
        flex-direction: row;
        gap: 10px;
        align-items: flex-start;
    }

    /* Dropdown trigger */
    .mob-doc-dropdown { position: relative; }
    .mob-doc-trigger {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 8px 14px;
        border-radius: 8px;
        background: var(--surface-3);
        color: var(--white);
        font-size: 13px;
        font-weight: 600;
        border: 1px solid var(--line);
        cursor: pointer;
        white-space: nowrap;
    }
    .mob-doc-menu {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        background: var(--surface-3);
        border: 1px solid var(--line-strong);
        border-radius: 8px;
        overflow: hidden;
        z-index: 100;
        min-width: 130px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    }
    .mob-doc-menu.open { display: block; }
    .mob-doc-menu a {
        display: block;
        padding: 10px 16px;
        color: var(--white);
        text-decoration: none;
        font-size: 13px;
        font-weight: 500;
        border-bottom: 1px solid var(--line);
    }
    .mob-doc-menu a:last-child { border-bottom: none; }
    .mob-doc-menu a:active { background: var(--accent-dim); }

    

    /* Expand panel */
    .history-expand { padding: 12px 16px; }
    .expand-inner { flex-direction: column; gap: 10px; }
    .source-row { flex-wrap: wrap; gap: 8px; }
    .url-text { font-size: 11px; word-break: break-all; }

    /* Hide generate panel + previews entirely */
    #tab-new,
    .preview-grid,
    #review-card { display: none !important; }
}
