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

:root {
    --bg: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #1a2234;
    --bg-input: #0d1321;
    --border: #1e293b;
    --border-focus: #3b82f6;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-heading: #f1f5f9;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --info: #6366f1;
    --info-bg: rgba(99, 102, 241, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --font: 'DM Sans', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Topbar (unified navbar — same spec as public /jobs, /apply, landing) ── */
.topbar {
    background: rgba(13, 17, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.logo {
    font-family: 'Space Mono', 'JetBrains Mono', monospace;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-heading);
    text-decoration: none;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.logo-icon { color: #58a6ff; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-user { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ─── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-admin { background: var(--accent-glow); color: var(--accent); }
.badge-manager { background: var(--success-bg); color: var(--success); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ─── Container ───────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }

/* ─── Page header ─────────────────────────────────────────────── */
.page-header {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.03em;
}
.page-header p { color: var(--text-muted); margin-top: 4px; font-size: 0.93rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: rgba(59, 130, 246, 0.3); }
.card-header { margin-bottom: 1rem; }
.card-header h2 { font-size: 1.15rem; font-weight: 600; color: var(--text-heading); }
.card-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-heading); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* ─── Stats row ───────────────────────────────────────────────── */
.stats-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.stat {
    background: rgba(100, 116, 139, 0.08);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.stat strong { color: var(--text); font-weight: 600; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #000; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group .hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.form-card {
    max-width: 640px;
    margin: 0 auto;
}

/* ─── Table ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
th {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(100, 116, 139, 0.05);
}
tr:hover td { background: rgba(100, 116, 139, 0.04); }

/* ─── Flash messages ──────────────────────────────────────────── */
.flash-container { max-width: 1200px; margin: 0 auto; padding: 1rem 2rem 0; }
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
    transition: opacity 0.3s;
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.flash-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.flash-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.flash-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(99,102,241,0.2); }
.flash-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; opacity: 0.6; }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Login page ──────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 60%), var(--bg);
}
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}
.login-box .logo {
    display: block;
    text-align: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* ─── Candidate test page ─────────────────────────────────────── */
.test-page {
    background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.05) 0%, transparent 60%), var(--bg);
}
.test-container { max-width: 760px; margin: 0 auto; padding: 2rem; }
.test-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}
.test-header h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.test-header p { color: var(--text-muted); }
.question-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.question-number {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.question-text { font-size: 1.05rem; font-weight: 500; margin-bottom: 1rem; color: var(--text-heading); }
.option-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.93rem;
}
.option-label:hover { background: var(--bg-card-hover); border-color: rgba(59,130,246,0.3); }
.option-label input { margin-top: 3px; accent-color: var(--accent); }
.option-label input:checked + span { color: var(--accent); }
.open-answer {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    resize: vertical;
}
.open-answer:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.test-submit { text-align: center; margin-top: 2rem; }
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 2rem;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #818cf8);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ─── Ranking charts ──────────────────────────────────────────── */
.ranking-card {
    display: flex;
    align-items: stretch;
    gap: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
}
.rank-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rank-1 .rank-number { color: #fbbf24; }
.rank-2 .rank-number { color: #94a3b8; }
.rank-3 .rank-number { color: #b45309; }
.ranking-info { flex: 1; }
.ranking-name { font-size: 1.15rem; font-weight: 600; color: var(--text-heading); }
.ranking-email { font-size: 0.82rem; color: var(--text-muted); }
.ranking-summary { font-size: 0.9rem; color: var(--text); margin-top: 0.5rem; }
.ranking-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    flex-shrink: 0;
    position: relative;
}
.score-high { background: var(--success-bg); color: var(--success); border: 2px solid rgba(16,185,129,0.3); }
.score-mid { background: var(--warning-bg); color: var(--warning); border: 2px solid rgba(245,158,11,0.3); }
.score-low { background: var(--error-bg); color: var(--error); border: 2px solid rgba(239,68,68,0.3); }

.score-bars { margin-top: 1rem; }
.score-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 6px;
    font-size: 0.82rem;
}
.score-bar-label { width: 160px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.score-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; transition: width 1s ease; }
.score-bar-value { width: 35px; font-weight: 600; font-family: var(--mono); font-size: 0.8rem; }

/* ─── Status page (candidate) ─────────────────────────────────── */
.status-page {
    text-align: center;
    padding: 4rem 2rem;
}
.status-icon { font-size: 4rem; margin-bottom: 1rem; }
.status-page h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.status-page p { color: var(--text-muted); max-width: 500px; margin: 0 auto; }

/* ─── Copy link ───────────────────────────────────────────────── */
.link-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}
.copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--font);
    transition: all 0.15s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--success); color: var(--success); }

/* ─── Empty state ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

/* ─── Live update banner ──────────────────────────────────────── */
.update-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 2rem;
    background: linear-gradient(90deg, #1e3a5f 0%, #1a2744 100%);
    border-bottom: 1px solid rgba(59,130,246,0.3);
    font-size: 0.85rem;
    color: #93c5fd;
    animation: bannerSlide 0.35s ease;
}
.update-banner.show { display: flex; }
@keyframes bannerSlide { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.update-btn {
    padding: 5px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.update-btn:hover { background: var(--accent-hover); }
.update-dismiss {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.update-dismiss:hover { color: #94a3b8; }

/* ─── Loading overlay (v2.0) ──────────────────────────────── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 14, 23, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.75rem;
    animation: fadeIn 0.2s ease;
}
.loading-overlay.show { display: flex; }

.loading-spinner {
    width: 52px;
    height: 52px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: logihr-spin 0.75s linear infinite;
}
@keyframes logihr-spin { to { transform: rotate(360deg); } }

.loading-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow);
    min-width: 280px;
    max-width: 420px;
    text-align: center;
}

.loading-title {
    color: var(--text-heading);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.loading-sub {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.loading-dots {
    display: flex;
    gap: 6px;
    margin-top: 0.25rem;
}
.loading-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotPulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}


/* ─── Tab navigation ──────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}
.tab-link {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}
.tab-link:hover { color: var(--text); }
.tab-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ─── Stat cards (AI usage) ───────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    text-align: center;
}
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-heading); font-family: 'JetBrains Mono', monospace; }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Utility classes ─────────────────────────────────────────── */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }
.mb-1-5 { margin-bottom: 1.5rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-0-75 { margin-top: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-heading { color: var(--text-heading); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.82rem; }
.flex-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.section-card { margin-bottom: 1.5rem; }
.section-card-padded { margin-bottom: 1.5rem; padding: 2rem; }
.limit-bar-wrapper { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; padding: 1rem 1.5rem; }
.disclaimer-box {
    display: flex; align-items: flex-start; gap: 12px;
    background: rgba(245,158,11,0.07);
    border: 1px solid rgba(245,158,11,0.25);
    border-left: 3px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 1.5rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-muted);
}
.disclaimer-box strong { color: var(--text); display: block; margin-bottom: 2px; }

/* ─── Responsive table → card system ─────────────────────────── */
/* Add class "table-cards" to <table> to enable card mode on mobile.
   Each <td> needs data-label="Column Name" attribute. */
@media (max-width: 768px) {
    table.table-cards thead { display: none; }
    table.table-cards,
    table.table-cards tbody,
    table.table-cards tr,
    table.table-cards td { display: block; width: 100%; }
    table.table-cards tr {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
        margin-bottom: 10px;
    }
    table.table-cards tr:hover td { background: transparent; }
    table.table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border-bottom: none;
        font-size: 0.85rem;
        gap: 8px;
    }
    table.table-cards td::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        min-width: 90px;
    }
    table.table-cards td:empty { display: none; }
    table.table-cards td.card-actions {
        justify-content: flex-end;
        padding-top: 8px;
        margin-top: 4px;
        border-top: 1px solid var(--border);
    }
    table.table-cards td.card-actions::before { display: none; }
    table.table-cards td.card-title {
        font-size: 0.95rem;
        font-weight: 600;
        padding-bottom: 6px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--border);
    }
    table.table-cards td.card-title::before { display: none; }
    /* Hide columns marked as mobile-hidden */
    table.table-cards td.mobile-hide { display: none; }
}

/* ─── Responsive ──────────────────────────────────────────────── */

/* Tablet / small desktop */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .topbar-inner { padding: 0 1rem; height: 52px; gap: 10px; }
    .topbar-user { font-size: 0.78rem; }
    .logo { font-size: 1rem; }
    .card-grid { grid-template-columns: 1fr; }
    .ranking-card { flex-direction: column; }
    .score-bar-label { width: 100px; font-size: 0.75rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 1.35rem; }
    th, td { padding: 8px 10px; font-size: 0.82rem; }
    .question-nav { padding: 8px 1rem; }
    .question-nav-inner { gap: 4px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .question-nav-inner::-webkit-scrollbar { display: none; }
    .question-nav-dot { width: 32px; height: 32px; font-size: 0.75rem; flex-shrink: 0; }
    .btn-sm { padding: 8px 14px; min-height: 36px; }
    .flash-container { padding: 0.5rem 1rem 0; }
    .dropdown-menu { min-width: 180px; }
    .table-filter input { max-width: 100%; }
    .update-banner { padding: 8px 1rem; font-size: 0.78rem; flex-wrap: wrap; gap: 8px; }
    .section-card-padded { padding: 1.25rem; }
    .limit-bar-wrapper { padding: 0.75rem 1rem; }
}

/* Phone */
@media (max-width: 480px) {
    html { font-size: 14px; }
    .container { padding: 0.75rem; }
    .topbar-inner { padding: 0 0.75rem; }
    .topbar-user .badge { display: none; }
    .topbar-user { max-width: 120px; }
    .card { padding: 1rem; }
    .page-header h1 { font-size: 1.2rem; }
    .btn { padding: 10px 16px; font-size: 0.85rem; }
    .btn-sm { padding: 8px 12px; font-size: 0.78rem; min-height: 40px; }
    .btn-group { width: 100%; }
    .btn-group .btn { flex: 1; justify-content: center; }
    .score-bar-label { width: 80px; }
    .rank-number { font-size: 1.5rem; min-width: 36px; }
    .score-circle { width: 60px; height: 60px; font-size: 1.1rem; }
    .empty-state { padding: 2rem 1rem; }
    .empty-state .icon { font-size: 2.5rem; }
    th, td { padding: 6px 8px; font-size: 0.78rem; }
    th { font-size: 0.68rem; letter-spacing: 0.03em; }
    .form-group label { font-size: 0.78rem; letter-spacing: 0.02em; }
    .dropdown-menu { position: fixed; left: 8px; right: 8px; min-width: auto; width: auto; }
    .test-container { padding: 1rem; }
    .question-block { padding: 1rem; }
    .test-header { margin-bottom: 1.5rem; padding-bottom: 1.5rem; }
    .test-header h1 { font-size: 1.2rem; }
    .status-page { padding: 2rem 1rem; }
    .status-icon { font-size: 3rem; }
}

/* Small phone */
@media (max-width: 375px) {
    .topbar-right { gap: 8px; }
    .topbar-user { max-width: 90px; }
    .logo { font-size: 0.95rem; }
    .score-bar-label { width: 70px; }
    .ranking-name { font-size: 1rem; }
}

/* ─── Custom Questions Builder (v1.6) ─────────────────────────── */
.cq-card {
    background: rgba(59, 130, 246, 0.04);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 12px;
    animation: fadeIn 0.25s ease;
}
.cq-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
}
.cq-header strong { color: var(--accent); font-size: 0.88rem; }
.cq-card .form-group { margin-bottom: 10px; }
.cq-card label {
    font-size: 0.8rem; font-weight: 500; color: var(--text-muted);
    text-transform: none; letter-spacing: 0; margin-bottom: 4px;
}
.cq-card input[type="text"], .cq-card textarea, .cq-card select { font-size: 0.88rem; }
.cq-warning { animation: fadeIn 0.25s ease; }
.cq-candidate-section summary { user-select: none; }
.cq-candidate-section summary:hover { color: var(--accent); }

/* ─── v2.2: Prompt Manager ──────────────────────────── */
.prompt-textarea {
    width: 100%;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    background: var(--card-bg, #161b22);
    color: var(--text, #e6edf3);
    border: 1px solid var(--border, #30363d);
    border-radius: 8px;
    padding: 1rem;
    resize: vertical;
    transition: border-color 0.2s, opacity 0.2s;
}
.prompt-textarea:focus {
    outline: none;
    border-color: var(--accent, #1f6feb);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}
.prompt-textarea:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--bg, #0d1117);
}
.prompt-default-box {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(31, 111, 235, 0.06);
    border: 1px solid rgba(31, 111, 235, 0.15);
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text-muted, #8b949e);
    max-height: 200px;
    overflow-y: auto;
}
.prompt-vars {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted, #8b949e);
}
.prompt-vars code {
    background: rgba(110, 118, 129, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.76rem;
    margin: 0 2px;
}
.prompt-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text, #e6edf3);
}
.prompt-label input[type="checkbox"] {
    accent-color: var(--accent, #1f6feb);
}
.preset-btn.btn-success {
    background: var(--success, #238636) !important;
    border-color: var(--success, #238636) !important;
}

/* ─── v2.3: Operator role ───────────────────────────── */
.badge-operator { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }

/* ─── v2.4: UX Improvements ──────────────────────────── */

/* Dropdown menu */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle::after { content: " ▾"; font-size: 0.75em; }
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 50;
    padding: 4px 0;
    animation: fadeIn 0.15s ease;
}
.dropdown-menu.show { display: block; }
.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s;
    text-align: left;
}
.dropdown-menu .dropdown-item:hover { background: var(--bg-card-hover); }
.dropdown-menu .dropdown-item.danger { color: var(--error); }
.dropdown-menu .dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Sortable table headers */
th.sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
th.sortable:hover { color: var(--accent); }
th.sortable::after { content: " ⇅"; font-size: 0.7em; opacity: 0.4; }
th.sortable.asc::after { content: " ↑"; opacity: 0.8; color: var(--accent); }
th.sortable.desc::after { content: " ↓"; opacity: 0.8; color: var(--accent); }

/* Search / filter input */
.table-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
}
.table-filter input {
    flex: 1;
    max-width: 320px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
}
.table-filter input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.table-filter input::placeholder { color: var(--text-muted); }

/* Question nav (test page) */
.question-nav {
    position: sticky;
    top: 52px;
    z-index: 40;
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 8px 2rem;
}
.question-nav-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 760px;
    margin: 0 auto;
    flex-wrap: wrap;
    justify-content: center;
}
.question-nav-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.question-nav-dot:hover { border-color: var(--accent); color: var(--accent); }
.question-nav-dot.answered { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Password toggle */
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 44px; }
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    line-height: 1;
}
.password-toggle:hover { color: var(--text); }
