/* Assignment Manager — shared stylesheet for the PWA and the native app (no external fonts/CDNs: works offline).
   Mobile-first (360px →), 44px touch targets, WCAG AA contrast, light + dark (prefers-color-scheme). */

:root {
    color-scheme: light dark;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --text: #1a1d23;
    --muted: #4f5866;
    --border: #cfd5de;
    --primary: #1d4ed8;
    --primary-text: #ffffff;
    --primary-soft: #dbe6ff;
    --danger: #b42318;
    --danger-soft: #fde8e7;
    --warning: #8a5300;
    --warning-soft: #fff2d6;
    --success: #146c2e;
    --success-soft: #dcf5e3;
    --info: #155e9c;
    --info-soft: #dff0ff;
    --focus: #f59e0b;
    --cov-covered: #16a34a;
    --cov-partial: #d97706;
    --cov-uncovered: #dc2626;
    --mine: #7c3aed;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.06);
    --touch: 44px;
    --nav-width: 260px;
    --topbar: 56px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-2: #20262e;
        --text: #e8ebef;
        --muted: #a9b2be;
        --border: #343c47;
        --primary: #7aa2ff;
        --primary-text: #0b1020;
        --primary-soft: #1d2b4d;
        --danger: #ff8a80;
        --danger-soft: #3b1715;
        --warning: #ffc266;
        --warning-soft: #3a2a0d;
        --success: #6fdc8c;
        --success-soft: #11301b;
        --info: #8cc8ff;
        --info-soft: #102a40;
        --shadow: 0 1px 2px rgba(0,0,0,.4);
    }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h1:focus { outline: none; }
p { margin: .25rem 0 .75rem; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--surface-2); padding: 0 .35em; border-radius: 4px; }
.pre-line { white-space: pre-line; }
.spacer { flex: 1; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--surface); padding: .75rem 1rem; }
.skip-link:focus { left: .5rem; top: .5rem; }
.boot { display: grid; place-items: center; min-height: 60vh; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar);
    display: flex; align-items: center; gap: .5rem; padding: 0 .5rem;
    padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.event-chip {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem;
    padding: .3rem .6rem; border-radius: 999px; background: var(--primary-soft); color: var(--text); text-decoration: none;
}
.topbar-end { margin-left: auto; }
.sidenav {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(85vw, var(--nav-width));
    transform: translateX(-100%); transition: transform .2s ease;
    overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
    padding: calc(1rem + env(safe-area-inset-top)) .5rem 2rem;
}
.menu-open .sidenav { transform: none; }
.scrim { display: none; }
.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.4); }
.content { padding: 1rem; padding-bottom: calc(2rem + env(safe-area-inset-bottom)); max-width: 1200px; }
.content:focus { outline: none; }
@media (min-width: 960px) {
    .menu-toggle { display: none; }
    .sidenav { transform: none; top: calc(var(--topbar) + env(safe-area-inset-top)); padding-top: 1rem; }
    .content { margin-left: var(--nav-width); padding: 1.5rem 2rem; }
    .menu-open .scrim { display: none; }
}
.nav-group { margin-bottom: 1rem; }
.nav-group-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .5rem .75rem; }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-link {
    display: flex; align-items: center; gap: .6rem; min-height: var(--touch); padding: .5rem .75rem; border-radius: 8px;
    color: var(--text); text-decoration: none; width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--primary-soft); font-weight: 600; }
.nav-icon { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.nav-link.active .nav-icon { background: var(--primary); }
.nav-signout { margin-top: 1rem; color: var(--danger); }

.public-shell { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { display: flex; justify-content: space-between; align-items: center; padding: calc(.5rem + env(safe-area-inset-top)) 1rem .5rem; }
.public-content { flex: 1; padding: 1rem; display: flex; justify-content: center; align-items: flex-start; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }

/* ---------- page structure ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; justify-content: space-between; margin-bottom: 1rem; }
.page-header h1 { margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.greeting { font-size: 1.05rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel-attention { border-color: var(--warning); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; margin-bottom: .75rem; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.cached-notice { background: var(--warning-soft); color: var(--warning); padding: .5rem .75rem; border-radius: 8px; font-size: .875rem; }
.details-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }

/* ---------- cards & lists ---------- */
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
@media (min-width: 720px) { .card-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; margin-bottom: .75rem; }
.card-list .card { margin-bottom: 0; }
.card-selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.card-body { padding: .9rem 1rem; flex: 1; }
.card-title { font-size: 1.05rem; margin: 0 0 .25rem; }
.card-kicker { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 .25rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--border); align-items: center; }
.announcement-card.urgent { border-left: 5px solid var(--danger); }
.invitation-card { border-left: 5px solid var(--warning); }
.instructions { background: var(--surface-2); padding: .5rem .75rem; border-radius: 8px; }
.countdown { font-weight: 600; }
.countdown.urgent { color: var(--danger); }
.status-line { font-weight: 600; color: var(--success); }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; gap: .75rem; justify-content: space-between; align-items: flex-start; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.unread { font-weight: 500; }
.list-item.unread::before { content: ""; width: 8px; height: 8px; margin-top: .45rem; border-radius: 50%; background: var(--primary); flex: none; }
.list-item > div { flex: 1; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { display: flex; flex-direction: column; gap: .15rem; padding: .75rem; min-height: 76px; border-radius: 8px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .85rem; }
.tile-num { font-size: 1.5rem; font-weight: 700; }
.tile-warn { background: var(--warning-soft); }
.tile-danger { background: var(--danger-soft); }
.tree, .tree ul { list-style: none; margin: 0; padding-left: 1rem; }
.tree > li { padding-left: 0; }
.tree li { padding: .25rem 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .9rem; }
.field-inline { margin-bottom: 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
    font: inherit; font-size: 16px; /* prevents iOS zoom on focus */
    min-height: var(--touch); padding: .5rem .65rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); width: 100%; max-width: 100%;
}
textarea { min-height: 88px; resize: vertical; }
input[readonly] { background: var(--surface-2); }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--touch); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.choice { padding: 0 .75rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: .4rem; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.urgent-responses { border: 0; padding: 0; margin: .5rem 0; }
.urgent-responses legend { font-weight: 600; margin-bottom: .4rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field-errors { color: var(--danger); margin: .25rem 0 .75rem; padding-left: 1.2rem; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: var(--touch); min-width: var(--touch); padding: .5rem 1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger { color: #1a0b0a; } }
.btn-small { min-height: var(--touch); padding: .35rem .75rem; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-icon { min-width: var(--touch); min-height: var(--touch); border-radius: 8px; border: 0; background: transparent; color: var(--text); font-size: 1.25rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--surface-2); }
.btn.btn-icon { border: 1px solid var(--border); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.segmented { display: inline-flex; flex-wrap: nowrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented-wrap { flex-wrap: wrap; }
.seg { min-height: var(--touch); padding: .4rem .8rem; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.seg:last-child { border-right: 0; }
.seg.active { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.lang-switch .seg { padding: .3rem .6rem; min-width: var(--touch); }
.day-session-picker { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }

/* ---------- badges / alerts / toasts ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text); vertical-align: middle; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.alert { padding: .75rem 1rem; border-radius: 8px; margin: .5rem 0 1rem; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom)); width: min(92vw, 480px); display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .5rem; justify-content: space-between; padding: .5rem .5rem .5rem 1rem; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.toast .btn-icon { color: inherit; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); }
.toast-success { background: var(--success); color: #fff; }
@media (prefers-color-scheme: dark) { .toast-error, .toast-success { color: #0f1216; } }
.sync-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem .75rem; margin-bottom: 1rem; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: .9rem; }
.sync-banner.offline { background: var(--warning-soft); color: var(--warning); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.sync-failed { color: var(--danger); font-weight: 600; }
.loading { display: flex; align-items: center; gap: .6rem; padding: 1rem 0; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .sidenav { transition: none; } }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); }
table.data th, table.data td { padding: .55rem .65rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
table.data tr.row-error td { background: var(--danger-soft); }
table.data tr.row-warning td { background: var(--warning-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); }
.modal {
    position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(94vw, 560px); max-height: 90vh; max-height: 90dvh; overflow: auto;
    background: var(--surface); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem 1rem; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-footer { border-top: 1px solid var(--border); justify-content: flex-end; flex-wrap: wrap; }
.modal-body { padding: 1rem; }

/* ---------- availability ---------- */
.availability-grid { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .availability-grid { grid-template-columns: 1fr 1fr; } }
.availability-cell { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.availability-head { margin-bottom: .5rem; }

/* ---------- interactive map ---------- */
.map-layout { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .map-layout.with-panel { grid-template-columns: 1fr 340px; } }
.map-main { min-width: 0; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.map-zoom, .map-page { font-size: .875rem; min-width: 5.5em; text-align: center; font-variant-numeric: tabular-nums; }
.map-viewport {
    position: relative; overflow: hidden; width: 100%; height: 65vh; height: 65dvh; min-height: 320px;
    border: 1px solid var(--border); border-radius: var(--radius); background: #8a9099;
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab;
}
.map-viewport:active { cursor: grabbing; }
.map-viewport.editing { cursor: crosshair; }
/* will-change only while moving (class set by mapViewer.js): a permanent will-change makes WebKit stretch an old
   bitmap of the stage when zoomed, which blurred the labels and the PDF. */
.map-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.3); --inv-zoom: 1; --label-scale: 1; }
.map-stage.moving { will-change: transform; }
.map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-overlay { position: absolute; inset: 0; }
.hotspot {
    position: absolute; padding: 0; margin: 0; border: calc(2px * var(--inv-zoom)) solid #1d4ed8;
    background: rgba(29, 78, 216, .18); cursor: pointer; border-radius: calc(3px * var(--inv-zoom));
}
/* Invisible enlarged hit area: at least 44 CSS px regardless of zoom (matches PdfCoordinateMapper.HitTest). */
.hotspot::before {
    content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: max(100%, calc(44px * var(--inv-zoom))); height: max(100%, calc(44px * var(--inv-zoom)));
}
.hotspot.shape-circle { border-radius: 50%; }
.hotspot:focus-visible { outline: calc(3px * var(--inv-zoom)) solid var(--focus); outline-offset: calc(2px * var(--inv-zoom)); }
.hotspot.cov-covered { border-color: var(--cov-covered); background: rgba(22, 163, 74, .22); }
.hotspot.cov-partial { border-color: var(--cov-partial); background: rgba(217, 119, 6, .28); }
.hotspot.cov-uncovered { border-color: var(--cov-uncovered); background: rgba(220, 38, 38, .3); }
.hotspot.cov-notrequired { border-color: #6b7280; background: rgba(107, 114, 128, .15); }
.hotspot.sev-critical { animation: pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .hotspot.sev-critical { animation: none; border-style: double; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 calc(6px * var(--inv-zoom)) rgba(220, 38, 38, .35); } }
.hotspot.mine { border-color: var(--mine); background: rgba(124, 58, 237, .28); border-width: calc(3px * var(--inv-zoom)); }
.hotspot.selected { outline: calc(3px * var(--inv-zoom)) dashed var(--focus); outline-offset: calc(2px * var(--inv-zoom)); }
.hs-pin, .hs-alert {
    position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 0) scale(var(--inv-zoom)); transform-origin: 50% 100%;
    font-size: 18px; line-height: 1; color: var(--mine); text-shadow: 0 0 2px #fff; pointer-events: none;
}
.hs-alert { left: 100%; bottom: auto; top: 0; color: #fff; background: var(--cov-uncovered); border-radius: 50%; width: 18px; height: 18px; font-size: 13px; font-weight: 700; display: grid; place-items: center; transform: translate(-50%, -50%) scale(var(--inv-zoom)); }
.hs-handle {
    position: absolute; right: 0; bottom: 0; width: calc(22px * var(--inv-zoom)); height: calc(22px * var(--inv-zoom));
    transform: translate(50%, 50%); background: var(--focus); border: calc(2px * var(--inv-zoom)) solid #fff; border-radius: 50%; cursor: nwse-resize;
}
/* Floor-plan position markers (codes like SA-12): category colour, white rim, code + names label kept at a constant
   on-screen size with --inv-zoom. Coverage and "my post" stay visible as the rim colour.
   Label sizes and weight come from Map label settings (--map-code-size, --map-name-size, --map-label-weight on the
   viewport; defaults 18px / 16px / bold) times --label-scale (mapMath.labelScale: 1 from 300% zoom up, smaller on
   the overview so labels do not pile up). */
.map-stage { --cat-sa: #0f766e; --cat-l: #b91c1c; --cat-o: #15803d; --cat-lu: #a21caf; --cat-w: #1d4ed8; --cat-b: #c2410c; }
.hotspot.marker { border-color: #fff; border-width: calc(2px * var(--inv-zoom)); box-shadow: 0 0 0 calc(1px * var(--inv-zoom)) rgba(0,0,0,.45); }
.hotspot.marker.cat-sa { background: var(--cat-sa); }
.hotspot.marker.cat-l { background: var(--cat-l); }
.hotspot.marker.cat-o { background: var(--cat-o); }
.hotspot.marker.cat-lu { background: var(--cat-lu); }
.hotspot.marker.cat-w { background: var(--cat-w); }
.hotspot.marker.cat-b { background: var(--cat-b); }
.hotspot.marker.cov-covered { border-color: var(--cov-covered); }
.hotspot.marker.cov-partial { border-color: var(--cov-partial); }
.hotspot.marker.cov-uncovered { border-color: var(--cov-uncovered); }
.hotspot.marker.mine { border-color: var(--mine); border-width: calc(3px * var(--inv-zoom)); }
.hs-label {
    position: absolute; left: 100%; top: 50%; z-index: 1; pointer-events: none;
    transform: translate(calc(3px * var(--inv-zoom)), -50%) scale(var(--inv-zoom)); transform-origin: 0 50%;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    font-family: system-ui, -apple-system, sans-serif; line-height: 1.15; font-weight: var(--map-label-weight, 700);
    white-space: nowrap; -webkit-font-smoothing: antialiased;
}
.hs-code, .hs-name { padding: 1px 4px; border-radius: 3px; color: #fff; background: rgba(17, 24, 39, .82); }
.hs-code { font-size: calc(var(--map-code-size, 18px) * var(--label-scale, 1)); }
.hs-name { font-size: calc(var(--map-name-size, 16px) * var(--label-scale, 1)); }
.hotspot.marker.cat-sa .hs-code { background: var(--cat-sa); }
.hotspot.marker.cat-l .hs-code { background: var(--cat-l); }
.hotspot.marker.cat-o .hs-code { background: var(--cat-o); }
.hotspot.marker.cat-lu .hs-code { background: var(--cat-lu); }
.hotspot.marker.cat-w .hs-code { background: var(--cat-w); }
.hotspot.marker.cat-b .hs-code { background: var(--cat-b); }
.hs-name { display: none; max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.hs-name.unassigned { font-style: italic; background: rgba(75, 85, 99, .85); }
.map-stage.show-names .hs-name, .hotspot.selected .hs-name { display: block; }
.hotspot.selected .hs-label { z-index: 2; }
/* Map label settings panel (toolbar "Aa" button). Local to this device; never sent to the server. */
.map-label-settings { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .75rem; margin: 0 0 .5rem; }
.map-label-settings h2 { font-size: 1rem; margin: 0 0 .5rem; }
.map-label-settings .mls-grid { display: grid; grid-template-columns: 1fr; gap: .25rem 1rem; }
@media (min-width: 720px) { .map-label-settings .mls-grid { grid-template-columns: 1fr 1fr; } }
.map-label-settings .field { margin-bottom: .25rem; }
.map-label-settings .field > span { display: flex; justify-content: space-between; gap: .5rem; }
.map-label-settings output { font-weight: 400; font-variant-numeric: tabular-nums; }
.map-label-settings input[type=range] { width: 100%; min-height: var(--touch); padding: 0; border: 0; background: transparent; }
.map-label-settings .mls-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.map-label-settings .mls-sample { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: .35rem; border-radius: 6px; background: #e8e3c4; line-height: 1.15; font-family: system-ui, -apple-system, sans-serif; font-weight: var(--map-label-weight, 700); max-width: 100%; overflow: hidden; }
.map-label-settings .mls-sample .hs-code { background: var(--cat-sa, #0f766e); font-size: var(--map-code-size, 18px); }
.map-label-settings .mls-sample .hs-name { display: block; font-size: var(--map-name-size, 16px); }
.map-filter { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .5rem; padding: 0; list-style: none; }
.map-filter .chip { min-height: var(--touch); padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: inherit; font-size: .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.map-filter .chip[aria-pressed="true"] { border-color: currentColor; font-weight: 700; box-shadow: inset 0 0 0 1px currentColor; }
.map-filter .dot { width: .75rem; height: .75rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.3); }
.dot.cat-sa { background: #0f766e; } .dot.cat-l { background: #b91c1c; } .dot.cat-o { background: #15803d; }
.dot.cat-lu { background: #a21caf; } .dot.cat-w { background: #1d4ed8; } .dot.cat-b { background: #c2410c; }
.map-loading, .map-error { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--surface); padding: .5rem 1rem; border-radius: 8px; }
.map-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; list-style: none; padding: 0; margin: .5rem 0; font-size: .85rem; }
.map-legend li { display: flex; align-items: center; gap: .35rem; }
.legend-swatch { width: 14px; height: 14px; border-radius: 50%; border: 2px solid; }
.legend-swatch.mine { border-color: var(--mine); background: rgba(124, 58, 237, .28); }
.legend-swatch.cov-covered { border-color: var(--cov-covered); background: rgba(22, 163, 74, .22); }
.legend-swatch.cov-partial { border-color: var(--cov-partial); background: rgba(217, 119, 6, .28); }
.legend-swatch.cov-uncovered { border-color: var(--cov-uncovered); background: rgba(220, 38, 38, .3); }

/* ---------- Blazor framework UI ---------- */
#blazor-error-ui { background: var(--warning-soft); color: var(--warning); bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: var(--danger-soft); color: var(--danger); padding: 1rem; border-radius: 8px; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); }
.status-bar-safe-area { display: none; }

/* ---------- admin / supervisor helpers ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tree-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.roster-cell { display: flex; flex-direction: column; gap: .2rem; }
.issue-blocking { color: var(--danger); font-weight: 600; }
.issue-warning { color: var(--warning); }
.msg-errors, .msg-warnings { margin: .25rem 0; padding-left: 1.1rem; font-size: .85rem; }
.msg-errors { color: var(--danger); }
.msg-warnings { color: var(--warning); }

/* ---------- M5: PIN sign-in and circuit PIN management ---------- */
.segmented-block { display: flex; width: 100%; margin-bottom: 1rem; }
.segmented-block .seg { flex: 1 1 0; min-height: 48px; padding: .5rem .5rem; text-align: center; line-height: 1.2; }
.segmented-block .seg:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.pin-input { font-size: 1.35rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.pin-masked { -webkit-text-security: disc; }
.badge-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.circuit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; }
.circuit-settings { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 720px) { .circuit-settings { grid-template-columns: 1fr 1fr; } }
.pin-once { border-width: 2px; }
.pin-display {
    font-size: 2.25rem; font-weight: 700; letter-spacing: .2em; font-variant-numeric: tabular-nums; text-align: center;
    margin: .75rem 0; padding: .75rem; border-radius: 8px; background: var(--surface-2); user-select: all; -webkit-user-select: all; overflow-wrap: anywhere;
}
table.data tr.row-selected td { background: var(--primary-soft); }
/* Phones: data tables marked .stack become one card per row, each cell labelled from data-label (no horizontal scroll). */
@media (max-width: 480px) {
    .table-wrap:has(> table.stack) { border: 0; overflow: visible; }
    table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
    table.data.stack thead { display: none; }
    table.data.stack tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: .75rem; padding: .25rem 0; background: var(--surface); }
    table.data.stack td { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; border-bottom: 1px dashed var(--border); padding: .45rem .75rem; }
    table.data.stack td:last-child { border-bottom: 0; }
    table.data.stack td::before { content: attr(data-label); flex: 0 0 7.5em; font-weight: 600; font-size: .8rem; color: var(--muted); }
    table.data.stack td > .btn-row { flex: 1 1 100%; margin-top: 0; }
    table.data.stack td > .btn-row .btn { flex: 1 1 auto; }
}
