html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", system-ui, sans-serif;
}

#myMap {
    width: 100%;
    height: 100vh;
}

/* --- Block info panel --- */
.info-panel {
    position: absolute;
    top: 60px;
    right: 12px;
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    max-width: 340px;
    z-index: 1000;
}

.info-panel.hidden {
    display: none;
}

.info-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.info-panel h3 {
    margin: 0;
    color: #2E4057;
    font-size: 18px;
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.info-panel table {
    width: 100%;
    border-collapse: collapse;
}

.info-panel td {
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.info-panel td:first-child {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.info-panel tr.info-section td {
    font-weight: 700;
    color: #2E4057;
    padding-top: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #ddd;
}

.info-panel-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.info-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: #2E4057;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.info-icon-btn:hover {
    background: #eef1f5;
}

.info-icon-btn svg {
    fill: currentColor;
}

.info-open-block-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 8px 12px;
    background: #2E4057;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.info-open-block-btn:hover {
    background: #3d5470;
}

.info-open-block-btn.hidden {
    display: none;
}

/* --- Coordinate display --- */
/* Coordinates readout tracks the mouse — meaningless on touch devices. */
@media (hover: none) {
    .coords-display { display: none; }
}

.coords-display {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-family: "Consolas", "Courier New", monospace;
    z-index: 1000;
    pointer-events: none;
}

/* --- Project-overview legends (stacked just above the coords display).
       The container owns positioning; each legend card keeps only its visual
       styling so heli pads + progress stack without overlapping. --- */
.overview-legends {
    position: absolute;
    bottom: 64px;
    left: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    z-index: 1000;
    pointer-events: none;
}

.overview-progress-legend {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    font-size: 12px;
    pointer-events: none;
}

.overview-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #333;
}

.overview-legend-chip {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.25);
}

/* Round variant for point markers (heli pads). */
.overview-legend-chip-round {
    border-radius: 50%;
}

/* --- Application header --- */
.app-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #000;
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 1002;
    box-sizing: border-box;
}

.app-header-logo {
    height: 32px;
    width: auto;
    display: block;
}

.app-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-header-version {
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    white-space: nowrap;
    font-family: "Consolas", "Courier New", monospace;
}

/* Map controls panel removed — replaced by header mega-menu (header-menu.css) */

/* --- Popup tooltip --- */
.popup-content {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
}

/* --- Cutblock identify popup --- */
.popup-identify {
    white-space: normal;
    min-width: 200px;
    max-width: 280px;
}

.popup-identify strong {
    font-size: 15px;
    color: #2E4057;
    display: block;
    margin-bottom: 6px;
}

.popup-identify table {
    width: 100%;
    border-collapse: collapse;
}

.popup-identify td {
    padding: 3px 6px;
    font-size: 12px;
    border-bottom: 1px solid #eee;
}

.popup-identify td:first-child {
    font-weight: 600;
    color: #666;
    white-space: nowrap;
    width: 70px;
}

/* --- Login screen --- */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a3a2a 0%, #2E4057 100%);
}

.login-card {
    background: #fff;
    padding: 48px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
}

.login-card h1 {
    margin: 0 0 12px 0;
    color: #2E4057;
    font-size: 24px;
}

.login-card p {
    margin: 0 0 24px 0;
    color: #666;
    font-size: 14px;
}

.login-btn {
    display: inline-block;
    padding: 12px 32px;
    background: #0078d4;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: #106ebe;
}

.login-error {
    margin-top: 16px;
    color: #d32f2f;
    font-size: 13px;
}

/* The logo's wordmark is cream (designed for the black header) — give it a
   dark backing chip so it reads on the white card. */
.login-logo {
    height: 52px;
    padding: 12px 20px;
    background: #111;
    border-radius: 8px;
    margin-bottom: 20px;
}

.login-card .login-help {
    margin: 20px 0 0 0;
    color: #999;
    font-size: 12px;
}

/* One-time-code note under the sign-in button — quiet, but readable enough
   for a first-time guest who has never had a Microsoft account. */
.login-card .login-hint {
    margin: 12px auto 0;
    max-width: 300px;
    color: #666;
    font-size: 12px;
    line-height: 1.5;
}

/* --- User bar (inside app header) --- */
.user-bar {
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-bar.hidden {
    display: none;
}

.user-role {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.user-role:empty {
    display: none;
}

.signout-btn {
    padding: 4px 10px;
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.signout-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- Loading overlay --- */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 900;
    font-size: 1.1rem;
    color: #555;
    font-weight: 500;
}

.loading-overlay.hidden {
    display: none;
}

/* --- Progress panel (drawing controls — triggered from Progress mega-panel) --- */
.progress-panel {
    position: absolute;
    top: 60px;
    left: 12px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    width: 280px;
    font-size: 13px;
    transform: translateX(-20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.progress-panel.hidden {
    display: none;
}

.progress-panel.visible {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.progress-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-weight: 600;
    color: #2E4057;
    border-bottom: 1px solid #e0e0e0;
}

.progress-panel-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0 4px;
}

.progress-panel-close:hover {
    color: #333;
}

.progress-panel-body {
    padding: 10px 14px;
}

/* --- Activity rows --- */
.progress-activity-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-radius: 4px;
    transition: background 0.15s;
}

.progress-activity-row.active {
    background: #e8f0fe;
}

.progress-pencil-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, background 0.15s;
}

.progress-pencil-btn:hover {
    border-color: #888;
    background: #f5f5f5;
}

.progress-activity-row.active .progress-pencil-btn {
    border-color: #1a73e8;
    background: #e8f0fe;
}

.pencil-icon {
    fill: currentColor;
}

.progress-activity-label {
    font-weight: 500;
    color: #333;
}

.progress-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ccc;
    cursor: pointer;
}

.progress-color-input {
    width: 0;
    height: 0;
    padding: 0;
    border: none;
    opacity: 0;
    position: absolute;
}

/* --- Color confirm/cancel icons --- */
.color-actions {
    display: inline-flex;
    gap: 2px;
    align-items: center;
}

.color-actions.hidden {
    display: none;
}

.color-confirm,
.color-cancel {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 1px 3px;
    color: #555;
}

.color-confirm:hover {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.color-cancel:hover {
    background: #fde8e8;
    border-color: #d32f2f;
    color: #d32f2f;
}

/* --- Save / Cancel actions --- */
.progress-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    margin-top: 8px;
}

/* One-line coaching text under Save/Cancel (split / back-edge feature) */
.progress-hint {
    flex-basis: 100%;
    font-size: 11px;
    color: #666;
    line-height: 1.35;
}

.progress-save-btn {
    flex: 1;
    padding: 6px 12px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.progress-save-btn:hover {
    background: #1557b0;
}

.progress-cancel-btn {
    flex: 1;
    padding: 6px 12px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.progress-cancel-btn:hover {
    background: #e8e8e8;
}

/* --- History section --- */
.progress-history-section {
    border-top: 1px solid #e0e0e0;
}

.progress-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 500;
    color: #555;
    user-select: none;
}

.progress-history-header:hover {
    background: #f9f9f9;
}

.history-toggle {
    font-size: 10px;
    transition: transform 0.2s;
}

.history-toggle.open {
    transform: rotate(180deg);
}

.progress-history {
    padding: 0 14px 10px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.progress-history table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

/* Column widths: Date | Activity | Ha | % | Delete icon */
.progress-history th:nth-child(1),
.progress-history td:nth-child(1) { width: 30%; }
.progress-history th:nth-child(2),
.progress-history td:nth-child(2) { width: 28%; padding-right: 6px; }
.progress-history th:nth-child(3),
.progress-history td:nth-child(3) { width: 18%; }
.progress-history th:nth-child(4),
.progress-history td:nth-child(4) { width: 16%; }
.progress-history th:nth-child(5),
.progress-history td:nth-child(5) { width: 8%; text-align: center; }

.progress-history th {
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid #ddd;
    color: #666;
    font-weight: 600;
}

.progress-history td {
    padding: 4px 6px;
    border-bottom: 1px solid #eee;
}

.progress-history-empty {
    color: #999;
    font-size: 12px;
    font-style: italic;
    padding: 8px 0;
}

.progress-history .delete-btn {
    background: none;
    border: none;
    color: #d32f2f;
    cursor: pointer;
    padding: 2px 4px;
    display: inline-flex;
    align-items: center;
    border-radius: 3px;
}

.progress-history .delete-btn:hover {
    background: #fde8e8;
}

/* --- Inline activity stats (Ha + %) --- */
.progress-activity-stats {
    font-size: 11px;
    color: #666;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-left: auto;
}

/* --- Drawing mode area info --- */
.progress-area-display {
    position: absolute;
    bottom: 50px;
    left: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-family: "Consolas", "Courier New", monospace;
    z-index: 1000;
    pointer-events: none;
}

.progress-area-display.hidden {
    display: none;
}

/* --- Generic hidden class --- */
.hidden {
    display: none !important;
}

/* --- Worker safety hazards --- */
.hazard-edit-btn {
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 12px;
    background: #c62828;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.hazard-edit-btn:hover {
    background: #a31515;
}

.hazards-toolbar {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.hazards-toolbar-title {
    font-weight: 600;
    color: #ff8a80;
}
.hazards-toolbar button {
    padding: 4px 12px;
    font-size: 12px;
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
}
.hazards-toolbar button:hover {
    background: #444;
}
.hazards-toolbar button.active {
    background: #c62828;
    border-color: #c62828;
}
.hazards-toolbar-done {
    margin-left: 4px;
}
.hazards-toolbar-hint {
    flex-basis: 100%;
    font-size: 11px;
    color: #ccc;
    text-align: center;
}

/* --- View Options: 3D / AR modal overlay --- */
.vo-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;   /* above the header (1002) and mega-panels (1100) */
    display: flex;
    align-items: center;
    justify-content: center;
}

.vo-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.vo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    font-weight: 600;
    color: #2E4057;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}

.vo-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vo-fullscreen-link {
    color: #1a73e8;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.vo-fullscreen-link:hover {
    text-decoration: underline;
}

.vo-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0 2px;
}

.vo-close:hover {
    color: #000;
}

.vo-modal-3d {
    width: min(92vw, 1100px);
    height: min(88vh, 820px);
}

.vo-modal-3d .vo-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.vo-3d-frame {
    flex: 1;
    width: 100%;
    border: 0;
}

.vo-modal-ar {
    width: min(92vw, 400px);
}

.vo-modal-ar .vo-modal-body {
    padding: 14px;
}

.vo-status {
    padding: 24px 14px;
    text-align: center;
    color: #777;
    font-size: 13px;
}

.vo-ar-buttons {
    display: flex;
    gap: 8px;
}

.vo-ar-buttons button {
    flex: 1;
    padding: 8px 10px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    font-family: "Segoe UI", system-ui, sans-serif;
}

.vo-ar-buttons button:hover:not(:disabled) {
    background: #e8e8e8;
}

.vo-ar-buttons button.active {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
    font-weight: 600;
}

.vo-ar-buttons button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.vo-qr-wrap {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 16px auto 4px;
}

.vo-qr-code,
.vo-qr-code svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* White backing pad guarantees scan contrast behind the platform icon */
.vo-qr-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    background: #fff;
    border-radius: 10px;
    padding: 6px;
    box-sizing: border-box;
    box-shadow: 0 0 0 1px #e0e0e0;
}

.vo-qr-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.vo-qr-hint {
    margin: 8px 0 2px;
    text-align: center;
    color: #777;
    font-size: 12px;
}

@media (max-width: 640px) {
    .vo-modal-3d {
        width: 96vw;
        height: 90vh;
    }
}
