/* ---------------------------------------------------------------- base */
:root {
    --gv-navy: #12355b;
    --gv-navy-dark: #0c2742;
    --gv-accent: #4fb3e8;
    --gv-bg: #f3f5f8;
    --gv-border: #dfe4ea;
    --gv-sidebar-width: 16.5rem;
    --bs-primary: #1d5fa0;
    --bs-primary-rgb: 29, 95, 160;
    --bs-link-color: #1d5fa0;
    --bs-link-color-rgb: 29, 95, 160;
    --bs-link-hover-color: #12355b;
}
body { background: var(--gv-bg); color: #1f2933; }
.btn-primary { --bs-btn-bg: #1d5fa0; --bs-btn-border-color: #1d5fa0; --bs-btn-hover-bg: #174d83; --bs-btn-hover-border-color: #174d83; --bs-btn-active-bg: #12355b; }
.btn-outline-primary { --bs-btn-color: #1d5fa0; --bs-btn-border-color: #1d5fa0; --bs-btn-hover-bg: #1d5fa0; --bs-btn-hover-border-color: #1d5fa0; }
.card { border-radius: .6rem; border-color: var(--gv-border); box-shadow: 0 1px 2px rgba(16, 42, 67, .04); }
.card > .table { margin-bottom: 0; }
.card > .table tr:last-child td { border-bottom: 0; }
.table { --bs-table-bg: #fff; }
.table td, .table th { vertical-align: middle; }
.table thead th { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: #52606d; }
.invite-link { word-break: break-all; font-family: monospace; font-size: .85rem; }
.authenticator-qr { image-rendering: pixelated; border: 1px solid #ddd; border-radius: .25rem; background: #fff; }
.notes { white-space: pre-line; }
.project-picks { max-height: 14rem; overflow-y: auto; }

/* ---------------------------------------------------------------- page furniture */
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 600; margin: 0; color: var(--gv-navy-dark); }
.page-kicker { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #7b8794; }
.empty-state { background: #fff; border: 1px dashed var(--gv-border); border-radius: .6rem; padding: 2rem; text-align: center; color: #52606d; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 1rem; }
.stat-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--gv-border); border-radius: .6rem; padding: 1rem 1.1rem; color: inherit; text-decoration: none; }
a.stat-card:hover { border-color: var(--bs-primary); box-shadow: 0 2px 8px rgba(18, 53, 91, .08); }
.stat-value { font-size: 1.8rem; font-weight: 600; color: var(--gv-navy); line-height: 1.1; }
.stat-label { font-weight: 500; }
.stat-note { font-size: .8rem; color: #7b8794; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.project-card { display: flex; flex-direction: column; gap: .2rem; background: #fff; border: 1px solid var(--gv-border); border-left: 4px solid var(--gv-navy); border-radius: .6rem; padding: 1rem 1.1rem; color: inherit; text-decoration: none; }
.project-card:hover { border-color: var(--bs-primary); box-shadow: 0 2px 8px rgba(18, 53, 91, .08); }
.project-name { font-weight: 600; font-size: 1.05rem; color: var(--gv-navy-dark); }
.project-meta { font-size: .85rem; color: #616e7c; }

/* ---------------------------------------------------------------- app shell */
.app-shell { min-height: 100vh; }
.app-content { padding: 1.25rem 2rem 3rem; max-width: 1400px; }
.app-content-full { max-width: none; padding: .75rem 1rem; }

/* The title bar across the top of every page: its title, a subtitle beside it, and its buttons on the right. */
.page-titlebar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 1rem; min-height: 3rem;
    padding: .4rem 2rem; background: #fff; border-bottom: 1px solid var(--gv-border); }
.page-titlebar-text { display: flex; align-items: baseline; gap: .6rem; min-width: 0; flex: 1 1 auto; }
.page-titlebar .page-title { font-size: 1.15rem; font-weight: 600; margin: 0; color: var(--gv-navy-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-subtitle { font-size: .875rem; color: #616e7c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.page-titlebar .badge { align-self: center; }
.page-titlebar-actions { display: flex; align-items: center; gap: .4rem; flex: none; }
/* A success message in the title bar: shown for 5 seconds, then fades and takes no room. CSS only (no script). */
.page-flash { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem;
    color: #0f5132; background: #d1e7dd; border: 1px solid #badbcc; border-radius: .4rem; padding: .2rem .65rem;
    animation: page-flash 5.6s ease-in forwards; }
@keyframes page-flash {
    0%, 89% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; max-width: 0; padding: 0; border-width: 0; margin: 0; }
}
@media (prefers-reduced-motion: reduce) { .page-flash { animation: page-flash 5s step-end forwards; } }
@media (max-width: 991.98px) { .page-titlebar { top: 3.05rem; padding: .4rem 1rem; } .app-content { padding: 1rem 1rem 2rem; } }

/* A page that fills the window (the waterfall): it never scrolls; what is inside it does. */
.app-main-fill { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.app-content-fill { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: .5rem .75rem; }
@media (max-width: 991.98px) { .app-main-fill { height: calc(100dvh - 3.05rem); } .app-main-fill .page-titlebar { top: 0; } }
.app-logo img { height: 2rem; width: auto; display: block; }
.app-topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: #fff; border-bottom: 1px solid var(--gv-border); }
.btn-topbar { border: 1px solid var(--gv-border); padding: .35rem .5rem; }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 1.2rem; height: 2px; background: var(--gv-navy); border-radius: 1px; position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }

.app-sidebar { background: var(--gv-navy); color: #dbe7f3; }
.app-sidebar.offcanvas-lg { --bs-offcanvas-width: 18rem; --bs-offcanvas-bg: var(--gv-navy); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem .9rem; }
.sidebar-body { padding: 0 .75rem 1.5rem; overflow-y: auto; }
@media (min-width: 992px) {
    /* Bootstrap makes .offcanvas-lg transparent on large screens; keep the sidebar's colour. */
    .app-sidebar.offcanvas-lg { position: fixed; inset: 0 auto 0 0; width: var(--gv-sidebar-width); display: flex !important; flex-direction: column; background-color: var(--gv-navy) !important; }
    .sidebar-body { flex: 1; }
    .app-main { margin-left: var(--gv-sidebar-width); }
}

/* Menu */
.app-sidebar ul { list-style: none; margin: 0; padding: 0; }
.app-sidebar .nav-link { display: flex; align-items: center; gap: .5rem; padding: .38rem .75rem; border-radius: .4rem; color: #c6d6e6; text-decoration: none; font-size: .92rem; border-left: 3px solid transparent; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.app-sidebar .nav-link.active { background: rgba(255, 255, 255, .13); color: #fff; border-left-color: var(--gv-accent); }
.app-sidebar .nav-top { font-weight: 600; color: #fff; font-size: .97rem; padding-top: .5rem; padding-bottom: .5rem; }
.app-sidebar .nav-sub { margin: 0 0 .35rem .6rem; padding-left: .5rem; border-left: 1px solid rgba(255, 255, 255, .12); }
.app-sidebar .nav-sub .nav-link { font-size: .88rem; padding: .28rem .65rem; }
.app-sidebar .nav-main > li { margin-top: .3rem; }
.app-sidebar .nav-section-label { display: block; margin: 1rem .75rem .3rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8fb0cf; }
.app-sidebar .nav-button { width: 100%; background: none; border: 0; border-left: 3px solid transparent; text-align: left; }
.app-sidebar .nav-badge { margin-left: auto; background: var(--gv-accent); color: var(--gv-navy-dark); font-weight: 700; }
.app-sidebar .nav-empty { color: #8fb0cf; font-style: italic; cursor: default; }
.app-sidebar .nav-empty:hover { background: none; color: #8fb0cf; }
.app-sidebar .nav-more { color: var(--gv-accent); }

.nav-profile { margin-bottom: .5rem; padding-bottom: .5rem; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.nav-profile .nav-section-title { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem .5rem; }
.avatar { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; background: var(--gv-accent); color: var(--gv-navy-dark); font-weight: 700; }
.nav-profile-text { display: flex; flex-direction: column; min-width: 0; }
.nav-profile-name { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-profile-company { font-size: .8rem; color: #8fb0cf; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-selected { background: rgba(0, 0, 0, .14); border-radius: .5rem; padding: .25rem .25rem .1rem; }
.nav-selected-head { display: flex; align-items: flex-start; }
.nav-selected-head .nav-link { flex-direction: column; align-items: flex-start; gap: 0; flex: 1; min-width: 0; }
.nav-kicker { font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--gv-accent); }
.nav-selected-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.btn-clear { background: none; border: 0; color: #8fb0cf; font-size: 1.15rem; line-height: 1; padding: .45rem .5rem; border-radius: .3rem; }
.btn-clear:hover { color: #fff; background: rgba(255, 255, 255, .1); }

/* Signed-out pages (sign in, accept invitation) */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 3rem 1rem; }
.auth-logo img { height: 2.6rem; margin-bottom: 2rem; }
.auth-content { width: 100%; max-width: 32rem; background: #fff; border: 1px solid var(--gv-border); border-radius: .75rem; padding: 2rem; box-shadow: 0 4px 16px rgba(16, 42, 67, .06); }

/* Project map */
.app-content-fill > .map-wrap { flex: 1 1 auto; height: auto; min-height: 0; }
.map-wrap { position: relative; height: calc(100vh - 5.25rem); min-height: 420px; border: 1px solid #ddd; border-radius: .5rem; overflow: hidden; background: #eef0ea; }
.map-canvas { position: absolute; inset: 0; }
.map-box { position: absolute; z-index: 2; background: #fff; border-radius: .5rem; box-shadow: 0 1px 4px rgba(0,0,0,.25); padding: .75rem; }
.map-layers { top: .75rem; left: .75rem; width: 17rem; max-height: calc(100% - 3rem); overflow-y: auto; }
.map-layers li { padding: .25rem 0; border-top: 1px solid #eee; }
.map-layers li:first-child { border-top: 0; }
.map-layers .layer-row { display: flex; align-items: center; gap: .35rem; }
.map-layers .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-layers input[type=range] { width: 100%; }
.map-layers .btn-move { padding: 0 .35rem; line-height: 1.2; }
.map-panel { top: .75rem; right: .75rem; width: 21rem; max-height: calc(100% - 3rem); overflow-y: auto; }
.map-panel dl { margin-bottom: .5rem; }
.map-panel dt { font-weight: 500; }
.map-readout { position: absolute; z-index: 2; left: .75rem; bottom: 2.4rem; background: rgba(255,255,255,.85); padding: .1rem .4rem; border-radius: .25rem; font-variant-numeric: tabular-nums; }
.layer-swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; background: #0d6efd; border: 2px solid #fff; box-shadow: 0 0 0 1px #0d6efd; }
.layer-swatch.logs { background: #fd7e14; box-shadow: 0 0 0 1px #fd7e14; }
@media (max-width: 768px) {
    .map-layers { width: 12rem; }
    .map-panel { left: .75rem; right: .75rem; width: auto; top: auto; bottom: .75rem; max-height: 50%; }
}
.input-opacity { width: 5rem; }
.app-content h1 { color: var(--gv-navy-dark); font-weight: 600; }
.auth-content .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
@media (max-width: 991.98px) { .map-wrap { height: calc(100vh - 8.75rem); } }

/* Map data (Geovista admin) */
.basemap-progress { height: .45rem; max-width: 16rem; }
.map-wrap-test { height: 32rem; min-height: 320px; }

/* Import wizard */
.wizard-table .wiz-tick { width: 2rem; }
.wizard-table .wiz-narrow { width: 6rem; }
.wizard-table .wiz-normal { min-width: 9rem; }
.wizard-table .wiz-wide { min-width: 14rem; }
.wizard-table .wiz-fill { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wizard-summary { white-space: pre-wrap; font-size: .875rem; }

/* Tables page: the list beside the table, and a grid that only holds the rows on screen */
.tv-layout { display: block; }
@media (min-width: 992px) {
    .tv-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1.25rem; align-items: start; }
}
.tv-list { background: #fff; border: 1px solid var(--gv-border); border-radius: .6rem; padding: .35rem; max-height: calc(100vh - 11rem); overflow-y: auto; position: sticky; top: 1rem; }
.tv-list-item { display: block; padding: .45rem .6rem; border-radius: .4rem; color: inherit; text-decoration: none; border-left: 3px solid transparent; }
.tv-list-item:hover { background: var(--gv-bg); }
.tv-list-item.active { background: #e8f1fa; border-left-color: var(--gv-accent); }
.tv-list-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.tv-list-info { display: block; font-size: .78rem; color: #52606d; }
.tv-main { min-width: 0; }
.tv-scroll { height: max(18rem, calc(100vh - 16rem)); overflow: auto; background: #fff; border: 1px solid var(--gv-border); border-radius: .6rem; outline-offset: 2px; }
.tv-scroll:focus-visible { outline: 2px solid var(--bs-primary); }
.tv-table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; font-variant-numeric: tabular-nums; }
.tv-table thead th { position: sticky; top: 0; z-index: 1; background: #f8fafc; border-bottom: 1px solid var(--gv-border); padding: .4rem .75rem; text-align: right; white-space: nowrap; font-family: var(--bs-body-font-family); font-weight: 600; font-size: .8rem; color: var(--gv-navy-dark); }
.tv-table td { height: 28px; padding: 0 .75rem; text-align: right; white-space: nowrap; border-left: 3px solid transparent; }
.tv-table td + td { border-left: 0; }
.tv-table tbody tr:nth-child(even):not(.tv-pad) { background: #f8fafc; }
.tv-table tbody tr:not(.tv-pad) { cursor: pointer; }
.tv-table tbody tr.tv-selected { background: #e8f1fa; }
.tv-table tbody tr.tv-selected td:first-child { border-left-color: var(--gv-accent); }
.tv-table tr.tv-pad td { padding: 0; border: 0; }
.tv-table tr.tv-loading td::after { content: "\00a0"; }
.tv-f { display: inline-block; text-align: left; }
.tv-meta-child { border-left: 2px solid var(--gv-border); padding-left: .75rem; margin: .25rem 0 .5rem; }

/* Deviation plot: plan view beside two sections */
.dev-layout { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 992px) { .dev-layout { grid-template-columns: 2fr 1fr 1fr; } }
.dev-caption { font-weight: 600; font-size: .85rem; color: var(--gv-navy-dark); padding: .1rem .3rem; }
.dev-svg { width: 100%; display: block; }
.dev-plan .dev-svg { aspect-ratio: 1 / 1; }
.dev-section .dev-svg { height: 26rem; }
@media (min-width: 992px) { .dev-section .dev-svg { height: calc(100% - 1.5rem); min-height: 26rem; } }
.dev-grid line, .dev-grid circle { stroke: var(--gv-border); stroke-width: 1; fill: none; }
.dev-tick { font-size: 10px; fill: #52606d; font-variant-numeric: tabular-nums; }
.dev-axis { font-size: 11px; fill: #3e4c59; }
.dev-frame { fill: none; stroke: #b8c2cc; }
.dev-axis-line { stroke: #7b8794; stroke-width: 1; }
.dev-compass { font-size: 12px; font-weight: 600; fill: var(--gv-navy-dark); }
.dev-centre { stroke: #7b8794; stroke-width: 1; stroke-dasharray: 4 3; }
.dev-marker { fill: #fff; stroke-width: 2.5; }
.dev-swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: .15rem; margin-right: .4rem; vertical-align: -.05rem; }

/* Waterfall plot: three stacked canvases (grid, WebGPU data, text) filling the host, which sets the height. */
.wf-host { position: relative; height: calc(100vh - 13rem); min-height: 24rem; border: 1px solid var(--gv-border); border-radius: .4rem; overflow: hidden; background: #fbfbfb; }
.wf-host canvas { position: absolute; top: 0; left: 0; bottom: 0; width: calc(100% - 14px); height: 100%; display: block; }
.wf-scroll { position: absolute; top: 0; right: 0; bottom: 0; width: 14px; background: var(--gv-border); cursor: pointer; }
.wf-thumb { position: absolute; left: 2px; right: 2px; top: 0; border-radius: 5px; background: #8c96a0; cursor: grab; touch-action: none; }
.wf-thumb:hover { background: #6b7682; }
.wf-thumb[hidden] { display: none; }
.wf-host .wf-over { cursor: crosshair; touch-action: none; }
.wf-host .wf-over.wf-dragging { cursor: grabbing; }
.wf-foot { display: flex; align-items: baseline; gap: .75rem; padding-top: .2rem; white-space: nowrap; min-width: 0; }
.wf-foot .wf-stats:empty, .wf-foot .wf-status:empty { display: none; }
.wf-help { margin-left: auto; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wf-view-menu { width: 22rem; }

/* On a page that fills the window the plot takes all the room left, and only it (and the editor) scrolls. */
.wf-fill { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.wf-fill > .wf-host { flex: 1 1 auto; height: auto; }
.wf-fill > .wf-layout { flex: 1 1 auto; min-height: 0; align-items: stretch; }
.wf-fill .wf-plot-area { display: flex; flex-direction: column; min-height: 0; }
.wf-fill .wf-plot-area .wf-host { flex: 1 1 auto; height: auto; min-height: 10rem; }
.wf-fill .wf-editor { max-height: none; min-height: 0; }
@media (max-width: 991.98px) { .wf-fill .wf-layout.wf-editing .wf-editor { max-height: 45%; } }
.wf-layout { display: flex; gap: 1rem; align-items: flex-start; }
.wf-plot-area { flex: 1 1 auto; min-width: 0; }
.wf-editor { flex: 0 0 22rem; max-height: calc(100vh - 13rem); overflow-y: auto; }
@media (max-width: 991.98px) { .wf-layout.wf-editing { flex-direction: column; } .wf-editor { flex-basis: auto; width: 100%; max-height: none; } }
.wf-gradient-bar { display: block; width: 100%; height: 12px; border: 1px solid var(--gv-border); border-radius: 2px; }
.wf-colour { max-width: 3rem; }
.wf-host .wf-over { cursor: crosshair; }
.wf-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: #52606d; }
