/* ── Reset / base ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: #f4f5f7;
    color: #1a1a2e;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────── */
#app-header {
    height: 48px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    z-index: 110;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.app-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.5px;
}

#dataset-select {
    background: #2e2e50;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
}

#header-stats {
    font-size: 12px;
    opacity: 0.7;
}

/* ── Login overlay ───────────────────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.login-card {
    background: #fff;
    border-radius: 8px;
    padding: 32px 28px;
    width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.login-card h2 {
    margin-bottom: 20px;
    font-size: 20px;
}
.login-card label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 500;
}
.login-card input {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
.error-msg {
    color: #c0392b;
    font-size: 12px;
    margin-bottom: 8px;
}

/* ── Main layout ─────────────────────────────────────────────────── */
#app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#map-container {
    flex: 1;
    position: relative;
}
#map {
    width: 100%;
    height: 100%;
}

/* ── Side panel ──────────────────────────────────────────────────── */
#side-panel {
    width: 340px;
    min-width: 280px;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 12px;
    gap: 12px;
}

/* Meta section */
#candidate-meta {
    background: #f8f9fb;
    border-radius: 6px;
    padding: 10px 12px;
}
.meta-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
}
.meta-row .label {
    font-weight: 600;
    min-width: 90px;
    color: #555;
    font-size: 12px;
}

/* Name cards */
#name-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.name-card {
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition:
        border-color 0.15s,
        background 0.15s;
    outline: none;
}
.name-card:hover {
    border-color: #4a90d9;
    background: #f0f6ff;
}
.name-card.selected {
    border-color: #2563eb;
    background: #eff6ff;
}
.card-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #666;
    margin-bottom: 3px;
}
.card-name {
    font-size: 15px;
    font-weight: 500;
    word-break: break-word;
}

/* Custom + comment */
.field-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    display: block;
    margin-bottom: 4px;
}
#custom-name,
#comment-field {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}
#comment-field {
    resize: vertical;
}

#custom-name:focus,
#comment-field:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* External tools */
#ext-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.btn-ext {
    flex: 1;
    min-width: 90px;
    padding: 7px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.12s;
}
.btn-ext:hover {
    background: #f0f6ff;
    border-color: #4a90d9;
}

/* Action buttons */
#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

/* Buttons */
.btn-primary {
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover {
    background: #1d4ed8;
}
.btn-primary:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}
.btn-secondary {
    padding: 9px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s;
}
.btn-secondary:hover {
    background: #f4f5f7;
}
.btn-text {
    background: none;
    border: none;
    color: #aaa;
    font-size: 13px;
    cursor: pointer;
}
.btn-text:hover {
    color: #fff;
}

/* Util */
.hidden {
    display: none !important;
}
.muted {
    color: #888;
}
.center {
    text-align: center;
}

/* ── Notes row ───────────────────────────────────────────────── */
.meta-notes-row {
    background: #fffbe6;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
    padding: 4px 8px;
    margin-top: 4px;
}
.meta-notes-row .label {
    color: #92400e !important;
}

/* ── Category symbology ──────────────────────────────────────── */
:root {
    --cat-abbreviation: #7c3aed;
    --cat-reorder: #0891b2;
    --cat-suffix_only: #059669;
    --cat-typo: #d97706;
    --cat-different: #dc2626;
    --cat-other: #6b7280;
}

/* Side panel left-border stripe per category */
#side-panel.cat-panel {
    border-left-width: 5px;
    border-left-style: solid;
}
#side-panel.cat-abbreviation {
    border-left-color: var(--cat-abbreviation);
}
#side-panel.cat-reorder {
    border-left-color: var(--cat-reorder);
}
#side-panel.cat-suffix_only {
    border-left-color: var(--cat-suffix_only);
}
#side-panel.cat-typo {
    border-left-color: var(--cat-typo);
}
#side-panel.cat-different {
    border-left-color: var(--cat-different);
}
#side-panel.cat-other {
    border-left-color: var(--cat-other);
}

/* ── Map legend (bottom-right overlay) ──────────────────────── */
#map-legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.93);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 11px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    pointer-events: none;
}
.map-legend-title {
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    margin-bottom: 5px;
}
.map-legend-section {
    margin-bottom: 2px;
}
.map-legend-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 7px 0;
}
.map-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 2px 0;
    color: #333;
    border-radius: 3px;
    transition: background 0.1s;
}
.map-legend-item.map-legend-active {
    background: rgba(0, 0, 0, 0.06);
    font-weight: 700;
    color: #111;
    padding-left: 3px;
    padding-right: 3px;
}
/* Layer line swatches */
.map-legend-line {
    display: inline-block;
    width: 22px;
    border-radius: 2px;
    flex-shrink: 0;
}
.map-legend-sld {
    background: #00e5ff;
    height: 5px;
}
.map-legend-oit {
    background: repeating-linear-gradient(to right, #ff9800 0px, #ff9800 5px, transparent 5px, transparent 8px);
    height: 3px;
}
/* Category swatches */
.map-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
.map-legend-swatch.cat-abbreviation {
    background: var(--cat-abbreviation);
}
.map-legend-swatch.cat-reorder {
    background: var(--cat-reorder);
}
.map-legend-swatch.cat-suffix_only {
    background: var(--cat-suffix_only);
}
.map-legend-swatch.cat-typo {
    background: var(--cat-typo);
}
.map-legend-swatch.cat-different {
    background: var(--cat-different);
}
.map-legend-swatch.cat-other {
    background: var(--cat-other);
}

/* ── Group select screen ─────────────────────────────────────── */
.group-select-card {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    width: 740px;
    max-width: 96vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.group-select-header h2 {
    font-size: 20px;
    margin-bottom: 4px;
}
.group-select-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.group-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
#group-search {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    width: 280px;
    margin-left: auto;
}
#group-search:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.group-table-wrap {
    overflow-y: auto;
    flex: 1;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
}
#group-select-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#group-select-table th,
#group-select-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}
#group-select-table th {
    background: #f8f9fb;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}
#group-select-table tr:hover td {
    background: #f4f5f7;
}
#group-select-table tr.group-row-ramps td {
    background: #f9f5ff;
    border-top: 2px solid #e9d5ff;
}
#group-select-table tr.group-row-ramps:hover td {
    background: #f3e8ff;
}
#group-select-table tr.group-row-ramps .group-progress-fill {
    background: #7c3aed;
}

.group-action-cell {
    text-align: right;
}
.group-progress-bar {
    width: 120px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.group-progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 4px;
}
.group-select-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid #e8e8e8;
}

/* Group tag in header */
.header-group-tag {
    background: #3b3b6b;
    color: #a5b4fc;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

/* Dataset name tag in header (shown during verification) */
.header-dataset-tag {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Dataset selector row inside group modal */
.group-dataset-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 4px;
}
.group-dataset-label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}
.group-dataset-note {
    font-size: 12px;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    padding: 2px 8px;
    white-space: nowrap;
}
.group-dataset-row select {
    font-size: 13px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* ── Comment required badge ──────────────────────────────────── */
.required-badge {
    background: #fef2f2;
    color: #dc2626;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #fecaca;
    vertical-align: middle;
    margin-left: 4px;
}

/* ── "View group" link button ────────────────────────────────── */
.btn-group-link {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.btn-group-link:hover {
    color: #1d4ed8;
}

/* ── Group list panel ────────────────────────────────────────── */
.group-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
    width: 780px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.group-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid #e8e8e8;
    font-weight: 600;
    font-size: 14px;
}
.table-scroll {
    overflow-y: auto;
    flex: 1;
    padding: 0 4px 8px;
}
#group-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#group-table th,
#group-table td {
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}
#group-table th {
    background: #f8f9fb;
    font-weight: 600;
    position: sticky;
    top: 0;
}
#group-table tr:hover td {
    background: #f4f5f7;
}
.group-row-current td {
    background: #eff6ff !important;
    font-weight: 600;
}

/* Category badges (group table) */
.cat-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}
.cat-badge.cat-abbreviation {
    background: var(--cat-abbreviation);
}
.cat-badge.cat-reorder {
    background: var(--cat-reorder);
}
.cat-badge.cat-suffix_only {
    background: var(--cat-suffix_only);
}
.cat-badge.cat-typo {
    background: var(--cat-typo);
}
.cat-badge.cat-different {
    background: var(--cat-different);
}
.cat-badge.cat-other {
    background: var(--cat-other);
    color: #fff;
}

/* Status badges (group table) */
.status-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.status-pending {
    background: #fef3c7;
    color: #92400e;
}
.status-in_review {
    background: #dbeafe;
    color: #1e40af;
}
.status-verified {
    background: #d1fae5;
    color: #065f46;
}
.status-skipped {
    background: #f3f4f6;
    color: #6b7280;
}
.status-needs_followup {
    background: #fce7f3;
    color: #9d174d;
}

/* ── Auto-flag notice ────────────────────────────────────────── */
.auto-flag-notice {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: #92400e;
    margin-bottom: 8px;
    font-weight: 500;
}
