/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --nav-bg:      #0f172a;
    --nav-text:    #e2e8f0;
    --primary:     #2563eb;
    --primary-h:   #1d4ed8;
    --body-bg:     #f1f5f9;
    --surface:     #ffffff;
    --border:      #e2e8f0;
    --text:        #0f172a;
    --text-muted:  #64748b;
    --success:     #16a34a;
    --warning:     #d97706;
    --danger:      #dc2626;
    --radius:      0.5rem;
    --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: .9375rem;
    background: var(--body-bg);
    color: var(--text);
    margin: 0;
}

a { color: var(--primary); }
a:hover { color: var(--primary-h); }

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.app-nav {
    background: var(--nav-bg);
    padding: .625rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.app-nav .navbar-brand {
    color: #fff;
    font-weight: 600;
    font-size: .9375rem;
    letter-spacing: .01em;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}
.app-nav .navbar-brand:hover { color: #fff; }

.brand-dot {
    width: 8px; height: 8px;
    background: var(--primary);
    border-radius: 50%;
    display: inline-block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex: 1;
}

.app-nav .nav-link {
    color: var(--nav-text);
    font-size: .875rem;
    padding: .375rem .75rem;
    border-radius: var(--radius);
    transition: background .15s, color .15s;
    text-decoration: none;
    opacity: .8;
}
.app-nav .nav-link:hover { background: rgba(255,255,255,.1); color: #fff; opacity: 1; }
.app-nav .nav-link.active { background: rgba(255,255,255,.12); color: #fff; opacity: 1; }

.nav-right {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
}

.nav-user {
    color: rgba(255,255,255,.55);
    font-size: .8125rem;
}

.btn-signout {
    padding: .3rem .75rem;
    font-size: .8125rem;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--radius);
    background: transparent;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-signout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Main container ────────────────────────────────────────────────────────── */
.app-body {
    padding: 1.75rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 0 0 .2rem;
    line-height: 1.2;
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: .875rem;
    margin: 0;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .9375rem;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 1.25rem; }

/* ── Stats row ─────────────────────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .875rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

/* ── Section label ──────────────────────────────────────────────────────────── */
.section-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    padding: 1.25rem 0 .5rem;
    margin: 0;
    border-top: 1px solid var(--border);
}

.section-label:first-child { border-top: none; padding-top: 0; }

/* ── Queue table ───────────────────────────────────────────────────────────── */
.queue-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.queue-table th {
    text-align: left;
    padding: .5rem .75rem;
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.queue-table td {
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.queue-table tr:last-child td { border-bottom: none; }
.queue-table tbody tr:hover td { background: #f8fafc; }

/* ── Progress ───────────────────────────────────────────────────────────────── */
.prog-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.prog-bar {
    width: 90px;
    height: 5px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    flex-shrink: 0;
}

.prog-fill { height: 100%; border-radius: 99px; background: var(--primary); }
.prog-fill.done { background: var(--success); }

.prog-label { font-size: .8125rem; color: var(--text-muted); white-space: nowrap; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2em .55em;
    font-size: .6875rem;
    font-weight: 700;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.badge-pending  { background: #eff6ff; color: #1d4ed8; }
.badge-complete { background: #f0fdf4; color: #15803d; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .4375rem .875rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s, opacity .15s;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f8fafc; color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { background: var(--body-bg); color: var(--text); }

.btn-sm { padding: .3rem .625rem; font-size: .8125rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: .625rem;
}

.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-select, .form-control {
    padding: .4375rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color .15s;
}

.form-select:focus, .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Verify layout ─────────────────────────────────────────────────────────── */
body.verify-layout {
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.verify-topbar {
    background: var(--nav-bg);
    color: var(--nav-text);
    padding: .625rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.verify-queue-label {
    font-weight: 600;
    font-size: .9375rem;
    color: #fff;
    flex-shrink: 0;
}

.verify-progress-wrap {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex: 1;
}

.verify-prog-bar {
    width: 140px;
    height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 99px;
    overflow: hidden;
}

.verify-prog-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width .3s;
}

.verify-prog-label {
    font-size: .8125rem;
    color: rgba(255,255,255,.55);
    white-space: nowrap;
}

.verify-split {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.verify-image-pane {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #1e293b;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.verify-image-pane:active { cursor: grabbing; }

.verify-image-pane img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    pointer-events: none;
}

.zoom-hint {
    position: absolute;
    bottom: .75rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.5);
    color: rgba(255,255,255,.6);
    font-size: .6875rem;
    padding: .2rem .75rem;
    border-radius: 99px;
    pointer-events: none;
    white-space: nowrap;
}

.verify-panel {
    width: 380px;
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.verify-section {
    padding: .875rem 1.125rem;
    border-bottom: 1px solid var(--border);
}

.verify-section:last-child { border-bottom: none; }

.verify-section-label {
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: .5rem;
}

.candidate-row {
    display: flex;
    gap: 1.25rem;
    font-size: .875rem;
}

.candidate-row span { color: var(--text-muted); }
.candidate-row strong { color: var(--text); }

/* ── Marking instruction ────────────────────────────────────────────────────── */
.marking-instruction {
    font-size: .8125rem;
    color: var(--text);
    background: #f8fafc;
    border-left: 3px solid var(--primary);
    padding: .5rem .75rem;
    border-radius: 0 4px 4px 0;
    margin: 0 0 .75rem;
    line-height: 1.5;
}

/* ── Rubric entries ─────────────────────────────────────────────────────────── */
.rubric-list { display: flex; flex-direction: column; gap: .125rem; }

.rubric-item {
    display: flex;
    gap: .625rem;
    font-size: .8125rem;
    padding: .25rem .375rem;
    border-radius: 4px;
}

.rubric-item.rubric-current {
    background: #eff6ff;
    font-weight: 600;
}

.rubric-item.rubric-current .rubric-ans { color: var(--text); }

.rubric-q { font-weight: 600; min-width: 48px; color: var(--text-muted); }
.rubric-item.rubric-current .rubric-q { color: var(--primary); }
.rubric-ans { color: var(--text-muted); }

/* ── AI scores ──────────────────────────────────────────────────────────────── */
.ai-rows { display: flex; flex-direction: column; gap: .375rem; }

.ai-row {
    display: flex;
    align-items: center;
    gap: .625rem;
    font-size: .8125rem;
}

.model-tag {
    font-size: .625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .15em .5em;
    border-radius: 3px;
    min-width: 52px;
    text-align: center;
    flex-shrink: 0;
}

.tag-gemini { background: #fef3c7; color: #92400e; }
.tag-openai { background: #e0f2fe; color: #075985; }

.ai-resp { flex: 1; font-style: italic; color: var(--text); }
.ai-score { font-weight: 700; min-width: 18px; }
.ai-conf  { color: var(--text-muted); font-size: .75rem; white-space: nowrap; }

.flag-tag {
    display: inline-flex;
    align-items: center;
    font-size: .75rem;
    font-weight: 600;
    padding: .25em .625em;
    border-radius: 4px;
    margin-bottom: .625rem;
}

.flag-disagree { background: #fef2f2; color: var(--danger); }
.flag-lowconf  { background: #fffbeb; color: var(--warning); }

/* ── Score buttons ──────────────────────────────────────────────────────────── */
.score-options { display: flex; gap: .5rem; }

.score-btn {
    flex: 1;
    padding: .625rem .5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .12s, background .12s, color .12s;
    text-align: center;
    color: var(--text-muted);
}

.score-btn:hover { border-color: #94a3b8; color: var(--text); }
.score-btn[data-val="0"].selected { border-color: var(--danger);  background: #fef2f2; color: var(--danger); }
.score-btn[data-val="1"].selected { border-color: var(--success); background: #f0fdf4; color: var(--success); }
.score-btn[data-val="u"].selected { border-color: var(--warning); background: #fffbeb; color: var(--warning); }

.btn-submit-verify {
    width: 100%;
    padding: .75rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    margin-top: .875rem;
}

.btn-submit-verify:hover:not(:disabled) { background: var(--primary-h); }
.btn-submit-verify:disabled { opacity: .4; cursor: not-allowed; }

/* ── Discrepancy table ───────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table th {
    text-align: left;
    padding: .5rem .75rem;
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }

.delta-zero  { color: var(--success); font-weight: 700; }
.delta-small { color: var(--warning); font-weight: 700; }
.delta-large { color: var(--danger);  font-weight: 700; }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .35; }
.empty-state p { margin: 0; font-size: .9375rem; }

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1.5rem;
}

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .375rem; }
.form-control { width: 100%; }
.form-text { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; display: block; }
.text-danger { color: var(--danger); font-size: .8125rem; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .verify-split      { flex-direction: column; overflow: auto; }
    .verify-image-pane { min-height: 220px; flex: none; height: 45vw; }
    .verify-panel      { width: 100%; flex-shrink: 0; border-left: none; border-top: 1px solid var(--border); }
    body.verify-layout { overflow: auto; height: auto; }
    .app-body          { padding: 1rem; }
    .stats-row         { grid-template-columns: repeat(2, 1fr); }
    .nav-user          { display: none; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
