html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: sans-serif;
}

#app-shell {
    width: 100%;
    height: 100%;
    position: relative;
}

#compose-host {
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* Compose/Wasm renders much of the application on a shared canvas.  Its
   neutral surface must retain the normal arrow; individual Compose controls
   use pointerHoverIcon(Hand), while text inputs retain the I-beam. */
#compose-host, #compose-host canvas {
    cursor: default;
}
#compose-host input, #compose-host textarea, #compose-host [contenteditable="true"] {
    cursor: text !important;
}
#compose-host :disabled, #compose-host [aria-disabled="true"] {
    cursor: default !important;
}

#dashboard-photo-slider {
    position: fixed;
    bottom: 24px;
    left: 264px;
    right: 24px;
    z-index: 3;
    display: none;
    box-sizing: border-box;
    min-height: 0;
    overflow: hidden;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: none;
}

#dashboard-photo-slider.visible { display: block; }

.inspection-photo-preview-pane {
    position: fixed;
    z-index: 3;
    display: none;
    box-sizing: border-box;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    overflow: auto;
    padding: 4px;
}
.inspection-photo-preview-pane.visible { display: grid; }
.inspection-photo-preview-pane .inspection-photo-preview { min-width: 0; }

.inspection-report-photo-gallery {
    position: fixed;
    z-index: 3;
    display: none;
    box-sizing: border-box;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    padding: 4px;
    /* The gallery is mounted as a native DOM layer over Compose. Its bounds
       can briefly be stale after a long SIR render; never let transparent
       gallery space intercept navigation or form controls underneath. */
    pointer-events: none;
}
.inspection-report-photo-gallery.visible { display: grid; }
.inspection-report-photo-gallery-track { display: flex; gap: 10px; min-width: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.inspection-report-photo-gallery-track::-webkit-scrollbar { display: none; }
.inspection-report-photo-gallery-controls { display: flex; justify-content: center; gap: 8px; padding-top: 4px; }
.inspection-report-photo-gallery-controls button { min-width: 34px; height: 28px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; color: #278dad; font-size: 20px; line-height: 1; cursor: pointer; }
.inspection-report-photo-gallery-item {
    flex: 0 0 min(180px, 100%);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 10px;
    background: #e2e8f0;
    cursor: pointer;
    pointer-events: auto;
}
.inspection-report-photo-gallery-controls button { pointer-events: auto; }
.inspection-report-photo-gallery-item img { display: block; width: 100%; height: 100%; aspect-ratio: 1.35; object-fit: contain; transition: transform 180ms ease; }
.inspection-report-photo-gallery-item:hover img, .inspection-report-photo-gallery-item:focus-visible img { transform: scale(1.06); }
.inspection-report-photo-gallery-item:focus-visible { outline: 2px solid #278dad; outline-offset: 2px; }
.inspection-report-photo-gallery-item.unavailable, .inspection-report-photo-gallery-empty { display: grid; min-height: 140px; place-items: center; padding: 12px; color: #64748b; font: inherit; text-align: center; }

.photo-slider-title { display: block; margin: 0 0 12px; padding: 0; border: 0; color: #1e293b; background: transparent; font: inherit; font-size: 16px; font-weight: 700; text-align: left; }
.photo-slider-title[type="button"]:hover, .photo-slider-title[type="button"]:focus-visible { color: #278dad; text-decoration: underline; }
.photo-slider-empty { display: grid; min-height: 150px; place-items: center; color: #64748b; }
.photo-slider-track { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scrollbar-color: #94a3b8 transparent; }
.photo-slider-item { flex: 0 0 180px; height: 145px; padding: 0; overflow: hidden; border: 0; border-radius: 10px; background: #e2e8f0; cursor: pointer; }
.photo-slider-item-unavailable { display: grid; place-items: center; padding: 16px; color: #64748b; font: inherit; text-align: center; cursor: default; }
.photo-slider-item:hover, .photo-slider-item:focus-visible { outline: 2px solid #278dad; outline-offset: 2px; }
.photo-slider-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease; }
.photo-slider-item:hover img, .photo-slider-item:focus-visible img { transform: scale(1.08); }
.photo-lightbox { position: fixed; inset: 0; z-index: 10000; display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; grid-template-rows: minmax(0, 1fr) auto; align-items: center; padding: 32px; box-sizing: border-box; background: rgba(15, 23, 42, 0.9); }
.photo-lightbox-image { grid-column: 2; grid-row: 1; justify-self: center; max-width: 100%; max-height: calc(100vh - 112px); object-fit: contain; }
.photo-lightbox-caption { grid-column: 1 / -1; grid-row: 2; justify-self: center; padding-top: 12px; color: #fff; }
.photo-lightbox-close, .photo-lightbox-nav { border: 0; color: #fff; background: rgba(255, 255, 255, 0.16); cursor: pointer; }
.photo-lightbox-close { position: absolute; top: 20px; right: 24px; width: 44px; height: 44px; border-radius: 50%; font-size: 34px; line-height: 34px; }
.photo-lightbox-nav { width: 48px; height: 64px; border-radius: 10px; font-size: 48px; line-height: 42px; }
.photo-lightbox-nav.previous { grid-column: 1; grid-row: 1; }
.photo-lightbox-nav.next { grid-column: 3; grid-row: 1; }

.inspection-photo-picker { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 20px; box-sizing: border-box; background: rgba(15, 23, 42, 0.62); }
.inspection-photo-picker-dialog { width: min(780px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-sizing: border-box; padding: 24px; border-radius: 16px; background: #fff; color: #1e293b; box-shadow: 0 18px 48px rgba(15, 23, 42, 0.3); }
.inspection-photo-picker-dialog h2 { margin: 0 0 6px; }
.inspection-photo-picker-dialog p { margin: 0 0 16px; color: #64748b; }
.inspection-photo-picker-error { min-height: 20px; margin-bottom: 8px; color: #b91c1c; font-size: 14px; }
.inspection-photo-drop-zone { width: 100%; min-height: 120px; border: 2px dashed #278dad; border-radius: 12px; color: #176b84; background: #f0f9fc; font: inherit; font-weight: 600; cursor: pointer; }
.inspection-photo-drop-zone.dragging { background: #d8f1f8; border-color: #075b73; }
.inspection-photo-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin: 16px 0; }
.inspection-photo-preview { position: relative; overflow: hidden; border-radius: 10px; background: #f1f5f9; }
.inspection-photo-preview[role="button"] { cursor: pointer; }
.inspection-photo-preview[role="button"]:hover img, .inspection-photo-preview[role="button"]:focus-visible img { transform: scale(1.05); }
.inspection-photo-preview[role="button"]:focus-visible { outline: 2px solid #278dad; outline-offset: 2px; }
.inspection-photo-preview img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform 180ms ease; }
.inspection-photo-preview span { display: block; overflow: hidden; padding: 6px; color: #475569; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.inspection-photo-remove { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; color: #fff; background: #dc2626; font-size: 20px; line-height: 20px; cursor: pointer; }
.inspection-photo-done { float: right; padding: 10px 18px; border: 0; border-radius: 8px; color: #fff; background: #278dad; font: inherit; font-weight: 600; cursor: pointer; }

@media (max-width: 800px) {
    .photo-slider-item { flex-basis: 150px; height: 132px; }
}

#map-pane {
    position: fixed;
    left: 240px;
    top: 0;
    right: 0;
    bottom: 0;
    display: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: none;
    background: #dbeafe;
    z-index: 3;
}

body.map-visible #map-pane {
    display: block;
}

/* The in-canvas option layer must remain above native map/image surfaces. */
body.canvas-overlay-open #map-pane, body.canvas-overlay-open #dashboard-photo-slider, body.canvas-overlay-open .inspection-photo-preview-pane { visibility: hidden; }

#oms-paste-notice {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10020;
    max-width: min(620px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 10px;
    background: #173F4D;
    color: #FFFFFF;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    font: 500 14px/1.4 system-ui, sans-serif;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 160ms ease, transform 160ms ease;
}

#oms-paste-notice.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
body .oms-pane-clipped { visibility: hidden; }

button:focus-visible, a:focus-visible { outline: 2px solid #16566c; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
    .photo-slider-item img { transition: none; }
}

#map-host {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

canvas {
    display: block;
}

/* Native HTML buttons (photo tools and map controls) are actions.  Do not
   promote generic links, table cells or selectable text to the hand cursor. */
button {
    cursor: pointer !important;
}

.leaflet-container {
    width: 100%;
    height: 100%;
    font-family: inherit;
}

.leaflet-popup {
    width: min(340px, calc(100vw - 72px));
    margin-bottom: 2px;
}
#map-host .leaflet-popup-content-wrapper {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
    border: 1px solid rgba(39, 141, 173, 0.22);
    background: #ffffff;
    color: #20313c;
    opacity: 1;
    box-shadow: 0 8px 24px rgba(32, 49, 60, 0.28);
}
#map-host .leaflet-popup-content { width: auto !important; }
#map-host .leaflet-popup-tip {
    background: #ffffff;
    opacity: 1;
}
.oms-map-preview { min-width: 0; max-width: 340px; color: #20313c; line-height: 1.5; }
.oms-map-preview p { margin: 8px 0; color: #536571; }
.oms-map-status-badge { display: inline-block; padding: 3px 7px; border-radius: 4px; font-size: .82rem; font-weight: 500; line-height: 1.2; }
.oms-map-preview button { width: 100%; padding: 10px 12px; border: 0; border-radius: 6px; background: #278DAD; color: white; font: inherit; cursor: pointer; }

.oms-project-marker {
    display: block;
    width: 12px;
    height: 12px;
    border: 3px solid var(--marker-color);
    border-radius: 50%;
    background: color-mix(in srgb, var(--marker-color) 78%, white);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.32);
}

.oms-project-cluster {
    display: flex !important;
    box-sizing: border-box;
    width: 52px;
    height: 52px;
    align-items: center !important;
    justify-content: center !important;
    border: 3px solid white;
    border-radius: 50%;
    background: #278DAD;
    color: white;
    box-shadow: 0 2px 8px rgba(12, 69, 87, 0.4);
    font-weight: 700;
    font-size: 22px;
    line-height: 1;
    text-align: center;
}

/* MarkerCluster's own stylesheet is loaded after ours and styles nested
   elements. Force the counter itself to fill and centre in the custom icon. */
.oms-project-cluster > span {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    font: inherit !important;
    line-height: 1 !important;
    text-align: center !important;
}

#oms-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(18, 45, 56, 0.22);
    backdrop-filter: blur(2px);
    /* A request may outlive the screen that initiated it (for example, a
       dashboard refresh).  It must never prevent the user from navigating
       away or make the application look frozen. */
    pointer-events: none;
}

#oms-loading-overlay.visible { display: flex; }

.oms-loading-card {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 18px 22px;
    border-radius: 14px;
    background: #fff;
    color: #164d60;
    box-shadow: 0 12px 32px rgba(12, 69, 87, 0.25);
    font-weight: 600;
}

.oms-loading-spinner {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 3px solid #b9dce7;
    border-top-color: #278DAD;
    border-radius: 50%;
    animation: oms-loading-rotate 0.8s linear infinite;
}

@keyframes oms-loading-rotate { to { transform: rotate(360deg); } }
