html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: #0f0f1a;
    color: #e2e8f0;
    overflow: hidden;
    height: 100%;
}

/* Glassmorphism card effect */
.glass-card {
    background: rgba(26, 26, 46, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* ============================
   3-Panel Portal Layout
   ============================ */
.portal-layout {
    display: flex;
    height: 100%;
    gap: 0;
}

.portal-insights {
    width: 300px;
    min-width: 260px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    background: rgba(26, 26, 46, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-keywords {
    width: 280px;
    min-width: 240px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    background: rgba(26, 26, 46, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-left {
    width: 380px;
    min-width: 320px;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    background: rgba(26, 26, 46, 0.5);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    position: relative;
}

.portal-right {
    width: 380px;
    min-width: 340px;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    background: rgba(26, 26, 46, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

.portal-right.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    border-left: none;
    opacity: 0;
    overflow: hidden;
}

.portal-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Leaflet map container */
.map-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* Chat panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Leaflet zoom control — ensure visible below app bar */
.leaflet-top.leaflet-left {
    top: 10px;
    left: 10px;
}

/* Push Leaflet attribution to avoid overlap */
.leaflet-bottom {
    bottom: 0;
}

/* Quick questions in left panel */
.quick-questions-section {
    padding: 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.quick-questions-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.5;
    margin-bottom: 6px;
}

.quick-question-pill {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid color-mix(in srgb, var(--qc) 20%, transparent);
    color: var(--qc);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-family: inherit;
    text-align: left;
    line-height: 1.35;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    width: 100%;
    display: block;
    margin-bottom: 4px;
}

.quick-question-pill:hover {
    background: color-mix(in srgb, var(--qc) 10%, rgba(26, 26, 46, 0.95));
    border-color: color-mix(in srgb, var(--qc) 45%, transparent);
}

/* ============================
   Keyword List (vertical bar chart)
   ============================ */
.keyword-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyword-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyword-row-label {
    width: 90px;
    min-width: 90px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #e2e8f0;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.keyword-row-bar-track {
    flex: 1;
    height: 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
}

.keyword-row-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 3px;
}

.keyword-row-score {
    width: 32px;
    min-width: 32px;
    font-size: 0.62rem;
    font-weight: 600;
    opacity: 0.6;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ============================
   Map / Table Tabs
   ============================ */
.center-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    background: rgba(26, 26, 46, 0.4);
    backdrop-filter: blur(10px);
}

.center-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: none;
    background: transparent;
    color: rgba(226, 232, 240, 0.5);
    transition: all 0.2s ease;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.center-tab:hover {
    color: rgba(226, 232, 240, 0.8);
    background: rgba(255, 255, 255, 0.03);
}

.center-tab.active {
    color: var(--tab-color, #e2e8f0);
    border-bottom-color: var(--tab-color, #e2e8f0);
    background: rgba(255, 255, 255, 0.04);
}

.center-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* ============================
   Location Table
   ============================ */
.location-table-wrap {
    height: 100%;
    overflow-y: auto;
    padding: 8px;
}

.location-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
}

.location-table thead th {
    position: sticky;
    top: 0;
    background: rgba(15, 15, 26, 0.95);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(226, 232, 240, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    z-index: 1;
}

.location-table thead th:hover {
    color: rgba(226, 232, 240, 0.8);
}

.location-table thead th .sort-arrow {
    font-size: 0.6rem;
    margin-left: 3px;
    opacity: 0.6;
}

.location-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.location-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.location-table tbody tr.selected {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.location-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.prediction-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 8px;
    white-space: nowrap;
    font-weight: 500;
}

/* ============================
   Detail Panel (Right)
   ============================ */
.detail-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.detail-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    opacity: 0.35;
    text-align: center;
    padding: 32px;
    gap: 12px;
}

.prediction-display {
    text-align: center;
    padding: 16px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.prediction-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.prediction-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 8px;
}

/* Detail panel section title */
.section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.4;
    margin-bottom: 10px;
}

/* Knowledge support section */
.knowledge-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.knowledge-text {
    font-size: 0.72rem;
    line-height: 1.6;
    opacity: 0.8;
}

/* ============================
   Source Confidence Bars
   ============================ */
.source-confidence {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.source-confidence-bar {
    height: 4px;
    border-radius: 2px;
    max-width: 80px;
    min-width: 3px;
}

.source-confidence-label {
    font-size: 0.58rem;
    opacity: 0.45;
}

/* ============================
   Pulse animation for selected marker
   ============================ */
@keyframes marker-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

/* Landing page gradient background */
.landing-bg {
    background: radial-gradient(ellipse at 30% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(129, 140, 248, 0.08) 0%, transparent 50%),
                #0f0f1a;
    min-height: 100%;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #b32121;
    color: white;
    padding: 0.6rem 1.2rem;
    display: none;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* Leaflet marker overrides */
.custom-marker {
    background: none !important;
    border: none !important;
}

/* ============================
   Featured Insights (Left Panel)
   ============================ */
.left-insights {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.left-insights-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.5;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.left-insight-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.left-insight-card:hover {
    background: color-mix(in srgb, var(--qc) 8%, rgba(26, 26, 46, 0.9));
    border-color: color-mix(in srgb, var(--qc) 30%, transparent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.insight-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.insight-body {
    flex: 1;
    min-width: 0;
}

.insight-question {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--qc);
    margin-bottom: 4px;
    line-height: 1.3;
}

.insight-summary {
    font-size: 0.66rem;
    opacity: 0.55;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.insight-meta {
    font-size: 0.6rem;
    opacity: 0.3;
    margin-top: 6px;
}