:root {
    --fsm-navy: #062f5f;
    --fsm-blue: #1466d8;
    --fsm-blue-dark: #0d54b8;
    --fsm-blue-soft: #edf4ff;
    --fsm-border: #d9e1eb;
    --fsm-muted: #66778a;
    --fsm-surface: #ffffff;
    --fsm-page: #f4f7fb;
    --fsm-radius: 10px;
    --fsm-shadow: 0 8px 24px rgba(15, 38, 68, 0.06);
}

body {
    background: var(--fsm-page);
    color: #172536;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.app-shell {
    max-width: 1540px;
    padding-left: clamp(1rem, 2vw, 2rem);
    padding-right: clamp(1rem, 2vw, 2rem);
}

.app-navbar {
    background: var(--fsm-navy) !important;
    box-shadow: 0 2px 14px rgba(15, 23, 42, 0.1);
    min-height: 68px;
}

.app-navbar .navbar-brand {
    font-size: 1.18rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    margin-right: clamp(1.5rem, 4vw, 4rem);
}

.ui-icon {
    flex: 0 0 auto;
    height: 20px;
    width: 20px;
}

.app-nav-links {
    gap: 0.35rem;
}

.app-nav-links .nav-link {
    align-items: center;
    border-bottom: 2px solid transparent;
    color: rgba(255, 255, 255, 0.78);
    display: flex;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 0.55rem;
    margin-bottom: -0.5rem;
    padding: 1.05rem 0.9rem 0.95rem;
}

.app-nav-links .nav-link:hover,
.app-nav-links .nav-link:focus-visible {
    color: #fff;
}

.app-nav-links .nav-link.active {
    border-bottom-color: #8cbcff;
    color: #fff;
}

.app-user-menu,
.app-user-identity,
.app-logout-link {
    align-items: center;
    display: flex;
}

.app-user-menu {
    color: #fff;
    gap: 1.25rem;
}

.app-user-identity {
    font-size: 0.86rem;
    gap: 0.55rem;
}

.app-user-identity small {
    color: rgba(255, 255, 255, 0.68);
    font-size: inherit;
}

.app-logout-link {
    border-left: 1px solid rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.86rem;
    font-weight: 600;
    gap: 0.45rem;
    padding-left: 1.25rem;
    text-decoration: none;
}

.app-logout-link:hover {
    color: #fff;
}

.app-main {
    min-height: calc(100vh - 132px);
    padding-top: clamp(1.25rem, 2.2vw, 2.15rem);
}

.app-footer {
    color: #7a899a;
    font-size: 0.78rem;
    padding: 0 0 1.5rem;
    text-align: center;
}

.card {
    border: 1px solid var(--fsm-border);
    border-radius: var(--fsm-radius);
    box-shadow: var(--fsm-shadow) !important;
}

.card-body {
    padding: clamp(1rem, 1.6vw, 1.5rem);
}

.form-label {
    color: #33475b;
    font-size: 0.82rem;
    font-weight: 650;
    margin-bottom: 0.4rem;
}

.form-control,
.form-select,
.btn {
    border-radius: 8px;
    min-height: 42px;
}

.form-control,
.form-select {
    border-color: #cfd9e5;
}

.btn {
    align-items: center;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 650;
    justify-content: center;
    padding-left: 1rem;
    padding-right: 1rem;
}

.btn-sm {
    font-size: 0.78rem;
    min-height: 34px;
    padding: 0.35rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--fsm-blue);
    box-shadow: 0 0 0 0.2rem rgba(8, 120, 201, 0.14);
}

.btn-primary {
    background: var(--fsm-blue);
    border-color: var(--fsm-blue);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--fsm-blue-dark);
    border-color: var(--fsm-blue-dark);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f7faff;
    color: #2c3b4c;
    font-size: 0.86rem;
}

.table > :not(caption) > * > * {
    border-bottom-color: #e2e8f0;
    padding: 0.78rem 0.9rem;
}

.table thead th {
    background: #f7f9fc;
    color: #58697c;
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.alert {
    border-radius: var(--fsm-radius);
}

.dashboard-surface {
    background: var(--fsm-surface);
    border: 1px solid var(--fsm-border);
    border-radius: 12px;
    box-shadow: var(--fsm-shadow);
    padding: clamp(1.1rem, 2.2vw, 2rem);
}

.dashboard-heading {
    align-items: flex-start;
    display: flex;
    gap: 2rem;
    justify-content: space-between;
}

.dashboard-heading h1 {
    color: #17212d;
    font-size: clamp(1.65rem, 2.6vw, 2.35rem);
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1.12;
    margin: 0 0 0.55rem;
}

.dashboard-heading p {
    color: var(--fsm-muted);
    margin: 0;
    max-width: 760px;
}

.dashboard-heading-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.dashboard-stats {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 1.5rem;
}

.dashboard-stat {
    align-items: center;
    border: 1px solid var(--fsm-border);
    border-radius: 10px;
    display: flex;
    gap: 1rem;
    min-height: 100px;
    padding: 1rem 1.2rem;
}

.dashboard-stat-icon {
    align-items: center;
    background: var(--fsm-blue-soft);
    border-radius: 50%;
    color: var(--fsm-blue);
    display: flex;
    height: 54px;
    justify-content: center;
    width: 54px;
}

.dashboard-stat-icon svg {
    height: 27px;
    width: 27px;
}

.dashboard-stat-points .dashboard-stat-icon {
    background: #eaf7ee;
    color: #198754;
}

.dashboard-stat-measurements .dashboard-stat-icon {
    background: #f1efff;
    color: #564fc7;
}

.dashboard-stat small,
.dashboard-stat strong {
    display: block;
}

.dashboard-stat small {
    color: #536274;
    font-size: 0.85rem;
    margin-bottom: 0.1rem;
}

.dashboard-stat strong {
    color: var(--fsm-blue);
    font-size: 1.75rem;
    line-height: 1.1;
}

.dashboard-workflow {
    align-items: center;
    border: 1px solid var(--fsm-border);
    border-radius: 10px;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
}

.dashboard-workflow-step {
    align-items: center;
    display: flex;
    gap: 0.85rem;
}

.dashboard-workflow-step > span {
    align-items: center;
    border: 2px solid var(--fsm-blue);
    border-radius: 50%;
    color: var(--fsm-blue);
    display: flex;
    flex: 0 0 auto;
    font-size: 1rem;
    font-weight: 750;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.dashboard-workflow-step strong,
.dashboard-workflow-step small {
    display: block;
}

.dashboard-workflow-step strong {
    font-size: 0.92rem;
}

.dashboard-workflow-step small {
    color: var(--fsm-muted);
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

.dashboard-workflow-divider {
    border-right: 2px solid #bdc7d3;
    border-top: 2px solid #bdc7d3;
    height: 12px;
    transform: rotate(45deg);
    width: 12px;
}

.dashboard-projects {
    border: 1px solid var(--fsm-border);
    border-radius: 10px;
    margin-top: 1.5rem;
    overflow: hidden;
}

.dashboard-section-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: 0.95rem 1.2rem;
}

.dashboard-section-heading h2 {
    font-size: 1.05rem;
    font-weight: 750;
    margin: 0;
}

.dashboard-section-heading a {
    color: var(--fsm-blue);
    font-size: 0.8rem;
    font-weight: 650;
    text-decoration: none;
}

.dashboard-project-table thead th {
    text-transform: none;
}

.dashboard-project-table td:first-child {
    min-width: 220px;
}

.dashboard-project-table td:last-child {
    min-width: 155px;
}

.dashboard-project-name,
.dashboard-project-table td small {
    display: block;
}

.dashboard-project-name {
    color: var(--fsm-blue-dark);
    font-weight: 650;
    text-decoration: none;
}

.dashboard-project-table td small {
    color: #8190a0;
    font-size: 0.69rem;
    margin-top: 0.15rem;
}

.dashboard-progress {
    align-items: center;
    display: flex;
    gap: 0.55rem;
    min-width: 130px;
}

.dashboard-progress > span {
    color: #526173;
    font-size: 0.75rem;
    width: 34px;
}

.dashboard-progress > div {
    background: #e7ebf0;
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    width: 92px;
}

.dashboard-progress i {
    background: #45a348;
    border-radius: inherit;
    display: block;
    height: 100%;
}

.dashboard-status {
    align-items: center;
    color: #4a596a;
    display: inline-flex;
    font-size: 0.76rem;
    gap: 0.45rem;
    white-space: nowrap;
}

.dashboard-status i {
    background: #f59e0b;
    border-radius: 50%;
    height: 8px;
    width: 8px;
}

.dashboard-status.is-ready i {
    background: #35a853;
}

.dashboard-empty {
    color: var(--fsm-muted);
    margin: 0;
    padding: 1rem 1.2rem;
}

.channel-card[data-channel="main"] {
    border-top: 3px solid var(--fsm-blue);
}

.channel-card [hidden] {
    display: none !important;
}

.sinpo-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.sinpo-control {
    border: 0;
    min-width: 0;
    padding: 0;
}

.sinpo-control legend {
    color: #33475b;
    float: none;
    font-size: 0.76rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
    width: auto;
}

.sinpo-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.sinpo-options label {
    cursor: pointer;
    margin-left: -1px;
    min-width: 0;
}

.sinpo-options input {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.sinpo-options span {
    align-items: center;
    background: #fff;
    border: 1px solid var(--fsm-border);
    color: #33475b;
    display: flex;
    font-weight: 700;
    justify-content: center;
    min-height: 38px;
}

.sinpo-options label:first-child span {
    border-radius: 6px 0 0 6px;
}

.sinpo-options label:last-child span {
    border-radius: 0 6px 6px 0;
}

.sinpo-options input:checked + span {
    background: var(--fsm-blue);
    border-color: var(--fsm-blue);
    color: #fff;
    position: relative;
    z-index: 1;
}

.sinpo-options input:focus-visible + span {
    box-shadow: 0 0 0 3px rgba(8, 120, 201, 0.2);
    position: relative;
    z-index: 2;
}

.sinpo-control small {
    color: var(--fsm-muted);
    display: block;
    font-size: 0.7rem;
    margin-top: 0.35rem;
    min-height: 1rem;
}

form[data-submitting="true"] button[type="submit"] {
    opacity: 0.7;
    pointer-events: none;
}

.table td,
.table th {
    vertical-align: middle;
}

.stat-card {
    border-left: 4px solid #0d6efd;
}

.workflow-step {
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 0.9rem;
    background: #f9fafb;
}

.workflow-step.active {
    border-color: #0d6efd;
    background: #eff6ff;
}

.mobile-sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 1020;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #dee2e6;
    padding: 0.75rem;
}

@media (max-width: 991.98px) {
    .app-navbar {
        min-height: 60px;
    }

    .app-nav-links .nav-link {
        border-bottom: 0;
        margin: 0;
        padding: 0.7rem 0;
    }

    .app-user-menu {
        align-items: flex-start;
        border-top: 1px solid rgba(255, 255, 255, 0.18);
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem 0;
    }

    .app-logout-link {
        border-left: 0;
        padding-left: 0;
    }

    .dashboard-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .dashboard-heading-actions {
        padding: 0;
    }

    .dashboard-stats {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-workflow {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .dashboard-workflow-divider {
        border-bottom: 2px solid #bdc7d3;
        border-right: 0;
        border-top: 0;
        height: 1px;
        margin-left: 20px;
        transform: none;
        width: 32px;
    }

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

@media (max-width: 575.98px) {
    main.container-fluid,
    .app-shell {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .dashboard-surface {
        border-radius: 9px;
        padding: 1rem;
    }

    .dashboard-heading-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .dashboard-stat {
        min-height: 84px;
    }

    .dashboard-section-heading {
        padding: 0.85rem 1rem;
    }

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

    .sinpo-options span {
        min-height: 44px;
    }

    .mobile-sticky-actions {
        border-radius: 0 !important;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }

    .next-point-link {
        display: none;
    }

    .point-navigator-list {
        max-height: 310px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.marker-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}

.marker-green { background: #198754; }
.marker-yellow { background: #ffc107; }
.marker-orange { background: #fd7e14; }
.marker-red { background: #dc3545; }
.marker-grey { background: #6c757d; }

.leaflet-map {
    aspect-ratio: 4 / 3;
    min-height: 320px;
    width: 100%;
}

#reportMap.leaflet-map {
    aspect-ratio: auto;
    height: min(70vh, 680px);
    min-height: 260px;
    max-height: 680px;
}

.map-point-label-wrapper {
    background: transparent;
    border: 0;
}

.map-point-label {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.45);
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
    color: #111827;
    display: block;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    min-width: 18px;
    pointer-events: none;
    padding: 2px 5px;
    text-align: center;
    white-space: nowrap;
}

.map-point-label-no {
    display: block;
    font-weight: 700;
    text-align: center;
}

.map-point-label.is-interactive {
    cursor: pointer;
    pointer-events: auto;
}

.fsm-point-marker {
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.7));
    stroke-linejoin: round;
}

.print-map-container {
    display: none;
}

.print-map-container img {
    display: block;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    width: 100%;
}

.map-export-container {
    background: #fff;
    height: 900px;
    left: -10000px;
    overflow: hidden;
    pointer-events: none;
    position: fixed;
    top: 0;
    width: 1600px;
    z-index: -1;
}

.report-table {
    font-size: 11px;
}

.report-table td,
.report-table th {
    padding: 0.3rem;
}

/* Agency-approved report layout classes */
.agency-report {
    border-radius: 0;
}

.agency-heading {
    font-size: 13px;
    font-weight: 700;
    border-bottom: 1px solid #111;
}

.agency-meta-left,
.agency-meta-right,
.agency-main-table {
    font-size: 11px;
    margin-bottom: 0;
}

.agency-meta-left th,
.agency-meta-right th,
.agency-main-table th,
.agency-main-table td {
    border: 1px solid #1f1f1f !important;
    padding: 2px 4px !important;
    line-height: 1.1;
}

.agency-meta-left th,
.agency-meta-right th {
    width: 38%;
    background: #efefef !important;
    font-weight: 700;
}

.agency-meta-left td,
.agency-meta-right td {
    background: #fff !important;
    font-weight: 600;
}

.agency-main-table thead tr:first-child th {
    background: #9ec9d6 !important;
    text-align: center;
    vertical-align: middle;
    font-weight: 700;
}

.agency-main-table thead tr:first-child th:nth-child(n+9) {
    background: #b6cb8a !important;
}

.agency-main-table thead tr:nth-child(2) th {
    background: #d8e5c0 !important;
    text-align: center;
    vertical-align: middle;
    font-weight: 700;
    font-size: 10px;
}

.agency-main-table tbody td {
    background: #fff !important;
    vertical-align: middle;
}

/* Proportional report columns: descriptive fields get room, compact values stay compact. */
.agency-main-table .col-point { width: 3%; }
.agency-main-table .col-location { width: 9%; }
.agency-main-table .col-coordinate { width: 8%; }
.agency-main-table .col-amsl,
.agency-main-table .col-bearing { width: 2.75%; }
.agency-main-table .col-distance,
.agency-main-table .col-weather { width: 3.5%; }
.agency-main-table .col-strength { width: 3.75%; }
.agency-main-table .col-datetime { width: 5.75%; }
.agency-main-table .col-sinpo { width: 1.2%; }
.agency-main-table .col-remarks { width: 5%; }
.agency-main-table .col-frequency { width: 3.25%; }
.agency-main-table .col-station,
.agency-main-table .col-from-location { width: 4.25%; }

.agency-main-table .agency-unit {
    font-size: inherit;
    font-weight: 400;
}

.agency-main-table td.text-center,
.agency-main-table th {
    text-align: center;
}

.agency-signoff {
    font-size: 11px;
}

.agency-signoff-label {
    font-size: 11px;
    font-weight: 600;
}

.agency-signoff-name {
    font-size: 11px;
    margin-top: 0.3rem;
    font-weight: 600;
}

.evidence-photo {
    aspect-ratio: 4 / 3;
    background: #eef2f6;
    object-fit: contain;
    width: 100%;
}

.print-only {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 6mm;
    }

    body {
        background: #fff;
        color: #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-hidden {
        display: none !important;
    }

    .print-only {
        display: block;
    }

    #reportMap {
        display: none !important;
    }

    .print-map-container {
        display: block !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }

    .table-responsive,
    .report-table-wrap {
        overflow: visible !important;
    }

    .table thead {
        display: table-header-group;
    }

    .report-table {
        width: 100% !important;
        table-layout: fixed;
        font-size: 8px !important;
    }

    .report-table td,
    .report-table th {
        padding: 1px 2px !important;
        white-space: normal;
        word-break: break-word;
    }

    .agency-report {
        width: 100%;
    }

    .agency-heading {
        font-size: 9.5px;
    }

    .agency-meta-left,
    .agency-meta-right {
        font-size: 7.5px !important;
    }

    .agency-main-table {
        font-size: 7px !important;
    }

    .agency-main-table {
        table-layout: fixed;
        width: 100%;
    }

    .agency-main-table thead tr:nth-child(2) th {
        font-size: 6px !important;
        line-height: 1.08;
    }

    .agency-main-table thead tr:first-child th {
        font-size: 6px !important;
        font-weight: 500;
        line-height: 1.08;
    }

    .agency-main-table th,
    .agency-main-table td,
    .agency-meta-left th,
    .agency-meta-left td,
    .agency-meta-right th,
    .agency-meta-right td {
        padding: 1px 2px !important;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.08;
    }

    .agency-main-table th {
        font-weight: 500;
        word-break: normal;
        overflow-wrap: normal;
        hyphens: none;
    }

    .agency-main-table tbody td {
        word-break: normal;
        overflow-wrap: anywhere;
    }

    .agency-signoff,
    .agency-signoff-label,
    .agency-signoff-name {
        font-size: 7.5px !important;
        line-height: 1.15;
    }

    .print-map-container img {
        max-height: 150mm;
    }

    .evidence-photo {
        max-height: 55mm;
    }

    tr,
    td,
    th {
        page-break-inside: avoid;
    }

    .page-break {
        page-break-before: always;
    }
}
