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

/* ── Design tokens ── */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-light: #21262d;
    --border: #30363d;
    --accent: #2f81f7;
    --accent2: #3fb950;
    --warn: #f78166;
    --text: #e6edf3;
    --text-main: #e6edf3;
    --text-dim: #8b949e;
    --muted: #8b949e;
    --card-bg: #1c2128;
    --radius: 10px;
    --transition: all 0.3s ease;
}

[data-theme="light"] {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-light: #ebf0f4;
    --border: #d0d7de;
    --accent: #0969da;
    --accent2: #1a7f37;
    --warn: #cf222e;
    --text: #1f2328;
    --text-main: #1f2328;
    --text-dim: #656d76;
    --muted: #656d76;
    --card-bg: #ffffff;
}

html,
body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the branding */
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: absolute;
    /* Take out of flow to keep title centered */
    right: 32px;
}

.theme-toggle-btn:hover {
    background: rgba(139, 148, 158, 0.1);
    border-color: var(--accent);
}

.theme-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.header-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.system-health {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    justify-content: center;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    transition: var(--transition);
}

.health-dot.green {
    background-color: var(--accent2);
    box-shadow: 0 0 5px var(--accent2);
}

.health-dot.red {
    background-color: var(--warn);
    box-shadow: 0 0 5px var(--warn);
}

.health-dot.grey {
    background-color: var(--muted);
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.header-tagline {
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 500;
    margin-top: 2px;
}


/* ── Refresh bar ── */
.refresh-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.refresh-bar label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-right: 4px;
}

.status-chip {
    font-size: 0.75rem;
    color: var(--muted);
    background: rgba(139, 148, 158, 0.1);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 10px;
}

.last-fetched {
    font-size: 0.7rem;
    color: var(--muted);
    font-style: italic;
    white-space: nowrap;
    opacity: 0.8;
}

/* ── Buttons ── */
.btn {
    padding: 8px 18px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    min-height: 44px;
    touch-action: manipulation;
    flex-shrink: 0;
}

.btn-jobs {
    background: var(--accent);
    color: #fff;
}

.btn-cands {
    background: var(--accent2);
    color: #0d1117;
}

.btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Main layout ── */
main {
    padding: 28px 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 22px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    touch-action: manipulation;
    white-space: nowrap;
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.tab-count {
    font-size: 0.72rem;
    background: rgba(47, 129, 247, 0.15);
    color: var(--accent);
    border-radius: 10px;
    padding: 1px 7px;
    margin-left: 6px;
}

.tab:nth-child(2) .tab-count {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent2);
}

/* ── Search ── */
.search-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.voice-search-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.voice-search-btn {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}

.voice-search-btn:hover {
    color: var(--accent);
    background: rgba(47, 129, 247, 0.1);
}

.voice-search-btn svg {
    width: 20px;
    height: 20px;
}

.voice-search-btn.listening {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    animation: pulse-red 1.5s infinite;
}

.clear-search-btn {
    position: absolute;
    right: 48px;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
    opacity: 0.7;
}

.clear-search-btn:hover {
    color: var(--warn);
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}


@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.search-input {
    flex: 1;
    padding: 12px 18px;
    padding-right: 48px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    min-height: 44px;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--muted);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.search-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.search-btn:active {
    transform: translateY(0);
}

.count-label {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

/* ── Cards grid ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: border-color 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    min-width: 0;
    flex: 1;
}

.pill {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 1;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill-blue {
    background: rgba(47, 129, 247, 0.15);
    color: var(--accent);
    border: 1px solid rgba(47, 129, 247, 0.25);
}

.pill-green {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent2);
    border: 1px solid rgba(63, 185, 80, 0.25);
}

.pill-orange {
    background: rgba(247, 129, 102, 0.15);
    color: #f7a266;
    border: 1px solid rgba(247, 129, 102, 0.25);
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--muted);
}

.meta-item svg {
    flex-shrink: 0;
}

.card-desc {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.card-salary {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent2);
}

.card-link {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.card-link:hover {
    opacity: 1;
}

.source-tag {
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 4px;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
}

.page-btn {
    padding: 7px 16px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.82rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    min-height: 40px;
    touch-action: manipulation;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ── Panel states ── */
.panel {
    display: none;
}

.panel.active {
    display: block;
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ══════════════════════════════════════
   Matcher panel
══════════════════════════════════════ */
.matcher-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 220px);
    min-height: 500px;
}

.matcher-pane {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.matcher-pane-header {
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.matcher-pane-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.matcher-pane-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar label {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.filter-select,
.filter-input {
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
}

.filter-select:focus,
.filter-input:focus {
    border-color: var(--accent);
}

/* Source list items */
.src-item {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--bg);
}

.src-item:hover {
    border-color: var(--accent);
    background: rgba(47, 129, 247, 0.05);
}

.src-item.selected {
    border-color: var(--accent);
    background: rgba(47, 129, 247, 0.1);
}

.src-item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.src-item-meta {
    font-size: 0.75rem;
    color: var(--muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Match result cards */
.match-card {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.match-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.match-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.match-card-meta {
    font-size: 0.75rem;
    color: var(--muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.match-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.match-pane-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 0.85rem;
}

.score-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    background: rgba(47, 129, 247, 0.2);
    color: var(--accent);
    border: 1px solid rgba(47, 129, 247, 0.3);
}

.score-badge.high {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent2);
    border-color: rgba(63, 185, 80, 0.3);
}

.score-badge.med {
    background: rgba(255, 193, 7, 0.2);
    color: #f0c040;
    border-color: rgba(255, 193, 7, 0.3);
}

.score-badge.low {
    background: rgba(139, 148, 158, 0.15);
    color: var(--muted);
    border-color: var(--border);
}

/* Source search box */
.src-search {
    padding: 8px 12px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.src-search input {
    width: 100%;
    padding: 7px 12px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
}

.src-search input:focus {
    border-color: var(--accent);
}

/* Mode toggle */
.mode-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}

.mode-btn {
    padding: 6px 14px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.mode-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ══════════════════════════════════════
   Responsive
══════════════════════════════════════ */

/* Tablet (≤ 900px) */
@media (max-width: 900px) {
    header {
        padding: 14px 20px;
    }

    .refresh-bar {
        padding: 10px 20px;
        gap: 8px;
    }

    main {
        padding: 20px 20px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 12px;
    }
}

/* Mobile landscape (≤ 640px) */
@media (max-width: 640px) {
    header {
        padding: 12px 14px;
    }

    header h1 {
        font-size: 1.05rem;
    }

    .refresh-bar {
        padding: 10px 14px;
        gap: 8px;
    }

    .status-chip {
        display: none;
    }

    .refresh-bar label {
        font-size: 0.75rem;
    }

    main {
        padding: 14px 14px;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }

    .tab {
        padding: 10px 14px;
        font-size: 0.84rem;
    }

    .grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .card {
        padding: 12px;
        gap: 8px;
    }

    .card-title {
        font-size: 0.88rem;
    }

    .count-label {
        display: none;
    }

    .pagination {
        gap: 8px;
        flex-wrap: wrap;
    }

    .page-info {
        width: 100%;
        text-align: center;
        order: -1;
    }
}

/* Mobile portrait (≤ 420px) */
@media (max-width: 420px) {
    header h1 {
        font-size: 0.95rem;
    }

    .refresh-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: center;
    }

    .refresh-bar label {
        display: none;
    }

    .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.78rem;
        padding: 9px 8px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .card-link {
        font-size: 0.8rem;
    }

    .pill {
        font-size: 0.63rem;
    }

    .source-tag {
        font-size: 0.63rem;
    }
}

@media (max-width: 768px) {
    .matcher-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .matcher-pane {
        max-height: 50vh;
    }
}

/* ══════════════════════════════════════
   AI Search panel
══════════════════════════════════════ */

/* Search bar row for AI tab */
.ai-search-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 22px;
}

.voice-search-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.voice-search-btn {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}

.voice-search-btn:hover {
    color: var(--accent);
    background: rgba(47, 129, 247, 0.1);
}

.voice-search-btn svg {
    width: 20px;
    height: 20px;
}

.voice-search-btn.listening {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.search-input {
    flex: 1;
    padding: 12px 18px;
    padding-right: 48px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    min-height: 48px;
}

.ai-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.12);
}

.ai-search-input::placeholder {
    color: var(--muted);
}

.btn-ai {
    background: linear-gradient(135deg, #6e40c9 0%, #2f81f7 100%);
    color: #fff;
    white-space: nowrap;
    min-width: 110px;
    justify-content: center;
}

/* AI summary bubble */
.ai-summary {
    background: linear-gradient(135deg, rgba(110, 64, 201, 0.08) 0%, rgba(47, 129, 247, 0.08) 100%);
    border: 1px solid rgba(110, 64, 201, 0.35);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 22px;
    position: relative;
    display: none;
}

.ai-summary.visible {
    display: block;
}

[data-theme="light"] .ai-summary {
    background: linear-gradient(135deg, rgba(110, 64, 201, 0.05) 0%, rgba(47, 129, 247, 0.05) 100%);
    border-color: rgba(110, 64, 201, 0.2);
}

.ai-summary-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #a78bfa;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-summary-text {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text);
}

.ai-results-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: none;
}

.ai-results-label.visible {
    display: block;
}

/* Thinking skeleton */
.ai-thinking {
    display: none;
    gap: 10px;
    flex-direction: column;
    margin-bottom: 22px;
}

.ai-thinking.visible {
    display: flex;
}

.skeleton-line {
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--surface) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

.skeleton-line:nth-child(1) {
    width: 85%;
}

.skeleton-line:nth-child(2) {
    width: 70%;
}

.skeleton-line:nth-child(3) {
    width: 90%;
}

.skeleton-line:nth-child(4) {
    width: 60%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ══════════════════════════════════════
   Map panel
══════════════════════════════════════ */

#map-container {
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 500px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.map-legend {
    background: var(--card-bg);
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.78rem;
    line-height: 1.8;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    min-width: 180px;
    transition: var(--transition);
}

[data-theme="light"] .map-legend {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.legend-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
}

/* Custom cluster icons */
.custom-cluster {
    background: none !important;
    border: none !important;
}

.cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 12px rgba(47, 129, 247, 0.4);
    transition: transform 0.15s;
}

.cluster-icon:hover {
    transform: scale(1.15);
}

.cluster-small {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
    background: linear-gradient(135deg, #2f81f7 0%, #6e40c9 100%);
}

.cluster-medium {
    width: 42px;
    height: 42px;
    font-size: 0.82rem;
    background: linear-gradient(135deg, #2f81f7 0%, #f78166 100%);
}

.cluster-large {
    width: 50px;
    height: 50px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #f78166 0%, #da3633 100%);
}

/* Job marker dots */
.job-marker,
.candidate-marker {
    background: none !important;
    border: none !important;
}

.marker-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--marker-color, var(--accent));
    border: 3px solid #fff;
    box-shadow: 0 0 8px var(--marker-glow, rgba(47, 129, 247, 0.6));
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-icon {
    font-size: 12px;
    line-height: 1;
}

.job-marker-dot {
    border-color: #2f81f7;
    box-shadow: 0 0 8px rgba(47, 129, 247, 0.6);
}

.candidate-marker-dot {
    border-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Specialty Colors */
.dot-nurse {
    --marker-color: #38bdf8;
    --marker-glow: rgba(56, 189, 248, 0.6);
}

.dot-doctor {
    --marker-color: #a855f7;
    --marker-glow: rgba(168, 85, 247, 0.6);
}

.dot-consultant {
    --marker-color: #fbbf24;
    --marker-glow: rgba(250, 191, 36, 0.6);
}

.dot-pharmacist {
    --marker-color: #22c55e;
    --marker-glow: rgba(34, 197, 94, 0.6);
}

.dot-midwife {
    --marker-color: #ec4899;
    --marker-glow: rgba(236, 72, 153, 0.6);
}

.dot-surgeon {
    --marker-color: #ef4444;
    --marker-glow: rgba(239, 68, 68, 0.6);
}

.dot-radiologist {
    --marker-color: #00ffd0;
    --marker-glow: rgba(0, 255, 208, 0.6);
}

.dot-healthcare {
    --marker-color: #ffffff;
    --marker-glow: rgba(255, 255, 255, 0.6);
}

.dot-ot {
    --marker-color: #06b6d4;
    --marker-glow: rgba(6, 182, 212, 0.6);
}

.dot-cardio {
    --marker-color: #ef4444;
    --marker-glow: rgba(239, 68, 68, 0.6);
}

.dot-rn {
    --marker-color: #38bdf8;
    --marker-glow: rgba(56, 189, 248, 0.6);
}

.dot-mhn {
    --marker-color: #8b5cf6;
    --marker-glow: rgba(139, 92, 246, 0.6);
}

.dot-gp {
    --marker-color: #22c55e;
    --marker-glow: rgba(34, 197, 94, 0.6);
}

.dot-emc {
    --marker-color: #f97316;
    --marker-glow: rgba(249, 115, 22, 0.6);
}

.marker-dot:hover {
    transform: scale(1.3);
    box-shadow: 0 0 16px rgba(47, 129, 247, 0.9);
}

/* Dark popup styling */
.dark-popup .leaflet-popup-content-wrapper {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.dark-popup .leaflet-popup-tip {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.dark-popup .leaflet-popup-close-button {
    color: var(--muted) !important;
    font-size: 18px !important;
    top: 6px !important;
    right: 8px !important;
}

.dark-popup .leaflet-popup-close-button:hover {
    color: var(--text) !important;
}

.map-popup {
    font-family: 'Inter', sans-serif;
    padding: 4px;
}

.popup-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.3;
}

.popup-type-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-company {
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 6px;
    font-weight: 500;
}

.popup-email {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 3px;
}

.popup-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.popup-pill {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(47, 129, 247, 0.15);
    color: var(--accent);
    border: 1px solid rgba(47, 129, 247, 0.25);
}

.popup-meta {
    font-size: 0.68rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(139, 148, 158, 0.1);
    color: var(--muted);
    border: 1px solid var(--border);
}

.popup-loc,
.popup-salary {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 3px;
}

.popup-salary {
    color: var(--accent2);
    font-weight: 600;
}

.popup-desc {
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 6px;
    border-top: 1px solid var(--border);
    padding-top: 6px;
}

.popup-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.popup-date {
    font-size: 0.68rem;
    color: var(--muted);
}

.popup-link {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.popup-link:hover {
    text-decoration: underline;
}

/* Override Leaflet controls for dark theme */
.leaflet-control-zoom a {
    background: var(--card-bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--surface) !important;
}

[data-theme="light"] .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
}

.leaflet-control-attribution {
    background: rgba(13, 17, 23, 0.8) !important;
    color: var(--muted) !important;
    font-size: 0.6rem !important;
}

.leaflet-control-attribution a {
    color: var(--accent) !important;
}

@media (max-width: 640px) {
    main {
        padding: 16px;
    }

    #map-container {
        height: calc(100vh - 160px);
        min-height: 350px;
    }

    .search-row {
        flex-wrap: wrap;
    }

    .chat-input-area {
        flex-wrap: wrap;
    }

    .search-row .voice-search-wrapper,
    .chat-input-area .voice-search-wrapper {
        min-width: 100%;
    }

    .search-btn,
    .chat-input-area>button {
        width: 100%;
        justify-content: center;
    }
}

/* ── Footer ── */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 40px 32px;
    margin-top: 60px;
    color: var(--muted);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-logo {
    font-weight: 700;
    color: var(--text);
    font-size: 1.1rem;
}

.footer-tagline {
    font-size: 0.8rem;
    opacity: 0.7;
}

.footer-right {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.82rem;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .footer-right {
        text-align: center;
    }
}

/* ── Home Panel Styles ── */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.feature-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 35px;
}

.feature-section h2 {
    font-size: 1.5rem;
    margin-bottom: 25px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
}

/* ── Tab Features Grid ── */
.tab-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 20px;
}

.tab-feature-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tab-feature-col h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
}

.feature-item {
    margin-bottom: 20px;
}

.feature-title {
    display: block;
    font-weight: 700;
    color: var(--accent);
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.feature-desc {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.how-to {
    background: rgba(47, 129, 247, 0.1);
    border-left: 3px solid var(--accent);
    padding: 10px 15px;
    font-size: 0.85rem;
    border-radius: 4px;
}

.how-to b {
    color: var(--text);
}

.query-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.query-column-title {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 12px;
    opacity: 0.8;
}

.query-list {
    list-style: none;
    padding: 0;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
}

[data-theme="light"] .query-list {
    background: rgba(255, 255, 255, 0.5);
}

.query-list li {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
}

.query-list li:hover {
    background: rgba(47, 129, 247, 0.15);
    color: var(--text);
    padding-left: 20px;
}

.query-list li:last-child {
    border-bottom: none;
}

.query-loading {
    padding: 20px;
    text-align: center;
    font-style: italic;
}

@media (max-width: 1024px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .query-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Highlights ── */
.highlight-row {
    animation: highlight-fade 3s ease-out forwards;
}

@keyframes highlight-fade {
    0% {
        background-color: rgba(47, 129, 247, 1);
    }

    100% {
        background-color: transparent;
    }
}

.highlight-row-static {
    background-color: rgba(47, 129, 247, 0.1) !important;
}

/* ── Performance Metrics ── */
.performance-table-container {
    overflow-x: auto;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 400px;
}

.performance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.performance-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-light);
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.performance-table th:hover {
    background: rgba(47, 129, 247, 0.1);
    color: var(--text-main);
}

.performance-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.performance-table tr:hover td {
    background: rgba(47, 129, 247, 0.05);
}

.performance-chart-container {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 20px;
    min-height: 350px;
}

@media (max-width: 1000px) {
    #panel-health .health-grid+div>div {
        grid-template-columns: 1fr !important;
    }
}

/* ── CHAT PANEL STYLES ── */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    margin: -20px -20px 15px -20px;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
}

.chat-header span {
    font-weight: 600;
    color: var(--text);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 15px;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.chat-messages::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
    /* Ensure long words wrap */
    overflow-wrap: break-word;
    white-space: pre-wrap;
    /* Preserve newlines while wrapping */
}

.chat-message.user .chat-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message.bot .chat-bubble {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-bubble ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.chat-bubble li {
    margin: 4px 0;
}

.chat-bubble.loading {
    opacity: 0.6;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area .voice-search-wrapper {
    position: relative;
    flex: 1;
}

.chat-input-area .voice-search-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    padding-right: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    min-height: 48px;
    max-height: 150px;
    overflow-y: auto;
    display: block;
}

.chat-input-area .voice-search-wrapper textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-input-area>button {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-input-area>button:hover {
    background: var(--accent-hover, #2563eb);
}

/* ── Health Dashboard ── */
.health-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.health-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.health-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.health-card h3 {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    color: var(--text);
}

.health-status-badge {
    margin-left: auto;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-up {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent2);
    border: 1px solid rgba(63, 185, 80, 0.2);
}

.status-down {
    background: rgba(247, 129, 102, 0.15);
    color: var(--warn);
    border: 1px solid rgba(247, 129, 102, 0.2);
}

.health-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.health-details p {
    font-size: 0.95rem;
    line-height: 1.5;
}

.health-details strong {
    color: var(--text-dim);
    font-weight: 500;
}

.health-details span,
.health-details code {
    color: var(--text);
    font-family: inherit;
}

.health-resolution {
    margin-top: 20px;
}

.health-resume-btn {
    margin-top: 16px;
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: fit-content;
}

.health-resume-btn:hover {
    background: var(--accent-hover, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(47, 129, 247, 0.3);
}

.health-resume-btn:active {
    transform: translateY(0);
}

.health-resume-btn.processing {
    background: var(--text-dim);
    cursor: wait;
}

/* ── Professional Registers ── */
.reg-tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.reg-tab {
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--text-dim);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reg-tab:hover {
    border-color: var(--accent);
    color: var(--text-main);
    transform: translateY(-1px);
    background: rgba(47, 129, 247, 0.05);
}

.reg-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(47, 129, 247, 0.3);
}

.form-section-container {
    display: flex;
    gap: 32px;
}

.form-section {
    flex: 1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 600;
}

.info-section.card {
    width: 340px;
    flex-shrink: 0;
    background: rgba(47, 129, 247, 0.03) !important;
    border-color: rgba(47, 129, 247, 0.1) !important;
    padding: 24px !important;
    height: fit-content;
}

@media (max-width: 1100px) {
    .form-section-container {
        flex-direction: column;
    }
    .info-section.card {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}