:root {
    --navy: #0f172a;
    --navy-2: #111827;
    --blue: #2563eb;
    --blue-2: #60a5fa;
    --slate: #475569;
    --muted: #64748b;
    --light: #f8fafc;
    --line: #dbe2ea;
    --row: #f3f6f9;
    --yellow: #fde68a;
    --amber: #f59e0b;
    --green: #34d399;
    --white: #ffffff;
    --shadow: 0 22px 55px rgba(15, 23, 42, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--light);
    color: var(--navy);
    padding-bottom: 40px;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font-family: inherit;
}

button,
input,
label,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    -webkit-appearance: none;
    appearance: none;
}

input {
    -webkit-appearance: none;
    appearance: none;
}

input[type="file"] {
    appearance: auto;
    -webkit-appearance: auto;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   UNIFIED HEADER NAVIGATION SYSTEM
   ============================================================================ */
.site-header {
    background-color: var(--navy-2);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1320px;
    margin: 0 auto;
    padding: 16px 24px;
    position: relative;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--white);
    min-width: 0;
}

.nav-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--white);
    padding: 4px;
    flex: 0 0 auto;
}

.brand-text {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: #e2e8f0;
    overflow-wrap: anywhere;
}

.brand-text strong {
    color: var(--blue-2);
    font-weight: 700;
}

.nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 24px;
}

.nav-links a {
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible,
.nav-links .portal-link {
    color: var(--white);
}

.nav-links .portal-link {
    border-bottom: 2px solid var(--blue-2);
    padding-bottom: 4px;
}

/* Status Pill Setup */
.status-item {
    display: flex;
    align-items: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(52, 211, 153, 0.2);
    background: rgba(52, 211, 153, 0.1);
    border-radius: 6px;
    padding: 6px 12px;
    color: #6ee7b7;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    margin-right: 8px;
    flex: 0 0 auto;
}

/* Mobile Toggle Switch */
.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.menu-toggle:focus-visible,
.upload-button:focus-visible,
.print-button:focus-visible,
.secondary-button:focus-visible,
.approve-button:focus-visible,
.remove-adjustment:focus-visible,
.signature-row button:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.55);
    outline-offset: 2px;
}

/* ============================================================================
   MAIN CONTENT VIEW LAYOUT
   ============================================================================ */
.page-wrap {
    max-width: 1320px;
    margin: 0 auto;
    padding: 32px 24px;
}

.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    color: var(--white);
    background: linear-gradient(135deg, #1d4ed8, #312e81);
    padding: 42px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.hero-panel::after {
    content: "";
    position: absolute;
    right: -80px;
    bottom: -90px;
    width: 280px;
    height: 280px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    pointer-events: none;
}

.hero-copy,
.hero-action {
    position: relative;
    z-index: 2;
}

.hero-copy {
    min-width: 0;
}

.hero-action {
    flex: 0 0 auto;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 12px;
    font-weight: 700;
    color: #cbd5e1;
}

.eyebrow.dark {
    color: var(--blue);
}

.eyebrow.muted {
    color: #94a3b8;
}

.hero-panel h1 {
    margin: 0 0 12px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.hero-location {
    margin: 0;
    color: #dbeafe;
    font-size: 16px;
    font-weight: 500;
}

.upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    background: var(--white);
    color: var(--navy);
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15);
    min-height: 50px;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    border: 0;
    text-align: center;
}

.upload-button:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.upload-button input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.button-icon {
    color: var(--blue);
    font-size: 11px;
    border: 2px solid var(--blue);
    border-radius: 6px;
    padding: 2px 4px;
    font-weight: 700;
    flex: 0 0 auto;
}

.notice-card,
.panel-card,
.module-shell,
.module-viewer {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.02);
}

.notice-card {
    padding: 24px;
    margin: 24px 0 32px;
}

.notice-card h2,
.panel-card h3 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.notice-card p,
.panel-card p,
.module-header p,
.viewer-title-row p {
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
    font-size: 14px;
}

.section-icon {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    min-height: 24px;
    margin-right: 8px;
    color: var(--blue);
    font-weight: 700;
    font-size: 11px;
    border-radius: 6px;
    background: #dbeafe;
    vertical-align: middle;
}

.section-icon.blue {
    color: var(--blue);
    background: #dbeafe;
}

.section-icon.amber {
    color: #92400e;
    background: #fef3c7;
}

.portal-stack {
    display: grid;
    gap: 32px;
}

/* Stats Grid Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.02);
    min-width: 0;
}

.stat-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: #dbeafe;
    color: var(--blue);
    font-weight: 700;
    flex: 0 0 auto;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

/* Module Cards Segment */
.module-shell {
    padding: 24px;
}

.module-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.module-header h2 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.print-button,
.secondary-button,
.approve-button {
    border: 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s, transform 0.2s;
}

.print-button {
    background: var(--blue);
    color: var(--white);
    border-radius: 8px;
    padding: 10px 16px;
    white-space: nowrap;
}

.print-button:hover {
    background: #1d4ed8;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.module-card {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
    color: var(--navy);
    min-width: 0;
}

.module-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
    border-color: #cbd5e1;
}

.module-card:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

.module-card.active {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.module-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #dbeafe;
    color: var(--blue);
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 12px;
}

.module-card.active .module-icon {
    background: rgba(255, 255, 255, 0.15);
    color: var(--blue-2);
}

.module-label {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.module-sub {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    min-height: 34px;
}

.module-card.active .module-sub {
    color: #94a3b8;
}

.module-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    padding-top: 12px;
}

.module-card.active .module-mini {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.module-mini span {
    font-weight: 700;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.module-mini small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-top: 2px;
}

.module-card.active small {
    color: #94a3b8;
}

/* Data Tables Structure */
.module-viewer {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.viewer-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.viewer-title-row h3 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
}

.viewer-totals {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 16px;
    row-gap: 2px;
    text-align: right;
}

.viewer-totals span {
    font-weight: 700;
    font-size: 16px;
    color: var(--blue);
}

.viewer-totals small {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
    gap: 24px;
}

.left-stack,
.right-stack {
    display: grid;
    gap: 24px;
    align-content: start;
    min-width: 0;
}

.two-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.panel-card {
    padding: 24px;
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.badge-blue {
    background: var(--blue);
    color: var(--white);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 650px;
}

.data-table th {
    background: var(--navy);
    color: var(--white);
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    color: #334155;
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table .right {
    text-align: right;
    font-weight: 700;
}

.data-table tfoot td {
    background: var(--navy);
    color: var(--white);
    font-weight: 700;
    font-size: 13px;
}

.empty-row {
    text-align: center;
    color: var(--muted) !important;
    font-weight: 500;
    padding: 24px !important;
}

/* Listing Rows */
.list-stack {
    display: grid;
    gap: 10px;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.list-row span {
    min-width: 0;
    overflow-wrap: anywhere;
    color: #475569;
}

.list-row strong {
    color: var(--navy);
    font-weight: 700;
    white-space: nowrap;
}

.list-row.amber {
    background: #fffbeb;
    border-color: #fde68a;
}

.list-row.amber span {
    color: #92400e;
}

.list-row.empty {
    color: var(--muted);
    font-weight: 500;
    justify-content: center;
    background: transparent;
    border-style: dashed;
}

/* Financial Summary Sidebar */
.valuation-card {
    background: var(--navy);
    color: var(--white);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.money-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    color: #94a3b8;
    font-size: 14px;
}

.money-row strong {
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    overflow-wrap: anywhere;
    text-align: right;
}

#projectStatus {
    color: #6ee7b7;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
}

.grand-total-block {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.grand-total-block p {
    color: #94a3b8;
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.grand-total-block strong {
    display: block;
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.grand-total-block small {
    display: block;
    margin-top: 10px;
    color: #64748b;
    font-size: 11px;
}

/* Inputs and Forms */
.adjustment-inputs {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px 14px;
    outline: none;
    font-size: 14px;
    color: var(--navy);
}

input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.secondary-button {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    background: #e2e8f0;
    color: var(--slate);
}

.secondary-button:hover {
    background: #cbd5e1;
}

.approve-button {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    border-radius: 8px;
    background: var(--navy);
    color: var(--white);
    font-size: 14px;
}

.approve-button:hover {
    background: #1e293b;
}

/* Digital Sign-off Canvas */
.acceptance-card {
    background: var(--white);
    border: 2px solid var(--navy);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.acceptance-card h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
}

.acceptance-card p {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.signature-pad {
    width: 100%;
    height: 140px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    cursor: crosshair;
    display: block;
    touch-action: none;
}

.signature-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0 14px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.signature-row button {
    border: 0;
    background: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 0;
}

.signature-row button:hover {
    color: #ef4444;
}

.remove-adjustment {
    border: 0;
    background: none;
    color: #ef4444;
    cursor: pointer;
    font-weight: 700;
    font-size: 16px;
    padding: 2px 6px;
}

.download-fallback {
    margin-top: 14px;
    padding: 12px;
    border-radius: 8px;
    background: #eff6ff;
    color: var(--blue);
    font-weight: 600;
    font-size: 13px;
    text-align: center;
}

.download-fallback a {
    text-decoration: underline;
}

.brand-footer {
    max-width: 1280px;
    margin: 40px auto 0;
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--line);
}

.brand-footer p {
    margin: 0;
}

.brand-footer strong {
    color: var(--navy);
}

.upload-help {
    margin: 10px 0 0;
    color: #dbeafe;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    max-width: 260px;
    opacity: 0.9;
}

/* ============================================================================
   RESPONSIVE DESIGN SYSTEM MEDIA QUERIES
   ============================================================================ */
@media (max-width: 1100px) {
    .stats-grid,
    .module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 900px) {
    .menu-toggle {
        display: block;
        flex: 0 0 auto;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: calc(100% - 32px);
        position: absolute;
        top: calc(100% + 8px);
        left: 16px;
        right: 16px;
        background: var(--navy-2);
        padding: 20px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        gap: 16px;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
        z-index: 150;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links li,
    .nav-links a {
        width: 100%;
    }

    .status-item {
        margin-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-top: 16px;
        width: 100%;
    }
}

@media (max-width: 760px) {
    .site-nav {
        padding: 12px 16px;
    }

    .hero-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 24px;
        border-radius: 16px;
    }

    .hero-action {
        width: 100%;
    }

    .module-header,
    .panel-header,
    .viewer-title-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .stats-grid,
    .module-grid,
    .two-card-grid {
        grid-template-columns: 1fr;
    }

    .page-wrap {
        padding: 20px 16px;
    }

    .viewer-totals {
        text-align: left;
        grid-template-columns: 1fr;
    }

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

    .money-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .money-row strong {
        text-align: left;
    }

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

    .upload-help {
        text-align: left;
        max-width: none;
    }
}

@media (max-width: 420px) {
    .brand-text {
        font-size: 16px;
    }

    .hero-panel h1 {
        font-size: 24px;
    }

    .upload-button {
        width: 100%;
    }

    .list-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .list-row strong {
        white-space: normal;
    }
}

/* Print Overrides Optimization */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .site-header,
    .hero-panel,
    .notice-card,
    .stats-grid,
    .module-shell,
    .right-stack,
    .brand-footer {
        display: none !important;
    }

    .page-wrap {
        max-width: none;
        padding: 0;
    }

    .main-grid,
    .left-stack,
    .two-card-grid {
        display: block;
    }

    .panel-card,
    .module-viewer {
        box-shadow: none;
        border-color: #000;
    }
}
