* { box-sizing: border-box; }
body {
    font-family: -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
    margin: 0;
    background: #f4f5f8;
    color: #1a1d29;
    font-size: 14px;
}
a { color: inherit; }

/* ---- Topbar ---- */
.topbar {
    background: #1e2a47;
    color: #fff;
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.topbar-subtitle { color: #9fb0d3; font-size: 0.85rem; }
.topbar-divider { width: 1px; height: 1.2rem; background: #3a4a6b; margin: 0 0.25rem; }
.topbar-tab {
    text-decoration: none;
    color: #cfd9ef;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}
.topbar-tab.active { background: #324a78; color: #fff; }
.topbar-current { color: #cfd9ef; font-size: 0.88rem; }
.reviewer-badge {
    background: #324a78;
    color: #fff;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}

main { padding: 1.5rem; max-width: 1600px; margin: 0 auto; }

.breadcrumb { font-size: 0.82rem; color: #6b7280; margin-bottom: 0.5rem; }
.breadcrumb a { text-decoration: none; color: #6b7280; }
.page-title { margin: 0 0 0.35rem 0; font-size: 1.6rem; }
.page-subtitle { margin: 0 0 1.25rem 0; color: #5b6472; font-size: 0.92rem; }

/* ---- Cards ---- */
.card {
    background: white;
    border: 1px solid #e2e4e9;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* ---- Stat cards ---- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}
.stat-card {
    background: white;
    border: 1px solid #e2e4e9;
    border-radius: 8px;
    padding: 0.9rem 1rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.72rem; color: #767f8c; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.2rem; }
.stat-amber { color: #b4740e; }
.stat-green { color: #15803d; }
.stat-purple { color: #6d28d9; }
.stat-red { color: #b91c1c; }

/* ---- Pill tabs ---- */
.pill-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    color: #374151;
    background: white;
    border: 1px solid #d7dae1;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.pill-active { background: #1e2a47; color: #fff; border-color: #1e2a47; }
.pill-count {
    background: rgba(0,0,0,0.07);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.75rem;
}
.pill-active .pill-count { background: rgba(255,255,255,0.22); }

/* ---- Filter bar (confidence + sort/view) ---- */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    background: white;
    border: 1px solid #e2e4e9;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin-bottom: 0.75rem;
}
.filter-label { font-size: 0.7rem; font-weight: 700; color: #8a8f99; letter-spacing: 0.04em; margin-right: 0.3rem; }
.confidence-pills { display: flex; align-items: center; gap: 0.4rem; }
.conf-pill {
    text-decoration: none;
    border: 1px solid #d7dae1;
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.conf-pill.conf-active { background: #1e2a47; color: #fff; border-color: #1e2a47; }
.conf-high.conf-active { background: #15803d; border-color: #15803d; }
.conf-medium.conf-active { background: #b4740e; border-color: #b4740e; }
.conf-low.conf-active { background: #b91c1c; border-color: #b91c1c; }

.sort-view { display: flex; align-items: center; gap: 0.9rem; }
.sort-form { display: flex; align-items: center; gap: 0.3rem; }
.sort-form select { padding: 0.3rem 0.4rem; border: 1px solid #d7dae1; border-radius: 6px; font-size: 0.82rem; }
.view-toggle { display: flex; gap: 0.3rem; }
.view-toggle .btn { font-size: 0.78rem; }
.btn-active { background: #1e2a47 !important; color: #fff !important; border-color: #1e2a47 !important; }

/* ---- Action bar (search + bulk actions) ---- */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}
.search-form { display: flex; gap: 0.4rem; }
.search-form input[type=text] {
    padding: 0.45rem 0.7rem;
    border: 1px solid #d7dae1;
    border-radius: 6px;
    width: 280px;
    font-size: 0.85rem;
}
.action-buttons { display: flex; gap: 0.5rem; }
.action-buttons form { display: inline; }

/* ---- Shortcuts bar ---- */
.shortcuts-bar {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    background: white;
    border: 1px solid #e2e4e9;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: #6b7280;
}
.shortcuts-bar kbd {
    background: #f1f2f5;
    border: 1px solid #d7dae1;
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    font-family: inherit;
    font-size: 0.78rem;
    margin-right: 0.2rem;
}
.shortcuts-position { margin-left: auto; font-weight: 600; color: #374151; }

/* ---- Table ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    padding: 1rem 0 2rem;
    font-size: 0.85rem;
    color: #5b6472;
}

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; background: white; }
thead th {
    text-align: left;
    border-bottom: 2px solid #d6d9e0;
    padding: 0.5rem 0.6rem;
    background: #eef0f4;
    position: sticky;
    top: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5b6472;
}
tbody td { padding: 0.55rem 0.6rem; border-bottom: 1px solid #ebedf0; vertical-align: top; }
tr.data-row:hover { background: #fafbfd; }
tr.row-focused { outline: 2px solid #1e2a47; outline-offset: -2px; }
tr.row-rejected { background: #fdf1f1; border-left: 3px solid #d14343; }
tr.row-rejected td:first-child { border-left: none; }
tr.row-conflict { background: #fff8ec; border-left: 3px solid #d98c0f; }
tr.row-conflict td:first-child { border-left: none; }
.known-answer-line { font-size: 0.74rem; color: #8a6400; font-weight: 600; margin-top: 0.15rem; }

.parent-group-header td {
    background: #eef0f4;
    font-weight: 700;
    padding: 0.5rem 0.6rem;
}

.match-box {
    display: inline-block;
    min-width: 140px;
    padding: 0.3rem 0.5rem;
    border: 1px solid #d7dae1;
    border-radius: 6px;
    background: #fbfbfc;
}

.domains-cell { max-width: 180px; }
.domain-tag {
    display: inline-block;
    background: #e8f6ee;
    color: #0a6b35;
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    font-size: 0.74rem;
    margin: 0.07rem 0.15rem 0.07rem 0;
}

.conf-badge { padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.conf-badge.conf-high { background: #d6f5e0; color: #0a6b35; }
.conf-badge.conf-medium { background: #fff3cd; color: #8a6400; }
.conf-badge.conf-low { background: #fde2e1; color: #9b1c1c; }
.conf-badge.conf-none { background: #eceef1; color: #6b7280; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-auto_matched, .badge-alias_matched, .badge-parent_matched,
.badge-steward_approved, .badge-steward_reassigned,
.badge-steward_marked_alias, .badge-steward_marked_parent {
    background: #d6f5e0; color: #0a6b35;
}
.badge-needs_review { background: #fff3cd; color: #8a6400; }
.badge-unresolved, .badge-steward_marked_unresolved { background: #fde2e1; color: #9b1c1c; }
.badge-ground_truth_conflict { background: #fde9c8; color: #8a5a00; }

.why-line { font-size: 0.82rem; font-weight: 600; color: #1a1d29; margin-bottom: 0.2rem; cursor: pointer; }
.evidence-list { margin: 0; padding-left: 1.1rem; font-size: 0.78rem; color: #444; }
.evidence-detail { display: none; color: #767f8c; }
.evidence-detail.evidence-expanded { display: block; }
.evidence-deciding { font-weight: 600; color: #374151; }
.evidence-informational { color: #8a8f99; font-size: 0.76rem; }

.candidate-list { list-style: none; margin: 0; padding: 0; font-size: 0.78rem; }
.candidate-list li { padding: 0.1rem 0; }

.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.actions button, .actions a.btn, a.btn, .action-buttons button {
    font-size: 0.78rem;
    padding: 0.32rem 0.6rem;
    border: 1px solid #c7cad1;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    text-decoration: none;
    color: #1a1d29;
    display: inline-block;
}
.actions button:hover, .action-buttons button:hover, a.btn:hover { background: #f0f2f5; }
.action-buttons button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---- Popovers ---- */
.popover {
    display: none;
    position: fixed;
    background: white;
    border: 1px solid #c7cad1;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    padding: 0.85rem;
    z-index: 100;
    width: 320px;
}
.popover.open { display: block; }
.popover label { display: block; font-size: 0.8rem; margin-top: 0.5rem; }
.popover input, .popover textarea { width: 100%; padding: 0.3rem; font-size: 0.85rem; border: 1px solid #d7dae1; border-radius: 4px; }
.popover .search-results { max-height: 160px; overflow-y: auto; margin-top: 0.3rem; border: 1px solid #e2e4e9; border-radius: 4px; }
.popover .search-results button { display: block; width: 100%; text-align: left; border: none; padding: 0.3rem 0.4rem; background: none; font-size: 0.82rem; }
.popover .search-results button:hover { background: #f0f2f5; }
.popover .popover-actions { margin-top: 0.6rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.popover hr { border: none; border-top: 1px solid #e2e4e9; margin: 0.75rem 0; }
.popover-inner > strong { font-size: 0.92rem; }

.shortcuts-help-body { font-size: 0.85rem; }
.shortcuts-help-body div { margin-bottom: 0.3rem; }

/* ---- Upload / run list ---- */
.upload-form { display: flex; gap: 0.5rem; align-items: center; }
.run-list { font-size: 0.88rem; }
.summary-counts span { margin-right: 1rem; }

@media (max-width: 1200px) {
    .stat-cards { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    main { padding: 0.75rem; overflow-x: auto; }
}

/* ---- Auth (login/account/admin users) ---- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f4f5f8; }
.auth-card { width: 340px; }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 1rem 0; }
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.3rem; }
.field input { width: 100%; padding: 0.5rem 0.6rem; border: 1px solid #c7cad1; border-radius: 6px; font-size: 0.9rem; }
.btn-primary {
    width: 100%; padding: 0.55rem; border: none; border-radius: 6px;
    background: #1e2a47; color: #fff; font-weight: 600; cursor: pointer; font-size: 0.9rem;
}
.btn-primary:hover { background: #324a78; }
.error-text { color: #b42318; font-size: 0.82rem; margin-bottom: 0.9rem; }
.message-text { color: #15803d; font-size: 0.82rem; margin-bottom: 0.9rem; }
.inline-form { display: inline; }
