html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

:root {
    --ha-primary: #b51f2e;
    --ha-primary-dark: #861722;
    --ha-primary-light: #f8e9eb;
    --ha-black: #1c1c1f;
    --ha-charcoal: #2f3337;
    --ha-silver: #d9dde1;
    --ha-bg: #f3f4f5;
    --ha-surface: #ffffff;
    --ha-border: #d4d7da;
    --ha-text: #24282c;
    --ha-muted: #6c757d;
    --ha-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

body {
    margin-bottom: 70px;
    background-color: var(--ha-bg);
    color: var(--ha-text);
}


/* =========================================================
   General Layout
   ========================================================= */

main {
    padding-top: 1.25rem;
    padding-bottom: 2rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--ha-black);
    font-weight: 650;
}

h1 {
    letter-spacing: -0.025em;
}

a {
    color: var(--ha-primary);
}

    a:hover {
        color: var(--ha-primary-dark);
    }

.text-muted {
    color: var(--ha-muted) !important;
}


/* =========================================================
   Navigation
   ========================================================= */

.navbar {
    min-height: 72px;
    background-color: #ffffff !important;
    border-bottom: 3px solid var(--ha-primary) !important;
    box-shadow: 0 0.125rem 0.45rem rgba(0, 0, 0, 0.08);
}

.navbar-brand {
    padding-top: 0;
    padding-bottom: 0;
    margin-right: 1.5rem;
}

.navbar-logo {
    display: block;
    height: 54px;
    width: auto;
    max-width: 260px;
    object-fit: contain;
}

.navbar .nav-link {
    color: var(--ha-charcoal) !important;
    font-weight: 600;
    border-radius: 0.375rem;
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

    .navbar .nav-link:hover {
        color: var(--ha-primary) !important;
        background-color: var(--ha-primary-light);
    }

@media (max-width: 575.98px) {
    .navbar {
        min-height: 64px;
    }

    .navbar-logo {
        height: 44px;
        max-width: 210px;
    }
}


/* =========================================================
   Footer
   ========================================================= */

.footer {
    background-color: #ffffff;
    border-top: 1px solid var(--ha-border) !important;
    padding: 1rem 0;
}

    .footer a {
        color: var(--ha-primary);
        text-decoration: none;
    }

        .footer a:hover {
            color: var(--ha-primary-dark);
            text-decoration: underline;
        }


/* =========================================================
   Buttons
   ========================================================= */

.btn {
    border-radius: 0.4rem;
    font-weight: 600;
}

.btn-primary {
    background-color: var(--ha-primary);
    border-color: var(--ha-primary);
}

    .btn-primary:hover,
    .btn-primary:focus {
        background-color: var(--ha-primary-dark);
        border-color: var(--ha-primary-dark);
    }

.btn-outline-primary {
    color: var(--ha-primary);
    border-color: var(--ha-primary);
}

    .btn-outline-primary:hover {
        background-color: var(--ha-primary);
        border-color: var(--ha-primary);
        color: #ffffff;
    }

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem rgba(181, 31, 46, 0.28);
}


/* =========================================================
   Cards
   ========================================================= */

.card {
    border: 1px solid var(--ha-border);
    border-radius: 0.6rem;
    box-shadow: var(--ha-shadow);
}

.card-header {
    background-color: #f7f7f8;
    border-bottom: 1px solid var(--ha-border);
    color: var(--ha-black);
    font-weight: 600;
}

.card-body {
    background-color: var(--ha-surface);
}


/* =========================================================
   Forms
   ========================================================= */

.form-control,
.form-select {
    border-color: #cfd3d7;
    border-radius: 0.4rem;
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--ha-primary);
    }

.form-label {
    font-weight: 600;
    color: var(--ha-charcoal);
}


/* =========================================================
   Tables
   ========================================================= */

.table {
    background-color: #ffffff;
}

    .table thead th {
        background-color: #eceeef;
        color: var(--ha-charcoal);
        font-size: 0.82rem;
        text-transform: uppercase;
        letter-spacing: 0.035em;
        vertical-align: middle;
    }

    .table tbody tr:hover {
        background-color: #f8f9fa;
    }


/* =========================================================
   Alerts / Badges
   ========================================================= */

.alert {
    border-radius: 0.5rem;
}

.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
}


/* =========================================================
   Login
   ========================================================= */

.login-page {
    min-height: calc(100vh - 190px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    border-top: 4px solid var(--ha-primary);
}

.login-logo {
    display: block;
    width: min(100%, 360px);
    max-height: 175px;
    object-fit: contain;
    margin: 0 auto;
}

.login-title {
    color: var(--ha-black);
    font-weight: 700;
}


/* =========================================================
   Maintenance Report
   ========================================================= */

.maintenance-document {
    position: relative;
    background: #ffffff;
    color: #212529;
    max-width: 1050px;
    margin: 0 auto;
    padding: 36px;
    border-radius: 0.5rem;
}

.maintenance-logo {
    width: 155px;
    height: auto;
    object-fit: contain;
}

.maintenance-company-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ha-black);
}

.maintenance-title {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--ha-primary);
}

.maintenance-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ha-primary);
    border-bottom: 2px solid var(--ha-primary);
    padding-bottom: 5px;
    margin-bottom: 12px;
}

.maintenance-field {
    margin-bottom: 12px;
}

.maintenance-field-label {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--ha-muted);
    margin-bottom: 2px;
}

.maintenance-text-block {
    white-space: pre-wrap;
}

.maintenance-info-box {
    border: 1px solid #d7dade;
    border-radius: 0.4rem;
    padding: 9px 11px;
    height: 100%;
    background-color: #fafafa;
}

.maintenance-table thead th {
    background-color: var(--ha-black);
    color: #ffffff;
    border: 0;
    white-space: nowrap;
}

.maintenance-summary {
    font-weight: 700;
}


/* =========================================================
   Invoice
   ========================================================= */

.invoice-document {
    position: relative;
    background: #ffffff;
    color: #212529;
    max-width: 1050px;
    margin: 0 auto;
    padding: 42px;
    overflow: hidden;
    border-radius: 0.5rem;
}

.invoice-logo {
    display: block;
    width: 175px;
    height: auto;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.invoice-company-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ha-black);
}

.invoice-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--ha-primary);
}

.invoice-section-label {
    font-weight: 700;
    color: var(--ha-primary);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.invoice-meta-table td {
    padding: 3px 0 3px 18px;
}

    .invoice-meta-table td:first-child {
        font-weight: 700;
        text-align: right;
        padding-left: 0;
    }

.invoice-table thead th {
    background-color: var(--ha-black);
    color: #ffffff;
    border: 0;
    white-space: nowrap;
}

.invoice-table td {
    vertical-align: top;
}

.invoice-summary {
    max-width: 420px;
    margin-left: auto;
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    gap: 20px;
}

.invoice-total-row {
    font-size: 1.15rem;
    font-weight: 700;
}

.invoice-balance-row {
    font-size: 1.4rem;
    font-weight: 700;
    border-top: 2px solid #212529;
    padding-top: 10px;
    margin-top: 5px;
}

.invoice-reference-block {
    line-height: 1.7;
}

.invoice-watermark {
    position: absolute;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-28deg);
    font-size: 8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    opacity: 0.12;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
}

.paid-watermark {
    color: #198754;
}

.void-watermark {
    color: #dc3545;
}

.invoice-content {
    position: relative;
    z-index: 10;
}


/* =========================================================
   Audit History
   ========================================================= */

.audit-table {
    width: 100%;
    table-layout: fixed;
}

    .audit-table th {
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        white-space: nowrap;
        vertical-align: middle;
    }

    .audit-table td {
        vertical-align: middle;
        padding: 1rem 0.65rem;
    }

.audit-date {
    width: 10%;
}

.audit-report {
    width: 7%;
}

.audit-user {
    width: 14%;
}

.audit-action {
    width: 15%;
}

.audit-field {
    width: 12%;
}

.audit-value {
    width: 17%;
}

.audit-button {
    width: 8%;
}

.audit-value-box {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.5rem 0.65rem;
    white-space: normal;
    overflow-wrap: anywhere;
    min-height: 42px;
}

.audit-table .btn {
    white-space: nowrap;
}


/* =========================================================
   Audit History - Mobile
   ========================================================= */

@media (max-width: 767.98px) {

    .audit-table {
        display: block;
        width: 100%;
        table-layout: auto;
    }

        .audit-table thead {
            display: none;
        }

        .audit-table tbody {
            display: block;
            width: 100%;
        }

        .audit-table tr {
            display: block;
            width: 100%;
            margin-bottom: 1rem;
            border: 1px solid #dee2e6;
            border-radius: 0.5rem;
            background-color: #ffffff;
            overflow: hidden;
        }

        .audit-table td {
            display: grid;
            grid-template-columns: 115px minmax(0, 1fr);
            gap: 0.75rem;
            width: 100%;
            padding: 0.75rem 1rem;
            border-bottom: 1px solid #eeeeee;
            text-align: left !important;
            word-break: normal;
            overflow-wrap: anywhere;
        }

            .audit-table td:last-child {
                border-bottom: none;
            }

            .audit-table td::before {
                content: attr(data-label);
                font-weight: 700;
                font-size: 0.75rem;
                text-transform: uppercase;
                color: #6c757d;
            }

    .audit-value-box {
        width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 0.5rem;
    }

    .audit-table .badge {
        width: fit-content;
        max-width: 100%;
        white-space: normal;
        text-align: left;
    }

    .audit-table .btn {
        width: 100%;
        white-space: nowrap;
    }

    .audit-date,
    .audit-report,
    .audit-user,
    .audit-action,
    .audit-field,
    .audit-value,
    .audit-button {
        width: auto;
    }
}


/* =========================================================
   Print
   ========================================================= */

@media print {

    html,
    body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        margin-bottom: 0 !important;
    }

    header,
    footer,
    nav,
    .navbar,
    .maintenance-screen-only,
    .invoice-screen-only {
        display: none !important;
    }

    main {
        margin: 0 !important;
        padding: 0 !important;
    }

    .container,
    .container-fluid {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;

        .timecard-logo {
            width: 145px !important;
            height: auto !important;
            -webkit-print-color-adjust: exact;
            print-color-adjust: exact;
        }
    }


    /* Maintenance */

    .maintenance-document {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 14px !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        font-size: 0.82rem;
    }

    .maintenance-logo {
        width: 125px !important;
        height: auto !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .maintenance-document .row {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    .maintenance-document .col-md-3 {
        flex: 0 0 25% !important;
        width: 25% !important;
        max-width: 25% !important;
    }

    .maintenance-document .col-md-4 {
        flex: 0 0 33.333333% !important;
        width: 33.333333% !important;
        max-width: 33.333333% !important;
    }

    .maintenance-document .col-md-6 {
        flex: 0 0 50% !important;
        width: 50% !important;
        max-width: 50% !important;
    }

    .maintenance-document .col-sm-5 {
        flex: 0 0 41.666667% !important;
        width: 41.666667% !important;
        max-width: 41.666667% !important;
    }

    .maintenance-document .col-sm-7 {
        flex: 0 0 58.333333% !important;
        width: 58.333333% !important;
        max-width: 58.333333% !important;
    }

    .maintenance-title {
        color: #b51f2e !important;
        font-size: 1.7rem !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .maintenance-company-name {
        color: #1c1c1f !important;
        font-size: 1.15rem !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .maintenance-section-title {
        color: #b51f2e !important;
        border-color: #b51f2e !important;
        margin-bottom: 8px !important;
        padding-bottom: 3px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .maintenance-info-box {
        background-color: #fafafa !important;
        border-color: #cfd3d7 !important;
        padding: 7px 9px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .maintenance-table thead th {
        background-color: #1c1c1f !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .maintenance-field-label {
        font-size: 0.68rem !important;
    }


    /* Invoice */

    .invoice-document {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 20px !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .invoice-logo {
        width: 145px !important;
        height: auto !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-title,
    .invoice-section-label {
        color: #b51f2e !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-table thead th {
        background-color: #1c1c1f !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-watermark {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }


    /* Page Break Behavior */

    .maintenance-no-break,
    .maintenance-info-box {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .maintenance-section-title {
        break-after: avoid;
        page-break-after: avoid;
    }

    table {
        break-inside: auto;
    }

    tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }
}

.timecard-logo {
    display: block;
    width: 175px;
    height: auto;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

/* =========================================================
   Backup / Archive
   ========================================================= */

.backup-range-button {
    border: 1px solid var(--ha-primary);
    color: var(--ha-primary);
    background-color: var(--ha-surface);
    font-weight: 600;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

    .backup-range-button:hover {
        border-color: var(--ha-primary-dark);
        color: var(--ha-primary-dark);
        background-color: var(--ha-primary-light);
    }

    .backup-range-button.backup-range-selected {
        background-color: var(--ha-primary);
        border-color: var(--ha-primary);
        color: #ffffff;
    }

        .backup-range-button.backup-range-selected:hover {
            background-color: var(--ha-primary-dark);
            border-color: var(--ha-primary-dark);
            color: #ffffff;
        }

/* Backup validation: hide the container when there are no errors. */
.backup-validation-summary.validation-summary-valid {
    display: none;
}

/* Display a red alert only when validation has failed. */
.backup-validation-summary.validation-summary-errors {
    display: block;
    background-color: #f8d7da;
    color: #842029 !important;
    border: 1px solid #f5c2c7;
    border-radius: 8px;
    padding: 14px
}