/* Civic Sentinel design system (mockup/civic_sentinel/DESIGN.md) */

:root {
    --surface: #fcf8fa;
    --surface-muted: #F8FAFC;
    --surface-white: #ffffff;
    --surface-container: #f0edef;
    --on-surface: #1b1b1d;
    --on-surface-variant: #45464d;
    --border-subtle: #E2E8F0;
    --outline: #76777d;
    --primary: #0F172A;
    --secondary: #334155;
    --status-critical: #DC2626;
    --status-critical-bg: #FEE2E2;
    --status-ongoing: #D97706;
    --status-ongoing-bg: #FEF3C7;
    --status-resolved: #059669;
    --status-resolved-bg: #D1FAE5;
    --status-action: #2563EB;
    --status-action-bg: #DBEAFE;
    /* Due states (Phase 5): one scale for every list, chip and map pin. */
    --due-ok: #059669;
    --due-ok-bg: #D1FAE5;
    --due-soon: #D97706;
    --due-soon-bg: #FEF3C7;
    --due-today: #EA580C;
    --due-today-bg: #FFEDD5;
    --due-overdue: #DC2626;
    --due-overdue-bg: #FEE2E2;
    /* Map (Phase A): sampled from docs/prompts/2026-10-15-map-revamp-reference.png */
    --map-grass-1: #9AA45A;
    --map-grass-2: #B3B478;
    --map-grass-3: #7A8A46;
    --map-tree: #3F5A2A;
    --map-tree-light: #5E7A36;
    --map-tree-dark: #2E4420;
    /* Sprite fidelity: four canopy greens, sidewalks and curbs, lit and shaded roof planes, slate. */
    --map-tree-2: #6E8C3A;
    --map-tree-3: #2C4A26;
    --map-tree-4: #4E7436;
    --map-sidewalk: #E3E1D8;
    --map-curb: #A3A59E;
    --map-roof-light: #F7F5F0;
    --map-roof-shade: #8E897F;
    --map-slate: #7F8B98;
    --map-slate-light: #A3AEBA;
    --map-asphalt: #7D8083;
    --map-road-edge: #CFD1CA;
    --map-path: #CFC7A8;
    --map-sand: #D8C9A2;
    --map-court: #C96B4A;
    --map-roof: #D9D6CF;
    --map-roof-dark: #B9B5AC;
    --map-facade: #E6D8BD;
    --map-facade-shade: #C9B897;
    --map-window: #9FB4C7;
    --map-wall: #4B5563;
    --map-corridor: #FFFFFF;
    --map-plan-sheet: #F6F7F9;
    --map-plan-service: #D9DDE3;
    --map-room-neutral: #E8EAEE;
    --map-room-clear: #C2E9D4;
    --map-room-maint: #FBE8C5;
    --map-room-due-today: #F9CDB6;
    --map-room-overdue: #F7CECE;
    --map-room-issues: #F7C8CA;
    --map-room-emergency: #F3B3B3;
    --map-room-multiple: #DCCEFC;
    --map-pool-water: #8DCAE7;
    --map-pool-deck: #C9C3B3;
    --map-shadow: rgba(15, 23, 42, 0.22);
    --map-st-clear: rgba(50, 182, 112, 0.6);
    --map-st-clear-line: #2AAA66;
    --map-st-maint: rgba(240, 178, 60, 0.6);
    --map-st-issues: rgba(229, 72, 77, 0.6);
    --map-st-issues-line: #DC2626;
    --map-st-multiple: rgba(139, 92, 246, 0.6);
    --map-st-multiple-line: #7C3AED;
    --map-pill: rgba(17, 24, 39, 0.85);
    --map-primary: #2563EB;
    --map-tile-blue: #DBEBFD;
    --map-tile-red: #FEE0DF;
    --map-tile-amber: #FEEFC6;
    --map-tile-grey: #EAEEF2;
    --map-glyph-blue: #3D84D3;
    --map-glyph-red: #E6444A;
    --map-glyph-amber: #F5A623;
    --map-glyph-grey: #6B7A90;
    --shadow-float: 0 4px 12px rgba(15, 23, 42, 0.08);
    --radius: 0.25rem;
    --radius-lg: 0.5rem;
    --font-ui: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 20px;
    color: var(--on-surface);
    background: var(--surface-muted);
    height: 100%;
}

h1, h2, h3 { margin: 0; }
a { color: var(--status-action); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #f0edef;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    gap: 8px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; }
.sidebar .brand-mark {
    width: 40px; height: 40px; border-radius: 10px; background: var(--primary);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.sidebar .brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sidebar .brand-sub { font-size: 12px; color: var(--on-surface-variant); }

.btn-new-ticket {
    display: block; width: 100%; background: #000; color: #fff; border: none;
    padding: 12px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
    cursor: pointer; text-align: center; margin-bottom: 16px; font-family: inherit;
}
.btn-new-ticket:hover { background: var(--primary); text-decoration: none; color: #fff; }

.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: var(--radius-lg); color: var(--on-surface-variant);
    font-weight: 500; font-size: 14px;
}
.nav-item:hover { background: #e4e2e4; text-decoration: none; }
.nav-item.active { background: #dbe4fd; color: var(--primary); font-weight: 600; }
.nav-item .icon { width: 20px; text-align: center; }
.sidebar .spacer { flex: 1; }

/* ---- Top bar ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 16px; padding: 14px 32px;
    background: var(--surface-white); border-bottom: 1px solid var(--border-subtle);
    position: sticky; top: 0; z-index: 10;
}
.topbar .search {
    flex: 1; max-width: 480px; background: var(--surface-muted);
    border: 1px solid var(--border-subtle); border-radius: var(--radius);
    padding: 9px 14px; font-size: 14px; font-family: inherit; color: var(--on-surface);
}
.topbar .search:focus { outline: 2px solid var(--status-action); outline-offset: -1px; }
.topbar .grow { flex: 1; }
.community-selector {
    border: 1px solid var(--border-subtle); background: var(--surface-white);
    padding: 9px 14px; border-radius: var(--radius); font-size: 14px; font-family: inherit;
    color: var(--on-surface); cursor: pointer;
}
.user-chip { font-size: 13px; color: var(--on-surface-variant); white-space: nowrap; }

/* ---- Content ---- */
.content { padding: 32px; max-width: 1400px; width: 100%; }
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 40px; }
.page-sub { color: var(--on-surface-variant); margin-top: 4px; margin-bottom: 24px; }

/* ---- Cards & stats ---- */
.card {
    background: var(--surface-white); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 20px;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin-bottom: 24px; }
.stat-card { position: relative; padding-left: 24px; }
.stat-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    border-radius: 4px 0 0 4px; background: var(--border-subtle);
}
.stat-card.critical::before { background: var(--status-critical); }
.stat-card.ongoing::before { background: var(--status-ongoing); }
.stat-card.action::before { background: var(--status-action); }
.stat-card.resolved::before { background: var(--status-resolved); }
.stat-label {
    font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--on-surface-variant);
}
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 2px; }
.stat-card.tile { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.stat-card.tile::before { display: none; }
.stat-card.tile .stat-tile { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.stat-card.tile .stat-tile svg.glyph { width: 24px; height: 24px; }
.stat-tile.blue { background: var(--map-tile-blue); color: var(--map-glyph-blue); }
.stat-tile.red { background: var(--map-tile-red); color: var(--map-glyph-red); }
.stat-tile.amber { background: var(--map-tile-amber); color: var(--map-glyph-amber); }
.stat-tile.grey { background: var(--map-tile-grey); color: var(--map-glyph-grey); }
.stat-card.tile .stat-value { font-size: 26px; margin: 0; line-height: 30px; }
.stat-card.tile .stat-caption { font-size: 13px; color: var(--on-surface-variant); line-height: 16px; }
.stat-hint { font-size: 13px; color: var(--on-surface-variant); }
.stat-hint.alert { color: var(--status-critical); }

/* ---- Chips ---- */
.chip {
    display: inline-block; padding: 3px 10px; border-radius: 9999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
/* "critical" is a colour token (red = urgent), not a ticket class: the ticket-level meaning is
   Emergency severity, so .emergency is the name to reach for in new markup. */
.chip.critical, .chip.emergency { background: var(--status-critical-bg); color: var(--status-critical); }
.chip.high, .chip.ongoing { background: var(--status-ongoing-bg); color: var(--status-ongoing); }
.chip.medium { background: var(--map-tile-amber); color: #92400E; }
.chip.low { background: var(--map-tile-grey); color: var(--on-surface-variant); }
.chip.resolved, .chip.approved, .chip.completed { background: var(--status-resolved-bg); color: var(--status-resolved); }
.chip.action, .chip.inprogress, .chip.assigned { background: var(--status-action-bg); color: var(--status-action); }
.chip.neutral { background: var(--surface-container); color: var(--on-surface-variant); }
.chip.due-ok { background: var(--due-ok-bg); color: var(--due-ok); }
.chip.due-soon { background: var(--due-soon-bg); color: var(--due-soon); }
.chip.due-today { background: var(--due-today-bg); color: var(--due-today); }
.chip.due-overdue { background: var(--due-overdue-bg); color: var(--due-overdue); }

.mono { font-family: var(--font-mono); font-size: 13px; }

/* ---- Tables / queues ---- */
.queue-table { width: 100%; border-collapse: collapse; }
.queue-table th {
    text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--on-surface-variant);
    padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-muted);
}
.queue-table td { padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.queue-table tbody tr { cursor: pointer; border-left: 4px solid transparent; }
.queue-table tbody tr:hover { background: var(--surface-muted); }
/* Row accent keys off Severity: Emergency replaced the old Critical value (spec §3.1). */
.queue-table tbody tr.sev-emergency { border-left-color: var(--status-critical); }
.queue-table tbody tr.sev-high { border-left-color: var(--status-ongoing); }
.queue-table .title { font-weight: 600; }
.queue-table .desc { color: var(--on-surface-variant); font-size: 13px; margin-top: 2px; }
.sla-ok { color: var(--on-surface-variant); }
.sla-warn { color: var(--status-ongoing); font-weight: 600; }
.sla-breach { color: var(--status-critical); font-weight: 700; }

/* ---- Buttons & forms ---- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
    border-radius: var(--radius); font-size: 14px; font-weight: 600; font-family: inherit;
    border: 1px solid transparent; cursor: pointer; background: var(--primary); color: #fff;
}
.btn:hover { opacity: 0.92; text-decoration: none; }
.btn.secondary { background: var(--surface-white); color: var(--secondary); border-color: var(--border-subtle); }
.btn.resolve { background: var(--status-resolved); }
.btn.danger { background: var(--status-critical); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field-label {
    display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--on-surface-variant); margin-bottom: 6px;
}
.field-input, .field-select, .field-textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border-subtle);
    border-radius: var(--radius); font-size: 14px; font-family: inherit; background: var(--surface-white);
    color: var(--on-surface);
}
.field-input:focus, .field-select:focus, .field-textarea:focus { outline: 2px solid var(--status-action); outline-offset: -1px; }
.field-row { margin-bottom: 16px; }

/* ---- Timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 20px 24px; border-left: 2px solid var(--border-subtle); margin-left: 8px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
    content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--surface-white); border: 2px solid var(--outline);
}
.timeline li.accent-critical::before { border-color: var(--status-critical); background: var(--status-critical); }
.timeline li.accent-action::before { border-color: var(--status-action); background: var(--status-action); }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { font-family: var(--font-mono); font-size: 12px; color: var(--on-surface-variant); margin-top: 2px; }

/* ---- Grid helpers ---- */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.grid-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.muted { color: var(--on-surface-variant); }
.section-title { font-size: 18px; font-weight: 600; line-height: 24px; }
.divider { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }

/* ---- Report cards ---- */
.report-card { background: var(--surface-muted); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 14px 16px; }
.report-card .who { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--secondary); color: #fff;
    display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.report-card .name { font-weight: 600; }
.report-card .meta { font-size: 12px; color: var(--on-surface-variant); }
.report-card .quote { font-style: normal; }

/* ---- Score bar ---- */
.score-bar { height: 6px; background: var(--border-subtle); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.score-bar > div { height: 100%; background: var(--status-action); }
.score-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; }
.score-label { color: var(--status-resolved); font-weight: 600; font-size: 13px; margin-left: 8px; }

/* ---- Simple bar chart ---- */
.bars { display: flex; align-items: flex-end; gap: 18px; height: 160px; padding: 8px 4px 0; }
.bars .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; align-items: flex-end; gap: 4px; flex: 1; width: 100%; justify-content: center; }
.bars .bar { width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .bar.reports { background: var(--secondary); }
.bars .bar.resolved { background: var(--status-resolved); }
.bars .day-label { font-family: var(--font-mono); font-size: 11px; color: var(--on-surface-variant); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--surface-muted); }
.login-card { width: 380px; box-shadow: var(--shadow-float); }
.login-card .brand-mark { margin: 0 auto 12px; }

/* ---- Workload meter ---- */
.workload { display: flex; gap: 3px; }
.workload span { width: 8px; height: 18px; border-radius: 2px; background: var(--border-subtle); }
.workload span.filled { background: var(--status-resolved); }
.workload.busy span.filled { background: var(--status-ongoing); }

/* ---- Complex map ---- */
/* The map pages are full-viewport workspaces (PropertyHub-style): the shell stops scrolling and
   the page fills whatever is left below the top bar, so the canvas gets every pixel it can. */
.main.map-main { height: 100vh; overflow: hidden; }
.content.map-page {
    flex: 1; min-height: 0; max-width: none;
    padding: 16px 32px 12px;
    display: flex; flex-direction: column; overflow-y: auto;
}
.map-page > .map-header { flex-shrink: 0; }
.map-page > .map-stats { flex-shrink: 0; margin-bottom: 10px; }
.map-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.map-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px; }
.map-empty-icon { font-size: 44px; }
.map-empty h2 { margin: 14px 0 8px; font-size: 22px; }
.map-empty p { max-width: 420px; margin: 0; }
.map-header .page-title { font-size: 24px; line-height: 32px; }
.map-breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--on-surface-variant); flex-wrap: wrap; margin-top: 4px; }
.map-breadcrumbs a { color: var(--status-action); font-weight: 500; }
.map-breadcrumbs .sep { color: var(--outline); }
.map-breadcrumbs .current { color: var(--on-surface); font-weight: 600; }
.map-search { position: relative; }
.map-search .field-input { width: 260px; padding: 7px 12px; }
.map-search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
    background: var(--surface-white); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-float); max-height: 320px; overflow-y: auto;
}
.map-search-results .hit { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-subtle); }
.map-search-results .hit:last-child { border-bottom: none; }
.map-search-results .hit:hover { background: var(--surface-muted); }
.map-search-results .hit .kind { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--on-surface-variant); }
.map-search-results .hit .t { font-weight: 600; font-size: 14px; }
.map-search-results .hit .s { font-size: 12px; color: var(--on-surface-variant); }

.map-stats { grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.map-stats .stat-card { padding: 12px 14px; }
.map-stats .stat-value { font-size: 22px; margin: 4px 0 0; }
.map-stats .stat-hint { font-size: 12px; }

.map-stage { position: relative; flex: 1; min-height: 320px; }
.map-stage .map-canvas-area { position: absolute; inset: 0; }
.map-stage.with-inspector .map-canvas-area { right: 360px; }
.map-inspector { position: absolute; top: 0; right: 0; bottom: 0; width: 360px; max-width: 92%; z-index: 6; background: var(--surface-white); border-left: 1px solid var(--border-subtle); overflow-y: auto; }
.map-inspector-panel { padding: 16px 18px 20px; }
.map-inspector-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.map-inspector-header .close { margin-left: auto; border: none; background: none; cursor: pointer; font-size: 18px; color: var(--on-surface-variant); padding: 4px; }
.map-inspector-tile { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.map-inspector-tile.tile-clear { background: var(--status-resolved-bg); color: var(--status-resolved); }
.map-inspector-tile.tile-maint { background: var(--map-tile-amber); color: var(--map-glyph-amber); }
.map-inspector-tile.tile-issues { background: var(--map-tile-red); color: var(--map-glyph-red); }
.map-inspector-tile.tile-multiple { background: #EDE9FE; color: var(--map-st-multiple-line); }
.map-inspector-name { font-size: 18px; font-weight: 700; line-height: 22px; }
.map-inspector-path { font-size: 12px; color: var(--on-surface-variant); }
.map-inspector-tabs { margin-bottom: 14px; }
.map-inspector-tabs .tab { cursor: pointer; padding: 8px 10px; }
.map-inspector-overview { display: flex; gap: 14px; margin-bottom: 14px; }
.map-inspector-thumb { width: 136px; height: 96px; flex: none; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-muted); border: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: center; }
.map-inspector-thumb .map-svg-host, .map-inspector-thumb .map-svg-host svg { width: 100%; height: 100%; }
.map-inspector-thumb-glyph { color: var(--map-glyph-grey); }
.map-inspector-facts { display: grid; gap: 4px; align-content: start; font-size: 13px; }
.map-inspector-facts-name { font-size: 16px; font-weight: 700; }
.map-inspector-kind, .map-inspector-descendants { color: var(--on-surface-variant); }
.map-inspector-parent { display: inline-flex; align-items: center; gap: 4px; color: var(--on-surface-variant); }
.map-inspector-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.map-inspector-stat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-lg); }
.map-inspector-stat.tile-red { background: var(--map-tile-red); }
.map-inspector-stat.tile-amber { background: var(--map-tile-amber); }
.map-inspector-stat-glyph { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.7); }
.map-inspector-stat.tile-red .map-inspector-stat-glyph { color: var(--map-glyph-red); }
.map-inspector-stat.tile-amber .map-inspector-stat-glyph { color: var(--map-glyph-amber); }
.map-inspector-stat .stat-value { font-size: 22px; margin: 0; line-height: 24px; }
.map-inspector-stat .stat-caption { font-size: 12px; color: var(--on-surface-variant); }
.map-inspector-details { display: block; width: 100%; text-align: center; background: var(--map-primary); border-color: var(--map-primary); margin-bottom: 8px; box-sizing: border-box; }
.map-inspector-add { display: block; font-size: 13px; margin-bottom: 12px; }
.map-inspector-activity-head { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 6px; }
.map-inspector-view-all { font-size: 13px; }
.map-activity-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border-subtle); cursor: pointer; }
.map-activity-tile { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.map-activity-tile.tile-red { background: var(--map-tile-red); color: var(--map-glyph-red); }
.map-activity-tile.tile-amber { background: var(--map-tile-amber); color: var(--map-glyph-amber); }
.map-activity-body { flex: 1; min-width: 0; }
.map-activity-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-activity-path { font-size: 12px; color: var(--on-surface-variant); }
.map-activity-time { font-size: 12px; color: var(--on-surface-variant); white-space: nowrap; }
.map-child-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 4px; border-top: 1px solid var(--border-subtle); cursor: pointer; font-size: 14px; }
.map-child-row:hover { background: var(--surface-muted); }
.map-child-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.map-pill-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.map-pill-count.pill-issues { background: var(--status-critical); }
.map-pill-count.pill-maint { background: var(--due-soon); }
.map-pill-count.pill-maint.due-today { background: var(--due-today); }
.map-pill-count.pill-maint.overdue { background: var(--due-overdue); }
.map-pill-count.pill-clear { background: var(--status-resolved); }
.map-pill-count.pill-maint, .map-pill-count.pill-clear { color: #1b1b1d; }
.map-pill-count.pill-maint.overdue { color: #fff; }
.map-inspector .list-row { padding: 8px 4px; border-top: 1px solid var(--border-subtle); cursor: pointer; }
.map-inspector .list-row .t { font-weight: 600; font-size: 13px; }
.map-inspector .list-row .s { font-size: 12px; color: var(--on-surface-variant); }
.map-inspector-all-tickets { margin-top: 10px; }

.map-tooltip { position: absolute; z-index: 8; pointer-events: none; background: var(--map-pill); color: #fff; border-radius: 6px; padding: 6px 10px; font-size: 12px; max-width: 220px; opacity: 0; transition: opacity 0.08s; }
.map-tooltip.visible { opacity: 1; }
.map-tooltip-title { font-weight: 600; }
.map-tooltip-hint { opacity: 0.75; font-size: 11px; }

/* ---- Drill-down strip (Phase B) ---- */
.map-strip { display: grid; gap: 14px; margin-top: 14px; flex-shrink: 0; }
.map-strip.three { grid-template-columns: 1fr 2fr 1.4fr; }
.map-strip.two { grid-template-columns: 1fr 1.6fr; }
.map-strip.one { grid-template-columns: 1fr; }
.map-strip-panel { background: var(--surface-white); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 14px 16px; min-height: 300px; display: flex; flex-direction: column; }
.map-strip-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.map-strip-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border-subtle); }
.map-strip-row:hover { background: var(--surface-muted); }
.map-strip-row.highlighted.row-issues { background: var(--map-tile-red); color: #B91C1C; font-weight: 600; }
.map-strip-row.highlighted.row-maint { background: var(--map-tile-amber); color: #92400E; font-weight: 600; }
.map-strip-row.highlighted.row-clear { background: var(--status-resolved-bg); color: #065F46; font-weight: 600; }
.map-strip-plan-host { position: relative; flex: 1; min-height: 240px; }
.map-strip-plan-host .map-canvas-wrap { border: none; border-radius: var(--radius); }
.map-strip-tabs { margin-bottom: 8px; }
.map-strip-tabs .tab { cursor: pointer; padding: 6px 10px; font-size: 13px; }
/* A tower of 30 floors must not stretch the strip row (its middle plan letterboxed out of sight): the list scrolls. */
.map-strip-rows { flex: 1; max-height: 340px; overflow-y: auto; }
.map-strip-panel.map-strip-list { max-height: 400px; overflow-y: auto; }
.map-strip-summary .map-activity-row { text-decoration: none; color: inherit; }
.map-strip-summary .map-activity-row .chip { flex: none; }
.map-strip-details { width: 100%; text-align: center; background: var(--map-primary); border-color: var(--map-primary); margin-top: 10px; }
.map-strip-empty { align-items: flex-start; gap: 8px; min-height: 120px; }
.map-strip-add { margin-top: 4px; }
.map-canvas-wrap {
    position: absolute; inset: 0; background: var(--surface-white);
    border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden;
}
.map-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.map-svg.panning { cursor: grabbing; }
.map-bg { fill: #F8FAFC; stroke: var(--border-subtle); }
.map-grid line { stroke: #E9EEF5; stroke-width: 1; }
.map-svg-host, .map-svg-host svg { width: 100%; height: 100%; display: block; }
.map-canvas-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; gap: 6px; background: var(--surface-muted); }
.map-canvas-empty-title { font-size: 18px; font-weight: 600; }
.map-canvas-empty .muted { max-width: 420px; font-size: 14px; }
.map-canvas-wrap.static .map-svg { cursor: default; }
.map-shape { cursor: pointer; outline: none; }
.map-shape:hover, .map-shape:focus-visible { filter: drop-shadow(0 3px 5px rgba(15, 23, 42, 0.35)); }
.map-shape:focus-visible .status-fill, .map-shape:focus-visible .marker-circle, .map-shape:focus-visible .elev-shaft, .map-shape:focus-visible .polygon-outline { stroke: var(--status-action); stroke-width: 3; }
.map-label { font-size: 15px; font-weight: 600; fill: #1b1b1d; pointer-events: none; text-anchor: middle; }
.map-badge { pointer-events: none; }
.map-badge .badge-count { font-size: 12px; font-weight: 700; fill: #fff; text-anchor: middle; }
.map-badge .badge-glyph { display: none; fill: #fff; }
.badge-tickets .badge-circle { fill: var(--status-critical); stroke: #fff; stroke-width: 1.5; }
.badge-maint .badge-circle { fill: var(--due-soon); stroke: #fff; stroke-width: 1.5; }
.badge-maint.due-today .badge-circle { fill: var(--due-today); }
.badge-maint.overdue .badge-circle { fill: var(--due-overdue); }
.badge-clear .badge-circle { fill: var(--status-resolved); stroke: #fff; stroke-width: 1.5; }
/* AA contrast (Phase D): white digits read at only 3.2–3.8:1 on amber, orange and green, so those badges
   carry near-black digits; red keeps white (near-black on red is 3.6:1). */
.badge-maint .badge-count, .badge-clear .badge-count { fill: #1b1b1d; }
.badge-maint.overdue .badge-count { fill: #fff; }

.map-legend {
    position: absolute; top: 12px; left: 12px; z-index: 4;
    background: rgba(255, 255, 255, 0.94); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 10px 14px; font-size: 12px; display: grid; gap: 6px;
}
.map-legend .legend-item { display: flex; align-items: center; gap: 8px; color: var(--on-surface); font-size: 12px; }
.map-legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.map-legend .dot.st-clear { background: var(--map-st-clear-line); }
.map-legend .dot.st-maint { background: var(--due-soon); }
.map-legend .dot.st-due-today { background: var(--due-today); }
.map-legend .dot.st-overdue { background: var(--due-overdue); }
.map-legend .dot.st-issues { background: var(--map-st-issues-line); }
.map-legend .dot.st-multiple { background: var(--map-st-multiple-line); }
.map-legend .dot.dashed { outline: 2px dashed var(--due-overdue); outline-offset: 1px; background: var(--due-overdue-bg); }
.map-legend .legend-kind svg.glyph { width: 20px; height: 20px; padding: 3px; border-radius: 5px; background: var(--map-tile-grey); color: var(--map-glyph-grey); flex: none; box-sizing: border-box; }
.map-legend .legend-list { display: grid; gap: 6px; }
.map-legend .legend-first-kind { border-top: 1px solid var(--border-subtle); padding-top: 8px; margin-top: 2px; }
/* Collapsible (Phase D): the header is a button; collapsed, only the "Legend" chip shows. */
.map-legend .legend-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 0; border: 0; background: none; font: inherit; font-size: 12px; font-weight: 700; color: var(--on-surface); cursor: pointer; }
.map-legend .legend-toggle:focus-visible { outline: 2px solid var(--status-action); outline-offset: 2px; border-radius: 4px; }
.map-legend .legend-chevron { transition: transform 0.15s; }
.map-legend.collapsed { padding: 6px 12px; }
.map-legend.collapsed .legend-list { display: none; }
.map-legend.collapsed .legend-chevron { transform: rotate(-90deg); }
/* First paint, before the canvas script runs: narrow screens start collapsed, as the script would. */
@media (max-width: 1024px) {
    .map-legend.legend-auto { padding: 6px 12px; }
    .map-legend.legend-auto .legend-list { display: none; }
    .map-legend.legend-auto .legend-chevron { transform: rotate(-90deg); }
}

.map-zoom { position: absolute; bottom: 12px; z-index: 4; display: grid; gap: 6px; }
.map-zoom button {
    width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid var(--border-subtle);
    background: var(--surface-white); cursor: pointer; font-size: 16px; font-weight: 700; color: var(--on-surface);
}
.map-zoom button:hover { background: var(--surface-muted); }

.map-side {
    position: absolute; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92%; z-index: 6;
    background: var(--surface-white); border-left: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-float); overflow-y: auto; padding: 20px;
}
.map-side .close {
    position: absolute; top: 14px; right: 14px; border: none; background: none; cursor: pointer;
    font-size: 18px; color: var(--on-surface-variant); padding: 4px;
}
.map-side .loc-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; padding-right: 24px; }
.map-side .loc-path { font-size: 12px; color: var(--on-surface-variant); margin-top: 2px; }
.map-side .mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.map-side .mini-stat { background: var(--surface-muted); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 10px 12px; }
.map-side .mini-stat .v { font-size: 20px; font-weight: 700; }
.map-side .mini-stat .l { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--on-surface-variant); }
.map-side .mini-stat.alert .v { color: var(--status-critical); }
.map-side .mini-stat.warn .v { color: var(--status-ongoing); }
.map-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 12px; }
.map-tabs button {
    border: none; background: none; padding: 8px 12px; font-size: 13px; font-weight: 600;
    color: var(--on-surface-variant); cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit;
}
.map-tabs button.active { color: var(--status-action); border-bottom-color: var(--status-action); }
.map-side .list-row { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.map-side .list-row:last-child { border-bottom: none; }
.map-side .list-row .t { font-weight: 600; font-size: 14px; }
.map-side .list-row .s { font-size: 12px; color: var(--on-surface-variant); margin-top: 2px; }

.map-tree {
    position: absolute; top: 0; left: 0; bottom: 0; width: 330px; z-index: 7;
    background: var(--surface-white); border-right: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-float); overflow-y: auto; padding: 14px;
}
.map-tree .node { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.map-tree .node:hover { background: var(--surface-muted); }
.map-tree .node.selected { background: var(--status-action-bg); font-weight: 600; }
.map-tree .node .tw { width: 16px; text-align: center; color: var(--on-surface-variant); flex-shrink: 0; }
.map-tree .node .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-tree .node .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.map-tree .node .cnt { font-family: var(--font-mono); font-size: 11px; color: var(--on-surface-variant); }

.map-list { position: absolute; inset: 0; overflow-y: auto; background: var(--surface-white); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 18px; }
.map-list .filters { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; }
.map-list .filters label { display: flex; align-items: center; gap: 6px; color: var(--on-surface-variant); }
.map-list .field-select { width: auto; }
.map-list .name-cell { font-weight: 600; }
.map-list .lvl { font-size: 11px; color: var(--on-surface-variant); font-weight: 500; }

/* ---- Map builder ---- */
.builder-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.builder-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.builder-toolbar .tool {
    padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border-subtle);
    background: var(--surface-white); cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
}
.builder-toolbar .tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.builder-canvas-wrap { position: relative; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-white); }
.builder-canvas-wrap svg { width: 100%; display: block; touch-action: none; user-select: none; }
.builder-canvas-wrap svg.tool-draw { cursor: crosshair; }
.builder-canvas-wrap svg.tool-select { cursor: default; }
.builder-handle { fill: var(--surface-white); stroke: var(--status-action); stroke-width: 2; cursor: nwse-resize; }
.builder-note { position: absolute; top: 10px; left: 12px; max-width: 60%; font-size: 12px; color: var(--on-surface); background: rgba(255,255,255,.92); border: 1px solid var(--border-subtle); padding: 6px 10px; border-radius: var(--radius); }
.builder-hint { position: absolute; bottom: 10px; left: 12px; font-size: 12px; color: var(--on-surface-variant); background: rgba(255,255,255,.9); padding: 4px 10px; border-radius: var(--radius); }
.builder-element-row { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border-subtle); border-radius: var(--radius); margin-bottom: 8px; font-size: 13px; }
.builder-element-row.selected { border-color: var(--status-action); background: var(--status-action-bg); }
.builder-element-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.builder-element-row .icon { width: 20px; text-align: center; }
.builder-element-row button { border: none; background: none; cursor: pointer; color: var(--on-surface-variant); padding: 2px 4px; }
.builder-element-row button:hover { color: var(--on-surface); }
.builder-unbound { color: var(--status-critical); font-weight: 600; }

/* ---- Map environment (generated site / grounds / elevation / plan; Phase A) ---- */
.map-env { pointer-events: none; }
.env-grass { fill: var(--map-grass-1); }
.env-grass-texture { fill: var(--map-grass-1); }
.lawn-stop.light { stop-color: var(--map-grass-2); stop-opacity: 0.7; }
.lawn-stop.dark { stop-color: var(--map-grass-3); stop-opacity: 0.55; }
.lawn-stop.mid { stop-opacity: 0.35; }
.lawn-stop.fade { stop-opacity: 0; }
.env-perimeter { fill: none; stroke: var(--map-asphalt); stroke-width: 3; opacity: 0.35; }
.env-road-edge { stroke: var(--map-sidewalk); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.env-road { stroke: var(--map-asphalt); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.env-road-curb { stroke: var(--map-curb); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.env-parking .parking-kerb { fill: var(--map-sidewalk); stroke: var(--map-curb); stroke-width: 1; }
.env-parking .parking-pad { fill: var(--map-asphalt); }
.env-parking .parking-bay-lines { stroke: #F8FAFC; stroke-width: 1.1; fill: none; opacity: 0.9; }
.env-car-body { fill: currentColor; stroke: rgba(15, 23, 42, 0.45); stroke-width: 0.6; }
.env-car-glass { fill: #AFC2D0; opacity: 0.9; }
.env-car-light { fill: #FFF7D6; }
.env-car.car-c0 { color: #5B8DEF; }
.env-car.car-c1 { color: #E5484D; }
.env-car.car-c2 { color: #E4E7EB; }
.env-car.car-c3 { color: #1F2937; }
.env-car.car-c4 { color: #C9A227; }
.env-car.car-c5 { color: #9CA3AF; }
.env-path { fill: var(--map-path); stroke: var(--map-path); stroke-width: 6; stroke-linecap: round; }
.env-tree { color: var(--map-tree); }
.env-tree.t1 { color: var(--map-tree-2); }
.env-tree.t2 { color: var(--map-tree-3); }
.env-tree.t3 { color: var(--map-tree-4); }
.env-tree-shadow { fill: #000; opacity: 0.3; }
.env-tree-trunk { fill: #6B4A2B; }
.env-tree-canopy { fill: currentColor; stroke: rgba(20, 32, 12, 0.35); stroke-width: 0.8; }
.env-tree-canopy-light { fill: #FFFFFF; opacity: 0.17; }
.env-pave { fill: var(--map-path); stroke: #BDB6A2; stroke-width: 2; }
.env-pave-line { stroke: #C6BFAB; stroke-width: 1; opacity: 0.6; }
.env-floor { fill: #F4F2EC; }
.env-tile-line { stroke: #E6E3DA; stroke-width: 1; }
.env-sky { fill: #EEF3F8; }
.map-compass .compass-dial { fill: #FFFFFF; fill-opacity: 0.92; stroke: #C6C1B4; stroke-width: 1.5; }
.map-compass .compass-needle { fill: var(--status-critical); }
.map-compass .compass-n { font-size: 12px; font-weight: 700; fill: #1B1B1D; text-anchor: middle; }

/* Status fills: every sprite's status-bearing surface shares these (the roof, a room's floor, a band, the plain rect). */
.map-shape .status-fill { fill: var(--map-st-clear); stroke: var(--map-st-clear-line); stroke-width: 2; }
.map-shape.st-maint .status-fill { fill: var(--map-st-maint); stroke: var(--due-soon); }
.map-shape.st-due-today .status-fill { fill: rgba(234, 88, 12, 0.6); stroke: var(--due-today); }
.map-shape.st-overdue .status-fill { fill: rgba(220, 38, 38, 0.45); stroke: var(--due-overdue); stroke-dasharray: 6 4; }
.map-shape.st-issues .status-fill { fill: var(--map-st-issues); stroke: var(--map-st-issues-line); }
.map-shape.st-emergency .status-fill { fill: rgba(220, 38, 38, 0.7); stroke: var(--status-critical); }
.map-shape.st-multiple .status-fill { fill: var(--map-st-multiple); stroke: var(--map-st-multiple-line); }
.map-shape.unverified .room-floor, .map-shape.unverified .plain-fill, .map-shape.unverified .elev-band { fill: #FFFFFF; stroke: #CBD5E1; stroke-dasharray: none; }

/* ---- Map sprites ---- */
.sprite-shadow { fill: var(--map-shadow); }
.sprite-facade { fill: var(--map-facade); stroke: #B8B2A6; stroke-width: 1; }
.sprite-facade-shade { fill: var(--map-facade-shade); }
.sprite-window-glass { fill: var(--map-window); }
.sprite-window-bar { stroke: #FFFFFF; stroke-width: 0.8; opacity: 0.8; }
.sprite-roof { fill: var(--map-roof-dark); }
.sprite-roof-plane.front { fill: var(--map-roof); }
.sprite-roof-plane.hip-left { fill: var(--map-roof-light); }
.sprite-roof-plane.hip-right { fill: var(--map-roof-shade); }
.sprite-roof-ridge { fill: none; stroke: #FFFFFF; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }
.sprite-tint { fill-opacity: 0.9; }
.sprite-balcony { fill: #F4F2EC; }
.sprite-eave { fill: rgba(15, 23, 42, 0.28); }
.sprite-floor-line { fill: #B8B2A6; }
.sprite-plant { fill: #B9B5AC; stroke: #8F8A80; stroke-width: 1; }
.sprite-roof-glyph .roof-glyph { fill: #FFFFFF; opacity: 0.95; }
.sprite-pitch.back, .sprite-gable-roof.right { fill: var(--map-slate); }
.sprite-pitch.front, .sprite-gable-roof.left { fill: var(--map-slate-light); }
.sprite-gable { fill: var(--map-facade); stroke: #B8B2A6; stroke-width: 1; }
.sprite-hedge { fill: var(--map-tree-4); stroke: rgba(20, 32, 12, 0.35); stroke-width: 0.8; }
.sprite-path { fill: var(--map-path); }
.sprite-door { fill: #7A5A3A; }
.map-shape.selected { filter: drop-shadow(0 0 5px rgba(37, 99, 235, 0.7)); }
.map-shape.selected .status-fill, .map-shape.selected .marker-circle, .map-shape.selected .elev-shaft { stroke: var(--status-action); stroke-width: 3; stroke-dasharray: none; }
.map-shape.selected .polygon-outline { stroke: var(--status-action); stroke-width: 3; }
.polygon-outline { fill: none; stroke: rgba(15, 23, 42, 0.45); stroke-width: 1.5; stroke-linejoin: round; }
.map-pill { pointer-events: none; }
.map-pill-bg { fill: var(--map-pill); }
.map-pill-text { font-size: 13px; font-weight: 600; fill: #FFFFFF; text-anchor: middle; }
.map-pill.small .map-pill-text { font-size: 11px; }
.map-marker .marker-shadow { fill: rgba(15, 23, 42, 0.25); }
.map-marker .marker-circle { fill: #FFFFFF; stroke: var(--border-subtle); stroke-width: 1.5; }
.map-marker .marker-glyph { fill: var(--map-primary); }

.pool-deck { fill: var(--map-pool-deck); stroke: #B5AE9B; stroke-width: 1.5; }
.pool-water { fill: var(--map-pool-water); stroke: #5FAED6; stroke-width: 2; }
.pool-wave { stroke: #DCF1FB; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.pool-ladder-rail { stroke: #F8FAFC; stroke-width: 2.5; stroke-linecap: round; }
.pool-lounger { fill: #FFFFFF; stroke: #B5AE9B; stroke-width: 0.6; }
.pool-umbrella { fill: #F6E7B8; stroke: #D2B867; stroke-width: 1.5; }
.pg-sand { fill: var(--map-sand); stroke: #C4B48C; stroke-width: 1.5; }
.pg-sandbox { fill: #E8D6A6; stroke: #C4B48C; stroke-width: 1.5; }
.pg-slide { fill: #EF4444; stroke: #B91C1C; stroke-width: 1.5; }
.pg-swing-bar { stroke: #64748B; stroke-width: 2.5; stroke-linecap: round; }
.gate-hut { fill: var(--map-roof); stroke: #B8B2A6; stroke-width: 1.5; }
.gate-window { fill: var(--map-window); }
.gate-post { fill: #475569; }
.gate-barrier { fill: #F8FAFC; stroke: #CBD5E1; stroke-width: 1; }
.gate-barrier-stripe { fill: var(--status-critical); }
.parking-lot { fill: var(--map-asphalt); stroke: #6B6E70; stroke-width: 2; }
.parking-bay { stroke: #F8FAFC; stroke-width: 1.4; fill: none; opacity: 0.9; }
.garden-bed { fill: var(--map-grass-2); stroke: var(--map-grass-3); stroke-width: 1.5; }
.garden-path { fill: var(--map-path); }
.garden-tree { fill: var(--map-tree); stroke: var(--map-tree-dark); stroke-width: 1.5; }
.court-surface { fill: var(--map-court); stroke: #A8563A; stroke-width: 1.5; }
.court-line { fill: none; stroke: #FFFFFF; stroke-width: 2; }
.utility-box { fill: #9CA3AF; stroke: #6B7280; stroke-width: 1.5; }
.utility-vent { stroke: #6B7280; stroke-width: 1.5; }
.binstore-box { fill: #4B5563; stroke: #374151; stroke-width: 1.5; }
.bin { fill: #1F7A4D; stroke: #0F5132; stroke-width: 1; }
.lobby-floor { fill: #F1EDE3; stroke: #C9BEA6; stroke-width: 1.5; }
.lobby-desk { fill: #8B5E3C; }
.road-strip { fill: var(--map-asphalt); stroke: #6B6E70; stroke-width: 1; }
.map-sprite-corridor .road-strip { fill: var(--map-corridor); stroke: var(--map-wall); }
.road-sidewalk { fill: var(--map-sidewalk); }
.map-sprite-corridor .road-sidewalk { display: none; }

/* ---- Floor plan and unit plan ---- */
.map-env-floor .env-floor, .map-env-unit .env-floor { fill: var(--map-plan-sheet); }
.plan-envelope { fill: var(--map-plan-service); }
.plan-envelope-wall { fill: none; stroke: var(--map-wall); stroke-width: 7; stroke-linejoin: miter; }
.plan-corridor, .plan-hall { fill: var(--map-corridor); }
.plan-corridor-edge { stroke: var(--map-wall); stroke-width: 3; }
.plan-hatch-line { stroke: #6B7280; stroke-width: 1; }
.plan-stairs-frame { fill: none; stroke: var(--map-wall); stroke-width: 2.5; }
.plan-lift, .plan-lift-core { fill: #FFFFFF; stroke: var(--map-wall); stroke-width: 3; }
.plan-lift-x { stroke: var(--map-wall); stroke-width: 2; }
.map-room .room-wall { fill: none; stroke: var(--map-wall); stroke-width: 7; stroke-linejoin: miter; }
.plan-envelope.unit { fill: var(--map-corridor); }
.map-room .room-wall-inner { fill: none; stroke: #FFFFFF; stroke-width: 1.5; opacity: 0.7; }
.map-room .room-floor { stroke-width: 0; }
/* Plan rooms: the status tints at half strength over white, opaque so a room needs no white base. */
.map-shape .map-room .room-floor { fill: var(--map-room-clear); }
.map-shape.st-maint .map-room .room-floor { fill: var(--map-room-maint); }
.map-shape.st-due-today .map-room .room-floor { fill: var(--map-room-due-today); }
.map-shape.st-overdue .map-room .room-floor { fill: var(--map-room-overdue); }
.map-shape.st-issues .map-room .room-floor { fill: var(--map-room-issues); }
.map-shape.st-emergency .map-room .room-floor { fill: var(--map-room-emergency); }
.map-shape.st-multiple .map-room .room-floor { fill: var(--map-room-multiple); }
.map-shape.unverified .map-room .room-floor { fill: var(--map-room-neutral); }
.map-room .room-window { fill: #F8FAFC; stroke: var(--map-wall); stroke-width: 1; }
.map-room .room-window-pane { stroke: #93A3B5; stroke-width: 1; }
.map-room .room-code { font-size: 15px; font-weight: 600; fill: #1F2937; text-anchor: middle; pointer-events: none; }
.map-room .room-code.tight { font-size: 10px; }
.map-room .room-door-gap { stroke: #FFFFFF; stroke-width: 9; }
.map-room .room-door { fill: none; stroke: #6B7280; stroke-width: 1.5; }
.map-room .room-ticket-glyph { fill: var(--status-critical); }

/* ---- Building elevation ---- */
.elev-facade { fill: var(--map-facade); stroke: #B8B2A6; stroke-width: 1; }
.elev-facade-shade { fill: var(--map-facade-shade); }
.elev-parapet { fill: var(--map-roof-dark); }
.elev-underground { fill: #DED9CF; }
.elev-band { stroke-width: 1.5; fill-opacity: 0.55; }
.elev-band.roof { fill: var(--map-roof-dark); }
.elev-separator { stroke: #B8B2A6; stroke-width: 1; }
.elev-label { font-size: 13px; font-weight: 600; fill: #1F2937; text-anchor: end; }
.elev-ground { stroke: var(--map-asphalt); stroke-width: 4; stroke-linecap: round; }
.elev-lift { fill: var(--map-window); stroke: var(--map-wall); stroke-width: 1.5; opacity: 0.85; }
.elev-stairs { stroke: var(--map-wall); stroke-width: 1; }
.elev-shaft { fill: transparent; }
.elev-shaft-glyph { fill: #1F2937; }

/* ---- Zoom bands: CSS culls detail so a zoom never re-renders ---- */
.map-svg[data-zoom="far"] .map-pill { display: none; }
.map-svg[data-zoom="far"] .sprite-window { display: none; }
.map-svg[data-zoom="far"] .env-car { display: none; }
.map-svg[data-zoom="far"] .badge-count { display: none; }
.map-svg[data-zoom="far"] .badge-glyph { display: block; }
.map-svg[data-zoom="far"] .room-door { display: none; }
.map-svg[data-zoom="far"] .room-code { display: none; }
.map-svg[data-zoom="far"] .elev-label { display: none; }
.map-svg[data-zoom="mid"] .room-code.tight { display: none; }
.map-svg[data-zoom="near"] .map-pill-text { font-size: 11px; }

/* ---- Map gallery (development aid) ---- */
.gallery-section { margin-bottom: 28px; }
.gallery-reference { max-width: 100%; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
.gallery-canvas { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-white); max-width: 1100px; }
.gallery-canvas .map-svg-host svg { width: 100%; height: auto; display: block; }
.gallery-thumbs { display: flex; gap: 16px; flex-wrap: wrap; }
.gallery-thumb { width: 160px; border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; background: var(--surface-white); }
.gallery-thumb .map-svg-host svg { width: 100%; height: auto; display: block; }
.gallery-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.gallery-sprite { margin: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; background: var(--surface-white); }
.gallery-sprite .map-svg-host svg { width: 100%; height: auto; display: block; }
.gallery-sprite figcaption { padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--on-surface-variant); border-top: 1px solid var(--border-subtle); }

/* The builder draws its editable outlines over the published look; the preview itself is inert. */
.builder-canvas-wrap .builder-preview { pointer-events: none; }

@media (max-width: 1200px) {
    .map-stats { grid-template-columns: repeat(3, 1fr); }
    .builder-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { display: none; }
    .content { padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .map-stats { grid-template-columns: repeat(2, 1fr); }
    .map-stage { min-height: 240px; }
    /* The inspector becomes a bottom sheet; the strip stacks (map revamp Phase B). */
    .map-inspector { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 70vh; border-left: none; border-top: 1px solid var(--border-subtle); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.18); z-index: 40; }
    .map-inspector::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 2px; background: var(--outline-variant, #c6c6cd); margin: 8px auto 0; }
    .map-stage.with-inspector .map-canvas-area { right: 0; }
    .map-strip.three, .map-strip.two { grid-template-columns: 1fr; }
    .map-strip-panel { min-height: 0; }
}

/* ---- SearchSelect ---- */
.search-select { position: relative; width: 100%; }
.search-select.disabled { opacity: 0.6; }
.search-select-control { position: relative; }
.search-select-control .field-input { padding-right: 28px; }
.search-select-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--on-surface-variant); font-size: 16px; cursor: pointer; line-height: 1;
}
.search-select-list {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px);
    max-height: 280px; overflow-y: auto; background: var(--surface-white);
    border: 1px solid var(--border-subtle); border-radius: var(--radius); box-shadow: var(--shadow-float);
}
.search-select-option { display: flex; gap: 8px; align-items: baseline; padding: 7px 10px; font-size: 13px; cursor: pointer; min-height: 34px; box-sizing: border-box; }
.search-select-option:hover, .search-select-option.active { background: var(--status-action-bg); }
.search-select-option.selected .search-select-text { font-weight: 600; }
.search-select-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-select-detail { font-size: 11px; color: var(--on-surface-variant); white-space: nowrap; }
.search-select-empty { padding: 8px 10px; font-size: 13px; color: var(--on-surface-variant); }

/* ---- LocationCascadeFilter ---- */
.cascade-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---- CollapsibleTree ---- */
.ctree-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.ctree-row { display: flex; align-items: flex-start; gap: 4px; }
.ctree-toggle {
    width: 22px; height: 24px; margin-top: 4px; flex-shrink: 0; border: 0; background: transparent; cursor: pointer;
    color: var(--on-surface); font-family: inherit; font-size: 16px; line-height: 1; padding: 0; border-radius: var(--radius);
}
.ctree-toggle:hover { background: var(--surface-muted); }
.ctree-toggle-spacer { width: 22px; flex-shrink: 0; }
.ctree-content { flex: 1; min-width: 0; }

/* ---- Locations page ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: var(--radius) var(--radius) 0 0; color: var(--on-surface-variant); font-weight: 600; font-size: 14px; }
.tab.active { color: var(--primary); border-bottom: 2px solid var(--status-action); }
.tab .badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 9px; background: var(--status-action-bg); color: var(--status-action); font-size: 11px; text-align: center; }
.locations-summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.locations-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .locations-layout { grid-template-columns: 1fr; } }
.location-row { padding: 6px 0; border-bottom: 1px solid var(--border-subtle); }
.location-row.focused { background: var(--status-action-bg); outline: 2px solid var(--status-action); outline-offset: -2px; border-radius: var(--radius); padding-left: 6px; }
.queue-location-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 10px; }
.queue-location-chip button { border: none; background: none; cursor: pointer; color: inherit; font-size: 13px; padding: 0; }
.setup-checklist { margin-bottom: 16px; }
.setup-checklist ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.setup-checklist li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.setup-checklist li .tick { width: 16px; color: var(--on-surface-variant); }
.setup-checklist li.done .tick { color: var(--status-resolved); }
.setup-checklist li.done a { color: var(--on-surface-variant); text-decoration: line-through; }
.setup-checklist li .muted { font-size: 12px; }
.import-sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.import-source { display: grid; gap: 4px; cursor: pointer; }
.import-source.active { outline: 2px solid var(--status-action); }
.import-source .muted { font-size: 12px; }

/* ---- Clients grouped list ---- */
.client-group { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.client-block { margin: 4px 0 10px; }
.client-block td, .client-block th { padding: 8px 10px; }

/* ---- Equipment: types, photos, notes, by-location view (Phase 4) ---- */
.type-chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--border-subtle); border-radius: 999px; font-size: 12px; white-space: nowrap; color: var(--on-surface); }
.type-swatch { width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; }
.type-swatch.selected { border-color: var(--on-surface); }
.asset-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border-subtle); flex: none; }
.asset-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.asset-photo { margin: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; background: var(--surface-white); }
.asset-photo img { display: block; width: 100%; height: 120px; object-fit: cover; }
.asset-photo figcaption { padding: 6px 8px; font-size: 12px; }
.asset-note { padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.asset-note-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--on-surface-variant); margin-bottom: 4px; }
.asset-group { display: flex; gap: 8px; align-items: center; padding: 6px 0; }

/* ---- Schedules and work items (Phase 5) ---- */
tr.stopped td { color: var(--outline); background: var(--surface-muted); }
tr.stopped .title { text-decoration: none; }
.kind-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid var(--border-subtle); color: var(--on-surface-variant); }
.kind-chip.inspection { border-color: var(--status-action); color: var(--status-action); }
.work-history { list-style: none; margin: 0; padding: 0; }
.work-history li { padding: 6px 0; border-top: 1px solid var(--border-subtle); font-size: 13px; }
.work-history .meta { color: var(--on-surface-variant); font-size: 12px; }

/* Map revamp Phase C: auto-placed shapes in the builder draw dashed; a person's shapes draw solid. */
.builder-auto rect, .builder-auto polygon, .builder-auto circle { stroke-dasharray: 6 4; }
.builder-placement { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--on-surface-variant); border: 1px dashed var(--border-subtle); border-radius: 999px; padding: 1px 6px; }
.builder-relayout { margin-right: 8px; }
.map-inspector-kind-select { max-width: 100%; width: 100%; font: inherit; font-size: 12px; color: var(--on-surface-variant); border: 1px solid var(--border-subtle); border-radius: var(--radius); background: var(--surface); padding: 2px 6px; }
