﻿/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
    --sidebar-bg:      #0a0a0a;
    --sidebar-hover:   #1c1917;
    --sidebar-active:  #c2410c;
    --sidebar-text:    #a8a29e;
    --sidebar-active-t:#ffffff;
    --sidebar-w:       248px;
    --sidebar-border:  rgba(255,255,255,0.06);

    --bg:              #f6f6f3;
    --bg-card:         #ffffff;
    --bg-sec:          #faf9f6;
    --bg-hover:        #f1f0eb;
    --surface-alt:     #f4f3ee;   /* sub-surface inside cards (stat tiles, table headers) */

    --text:            #0c0a07;
    --text-muted:      #57534e;
    --text-sub:        #a8a29e;

    --primary:         #c2410c;
    --primary-h:       #9a3412;
    --primary-soft:    rgba(194,65,12,0.10);
    --accent:          #047857;
    --accent-soft:     rgba(4,120,87,0.10);
    --danger:          #b91c1c;
    --danger-soft:     rgba(185,28,28,0.10);
    --warning:         #b45309;
    --warning-soft:    rgba(180,83,9,0.10);
    --info:            #155e75;
    --info-soft:       rgba(21,94,117,0.10);
    --violet:          #6d28d9;
    --violet-soft:     rgba(109,40,217,0.10);

    --border:          #e7e5dc;
    --border-strong:   #d6d3c8;
    --shadow-sm:       0 1px 2px rgba(0,0,0,0.05);
    --shadow:          0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:       0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg:       0 10px 24px rgba(0,0,0,0.1);

    --radius-sm:       4px;
    --radius:          8px;
    --radius-lg:       12px;
    --radius-xl:       16px;

    --topbar-h:        56px;
    --transition:      0.15s ease;

    /* Type families */
    --font-display: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-body:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    /* ── Typography scale ────────────────────────────────────────────────────── */
    --text-xs:         11px;
    --text-sm:         12px;
    --text-base:       14px;
    --text-md:         15px;
    --text-lg:         16px;
    --text-xl:         18px;
    --text-2xl:        22px;
    --text-3xl:        28px;

    --weight-normal:   400;
    --weight-medium:   500;
    --weight-semibold: 600;
    --weight-bold:     700;

    --leading-tight:   1.25;
    --leading-normal:  1.5;
    --leading-relaxed: 1.7;

    --tracking-tight:  -0.02em;
    --tracking-normal:  0;
    --tracking-wide:    0.04em;

    /* ── Spacing (4px base) ──────────────────────────────────────────────────── */
    --sp-1:   4px;
    --sp-2:   8px;
    --sp-3:   12px;
    --sp-4:   16px;
    --sp-5:   20px;
    --sp-6:   24px;
    --sp-7:   32px;
    --sp-8:   40px;
    --sp-9:   48px;
    --sp-10:  64px;
    --sp-11:  80px;
    --sp-12:  96px;

    /* ── Motion ──────────────────────────────────────────────────────────────── */
    --duration-instant: 50ms;
    --duration-fast:    100ms;
    --duration-normal:  150ms;
    --duration-slow:    250ms;
    --duration-slower:  400ms;

    --ease-default:     cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out:         cubic-bezier(0, 0, 0.2, 1);
    --ease-in:          cubic-bezier(0.4, 0, 1, 1);
    --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ── Focus ───────────────────────────────────────────────────────────────── */
    --focus-ring:       0 0 0 2px var(--bg-card), 0 0 0 4px var(--primary);
    --border-focus:     var(--primary);

    /* ── Layout ──────────────────────────────────────────────────────────────── */
    --max-w-content:    680px;
    --max-w-wide:       960px;
    --max-w-page:       1280px;

    /* ── Avatar ──────────────────────────────────────────────────────────────── */
    --avatar-size:      32px;
    --avatar-size-lg:   40px;
    --avatar-bg:        var(--primary-soft);
    --avatar-text:      var(--primary);

    /* ── Hero search ─────────────────────────────────────────────────────────── */
    --hero-input-h:     48px;
    --hero-input-fs:    var(--text-lg);
    --hero-card-py:     var(--sp-8);
    --hero-card-px:     var(--sp-7);
    --hero-card-gap:    var(--sp-4);

    /* ── Dashboard ───────────────────────────────────────────────────────────── */
    --dash-page-gap:    var(--sp-7);
    --dash-section-fs:  var(--text-sm);
    --dash-section-fw:  var(--weight-semibold);
    --dash-section-ls:  var(--tracking-wide);
}

.dark {
    --sidebar-bg:      #000000;
    --sidebar-hover:   #1c1917;
    --bg:              #0c0a07;
    --bg-card:         #1c1917;
    --bg-sec:          #14110e;
    --bg-hover:        #292524;
    --surface-alt:     #262220;   /* sub-surface inside cards (stat tiles, table headers) */
    --text:            #fafaf9;
    --text-muted:      #a8a29e;
    --text-sub:        #78716c;
    --primary:         #fb923c;
    --primary-h:       #fdba74;
    --primary-soft:    rgba(251,146,60,0.14);
    --accent:          #34d399;
    --accent-soft:     rgba(52,211,153,0.14);
    --danger:          #f87171;
    --danger-soft:     rgba(248,113,113,0.14);
    --warning:         #fbbf24;
    --warning-soft:    rgba(251,191,36,0.14);
    --violet:          #a78bfa;
    --violet-soft:     rgba(167,139,250,0.14);
    --border:          #292524;
    --border-strong:   #44403c;
    --shadow-sm:       0 1px 2px rgba(0,0,0,0.3);
    --shadow:          0 1px 3px rgba(0,0,0,0.35);
    --shadow-md:       0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:       0 12px 28px rgba(0,0,0,0.5);

    --focus-ring:      0 0 0 2px var(--bg-card), 0 0 0 4px var(--primary);
    --avatar-bg:       rgba(251,146,60,0.15);
    --avatar-text:     var(--primary);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Shell layout ────────────────────────────────────────────────────────────── */
.shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: #fff;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12),
                0 4px 8px rgba(194,65,12,0.35);
}

.sidebar-brand-name {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.sidebar-brand-sub {
    font-family: var(--font-mono);
    font-size: 9.5px;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-top: 3px;
}

.sidebar-section {
    padding: 20px 12px 8px;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-text);
    padding: 0 8px;
    margin-bottom: 4px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
    text-decoration: none;
}

.sidebar-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-link.active {
    background: rgba(194,65,12,0.18);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--primary);
}
.sidebar-link .link-icon {
    font-size: 15px;
    width: 20px;
    height: 20px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid var(--sidebar-border);
}

/* ── Shell body ──────────────────────────────────────────────────────────────── */
.shell-body {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    margin-right: 4px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
}
.crumb-sep {
    opacity: 0.5;
}
.crumb-current {
    color: var(--text);
    font-weight: 600;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-sec);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    flex: 0 1 300px;
}
.topbar-search:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.topbar-search span:last-child {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.6;
}
.kbd {
    font-family: var(--font-mono);
    font-size: 10px;
}

.topbar-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all var(--transition);
    position: relative;
}
.topbar-icon-btn:hover {
    background: var(--bg-sec);
    color: var(--primary);
}
.topbar-icon-btn .dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    background: var(--danger);
    border-radius: 50%;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ── Theme toggle ───────────────────────────────────────────────────────────── */
.theme-btn {
    background: var(--bg-sec);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    transition: all var(--transition);
    display: flex; align-items: center; gap: 6px;
}
.theme-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Mobile overlay ─────────────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-overlay { display: block; }
    .shell-body { margin-left: 0; }
    .topbar-hamburger { display: flex; }
}

/* ── Page content ───────────────────────────────────────────────────────────── */
.page { padding: 24px; max-width: 1280px; }
.page-full { padding: 24px; }
.page-narrow { padding: 24px; max-width: 800px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.page-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-sub);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-card .stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums lining-nums;
    color: var(--text);
}
.stat-card .stat-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-sub);
}

.stat-primary .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-accent  .stat-icon { background: var(--accent-soft);  color: var(--accent); }
.stat-warning .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat-danger  .stat-icon { background: var(--danger-soft);  color: var(--danger); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-control {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    padding: 9px 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control { cursor: pointer; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-h); border-color: var(--primary-h); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-sec);
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { opacity: 0.88; }

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-sec); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    border-radius: 99px;
    padding: 2px 8px;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--bg-sec); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    border-left: 3px solid;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.alert-error   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--danger); }
.alert-success { background: var(--accent-soft);  border-color: var(--accent);  color: var(--accent); }
.alert-info    { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sec);
    white-space: nowrap;
}

.data-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.data-table .num,
.data-table .mono {
    font-family: var(--font-mono);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.data-table td {
    border-bottom: 1px solid var(--border);
    padding: 11px 14px;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Progress bar ───────────────────────────────────────────────────────────── */
.progress-wrap {
    background: var(--bg-sec);
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
    width: 100%;
    border: 1px solid var(--border);
}

.progress-fill {
    background: var(--primary);
    border-radius: 99px;
    height: 100%;
    transition: width 0.4s ease;
}

/* ── Section gap ────────────────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ── Analysis page ──────────────────────────────────────────────────────────── */
.analysis-shell {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - var(--topbar-h));
}

.analysis-panel {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.map-area { position: relative; height: 100%; }

#map { width: 100%; height: 100%; min-height: 400px; }

/* Info overlay card that appears after analysis inside the map panel */
.map-info-bar {
    position: absolute;
    bottom: 24px;
    left: 16px;
    right: 16px;
    z-index: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: map-bar-in 0.22s var(--ease-out) both;
    pointer-events: none;
}
@keyframes map-bar-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.map-info-bar-row1 {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.map-info-bar-zone-desc {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.map-info-bar-address {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.map-info-bar-coords {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-sub);
    margin-top: 2px;
}

.result-card {
    background: var(--bg-sec);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zoning-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 4px 12px;
}

.analysis-text {
    font-size: 13.5px;
    line-height: 1.75;
    white-space: pre-wrap;
    color: var(--text);
}

.citations-list { display: flex; flex-direction: column; gap: 4px; }
.citation-item {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--primary);
}

/* ── Chat page ──────────────────────────────────────────────────────────────── */
.chat-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h));
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 800px;
}

.chat-message.user-msg { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.ai-avatar   { background: var(--primary-soft); color: var(--primary); }
.user-avatar { background: var(--accent-soft);  color: var(--accent); }

.msg-body { display: flex; flex-direction: column; gap: 6px; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 13.5px;
    line-height: 1.7;
    max-width: 660px;
}

.ai-bubble   { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg); }
.user-bubble { background: var(--primary); color: #fff; border-radius: var(--radius-lg) 4px var(--radius-lg) var(--radius-lg); }

.msg-citations {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-left: 44px;
}

.msg-citation-badge {
    font-size: 11px;
    background: var(--bg-sec);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 99px;
    padding: 2px 8px;
}

.chat-input-area {
    padding: 16px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area .form-control { min-height: 44px; max-height: 120px; resize: none; border-radius: var(--radius-lg); flex: 1; }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.spinner-dark {
    border-color: var(--border);
    border-top-color: var(--primary);
    color: var(--primary);
}

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

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

.filter-bar .form-control { max-width: 200px; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    padding: 16px;
}

.page-info { font-size: 13px; color: var(--text-muted); margin: 0 8px; }

/* ── Admin nav sub-tabs ─────────────────────────────────────────────────────── */
.subnav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    background: var(--bg-card);
}

.subnav-link {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    transition: color var(--transition), border-color var(--transition);
    cursor: pointer;
}

.subnav-link:hover { color: var(--primary); }
.subnav-link.active { color: var(--primary); border-color: var(--primary); }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-sub); }

/* ── Responsive adjustments ─────────────────────────────────────────────────── */
@media (max-width: 767px) {
    /* Analysis page: stack panel above map, both scroll naturally */
    .analysis-shell {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
    }
    .analysis-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-y: visible;
        height: auto;
    }
    .map-area {
        height: 300px;
        flex-shrink: 0;
    }
    #map { min-height: 300px; }

    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .page { padding: 16px; }
    .chat-messages { padding: 16px; }
    .chat-input-area { padding: 12px 16px; }
}

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

/* ── Version bar ─────────────────────────────────────────────────────────────── */
.version-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 24px;
    font-size: 11px;
    font-family: ui-monospace, monospace;
    color: var(--text-sub);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    user-select: none;
    flex-wrap: wrap;
}
.version-bar span:first-child {
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 0.3px;
}
.version-sep {
    color: var(--border);
}

/* ── Reduced motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration:        0.01ms !important;
        animation-iteration-count: 1      !important;
        transition-duration:       0.01ms !important;
    }
}

/* ── Dashboard ───────────────────────────────────────────────────────────────── */
.dash-page {
    display: flex;
    flex-direction: column;
    gap: var(--dash-page-gap);
}

.hero-card {
    padding: var(--hero-card-py) var(--hero-card-px);
    display: flex;
    flex-direction: column;
    gap: var(--hero-card-gap);
}

.hero-card .hero-label {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--text);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}

.hero-card .hero-sub {
    font-size: var(--text-base);
    color: var(--text-muted);
    margin-top: 4px;
}

.hero-card .hero-row {
    display: flex;
    gap: var(--sp-3);
    align-items: flex-end;
}

.hero-card .form-control-hero {
    height: var(--hero-input-h);
    font-size: var(--hero-input-fs);
    flex: 1;
    padding: 0 var(--sp-4);
}

/* ── Address autocomplete (AddressAutocomplete.razor) ─────────────────────── */
.autocomplete-wrap { position: relative; flex: 1; }
.autocomplete-wrap .form-control,
.autocomplete-wrap .form-control-hero { width: 100%; }
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    z-index: 50;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    max-height: 320px;
    overflow-y: auto;
}
.autocomplete-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--surface-alt); }
.autocomplete-addr { flex: 1; }
.autocomplete-comm {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.autocomplete-empty {
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-muted);
}