:root {
    --background: #0b0f14;
    --background-elevated: rgba(18, 24, 31, 0.96);
    --background-soft: rgba(24, 31, 39, 0.92);
    --background-card: rgba(18, 24, 31, 0.94);
    --surface: #121820;
    --surface-2: #18202a;
    --surface-3: #202a35;
    --border: rgba(175, 190, 205, 0.14);
    --border-strong: rgba(175, 190, 205, 0.24);
    --text-primary: #eef2f5;
    --text-secondary: #a8b3bf;
    --text-muted: #788695;
    --accent: #8fb3cf;
    --accent-strong: #adc7da;
    --accent-soft: rgba(143, 179, 207, 0.14);
    --success: #78b892;
    --warning: #d3aa63;
    --danger: #c9767d;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.28);
    --shadow-strong: 0 18px 52px rgba(0, 0, 0, 0.45);
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font-stack: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background: var(--background);
    color: var(--text-primary);
    font-family: var(--font-stack);
    overflow-x: hidden;
}

html {
    height: 100%;
}

body {
    min-height: 100dvh;
    position: relative;
    overscroll-behavior: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

.hidden {
    display: none !important;
}

.app-background-glow {
    display: none;
}

.screen-centre {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: calc(var(--safe-top) + 1rem) 1rem calc(var(--safe-bottom) + 1rem);
    position: relative;
    z-index: 1;
    background:
        linear-gradient(180deg, rgba(31, 39, 49, 0.82), rgba(11, 15, 20, 1)),
        var(--background);
}

.panel {
    background: linear-gradient(180deg, rgba(24, 31, 39, 0.97), rgba(15, 20, 26, 0.97));
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.auth-panel {
    width: min(100%, 420px);
    padding: 1.1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.compact-header {
    margin-bottom: 0.75rem;
}

.panel-header h2,
.brand-title {
    margin: 0;
}

.panel-header h2 {
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.panel-header p,
.brand-subtitle,
.input-group label,
.objective-label,
.chip-label,
.eyebrow {
    color: var(--text-secondary);
}

.eyebrow {
    margin: 0 0 0.25rem 0;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    min-width: 0;
}

.brand-title {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.small-brand-title {
    font-size: 1.1rem;
}

.brand-subtitle {
    margin: 0.1rem 0 0 0;
    font-size: 0.9rem;
}

.brand-icon-wrap {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    overflow: hidden;
}

.brand-chip-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.brand-icon,
.brand-image {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
}

.small-brand-icon,
.small-brand-image,
.brand-chip-icon .brand-image {
    width: 22px;
    height: 22px;
}

.brand-icon-ring {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
}

.brand-icon-core {
    fill: var(--text-primary);
}

.brand-icon-needle {
    fill: var(--accent-strong);
}

.brand-icon-needle-alt {
    fill: rgba(255, 255, 255, 0.32);
}

.form-stack {
    display: grid;
    gap: 0.85rem;
}

.input-group {
    display: grid;
    gap: 0.38rem;
}

.input-group label {
    font-size: 0.86rem;
    font-weight: 650;
}

.input-control {
    width: 100%;
    border: 1px solid var(--border);
    background: rgba(8, 11, 15, 0.92);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 0.82rem 0.9rem;
    outline: none;
    min-height: 44px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-control:focus {
    border-color: rgba(173, 199, 218, 0.58);
    box-shadow: 0 0 0 3px rgba(143, 179, 207, 0.12);
}

textarea.input-control {
    resize: vertical;
    min-height: 82px;
}

.button {
    border: 0;
    border-radius: 12px;
    padding: 0.84rem 0.95rem;
    min-height: 44px;
    font-weight: 750;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.18s ease, background 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button-primary {
    color: #071016;
    background: linear-gradient(180deg, #b7cad8, #8fb3cf);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

.button-secondary {
    color: var(--text-primary);
    background: rgba(31, 39, 49, 0.96);
    border: 1px solid var(--border);
}

.button-danger {
    color: #fff;
    background: linear-gradient(180deg, #b56b72, #9f535b);
}

.button-large {
    padding: 0.95rem 1.05rem;
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.message-strip {
    margin-top: 0.75rem;
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: rgba(20, 26, 34, 0.92);
    color: var(--text-primary);
}

.message-strip.success {
    border-color: rgba(120, 184, 146, 0.38);
    background: rgba(32, 55, 43, 0.6);
}

.message-strip.error {
    border-color: rgba(201, 118, 125, 0.42);
    background: rgba(64, 34, 38, 0.62);
}

.message-strip.info {
    border-color: rgba(143, 179, 207, 0.38);
    background: rgba(28, 42, 54, 0.62);
}

.team-page-shell,
.team-app {
    height: 100dvh;
    min-height: 100dvh;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.team-app {
    width: 100%;
    background: #080c10;
}

.map-view {
    width: 100%;
    height: 100%;
}

#teamMapView {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100dvh;
}

.top-hud {
    position: absolute;
    top: calc(var(--safe-top) + 0.55rem);
    left: 0.55rem;
    right: 0.55rem;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
    align-items: start;
    pointer-events: none;
}

.map-hud .hud-chip {
    pointer-events: auto;
}

.hud-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 46px;
    max-width: 100%;
    border-radius: 14px;
    padding: 0.48rem 0.58rem;
    background: rgba(10, 14, 19, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.brand-chip {
    min-width: 0;
}

.chip-label {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chip-value {
    font-size: 0.82rem;
    font-weight: 750;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chip-value-status {
    color: var(--accent-strong);
}

.floating-map-button {
    position: absolute;
    right: 0.72rem;
    bottom: calc(var(--safe-bottom) + 4.85rem);
    z-index: 21;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: rgba(13, 18, 24, 0.92);
    color: var(--text-primary);
    font-size: 1.1rem;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.bottom-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 0 0.6rem calc(var(--safe-bottom) + 0.55rem) 0.6rem;
    pointer-events: none;
}

.drawer-toggle-button {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: rgba(13, 18, 24, 0.94);
    color: var(--text-primary);
    display: grid;
    place-items: center;
    gap: 0.22rem;
    padding: 0.48rem 0.85rem;
    box-shadow: var(--shadow-strong);
    backdrop-filter: blur(16px);
    pointer-events: auto;
    cursor: pointer;
}

.drawer-handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(210, 220, 230, 0.34);
    display: block;
}

.drawer-toggle-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.drawer-content {
    display: grid;
    gap: 0.62rem;
    max-height: min(64dvh, calc(100dvh - 8.7rem));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-top: 0.55rem;
    pointer-events: auto;
    transition: transform 0.2s ease, opacity 0.2s ease, max-height 0.2s ease, padding-top 0.2s ease;
    background-color: var(--background-elevated);
}

.bottom-drawer .panel {
    padding: 0.82rem;
    border-radius: 16px;
}

.bottom-drawer.drawer-collapsed .drawer-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px);
    padding-top: 0;
    pointer-events: none;
}

.bottom-drawer.drawer-expanded .drawer-content {
    opacity: 1;
    transform: translateY(0);
}

.mission-panel {
    box-shadow: var(--shadow-strong);
}

.badge {
    border-radius: 999px;
    padding: 0.36rem 0.62rem;
    font-size: 0.72rem;
    font-weight: 750;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge-accent {
    background: rgba(143, 179, 207, 0.12);
    color: var(--accent-strong);
    border-color: rgba(143, 179, 207, 0.24);
}

.objective-card {
    display: grid;
    gap: 0.72rem;
}

.objective-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.62rem;
}

.objective-metric,
.objective-description-wrap {
    border-radius: 13px;
    padding: 0.72rem;
    background: rgba(8, 11, 15, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.055);
}

.objective-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.075em;
    margin-bottom: 0.34rem;
}

.objective-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--accent-strong);
    word-break: break-word;
}

.objective-description {
    margin: 0.35rem 0 0 0;
    line-height: 1.42;
    color: var(--text-primary);
    font-size: 0.92rem;
}

.progress-list {
    display: grid;
    gap: 0.62rem;
}

.progress-item {
    border-radius: 13px;
    padding: 0.72rem;
    background: rgba(8, 11, 15, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.055);
}

.progress-item-top,
.status-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.65rem;
    align-items: flex-start;
}

.progress-item h3 {
    margin: 0 0 0.25rem 0;
    font-size: 0.94rem;
}

.progress-meta,
.progress-item p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.empty-state {
    padding: 0.85rem;
    border-radius: 13px;
    background: rgba(8, 11, 15, 0.58);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    text-align: center;
    color: var(--text-secondary);
}

.empty-state p {
    margin: 0;
}

.toast {
    position: absolute;
    left: 0.6rem;
    right: 0.6rem;
    top: calc(var(--safe-top) + 4.15rem);
    z-index: 25;
    padding: 0.78rem 0.85rem;
    border-radius: 13px;
    background: rgba(13, 18, 24, 0.95);
    border: 1px solid rgba(143, 179, 207, 0.24);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
    font-size: 0.9rem;
}

.toast.success {
    border-color: rgba(120, 184, 146, 0.36);
}

.toast.error {
    border-color: rgba(201, 118, 125, 0.38);
}

.admin-shell {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    padding: calc(var(--safe-top) + 0.8rem) 0.75rem calc(var(--safe-bottom) + 0.8rem);
    background: var(--background);
}

.admin-topbar {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.admin-content {
    display: grid;
    gap: 0.85rem;
}

.map-panel,
.admin-grid .panel {
    padding: 0.85rem;
}

.admin-map {
    height: 42dvh;
    min-height: 280px;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.legend-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot-team {
    background: var(--accent-strong);
}

.legend-dot-point {
    background: var(--success);
}

.admin-grid {
    display: grid;
    gap: 0.85rem;
}

.admin-span-two {
    grid-column: span 1;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.055);
    border-radius: 14px;
    background: rgba(8, 11, 15, 0.58);
}

.top-space {
    margin-top: 0.85rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}

.data-table th,
.data-table td {
    padding: 0.78rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
    vertical-align: top;
}

.data-table th {
    color: var(--text-secondary);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.data-table td {
    color: var(--text-primary);
    font-size: 0.88rem;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.action-button-small {
    border: 1px solid var(--border);
    background: rgba(31, 39, 49, 0.96);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 0.48rem 0.65rem;
    min-height: 38px;
    cursor: pointer;
}

.action-button-delete {
    border-color: rgba(201, 118, 125, 0.34);
    color: #efc8cc;
}

.split-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.route-rows {
    display: grid;
    gap: 0.65rem;
}

.route-row {
    display: grid;
    grid-template-columns: 1fr 92px auto;
    gap: 0.6rem;
    align-items: end;
    padding: 0.65rem;
    border-radius: 13px;
    background: rgba(8, 11, 15, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.055);
}

.stack-list {
    display: grid;
    gap: 0.65rem;
}

.status-card {
    border-radius: 13px;
    padding: 0.78rem;
    background: rgba(8, 11, 15, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.055);
}

.status-card h3 {
    margin: 0;
    font-size: 0.94rem;
}

.status-card p {
    margin: 0.16rem 0 0 0;
    color: var(--text-secondary);
    line-height: 1.38;
    font-size: 0.86rem;
}

.photo-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.photo-card {
    border-radius: 13px;
    overflow: hidden;
    background: rgba(8, 11, 15, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.055);
}

.photo-card img {
    display: block;
    width: 100%;
    height: 128px;
    object-fit: cover;
}

.photo-card-body {
    padding: 0.7rem;
}

.photo-card-body h3 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
}

.photo-card-body p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

@media (max-width: 430px) {
    .top-hud {
        grid-template-columns: minmax(0, 1fr) minmax(90px, auto);
    }

    .hud-chip {
        min-height: 42px;
        padding: 0.42rem 0.5rem;
        gap: 0.45rem;
    }

    .brand-chip-icon {
        width: 30px;
        height: 30px;
    }

    .chip-label {
        font-size: 0.58rem;
    }

    .chip-value {
        font-size: 0.78rem;
    }

    .objective-grid,
    .button-row {
        gap: 0.55rem;
    }

    .bottom-drawer .panel {
        padding: 0.75rem;
    }

    .panel-header h2 {
        font-size: 1rem;
    }
}

@media (max-width: 380px) {
    .top-hud {
        grid-template-columns: 1fr;
    }

    .top-hud .hud-chip:last-child {
        justify-self: start;
        max-width: 190px;
    }

    .objective-grid,
    .button-row,
    .split-inputs {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .bottom-drawer {
        right: auto;
        width: min(420px, calc(100vw - 1.5rem));
    }

    .bottom-drawer.drawer-expanded .drawer-content {
        max-height: calc(100dvh - 8rem);
    }

    .floating-map-button {
        bottom: calc(var(--safe-bottom) + 0.85rem);
    }

    .admin-topbar {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-span-two {
        grid-column: span 2;
    }

    .photo-gallery {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1100px) {
    .admin-shell {
        padding: 1.1rem;
    }

    .admin-map {
        height: 50dvh;
    }

    .photo-gallery {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =========================================================
   MOBILE FIT + SCROLL FIX
   Add this at the very bottom of static/css/styles.css
   ========================================================= */

/* Let normal pages scroll properly */
html,
body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Use dynamic viewport height for mobile browsers like iPhone Chrome */
.screen-centre {
    min-height: 100dvh;
    padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
}

/* Admin pages must scroll normally */
.admin-body {
    overflow-y: auto;
}

.admin-shell {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
    padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(1rem, env(safe-area-inset-bottom));
}

.admin-content,
.admin-grid {
    min-width: 0;
    overflow: visible;
}

/* Make admin cards fit phones better */
.admin-grid {
    grid-template-columns: 1fr;
}

.admin-grid .panel,
.map-panel {
    min-width: 0;
    padding: 0.85rem;
    border-radius: 18px;
}

.admin-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.75rem;
}

.admin-topbar .brand-lockup {
    margin-bottom: 0;
}

.topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.topbar-actions .button,
.topbar-actions form,
.topbar-actions form .button {
    width: 100%;
}

/* Make the admin map usable without consuming the whole phone screen */
.admin-map {
    height: 42dvh;
    min-height: 260px;
    max-height: 420px;
    border-radius: 16px;
}

/* Prevent headings and legends from forcing overflow */
.panel-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

.panel-header h2 {
    font-size: 1.1rem;
}

.panel-header p {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    line-height: 1.35;
}

.legend-inline {
    gap: 0.55rem;
    font-size: 0.78rem;
}

/* Tables should scroll horizontally inside their card, not break the page */
.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    min-width: 460px;
}

/* Route builder rows were too wide for mobile */
.route-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.split-inputs {
    grid-template-columns: 1fr;
}

/* Photo gallery should be single-column on small phones */
.photo-gallery {
    grid-template-columns: 1fr;
}

/* Team app uses a fixed map layout, but should fit dynamic mobile viewport */
.team-app {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
}

#teamMapView {
    height: 100dvh;
}

/* Top HUD was too wide/tall on iPhone */
.top-hud {
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    left: 0.5rem;
    right: 0.5rem;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.hud-chip {
    min-height: 46px;
    padding: 0.55rem 0.65rem;
    border-radius: 14px;
}

.brand-chip-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.chip-label {
    font-size: 0.65rem;
}

.chip-value {
    font-size: 0.86rem;
}

/* Drawer should never fill the whole screen */
.bottom-drawer {
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 0.55rem calc(env(safe-area-inset-bottom, 0px) + 0.55rem);
}

.drawer-toggle-button {
    min-height: 42px;
    border-radius: 16px 16px 0 0;
    padding: 0.45rem 0.75rem;
}

.drawer-toggle-label {
    font-size: 0.68rem;
}

.drawer-handle {
    width: 44px;
    height: 4px;
}

.drawer-content {
    max-height: min(58dvh, 520px);
    gap: 0.65rem;
    padding-top: 0.55rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.bottom-drawer.drawer-expanded .drawer-content {
    max-height: min(58dvh, 520px);
}

.bottom-drawer.drawer-collapsed .drawer-content {
    max-height: 0;
}

/* Team drawer cards need to be tighter on phones */
.bottom-drawer .panel {
    padding: 0.8rem;
    border-radius: 16px;
}

.objective-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.objective-metric,
.objective-description-wrap {
    padding: 0.75rem;
    border-radius: 14px;
}

.objective-value {
    font-size: 0.95rem;
}

.objective-description {
    font-size: 0.92rem;
    line-height: 1.4;
}

.button-row {
    gap: 0.55rem;
}

.button {
    padding: 0.75rem 0.8rem;
    border-radius: 12px;
}

/* Keep locate button above the closed drawer */
.floating-map-button {
    right: 0.75rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 4.5rem);
    width: 46px;
    height: 46px;
}

/* Toast should not collide with iPhone address bar/HUD */
.toast {
    top: calc(env(safe-area-inset-top, 0px) + 6.7rem);
    left: 0.55rem;
    right: 0.55rem;
    padding: 0.75rem 0.85rem;
    border-radius: 14px;
}

/* Slightly larger layout only when there is room */
@media (min-width: 768px) {
    .admin-shell {
        padding: 1rem;
    }

    .admin-topbar {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-span-two {
        grid-column: span 2;
    }

    .split-inputs {
        grid-template-columns: 1fr 1fr;
    }

    .route-row {
        grid-template-columns: 1fr 110px auto;
    }

    .photo-gallery {
        grid-template-columns: repeat(3, 1fr);
    }

    .top-hud {
        grid-template-columns: 1fr auto;
        left: 0.75rem;
        right: 0.75rem;
    }

    .bottom-drawer {
        right: auto;
        width: min(430px, calc(100vw - 1.5rem));
        padding-left: 0.75rem;
    }

    .bottom-drawer.drawer-expanded .drawer-content {
        max-height: calc(100dvh - 8rem);
    }
}

/* =========================================================
   HARD ADMIN SCROLL FIX
   Makes the admin page scroll inside .admin-shell instead
   of relying on body/html scrolling.
   Put this at the VERY BOTTOM of styles.css.
   ========================================================= */

body.admin-body {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}

/* This becomes the scrolling container */
body.admin-body .admin-shell {
    position: fixed !important;
    inset: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(2rem, env(safe-area-inset-bottom)) !important;
}

/* Force the content to be taller than the viewport when needed */
body.admin-body .admin-content,
body.admin-body .admin-grid {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
}

/* Ensure panels don't become their own trapped layout */
body.admin-body .panel,
body.admin-body .map-panel,
body.admin-body .admin-grid .panel {
    height: auto !important;
    overflow: visible !important;
    min-width: 0 !important;
}

/* Keep the map compact on phones */
body.admin-body .admin-map,
body.admin-body #adminMapView {
    height: 220px !important;
    min-height: 220px !important;
    max-height: 220px !important;
}

/* On phones, make the map display-only so swipes scroll the dashboard */
@media (max-width: 767px) {
   

    body.admin-body .admin-topbar {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        position: relative !important;
    }

    body.admin-body .topbar-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.55rem !important;
    }

    body.admin-body .admin-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    body.admin-body .admin-span-two {
        grid-column: span 1 !important;
    }

    body.admin-body .panel-header {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.55rem !important;
    }

    body.admin-body .split-inputs,
    body.admin-body .route-row,
    body.admin-body .photo-gallery {
        grid-template-columns: 1fr !important;
    }

    body.admin-body .table-wrap {
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    body.admin-body .data-table {
        min-width: 460px !important;
    }
}

/* Desktop/tablet can keep the map interactive */
@media (min-width: 768px) {
    body.admin-body .admin-map .esri-view-root,
    body.admin-body .admin-map .esri-view-surface,
    body.admin-body .admin-map canvas {
        pointer-events: auto !important;
    }
}

/* =========================================================
   ADMIN PHOTO VIEWER MODAL
   ========================================================= */

.photo-card {
    cursor: pointer;
}

.photo-card img {
    transition: transform 160ms ease, filter 160ms ease;
}

.photo-card:hover img {
    transform: scale(1.02);
    filter: brightness(1.08);
}

.photo-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(14px);
}

.photo-viewer-modal.hidden {
    display: none !important;
}

.photo-viewer-content {
    width: min(1100px, 100%);
    max-height: 92dvh;
    display: grid;
    gap: 0.85rem;
    justify-items: center;
}

.photo-viewer-content img {
    max-width: 100%;
    max-height: 82dvh;
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
    background: #020617;
}

.photo-viewer-caption {
    width: min(900px, 100%);
    color: #e5e7eb;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
}

.photo-viewer-close-button {
    position: fixed;
    top: max(0.8rem, env(safe-area-inset-top));
    right: max(0.8rem, env(safe-area-inset-right));
    z-index: 10000;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    color: #f8fafc;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.photo-viewer-close-button:hover {
    background: rgba(30, 41, 59, 0.96);
}