:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --line: #d8dee6;
    --text: #1d2733;
    --muted: #667487;
    --brand: #126b74;
    --brand-2: #e7f3f4;
    --warn: #8a5a00;
    --warn-bg: #fff4d6;
    --ok: #176a3a;
    --ok-bg: #e8f6ee;
    --danger: #9c2f2f;
    --danger-bg: #fde9e9;
    --focus: #2f80ed;
    --shadow: 0 18px 45px rgba(29, 39, 51, .12);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Limit width of specific filter inputs/selects */
.filter-panel [name="Search"],
.filter-panel [name="Status"],
.filter-panel [name="TourOperator"],
.filter-panel [name="AccountingReference"],
.filter-panel [name="TravelTag"] {
    max-width: 400px;
    width: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    letter-spacing: 0;
}

button, input, select, textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 420px;
    background: #eef3f5;
}

.login-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 64px;
    background: linear-gradient(rgba(18, 107, 116, .78), rgba(18, 107, 116, .78)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Crect width='1200' height='800' fill='%23dfe8ea'/%3E%3Cpath d='M110 540h980v70H110zM190 420h820v70H190zM280 300h610v70H280z' fill='%23c3d4d8'/%3E%3Cpath d='M150 175h900v62H150z' fill='%23b3c8ce'/%3E%3C/svg%3E");
    background-size: cover;
    color: #fff;
}

    .login-side h1 {
        max-width: 680px;
        margin: 0 0 18px;
        font-size: 46px;
        line-height: 1.05;
        font-weight: 750;
    }

    .login-side p {
        max-width: 560px;
        margin: 0;
        color: rgba(255,255,255,.88);
        font-size: 18px;
        line-height: 1.5;
    }

.login-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36px;
    background: #fff;
}

.login-form {
    width: 100%;
    max-width: 330px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand);
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
}

.login-form h2 {
    margin: 0 0 28px;
    font-size: 28px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

label {
    color: #3d4b5f;
    font-weight: 650;
    font-size: 12px;
}

input, select, textarea {
    width: 100%;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px;
    color: var(--text);
    background: #fff;
    outline: none;
}

textarea {
    resize: vertical;
}

    input:focus, select:focus, textarea:focus {
        border-color: var(--focus);
        box-shadow: 0 0 0 3px rgba(47,128,237,.14);
    }

/* cost rows: disabled fields should show a gray background */
.row-costi input:disabled,
.row-costi select:disabled,
.row-costi textarea:disabled,
.row-acconto input:disabled,
.row-acconto select:disabled,
.row-acconto textarea:disabled {
    background: #f3f4f6; /* light gray */
    border-color: var(--line);
    color: var(--muted);
}

.drawer-error-banner {
    width: 100%;
    background: var(--danger-bg);
    color: var(--danger);
    font-weight: 700;
    text-align: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--danger);
}

.tab-error-icon {
    color: var(--danger);
    margin-left: 6px;
    font-size: 16px;
}

.login-actions {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

    .check input {
        width: 16px;
        min-height: 16px;
    }

.btn {
    min-height: 38px;
    border-radius: 6px;
    padding: 8px 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 750;
    white-space: nowrap;
}


.btn-icone {
    min-height: 30px !important;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 750;
    white-space: nowrap;
    width: 35px !important;
}

.btn-contact-wide {
    width: 45px !important;
}

.btn-contact-tall {
    height: 40px !important;
    min-height: 40px !important;
}


.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-save {
    background: #166534;
    color: #fff;
}

    .btn-save .fa {
        color: #fff;
    }

    .btn-save:hover {
        background: #e8f6ee;
        border-color: #176a3a;
    }

.btn-new:hover {
    background: #e8f6ee;
    border-color: #176a3a;
}

.btn-save:hover .fa {
    color: #fff;
}

.btn-new {
    background: #0f766e;
    color: #fff;
}

.btn-secondary {
    background: #edf1f5;
    color: #263241;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-delete .fa {
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: #fff;
}

    .btn-delete:hover .fa {
        color: #fff;
    }

.btn-view {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid var(--ok);
}

    .btn-view:hover {
        background: var(--ok);
        color: #fff;
        border: 1px solid var(--ok);
    }

    .btn-view .fa, .btn-view .fas, .btn-view .far {
        color: var(--ok);
    }

    .btn-view:hover .fa, .btn-view:hover .fas, .btn-view:hover .far {
        color: #fff;
    }

.icon {
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    border-radius: 4px;
    background: rgba(255,255,255,.18);
    font-size: 12px;
    font-weight: 900;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid var(--line);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    font-weight: 850;
    font-size: 16px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
}

.nav-section {
    display: grid;
    gap: 5px;
}

.nav-title {
    margin: 8px 8px 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav-btn {
    width: 100%;
    min-height: 36px;
    border-radius: 6px;
    padding: 7px 9px;
    color: #2d3a4b;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: left;
    font-weight: 650;
    text-decoration: none;
}

    .nav-btn.active {
        color: var(--brand);
        background: var(--brand-2);
    }

    .nav-btn.disabled {
        color: #a3adbb;
        cursor: default;
    }

    .nav-btn:hover:not(.disabled) {
        background: rgba(18, 107, 116, 0.08);
    }

.nav-btn-submenu {
    position: relative;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
}

.nav-btn-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    padding-left: 24px;
    margin-bottom: 4px;
}

    .nav-submenu.open {
        display: block;
    }

.nav-submenu-item {
    display: block;
    padding: 6px 12px;
    color: #2d3a4b;
    text-decoration: none;
    font-size: 13px;
    border-radius: 4px;
    margin-bottom: 2px;
}

    .nav-submenu-item:hover {
        background: rgba(18, 107, 116, 0.08);
    }

    .nav-submenu-item.active {
        color: var(--brand);
        background: var(--brand-2);
        font-weight: 600;
    }

.main {
    min-width: 0;
    display: grid;
    grid-template-rows: 58px 1fr;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    background: #fff;
    color: #3a4758;
    font-weight: 700;
}

.content {
    min-width: 0;
    padding: 22px;
    display: grid;
    gap: 18px;
    align-content: start;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

    .page-head h1 {
        margin: 0;
        font-size: 26px;
        line-height: 1.15;
    }

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.workspace {
    display: grid;
    gap: 14px;
}

.filter-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.filter-tabs {
    padding: 10px 12px 0;
    background: #fafbfc;
}

    .filter-tabs .nav-link {
        color: #4f5f73;
        font-weight: 750;
        border-top-left-radius: 6px;
        border-top-right-radius: 6px;
    }

        .filter-tabs .nav-link.active {
            color: var(--brand);
            background: #fff;
            border-color: var(--line) var(--line) #fff;
        }

.filter-content {
    padding: 14px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 260px));
    gap: 12px;
    align-items: end;
}

    /* Ensure zip and city align on same row for customer fields */
    .filter-grid.zip-city {
        display: grid;
        grid-template-columns: repeat(2, minmax(260px, 160px));
        gap: 12px;
        align-items: end;
    }

.filter-actions {
    border-top: 1px solid var(--line);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #fafbfc;
}

/* Posiziona i bottoni Cerca/Azzera in alto a destra accanto alle tab */
.filter-panel {
    position: relative;
}

.filter-tabs {
    padding: 10px 12px 0;
    background: #fafbfc;
    /* spazio riservato per i bottoni a destra */
    padding-right: 220px;
}

.filter-panel .filter-actions {
    position: absolute;
    top: 8px;
    right: 12px;
    border-top: none;
    background: transparent;
    padding: 0;
    gap: 8px;
    justify-content: flex-end;
}

    .filter-panel .filter-actions .btn {
        min-height: 38px;
        padding: 6px 10px;
    }

.filter-vertical-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 5px;
    margin-right: 50px;
    width: 120px;
    float: right;
    margin-top: 5px;
}

    .filter-vertical-actions .btn {
        padding: 8px 12px;
        min-width: 160px;
    }

/* Mobile: riporta i bottoni sotto le tab in colonna */
@media (max-width: 720px) {
    .filter-tabs {
        padding-right: 12px;
    }

    .filter-panel .filter-actions {
        position: static;
        border-top: 1px solid var(--line);
        background: #fafbfc;
        padding: 12px 14px;
    }
}

.filters {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: grid;
    grid-template-columns: 145px minmax(220px, 1.4fr) repeat(4, minmax(145px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.panel-head h2 {
    margin: 0;
    font-size: 18px;
}

.status {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
}

    .status.todo {
        color: var(--warn);
        background: var(--warn-bg);
    }

    .status.ok {
        color: var(--ok);
        background: var(--ok-bg);
    }

    .status.danger {
        color: var(--danger);
        background: var(--danger-bg);
    }

    .status.neutral {
        color: #3f536f;
        background: #eef2f7;
    }

    .status.quote {
        color: #145a86;
        background: #dff1ff;
    }

    .status.confirmed {
        color: #176a3a;
        background: #dcf7e7;
    }

    .status.paid {
        color: #ffffff;
        background: #0f5b2f;
    }

.booking-status {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.15;
    max-width: 220px;
}

.empty-cell {
    color: var(--muted);
    text-align: center;
    padding: 24px 12px;
}

.list-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}

.list-tab {
    min-height: 32px;
    border-radius: 6px;
    padding: 6px 11px;
    background: transparent;
    color: #4f5f73;
    font-weight: 750;
}

    .list-tab.active {
        background: var(--brand-2);
        color: var(--brand);
    }

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

th, td {
    padding: 11px 12px;
    border-bottom: 1px solid #edf0f3;
    text-align: left;
    vertical-align: top;
}

th {
    color: #5b6878;
    background: #fafbfc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

td {
    color: #243044;
}

tr:hover td {
    background: #eef3f5;
}

.money {
    font-weight: 850;
    color: #182232;
    min-width: 100px;
    text-align: right;
}

.row-actions {
    display: flex;
    gap: 8px;
}
/* Align action buttons to right inside passengers table */
#passengersTable .row-actions {
    justify-content: flex-end;
}
/* Confirm modal header styling */
.confirm-header {
    background: var(--ok);
    color: #fff;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
    padding: 12px 16px;
}

    .confirm-header .modal-title {
        margin: 0;
        font-weight: 700;
    }

.table-foot {
    min-height: 52px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

/* Header table controls: keep pagination and page-size select on one line */
.table-head-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
}

.table-head-left {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

    .table-head-left .pagination {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

.pagination-controls-inline {
    margin-left: auto; /* push to the right on the same line */
    display: inline-flex;
    align-items: center;
}

    .pagination-controls-inline select {
        min-width: 92px;
    }

.drawer-layer {
    position: fixed;
    inset: 0;
    background: rgba(20, 29, 39, .38);
    display: flex;
    justify-content: flex-end;
    z-index: 20;
}

.drawer {
    width: min(1160px, calc(100vw - 28px));
    height: 100%;
    background: #fff;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-rows: auto auto 1fr;
}

.drawer-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

    .drawer-head h2 {
        margin: 0;
        font-size: 22px;
    }

.drawer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.summary-bar {
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 10px;
    background: #fafbfc;
}

.summary-item {
    display: grid;
    gap: 2px;
    min-width: 0;
}

    .summary-item span {
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

    .summary-item strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.drawer-body {
    min-height: 0;
    display: grid;
    grid-template-columns: 190px 1fr;
}

.detail-tabs {
    border-right: 1px solid var(--line);
    padding: 12px;
    background: #fbfcfd;
    display: grid;
    align-content: start;
    gap: 6px;
}

.detail-tab {
    min-height: 38px;
    border-radius: 6px;
    padding: 8px 10px;
    background: transparent;
    color: #435166;
    text-align: left;
    font-weight: 800;
}

    .detail-tab.active {
        background: var(--brand);
        color: #fff;
    }

.detail-content {
    min-width: 0;
    overflow: auto;
    padding: 18px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

    .section-title h3 {
        margin: 0;
        font-size: 19px;
    }

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: start;
}

.passenger-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: 12px;
    align-items: start;
}

.wide {
    grid-column: span 2;
}

.full {
    grid-column: 1 / -1;
}

.contraente-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: start;
}

.form-band {
    grid-column: 1 / -1;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfd;
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: start;
}

    .form-band.accent {
        border-color: #b7d7dc;
        background: #eef8f9;
    }

.form-band-title {
    grid-column: 1 / -1;
    margin: 0;
    color: #2b3848;
    font-size: 14px;
    font-weight: 850;
}

.note {
    border: 1px solid #f0d89f;
    background: #fff9e9;
    color: #614a11;
    border-radius: 8px;
    padding: 5px;
    line-height: 1.45;
}

.mini-table {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.mini-row {
    display: grid;
    grid-template-columns: 1fr 150px 150px 44px;
    gap: 10px;
    padding: 3px;
    border-bottom: 1px solid #edf0f3;
    align-items: center;
}

    .mini-row:last-child {
        border-bottom: 0;
    }

.total-box {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

    .total-box strong {
        font-size: 24px;
    }

.lookup-field {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
}

    .lookup-field .field {
        min-width: 0;
    }

.product-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 29, 39, .44);
    z-index: 35;
    display: grid;
    place-items: center;
    padding: 24px;
}

.product-dialog {
    width: min(1040px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-rows: auto auto 1fr;
    overflow: hidden;
}

.product-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

    .product-head h2 {
        margin: 0;
        font-size: 21px;
    }

.product-filters {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(130px, 1fr)) auto;
    gap: 10px;
    align-items: end;
    background: #fbfcfd;
}

.product-results {
    overflow: auto;
    padding: 12px 18px 18px;
}

.product-card {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    text-align: left;
    margin-bottom: 10px;
}

    .product-card:hover {
        border-color: var(--brand);
        background: #fbfefe;
    }

    .product-card strong {
        display: block;
        margin-bottom: 5px;
        font-size: 15px;
    }

.product-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}

.product-type {
    align-self: start;
    border-radius: 999px;
    padding: 5px 9px;
    background: var(--brand-2);
    color: var(--brand);
    font-weight: 850;
    font-size: 12px;
}

.product-highlight {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.highlight-box {
    border: 1px solid #c9dde1;
    border-radius: 6px;
    background: #f0f8f9;
    padding: 8px;
    color: #254f57;
    font-weight: 800;
}

    .highlight-box span {
        display: block;
        color: #667487;
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .06em;
        margin-bottom: 3px;
    }

.empty-results {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 22px;
    color: var(--muted);
    background: #fbfcfd;
    text-align: center;
    font-weight: 700;
}

.suggest-wrap {
    position: relative;
}

.lookup-actions {
    display: flex;
    align-items: end;
    height: 100%;
}

    .lookup-actions .btn {
        width: 100%;
    }

.suggest-list {
    position: absolute;
    z-index: 12;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(29, 39, 51, .16);
    overflow: hidden;
}

.suggest-item {
    width: 100%;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    display: grid;
    gap: 3px;
    text-align: left;
    border-bottom: 1px solid #edf0f3;
}

    .suggest-item:last-child {
        border-bottom: 0;
    }

    .suggest-item:hover {
        background: #f5fafb;
    }

    .suggest-item small {
        color: var(--muted);
    }

.save-message {
    min-height: 32px;
    display: none;
    align-items: center;
    border-radius: 6px;
    padding: 7px 10px;
    color: var(--ok);
    background: var(--ok-bg);
    font-weight: 750;
}

    .save-message.visible {
        display: inline-flex;
    }

@media (max-width: 1100px) {
    .login-page {
        grid-template-columns: 1fr;
    }

    .login-side {
        min-height: 320px;
        padding: 40px;
    }

    .app {
        grid-template-columns: 76px 1fr;
    }

    .brand span, .nav-btn span:last-child, .nav-title {
        display: none;
    }

    .nav-btn {
        justify-content: center;
    }

    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .drawer-body {
        grid-template-columns: 1fr;
    }

    .detail-tabs {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-band {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .product-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .login-side h1 {
        font-size: 34px;
    }

    .login-side, .login-form-wrap {
        padding: 24px;
    }

    .topbar {
        padding: 0 12px;
    }

    .content {
        padding: 14px;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .filters, .form-grid {
        grid-template-columns: 1fr;
    }

    .form-band {
        grid-template-columns: 1fr;
    }

    .wide {
        grid-column: auto;
    }

    .drawer {
        width: 100vw;
    }

    .summary-bar {
        grid-template-columns: 1fr;
    }

    .mini-row {
        grid-template-columns: 1fr;
    }

    .lookup-field {
        grid-template-columns: 1fr;
    }

    .product-filters {
        grid-template-columns: 1fr;
    }

    .product-card {
        grid-template-columns: 1fr;
    }

    .product-highlight {
        grid-template-columns: 1fr;
    }
}

/* Drawer Layer Styles */
.drawer-layer {
    position: fixed;
    inset: 0;
    background: rgba(20, 29, 39, .38);
    display: flex;
    justify-content: flex-end;
    z-index: 20;
}

.drawer {
    width: min(1160px, calc(100vw - 28px));
    height: 100%;
    background: #fff;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-rows: auto auto 1fr;
}

.drawer-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

    .drawer-head h2 {
        margin: 0;
        font-size: 22px;
    }

.drawer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.summary-bar {
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 10px;
    background: #fafbfc;
}

.summary-item {
    display: grid;
    gap: 2px;
    min-width: 0;
}

    .summary-item span {
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

    .summary-item strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.drawer-body {
    min-height: 0;
    display: grid;
    grid-template-columns: 190px 1fr;
}

.detail-tabs {
    border-right: 1px solid var(--line);
    padding: 12px;
    background: #fbfcfd;
    display: grid;
    align-content: start;
    gap: 6px;
}

.detail-tab {
    min-height: 38px;
    border-radius: 6px;
    padding: 8px 10px;
    background: transparent;
    color: #435166;
    text-align: left;
    font-weight: 800;
}

    .detail-tab.active {
        background: var(--brand);
        color: #fff;
    }

.detail-content {
    min-width: 0;
    overflow: auto;
    padding: 18px;
}

/* Media Queries */
@media (max-width: 1100px) {
    .summary-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .drawer-body {
        grid-template-columns: 1fr;
    }

    .detail-tabs {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
    }
}

@media (max-width: 680px) {
    .drawer {
        width: 100vw;
    }

    .summary-bar {
        grid-template-columns: 1fr;
    }
}

/* ========================================================================== */
/* Responsive CRM - mobile/tablet                                             */
/* ========================================================================== */
.mobile-nav-toggle,
.sidebar-backdrop {
    display: none;
}

/* The previous 76px tablet sidebar hides text even though primary items have
   no icons. Keep navigation readable until the real mobile breakpoint. */
@media (min-width: 761px) and (max-width: 1100px) {
    .app {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .sidebar .brand span,
    .sidebar .nav-btn span:last-child,
    .sidebar .nav-title {
        display: inline;
    }

    .sidebar .nav-btn {
        justify-content: flex-start;
    }

    .sidebar {
        padding-inline: 12px;
    }

    .content {
        padding: 16px;
    }
}

@media (max-width: 760px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

        body.mobile-nav-open {
            overflow: hidden;
        }

    input,
    select,
    textarea,
    button {
        max-width: 100%;
        min-width: 0;
    }

    .app {
        display: block;
        width: 100%;
        min-height: 100vh;
    }

    .main {
        display: block;
        width: 100%;
        min-width: 0;
    }

    /* Mobile navigation drawer */
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1050;
        width: min(88vw, 320px);
        max-width: 320px;
        height: 100dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 12px 0 32px rgba(29, 39, 51, .18);
        padding: 16px 14px;
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }

        .sidebar .brand span,
        .sidebar .nav-btn span:last-child,
        .sidebar .nav-title {
            display: inline;
        }

        .sidebar .nav-btn {
            justify-content: flex-start;
            min-height: 42px;
        }

        .sidebar .nav-submenu {
            padding-left: 12px;
        }

        .sidebar .nav-submenu-item {
            min-height: 40px;
            display: flex;
            align-items: center;
            line-height: 1.25;
        }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
        background: rgba(20, 29, 39, .45);
        opacity: 0;
        pointer-events: none;
    }

        .sidebar-backdrop.visible {
            display: block;
            opacity: 1;
            pointer-events: auto;
        }

    /* Header */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 1030;
        width: 100%;
        min-height: 56px;
        padding: 8px 10px;
        gap: 8px;
    }

    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        color: var(--text);
    }

    .topbar-left,
    .topbar-right {
        min-width: 0;
        gap: 7px;
    }

    .topbar-left {
        flex: 1 1 auto;
    }

        .topbar-left > strong {
            max-width: 44vw;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .topbar-left .status,
        .user-pill {
            display: none;
        }

    .topbar .btn {
        min-height: 38px;
        padding: 7px 10px;
    }

    /* Generic page shell */
    .content {
        width: 100%;
        min-width: 0;
        padding: 10px;
        gap: 12px;
    }

    .workspace {
        width: 100%;
        min-width: 0;
        gap: 10px;
    }

        .workspace > .alert {
            margin: 0 !important;
            padding: 20px 14px !important;
        }

            .workspace > .alert h2 {
                font-size: 22px;
            }

    .page-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

        .page-head h1 {
            font-size: 22px;
            line-height: 1.2;
            overflow-wrap: anywhere;
        }

    .page-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 8px;
    }

        .page-actions .btn {
            width: 100%;
            min-width: 0;
            white-space: normal;
            text-align: center;
        }

    /* Booking filters */
    .filter-panel {
        width: 100%;
        min-width: 0;
        border-radius: 8px;
    }

    .filter-tabs {
        display: flex;
        flex-wrap: nowrap;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 2px;
        padding: 8px 8px 0 !important;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

        .filter-tabs .nav-item {
            flex: 0 0 auto;
        }

        .filter-tabs .nav-link {
            white-space: nowrap;
            padding: 8px 10px;
            font-size: 13px;
        }

    .filter-content {
        padding: 12px 10px;
    }

    .filter-grid,
    .filter-grid.zip-city,
    .filters {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .filter-panel [name="Search"],
    .filter-panel [name="Status"],
    .filter-panel [name="TourOperator"],
    .filter-panel [name="AccountingReference"],
    .filter-panel [name="TravelTag"] {
        max-width: none;
    }

    .filter-panel .filter-actions {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
        padding: 10px;
        border-top: 1px solid var(--line);
        background: #fafbfc;
    }

        .filter-panel .filter-actions .btn,
        .filter-panel .filter-actions .btn-group {
            width: 100%;
            min-width: 0;
        }

        .filter-panel .filter-actions .btn-group {
            grid-column: 1 / -1;
        }

    .filter-vertical-actions {
        float: none;
        width: 100%;
        margin: 0 0 10px;
    }

        .filter-vertical-actions .btn {
            width: 100%;
            min-width: 0;
        }

    /* Booking list: turn the 980px table into readable cards. */
    .panel.booking-panel {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .booking-panel .table-wrap {
        overflow: visible;
    }

    .booking-grid {
        width: 100%;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

        .booking-grid thead {
            display: none;
        }

        .booking-grid tbody,
        .booking-grid tr,
        .booking-grid td {
            display: block;
            width: 100%;
        }

            .booking-grid tbody tr {
                margin: 0 0 10px;
                padding: 8px 10px;
                border: 1px solid var(--line);
                border-radius: 10px;
                background: var(--panel);
            }

                .booking-grid tbody tr:hover td {
                    background: transparent;
                }

            .booking-grid tbody td {
                min-height: 34px;
                padding: 7px 0;
                border-bottom: 1px solid #edf0f3;
                display: grid;
                grid-template-columns: 104px minmax(0, 1fr);
                gap: 10px;
                align-items: start;
                text-align: left;
                overflow-wrap: anywhere;
            }

                .booking-grid tbody td:last-child {
                    border-bottom: 0;
                }

                .booking-grid tbody td::before {
                    content: attr(data-label);
                    color: var(--muted);
                    font-size: 11px;
                    font-weight: 800;
                    text-transform: uppercase;
                    letter-spacing: .04em;
                }

            .booking-grid tbody .empty-cell {
                display: block;
                padding: 18px 10px;
                text-align: center;
            }

                .booking-grid tbody .empty-cell::before {
                    display: none;
                    content: none;
                }

        .booking-grid .money {
            min-width: 0;
            text-align: left;
        }

        .booking-grid .row-actions {
            justify-content: flex-start;
        }

    .booking-status {
        max-width: 100%;
        white-space: normal;
    }

    /* Pagination */
    .table-foot {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 8px;
        min-height: 0;
        margin-top: 8px;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
    }

    .table-foot-left,
    .pagination {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pagination {
        flex-wrap: nowrap;
    }

        .pagination .page-link {
            white-space: nowrap;
        }

    .page-size {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        align-items: center;
    }

        .page-size select {
            width: 92px;
        }

    /* Booking drawer */
    .drawer-layer {
        align-items: stretch;
        justify-content: stretch;
        z-index: 1060;
    }

        .drawer-layer > form {
            width: 100%;
            height: 100%;
            border: 0;
            border-radius: 0;
            overflow: hidden;
        }

    .drawer {
        width: 100vw;
        max-width: 100%;
        height: 100dvh;
        grid-template-rows: auto auto 1fr;
    }

    .drawer-head {
        padding: 10px;
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

        .drawer-head h2 {
            font-size: 19px;
        }

        .drawer-head .eyebrow {
            margin-bottom: 4px;
        }

        .drawer-head .save-message {
            width: 100%;
        }

    .drawer-actions {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr) minmax(0, 1fr);
        width: 100%;
        gap: 6px;
    }

        .drawer-actions .btn {
            min-width: 0;
        }

    .summary-bar {
        padding: 8px 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .summary-item strong {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .drawer-body {
        min-height: 0;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .detail-tabs {
        display: flex;
        flex-wrap: nowrap;
        gap: 5px;
        width: 100%;
        max-width: 100vw;
        padding: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        -webkit-overflow-scrolling: touch;
    }

    .detail-tab {
        flex: 0 0 auto;
        min-height: 36px;
        white-space: nowrap;
    }

    .detail-content {
        width: 100%;
        min-width: 0;
        padding: 10px;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .form-grid,
    .form-band,
    .passenger-editor-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .wide,
    .full {
        grid-column: auto;
    }

    .form-band {
        padding: 10px;
    }

    .section-title {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

        .section-title > div,
        .section-title .d-flex {
            width: 100%;
            flex-wrap: wrap;
        }

        .section-title .btn {
            max-width: 100%;
        }

    .lookup-field {
        grid-template-columns: 1fr;
    }

        .lookup-field > .btn {
            width: 100%;
        }

    /* Cost and deposit rows are built by JS with fixed inline widths. */
    .row-costi,
    .row-acconto {
        min-width: 0;
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        padding: 10px !important;
        margin: 0 0 8px !important;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

        .row-costi > *,
        .row-acconto > * {
            width: 100% !important;
            min-width: 0 !important;
            margin-left: 0 !important;
            margin-right: 0 !important;
        }

        .row-costi > label,
        .row-acconto > label {
            width: auto !important;
        }

        .row-costi .check,
        .row-acconto .check {
            flex-direction: row;
            justify-content: flex-start;
            width: auto !important;
        }

            .row-costi .check input,
            .row-acconto .check input {
                width: 18px !important;
            }

    #rowCostHeader {
        display: none !important;
    }

    #costRowFooter {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 6px !important;
        margin-top: 8px !important;
    }

        #costRowFooter > div {
            width: 100% !important;
            min-width: 0 !important;
            text-align: left !important;
            align-items: stretch !important;
        }

        #costRowFooter #orderTotal {
            width: 100% !important;
        }

    .acconti-footer > div {
        flex-wrap: wrap;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .acconti-footer input,
    .acconti-footer select {
        width: 100% !important;
        min-width: 0 !important;
    }

    .acconti-footer label {
        min-width: 0 !important;
        margin-left: 0 !important;
    }

    /* Drawer areas with legacy fixed widths */
    #ecStatusSelect,
    #confirmationFileName,
    #bonusPointsBox,
    #bonusPointsBox .field {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    #verificationStatusBox {
        max-width: 100%;
        padding: 12px 16px !important;
    }

    #verificationTabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
    }

        #verificationTabs .nav-item {
            flex: 0 0 auto;
        }

    #verificationTabsContent {
        padding: 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #campiTable,
    #erroriTable {
        min-width: 720px !important;
        table-layout: auto !important;
    }

    #ecDocumentsTable {
        min-width: 520px !important;
    }

    iframe {
        max-width: 100%;
    }

    /* Product lookup */
    .product-modal {
        padding: 0;
        place-items: stretch;
    }

    .product-dialog {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .product-head {
        padding: 10px;
    }

        .product-head h2 {
            font-size: 19px;
        }

    .product-filters {
        padding: 10px;
        grid-template-columns: 1fr;
    }

    .product-results {
        padding: 10px;
    }

    .product-card,
    .product-highlight {
        grid-template-columns: 1fr;
    }

    /* Bootstrap dialogs and passenger editor */
    .modal-dialog {
        margin: 8px;
    }

    .modal-content {
        max-width: calc(100vw - 16px);
    }
}

@media (max-width: 420px) {
    .topbar-left > strong {
        max-width: 38vw;
        font-size: 13px;
    }

    .page-actions,
    .filter-panel .filter-actions {
        grid-template-columns: 1fr;
    }

        .filter-panel .filter-actions .btn-group {
            grid-column: auto;
        }

    .summary-bar {
        grid-template-columns: 1fr;
    }

    .drawer-actions {
        grid-template-columns: auto auto 1fr;
    }

        .drawer-actions #closeDrawer {
            grid-column: 1 / -1;
        }

    .booking-grid tbody td {
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 8px;
    }
}
