:root {
    --ats-primary: #0082d8;
    --ats-primary-hover: #0096fa;
    --ats-primary-dark: #005a9c;
    --ats-primary-light: #e8f4fc;
    --ats-primary-muted: #b8daf0;
    --ats-accent: #00a3e0;
    --ats-danger: #cc392f;
    --ats-danger-hover: #e84135;
    --ats-success: #2ea169;
    --ats-bg: #eef4fa;
    --ats-surface: #ffffff;
    --ats-text: #1a2b3c;
    --ats-text-muted: #5a6f82;
    --ats-border: #c5d9e8;
    --app-header-height: 120px;
    --touch-min: 44px;

    /* Bootstrap theme alignment */
    --bs-primary: #0082d8;
    --bs-primary-rgb: 0, 130, 216;
    --bs-link-color: #0082d8;
    --bs-link-hover-color: #005a9c;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    background-color: var(--ats-bg);
    color: var(--ats-text);
    min-height: 100vh;
}

/* Buttons */
.btn-primary {
    background-color: var(--ats-primary);
    border-color: var(--ats-primary-dark);
    color: #fff;
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--ats-primary-hover);
    border-color: var(--ats-primary-dark);
    color: #fff;
}
.btn-outline-primary {
    color: #fff;
    background-color: var(--ats-primary);
    border-color: #000;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus {
    color: #fff;
    background-color: var(--ats-primary-hover);
    border-color: #000;
}
.btn-danger {
    color: #fff;
    background-color: var(--ats-danger);
    border-color: #000;
}
.btn-danger:hover,
.btn-danger:focus {
    color: #fff;
    background-color: var(--ats-danger-hover);
    border-color: #000;
}
.margin-left,
.ms-legacy {
    margin-left: 20px;
}

/* App shell */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(135deg, var(--ats-primary-dark) 0%, var(--ats-primary) 55%, var(--ats-accent) 100%);
    border-bottom: 3px solid var(--ats-primary-dark);
    box-shadow: 0 2px 8px rgba(0, 90, 156, 0.25);
}
.app-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    gap: 0.75rem;
}
.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    min-width: 0;
}
.app-header-brand:hover {
    color: var(--ats-primary-light);
}
.app-header-brand img {
    height: 40px;
    width: auto;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}
.app-header-title {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}
.app-header-logos {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.app-header-logos img {
    height: 36px;
    width: auto;
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
}
.app-header .btn-outline-secondary {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
}
.app-header .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: #fff;
    color: #fff;
}
.app-nav {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 0.5rem;
    background: rgba(0, 0, 0, 0.08);
}
.app-nav .nav-link {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.65rem 0.85rem;
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    border-radius: 0.375rem 0.375rem 0 0;
    margin-top: 0.25rem;
    transition: background 0.15s, color 0.15s;
}
.app-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}
.app-nav .nav-link.active {
    color: var(--ats-primary-dark);
    background: var(--ats-surface);
    font-weight: 600;
}
.app-nav .dropdown-menu .dropdown-item.active,
.app-nav .dropdown-menu .dropdown-item:active {
    background-color: var(--ats-primary);
    color: #fff;
}
.app-main {
    padding-top: 1rem;
    padding-bottom: 2rem;
}
.app-dairy-title {
    font-size: 1.35rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
    color: var(--ats-primary-dark);
    background: linear-gradient(to right, transparent, var(--ats-primary-light), transparent);
    padding: 0.65rem 1rem;
    border-radius: 0.375rem;
}

/* Login */
.login-page {
    min-height: calc(100vh - 2rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--ats-surface);
    border-radius: 0.5rem;
    box-shadow: 0 4px 24px rgba(0, 90, 156, 0.15);
    padding: 2rem;
    border-top: 4px solid var(--ats-primary);
}
.login-card h1,
.login-card .h3 {
    color: var(--ats-primary-dark);
}
.login-card .form-control:focus {
    border-color: var(--ats-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 130, 216, 0.2);
}
.login-card .form-control {
    min-height: var(--touch-min);
    font-size: 16px;
}
.login-card .btn {
    min-height: var(--touch-min);
}

/* Page header pattern */
.page-header {
    background: var(--ats-primary-light);
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-primary);
}
.page-header .form-label {
    color: var(--ats-primary-dark);
    font-weight: 500;
}
.page-header .form-control,
.page-header .form-select,
.page-header .btn {
    min-height: var(--touch-min);
}

/* Sticky filter toolbar (4570 page) */
.inspection-sticky-controls {
    position: sticky;
    top: var(--app-header-height);
    z-index: 1020;
    background: var(--ats-primary-light);
    border-bottom: 2px solid var(--ats-primary-muted);
    margin-bottom: 0.5rem;
    border-radius: 0 0 0.375rem 0.375rem;
    overflow: visible;
}
.inspection-sticky-controls .nav-tabs {
    border-bottom-color: var(--ats-primary-muted);
}
.inspection-sticky-controls .nav-tabs .nav-link {
    color: var(--ats-primary-dark);
    border-color: transparent;
}
.inspection-sticky-controls .nav-tabs .nav-link:hover {
    border-color: var(--ats-primary-muted);
    background: rgba(255, 255, 255, 0.6);
}
.inspection-sticky-controls .nav-tabs .nav-link.active {
    color: var(--ats-primary-dark);
    background: var(--ats-surface);
    border-color: var(--ats-primary-muted) var(--ats-primary-muted) var(--ats-surface);
    font-weight: 600;
}
.stay-top-toolbar {
    padding: 0.75rem;
    background: transparent;
}

/* 4570 filter toolbar layout */
.inspection-filter-form .form-label {
    margin-bottom: 0.25rem;
}
.inspection-month-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.inspection-month-picker .btn {
    min-height: 2.25rem;
    padding: 0.25rem 0.65rem;
    pointer-events: auto;
}
.inspection-signature-desktop {
    background: var(--ats-surface);
    border: 1px solid var(--ats-primary-muted);
    border-radius: 0.375rem;
    padding: 0.75rem;
    text-align: center;
}
.inspection-signature-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    max-height: 200px;
}

/* Tables — blue headers */
.app-main .table-dark,
.app-main .table-dark th,
.app-main thead.table-dark th {
    background-color: var(--ats-primary-dark) !important;
    color: #fff !important;
    border-color: var(--ats-primary) !important;
}
.app-main .table-bordered {
    border-color: var(--ats-primary-muted);
}
.app-main .table-hover tbody tr:hover {
    background-color: var(--ats-primary-light);
}
.inspection-section-heading,
.inspection-card-heading {
    background: linear-gradient(90deg, var(--ats-primary) 0%, var(--ats-accent) 100%) !important;
    color: #fff !important;
    padding: 0.75rem 1rem;
    font-weight: 600;
}

/* Wide tables: normal thead (no sticky — breaks inside overflow wrappers) */
.table-sticky-head {
    border-collapse: collapse;
}

@media (min-width: 992px) {
    .inspection-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Focus */
.focusOff:focus {
    outline: none;
    box-shadow: none;
}

/* Icon sizes */
.fa-6 { font-size: 2em; }
.fa-4 { font-size: 1.5em; }

/* Inspections */
.upload-action {
    min-height: 80px;
    border: 2px dashed var(--ats-primary-muted);
    border-radius: 0.375rem;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    background: var(--ats-primary-light);
}
.upload-action:hover {
    border-color: var(--ats-primary);
    background: #dceefb;
}
.upload-action.is-dragging {
    background: #c5ffd2;
    border-color: #70ff8f;
}
.inspection-card {
    background: var(--ats-surface);
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-primary);
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 90, 156, 0.08);
}
.inspection-card-body {
    padding: 0.75rem 1rem;
}
.inspection-card-field {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--ats-primary-light);
    gap: 0.5rem;
}
.inspection-card-field:last-child {
    border-bottom: none;
}
.inspection-card-field-label {
    font-weight: 600;
    color: var(--ats-primary-dark);
    flex-shrink: 0;
}
.inspection-signature-block {
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--ats-primary-light);
    border-radius: 0.375rem;
    margin-top: 1rem;
    border: 1px solid var(--ats-primary-muted);
}
.inspection-signature-block img {
    max-width: 100%;
    height: auto;
}

/* Mobile card list (engine hours, etc.) */
.mobile-card-list .card {
    margin-bottom: 0.75rem;
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-primary);
    box-shadow: 0 1px 4px rgba(0, 90, 156, 0.08);
}
.mobile-card-list .card-header {
    background: linear-gradient(90deg, var(--ats-primary-dark) 0%, var(--ats-primary) 100%) !important;
    color: #fff !important;
    border-bottom: none;
}
.mobile-card-list .list-group-item {
    padding: 0.65rem 1rem;
}
.mobile-card-list .list-group-item strong {
    color: var(--ats-primary-dark);
}

/* No-more-tables responsive pattern */
@media only screen and (max-width: 767.98px) {
    #no-more-tables table,
    #no-more-tables thead,
    #no-more-tables tbody,
    #no-more-tables th,
    #no-more-tables td,
    #no-more-tables tr {
        display: block;
    }
    #no-more-tables thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    #no-more-tables tr {
        border: 1px solid var(--ats-border);
        margin-bottom: 0.75rem;
        border-radius: 0.375rem;
        background: var(--ats-surface);
    }
    #no-more-tables td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding: 0.65rem 0.65rem 0.65rem 45%;
        white-space: normal;
        text-align: left;
        min-height: var(--touch-min);
        display: flex;
        align-items: center;
    }
    #no-more-tables td:before {
        content: attr(data-title);
        position: absolute;
        top: 0.65rem;
        left: 0.65rem;
        width: 40%;
        font-weight: 600;
        color: var(--ats-text-muted);
    }
    #no-more-tables tr.only-desktop {
        display: none;
    }
    #no-more-tables td input[type="number"] {
        width: 100%;
        min-height: var(--touch-min);
        font-size: 16px;
    }
}

/* Mobile summary stat cards */
.mobile-stat-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
@media (min-width: 576px) {
    .mobile-stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}
.mobile-stat-card {
    background: var(--ats-surface);
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-accent);
    border-radius: 0.375rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 90, 156, 0.06);
}
.mobile-stat-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ats-primary-dark);
    margin-bottom: 0.25rem;
}
.mobile-stat-card-value {
    font-size: 0.9rem;
}

/* Admin mobile cards */
.admin-question-card {
    background: var(--ats-surface);
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-primary);
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 90, 156, 0.06);
}
.admin-question-card .form-check-input:checked {
    background-color: var(--ats-primary);
    border-color: var(--ats-primary);
}
.admin-question-card .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.15rem;
}
.admin-question-card .form-check-label {
    padding-left: 0.25rem;
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
}

/* Grower checkbox scroll area */
.grower-checkbox-list {
    max-height: 400px;
    overflow-y: auto;
}
@media (max-width: 767.98px) {
    .grower-checkbox-list {
        max-height: 300px;
    }
}

/* Month checkbox grid */
.month-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}
@media (min-width: 576px) {
    .month-checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
.month-checkbox-grid .form-check {
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    padding: 0.25rem 0;
}
.month-checkbox-grid .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
}

/* Engine hours entry */
.engine-hours-input {
    min-height: var(--touch-min);
    min-width: 3rem;
    font-size: 16px;
    text-align: center;
}
.engine-hours-month-row {
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-primary);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--ats-surface);
}
.mobile-save-bar {
    position: sticky;
    top: var(--app-header-height);
    z-index: 1020;
    background: var(--ats-primary-light);
    border-bottom: 2px solid var(--ats-primary-muted);
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.mobile-save-bar .btn {
    min-height: var(--touch-min);
    flex: 1 1 auto;
    min-width: 120px;
}

/* Contacts mobile cards */
.contact-card {
    background: var(--ats-surface);
    border: 1px solid var(--ats-primary-muted);
    border-left: 4px solid var(--ats-primary);
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 90, 156, 0.06);
}

/* Cards, alerts, forms */
.app-main .card {
    border-color: var(--ats-primary-muted);
    box-shadow: 0 1px 4px rgba(0, 90, 156, 0.06);
}
.app-main .card-header {
    background: var(--ats-primary-light);
    color: var(--ats-primary-dark);
    font-weight: 600;
    border-bottom-color: var(--ats-primary-muted);
}
.app-main .list-group-item.active {
    background-color: var(--ats-primary);
    border-color: var(--ats-primary);
}
.app-main .list-group-item-action:hover {
    background-color: var(--ats-primary-light);
}
.app-main .alert-info {
    background-color: var(--ats-primary-light);
    border-color: var(--ats-primary-muted);
    color: var(--ats-primary-dark);
}
.app-main .alert-success {
    border-left: 4px solid var(--ats-success);
}
.app-main .form-control:focus,
.app-main .form-select:focus {
    border-color: var(--ats-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 130, 216, 0.2);
}
.app-main .form-check-input:checked {
    background-color: var(--ats-primary);
    border-color: var(--ats-primary);
}
.app-main .btn-outline-secondary {
    color: var(--ats-primary-dark);
    border-color: var(--ats-primary-muted);
}
.app-main .btn-outline-secondary:hover,
.app-main .btn-outline-secondary.active {
    background-color: var(--ats-primary-light);
    border-color: var(--ats-primary);
    color: var(--ats-primary-dark);
}

/* Offcanvas mobile nav */
.offcanvas .list-group-item.active {
    background-color: var(--ats-primary-light);
    color: var(--ats-primary-dark);
    border-color: var(--ats-primary-muted);
    font-weight: 600;
}
.offcanvas .list-group-item-action:hover {
    background-color: var(--ats-primary-light);
}
.contact-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.contact-card-actions .btn {
    flex: 1;
    min-height: var(--touch-min);
}

/* Touch targets globally on mobile */
@media (max-width: 991.98px) {
    .form-control,
    .form-select,
    .btn,
    .nav-link {
        min-height: var(--touch-min);
    }
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    .only-desktop {
        display: none !important;
    }
}

@media (min-width: 992px) {
    .only-mobile {
        display: none !important;
    }
}

/* Vue transitions */
.fade-enter-active, .fade-leave-active {
    transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to {
    opacity: 0;
}

/* Lucee debug */
.-lucee-dump table {
    border: 1px solid #ccc;
    border-collapse: collapse;
}
.-lucee-dump table td {
    border: 1px solid #f79494;
    background: #ffc5c5;
    padding: 5px;
    font-size: 10px;
}
