/* ===============================
   GLOBAL PAGE / FOOTER LAYOUT
================================= */

html,
body {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#page-content {
    flex: 1 0 auto;
}

footer.footer {
    flex-shrink: 0;
}


/* ===============================
   FLASH / STATUS MESSAGES
================================= */

.notice-success,
.notice-error {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.5;
}

.notice-success {
    background: #ecfdf3;
    border: 1px solid #b7ebc6;
    color: #166534;
}

.notice-error {
    background: #fef2f2;
    border: 1px solid #f3c1c1;
    color: #991b1b;
}


/* ===============================
   BUTTON SYSTEM
================================= */

button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #6b7280;
    color: #fff;
}

.btn-light {
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #d1d5db;
}

.btn-light:hover {
    background: #e5e7eb;
}

.btn-danger {
    background-color: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-secondary:disabled,
.btn-primary:disabled,
.btn-danger:disabled,
.btn-light:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}


/* ===============================
   FORM INPUTS
================================= */

input,
select,
textarea {
    box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
}


/* ===============================
   TABLE SYSTEM
================================= */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f9fafb;
    font-weight: 700;
    color: #111827;
}

.actions-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}


/* ===============================
   PAGINATION
================================= */

.pagination {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.pagination li {
    display: inline-block;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    text-decoration: none;
    border-radius: 8px;
    color: #111827;
    background: #fff;
}

.pagination .active a {
    font-weight: 700;
    background: #eff6ff;
    border-color: #93c5fd;
}

.pagination .disabled {
    opacity: 0.5;
}


/* ===============================
   DANGER / WARNING UI SYSTEM
================================= */

.warning-box {
    margin: 25px 0 10px 0;
    padding: 16px 18px;
    border-radius: 12px;
    background: #fef2f2;
    border: 1px solid #f3c1c1;
    border-left: 6px solid #dc2626;
    color: #7f1d1d;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.warning-icon {
    font-size: 20px;
    line-height: 1;
    margin-top: 2px;
}

.warning-box strong {
    color: #991b1b;
}


/* ===============================
   MODAL SYSTEM
================================= */

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
}

.modal-backdrop.show {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 70px;
    left: 50%;
    width: calc(100% - 30px);
    transform: translateX(-50%);
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    z-index: 9999;
    box-shadow: 0 12px 35px rgba(0,0,0,0.22);
    box-sizing: border-box;
    height: auto;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.modal.show {
    display: block;
}

.modal h3 {
    margin: 0 0 18px 0;
    font-size: 22px;
    color: #111827;
    line-height: 1.2;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
}

.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-form-group label {
    font-weight: 700;
    color: #111827;
    font-size: 14px;
}

.modal-form-group input,
.modal-form-group select {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font-size: 15px;
}

.modal-form-group input:focus,
.modal-form-group select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.modal-actions,
.delete-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}


/* ===============================
   DANGER MODAL VARIANT
================================= */

.modal-delete {
    border-top: 6px solid #dc2626;
    background: #fff7f7;
}

.modal-delete h3 {
    color: #dc2626;
    font-weight: 700;
}

.modal-delete .delete-modal-text {
    color: #7f1d1d;
}

.delete-modal-text {
    margin: 0 0 12px 0;
    line-height: 1.6;
    color: #374151;
}

.delete-modal-highlight {
    font-weight: 700;
    color: #dc2626;
}


/* ===============================
   RESPONSIVE
================================= */

@media (max-width: 768px) {
    .actions-buttons {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .modal {
        top: 20px;
        max-height: calc(100vh - 40px);
        padding: 18px;
    }
}


/* ===============================
   SHARED PAGE SHELL / TYPOGRAPHY
================================= */

.page-shell {
    max-width: 1120px;
    margin: 28px auto;
    font-family: Arial, sans-serif;
    color: #1f2937;
}

.flash-shell {
    max-width: 1120px;
    margin: 20px auto 0 auto;
}

.page-title {
    margin: 0;
    font-size: 36px;
    line-height: 1.1;
    font-weight: 700;
    color: #111827;
}


/* ===============================
   SHARED TOP TOOLBAR / FILTERS
================================= */

.top-toolbar,
.page-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.toolbar-right,
.page-filters {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.filter-group,
.page-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 170px;
}

.filter-group label,
.page-filter-group label {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
}

.filter-group select,
.page-filter-select {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font-size: 15px;
    box-sizing: border-box;
}

.filter-group select:focus,
.page-filter-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}


/* ===============================
   SHARED CARD LAYOUT
================================= */

.card-grid,
.flex-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
}

.card,
.form-container,
.table-container {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 22px;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.card-title,
.form-container h3,
.table-container h3 {
    margin: 0 0 18px 0;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    color: #111827;
}

.table-container {
    overflow-x: auto;
}


/* ===============================
   SHARED FORM STYLES
================================= */

.entry-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.entry-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 16px;
}

.entry-form-group,
.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entry-form-group.full-width {
    grid-column: 1 / -1;
}

.entry-form-group label,
.modal-form-group label {
    font-weight: 700;
    color: #111827;
    font-size: 14px;
}

.entry-form-group input,
.entry-form-group select,
.modal-form-group input,
.modal-form-group select {
    width: 100%;
    height: 46px;
    box-sizing: border-box;
    padding: 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font-size: 15px;
}

.entry-form-group input:focus,
.entry-form-group select:focus,
.modal-form-group input:focus,
.modal-form-group select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.entry-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid #edf0f3;
}

.helper-text,
.vehicle-meta,
.petrol-summary-meta {
    font-size: 14px;
    line-height: 1.5;
    color: #4b5563;
}

.vehicle-meta,
.petrol-summary-meta {
    margin: -4px 0 16px 0;
}


/* ===============================
   SHARED TABLES
================================= */

.summary-table,
#customer {
    width: 100%;
    border-collapse: collapse;
}

.summary-table {
    overflow: hidden;
    border-radius: 10px;
}

.summary-table th,
.summary-table td,
#customer th,
#customer td {
    padding: 14px 14px;
    border: 1px solid #d9dee5;
    text-align: left;
    vertical-align: middle;
}

.summary-table th,
#customer th {
    font-weight: 700;
    color: #111827;
    background: #fafbfc;
}

.summary-table td,
#customer td {
    background: #fff;
    color: #1f2937;
}


/* ===============================
   SHARED RECORDS HEADER / ACTIONS
================================= */

.table-header-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 22px 0 10px 0;
    gap: 15px;
    flex-wrap: wrap;
}

.table-header-wrap h3 {
    margin: 0;
    font-size: 22px;
    color: #111827;
}

.cog-btn {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 11px;
    cursor: pointer;
    font-size: 18px;
}

.cog-btn:hover {
    background: #f9fafb;
}

.actions-col {
    display: none;
    white-space: nowrap;
}

.actions-visible .actions-col {
    display: table-cell;
}

.actions-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}


/* ===============================
   SHARED BUTTONS
================================= */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-light {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 600;
}

.btn-primary {
    background-color: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6b7280;
    color: #fff;
}

.btn-danger {
    background-color: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-light {
    background-color: #f9fafb;
    color: #111827;
    border: 1px solid #d1d5db;
}


/* ===============================
   SHARED NOTICES
================================= */

.notice-success,
.notice-error {
    max-width: 1120px;
    margin: 20px auto 0 auto;
    padding: 12px 16px;
    border-radius: 8px;
    box-sizing: border-box;
}

.notice-success {
    background: #eaf7ea;
    border: 1px solid #b7dfb7;
}

.notice-error {
    background: #fdeaea;
    border: 1px solid #efb8b8;
}

.submit-delay-note {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff3cd;
    border: 1px solid #ffe69c;
    color: #856404;
    font-size: 14px;
}


/* ===============================
   SHARED PAGINATION
================================= */

.pagination {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.pagination li {
    display: inline-block;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    text-decoration: none;
    border-radius: 8px;
    background: #fff;
    color: #111827;
}

.pagination .active a {
    font-weight: 700;
}

.pagination .disabled {
    opacity: 0.5;
}


/* ===============================
   SHARED MODALS
================================= */

.modal {
    max-width: 460px;
    border-radius: 16px;
    padding: 22px;
    box-sizing: border-box;
}

.modal h3 {
    margin: 0 0 18px 0;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    color: #111827;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid #edf0f3;
}

.modal-delete {
    max-width: 420px;
}

.delete-modal-text {
    margin: 0 0 12px 0;
    line-height: 1.5;
    color: #1f2937;
}

.delete-modal-highlight {
    font-weight: 700;
}


/* ===============================
   SHARED RESPONSIVE
================================= */

@media (max-width: 900px) {
    .card-grid,
    .flex-container {
        grid-template-columns: 1fr;
    }

    .top-toolbar,
    .page-topbar {
        align-items: stretch;
    }

    .toolbar-right,
    .page-filters {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .page-shell {
        margin: 18px auto;
    }

    .page-title {
        font-size: 28px;
    }

    .filter-form,
    .page-filters {
        width: 100%;
    }

    .filter-group,
    .page-filter-group,
    .page-filter-group-vehicle,
    .page-filter-group-year {
        min-width: 100%;
    }

    .entry-form-grid {
        grid-template-columns: 1fr;
    }

    .table-header-wrap {
        flex-direction: column;
        align-items: stretch;
    }
}