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

:root {
    --cw-primary: #55b7df;
    --cw-primary-strong: #2a9fcf;
    --cw-dark: #002050;
    --cw-ink: #111827;
    --cw-muted: #5f6f82;
    --cw-line: #b8c7d9;
    --cw-line-soft: #d9e3ee;
    --cw-bg: #dfe7f1;
    --cw-surface: #ffffff;
    --cw-surface-soft: #f4f8fb;
    --cw-danger: #b42318;
    --cw-success: #087443;
    --cw-warning: #b7791f;
    --cw-shadow: 0 12px 28px rgba(0, 32, 80, 0.08);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: var(--cw-bg);
    color: var(--cw-ink);
}

img,
svg,
video {
    height: auto;
    max-width: 100%;
}

.main {
    min-width: 0;
}

.topbar h5 {
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: right;
}

.topbar-actions {
    flex-wrap: wrap;
}

.brand-box {
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    margin-bottom: 14px;
    padding-bottom: 14px;
}

.brand-link {
    align-items: center;
    color: #ffffff;
    display: flex;
    font-size: 18px;
    font-weight: 800;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
}

.brand-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-logo {
    background: #ffffff;
    border-radius: 10px;
    height: 44px;
    object-fit: contain;
    padding: 4px;
    width: 44px;
}

.user-pill {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #eaf7fc;
    font-size: 13px;
    margin-top: 12px;
    padding: 10px;
}

.page-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.page-head h4 {
    color: #0f172a;
    font-weight: 700;
    margin: 0;
}

.page-head p {
    color: #64748b;
    margin: 4px 0 0;
}

.data-card,
.form-card,
.card-custom,
.card-table,
.dashboard-filter,
.form-section {
    background: #ffffff;
    border: 1px solid var(--cw-line);
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
    max-width: 100%;
}

.data-card,
.form-card {
    padding: 18px;
}

.filter-bar {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--cw-line);
    border-radius: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
}

.filter-bar > * {
    min-width: 0;
}

.filter-bar .form-control,
.filter-bar .form-select,
.filter-bar .btn {
    flex: 1 1 180px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid var(--cw-line);
    border-left: 4px solid #55b7df;
    border-radius: 10px;
    padding: 16px;
}

.metric-card span {
    color: #64748b;
    display: block;
    font-size: 13px;
}

.metric-card strong {
    color: #0f172a;
    display: block;
    font-size: 24px;
}

.metric-card.success {
    border-left-color: #55b7df;
}

.metric-card.muted {
    border-left-color: #94a3b8;
}

.table thead th {
    background: #eaf7fc;
    color: #002050;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    margin-bottom: 0;
    min-width: 0;
    width: 100%;
}

.table th,
.table td {
    vertical-align: middle;
    overflow-wrap: anywhere;
    white-space: normal;
}

.table-responsive {
    min-width: 0;
    max-width: 100%;
}

.table th {
    overflow-wrap: normal;
}

/* Let nested summaries fit their cards instead of imposing a page-wide width. */
@media screen {
    .card, .card-body, .card-header {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .table .badge, .table .btn {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .sales-actions, .history-actions {
        min-width: 0;
    }
}

.row > [class*="col-"] {
    min-width: 0;
}

.btn {
    border-radius: 8px;
    font-weight: 600;
}

.form-control,
.form-select {
    border-color: #cbd5e1;
    border-radius: 8px;
    max-width: 100%;
}

.permission-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.permission-block {
    border: 1px solid var(--cw-line);
    border-radius: 10px;
    padding: 14px;
}

.permission-title {
    color: #002050;
    font-weight: 700;
    margin-bottom: 10px;
}

.permission-item {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.report-page {
    background: #e8eef5;
    font-family: Inter, Segoe UI, system-ui, sans-serif;
    margin: 0;
    padding: 10px;
}

.report-sheet {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.10);
    margin: 0 auto;
    max-width: 1180px;
    overflow-x: auto;
    padding: 14px 16px;
}

.report-sheet > *:last-child {
    margin-bottom: 0 !important;
}

.report-sheet .row {
    --bs-gutter-x: 0.6rem;
    --bs-gutter-y: 0.6rem;
}

.report-header {
    align-items: stretch;
    border-bottom: 3px solid #55b7df;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(260px, 1.2fr) minmax(220px, 0.9fr) minmax(170px, 0.7fr);
    margin-bottom: 10px;
    padding-bottom: 8px;
}

.report-brand {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.report-logo {
    flex: 0 0 auto;
    height: 46px;
    max-width: 92px;
    object-fit: contain;
}

.report-company {
    color: #0f172a;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.15;
    text-transform: uppercase;
}

.report-slogan {
    color: #55b7df;
    font-size: 11px;
    font-weight: 700;
}

.report-brand small,
.report-meta small {
    color: #64748b;
    font-size: 10px;
    line-height: 1.2;
}

.report-meta {
    align-self: center;
    border-left: 1px solid #e2e8f0;
    min-width: 170px;
    padding-left: 10px;
}

.report-title {
    align-self: center;
    color: #0f172a;
    font-size: 16px;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.report-title small {
    display: inline-block;
    font-size: 11px;
    margin-top: 2px;
    text-transform: none;
}

.report-sheet .table {
    border-color: #55b7df;
    font-size: 12px;
    min-width: 0;
}

.report-sheet .table th {
    background: #55b7df;
    border-color: #55b7df;
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 800;
    padding: 7px 8px;
    text-transform: uppercase;
}

.report-sheet .table td {
    border-color: #94a3b8;
    border-style: dotted;
    color: #1e293b;
    padding: 6px 8px;
}

.report-sheet .table tfoot td,
.report-sheet .table tfoot th {
    background: #e5e7eb;
    border-color: #94a3b8;
    border-top: 2px solid #55b7df;
    color: #0f172a;
    font-weight: 800;
}

.report-section-title {
    color: #334155;
    font-size: 11px;
    font-weight: 800;
    margin: 8px 0 6px;
    text-transform: uppercase;
}

.report-empty {
    color: #64748b;
    font-weight: 600;
    padding: 18px !important;
    text-align: center;
}

.report-status {
    border-radius: 999px;
    display: inline-block;
    font-size: 10.5px;
    font-weight: 800;
    line-height: 1.1;
    padding: 3px 8px;
}

.report-status.success {
    background: #dcfce7;
    color: #166534;
}

.report-status.warning {
    background: #fef3c7;
    color: #92400e;
}

.report-status.info {
    background: #eaf7fc;
    color: #002050;
}

.report-status.muted {
    background: #e2e8f0;
    color: #475569;
}

.report-actions {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #55b7df;
    border-radius: 6px;
    margin-bottom: 10px !important;
    padding: 8px;
}

.report-actions .form-control,
.report-actions .form-select,
.report-actions .btn {
    font-size: 12px;
    min-height: 34px;
    padding-bottom: 5px;
    padding-top: 5px;
}

.report-sheet .table td:last-child,
.report-sheet .table th:last-child,
.money,
.amount {
    text-align: right;
}

.report-footer {
    align-items: center;
    color: #64748b;
    display: flex;
    font-size: 10px;
    justify-content: space-between;
    gap: 8px;
    margin: 8px auto 0;
    max-width: 1180px;
    padding: 6px 2px 0;
}

.report-page .metric-card {
    border: 1px solid #dbe3ec;
    border-left: 3px solid #55b7df;
    border-radius: 6px;
    min-height: 68px;
    padding: 10px 12px;
}

.report-page .metric-card span {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.report-page .metric-card strong {
    font-size: 18px;
    line-height: 1.15;
    margin-top: 3px;
}

.report-page .metric-card.success {
    border-left-color: #55b7df;
}

.report-page .metric-card.muted {
    border-left-color: #64748b;
}

.print-document {
    background: #ffffff;
    border: 1px solid var(--cw-line);
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
    padding: 22px;
}

.print-document-header {
    align-items: center;
    border-bottom: 3px solid #55b7df;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding-bottom: 14px;
}

.print-brand {
    align-items: center;
    display: flex;
    gap: 14px;
}

.print-logo {
    height: 68px;
    max-width: 130px;
    object-fit: contain;
}

.print-company {
    color: #002050;
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
}

.print-title {
    color: #0f172a;
    font-size: 22px;
    font-weight: 800;
    text-align: right;
    text-transform: uppercase;
}

.print-info-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.print-info-box {
    background: #f8fafc;
    border: 1px solid var(--cw-line);
    border-radius: 8px;
    padding: 12px;
}

.print-info-box small {
    color: #64748b;
    display: block;
    font-weight: 700;
    text-transform: uppercase;
}

.print-footer {
    border-top: 1px solid var(--cw-line);
    color: #64748b;
    display: flex;
    font-size: 12px;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 12px;
}

.dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)) !important;
}

.dashboard-card {
    min-width: 0;
}

.dashboard-card > div:last-child {
    min-width: 0;
}

.dashboard-card small,
.dashboard-card .fw-bold {
    overflow-wrap: anywhere;
}

.d-flex.gap-2,
.d-flex.gap-3 {
    min-width: 0;
}

@media print {
    @page {
        margin: 8mm;
        size: A4;
    }

    html,
    body {
        height: auto !important;
        margin: 0 !important;
        max-width: none;
        overflow: visible !important;
        padding: 0 !important;
        width: auto !important;
    }

    .no-print,
    .sidebar,
    .topbar {
        display: none !important;
    }

    .main {
        margin: 0 !important;
        padding: 0 !important;
    }

    body,
    .report-page {
        background: #ffffff !important;
        color: #0f172a !important;
        font-size: 10.5px;
        line-height: 1.25;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .report-page {
        display: block !important;
        padding: 0 !important;
    }

    .report-sheet {
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
        max-width: none !important;
        overflow: visible !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .data-card,
    .form-card,
    .print-document,
    .metric-card {
        border: none;
        overflow: visible;
        box-shadow: none;
    }

    .report-header {
        align-items: start;
        border-bottom: 1.5px solid #55b7df !important;
        break-inside: avoid;
        gap: 6mm;
        grid-template-columns: 1.25fr 0.9fr 0.7fr;
        margin: 0 0 5mm !important;
        padding: 0 0 3mm !important;
    }

    .report-logo {
        height: 13mm !important;
        max-width: 25mm !important;
    }

    .report-company {
        font-size: 12px !important;
    }

    .report-slogan,
    .report-title small,
    .report-brand small,
    .report-meta small {
        font-size: 8.5px !important;
    }

    .report-title {
        font-size: 13px !important;
        line-height: 1.15;
    }

    .report-meta {
        border-left: 0.5px solid #cbd5e1;
        min-width: 0;
        padding-left: 4mm;
    }

    .report-actions,
    form.no-print {
        display: none !important;
    }

    .report-sheet .row {
        --bs-gutter-x: 4mm;
        --bs-gutter-y: 3mm;
        margin-bottom: 3mm !important;
    }

    .report-page .metric-card {
        border: 0.4px solid #cbd5e1 !important;
        border-left: 1.8mm solid #55b7df !important;
        border-radius: 2mm !important;
        min-height: 14mm;
        padding: 2.2mm 3mm !important;
    }

    .report-page .metric-card.success {
        border-left-color: #55b7df !important;
    }

    .report-page .metric-card.muted {
        border-left-color: #64748b !important;
    }

    .report-page .metric-card span {
        font-size: 8px !important;
    }

    .report-page .metric-card strong {
        font-size: 12px !important;
    }

    .report-section-title {
        font-size: 8.5px !important;
        margin: 2.5mm 0 1.5mm !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .table,
    .table-responsive > .table,
    .report-sheet .table {
        border-collapse: collapse !important;
        font-size: 8.5px !important;
        margin-bottom: 0 !important;
        min-width: 0 !important;
        page-break-inside: auto;
        width: 100% !important;
    }

    .report-sheet .table th,
    .report-sheet .table td {
        padding: 1.6mm 1.8mm !important;
        vertical-align: middle !important;
        white-space: normal !important;
    }

    .report-sheet .table th {
        background: #55b7df !important;
        border-color: #55b7df !important;
        color: #ffffff !important;
        font-size: 7.6px !important;
    }

    .report-sheet .table td {
        border-color: #8b98a8 !important;
        border-style: dotted !important;
    }

    .report-sheet .table tfoot th,
    .report-sheet .table tfoot td {
        background: #d9d9d9 !important;
        border-color: #8b98a8 !important;
        color: #111827 !important;
    }

    .report-sheet .table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .report-status {
        border: 0.3px solid transparent;
        font-size: 7.4px !important;
        padding: 1mm 1.8mm !important;
    }

    .report-footer {
        border-top: 0.4px solid #cbd5e1;
        color: #64748b !important;
        font-size: 7.8px !important;
        margin-top: 4mm !important;
        max-width: none !important;
        padding-top: 2mm !important;
    }

    .report-footer::after {
        content: "Page " counter(page);
    }

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

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .page-head,
    .filter-bar,
    .report-header,
    .print-document-header,
    .print-footer,
    .report-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .page-head {
        gap: 10px;
    }

    .page-head > .d-flex,
    .main > .d-flex,
    .page-head .no-print,
    .no-print.d-flex,
    .filter-bar,
    form .d-flex,
    .card .d-flex,
    .data-card .d-flex,
    .form-card .d-flex {
        flex-wrap: wrap;
    }

    .main > .d-flex > *,
    .no-print.d-flex > * {
        min-width: 0;
    }

    .page-head .btn,
    .filter-bar .btn,
    .card .btn,
    .data-card .btn,
    .form-card .btn {
        white-space: normal;
    }

    .data-card,
    .form-card,
    .card-custom,
    .card-table,
    .dashboard-filter,
    .form-section,
    .card {
        border-radius: 9px;
    }

    .data-card,
    .form-card,
    .dashboard-filter,
    .form-section,
    .card.p-3 {
        padding: 12px !important;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-card strong {
        font-size: 20px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .form-control,
    .form-select,
    .btn {
        min-height: 40px;
    }

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

    .table-responsive > .table {
        min-width: 0;
    }

    .table th,
    .table td {
        font-size: 12px;
        padding: 0.55rem 0.5rem;
        white-space: normal;
    }

    .report-sheet {
        border-radius: 0;
        padding: 12px;
    }

    .report-header {
        text-align: left;
    }

    .report-title {
        font-size: 16px;
        text-align: left;
    }

    .print-title {
        font-size: 18px;
        text-align: left;
    }

    .report-logo {
        height: 52px;
    }

    .toast-container {
        left: 8px !important;
        padding: 0 !important;
        right: 8px !important;
        top: 8px !important;
    }

    .toast {
        width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1199.98px) {
    .table th,
    .table td {
        font-size: 13px;
    }
}

@media (max-width: 576px) {
    .page-head h4 {
        font-size: 19px;
    }

    .filter-bar .form-control,
    .filter-bar .form-select,
    .filter-bar .btn {
        flex-basis: 100%;
        width: 100%;
    }

    .page-head .btn,
    .page-head a.btn,
    .page-head button.btn,
    .no-print > .btn,
    .no-print > a.btn,
    .no-print > button.btn {
        width: 100%;
    }
}

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

    .brand-logo {
        height: 38px;
        width: 38px;
    }

    .table-responsive > .table {
        min-width: 0;
    }
}

/* PremiumCarwash global polish
   Applied late and with strong selectors because many legacy pages ship local styles. */
body:not(.report-page) {
    background:
        linear-gradient(180deg, rgba(85, 183, 223, .08), rgba(255, 255, 255, 0) 240px),
        var(--cw-bg) !important;
    color: var(--cw-ink) !important;
}

.main {
    background: transparent !important;
}

.page-head,
.main > .d-flex.justify-content-between.align-items-center.mb-3,
.main > .d-flex.justify-content-between.align-items-center.mb-4 {
    align-items: center !important;
    background: var(--cw-surface) !important;
    border: 1px solid var(--cw-line) !important;
    border-left: 6px solid var(--cw-primary) !important;
    border-radius: 2px !important;
    box-shadow: var(--cw-shadow) !important;
    display: flex !important;
    gap: 14px !important;
    margin-bottom: 16px !important;
    padding: 14px 16px !important;
}

.page-head h1,
.page-head h2,
.page-head h3,
.page-head h4,
.main > .d-flex.justify-content-between.align-items-center.mb-3 h1,
.main > .d-flex.justify-content-between.align-items-center.mb-3 h2,
.main > .d-flex.justify-content-between.align-items-center.mb-3 h3,
.main > .d-flex.justify-content-between.align-items-center.mb-3 h4,
.main > .d-flex.justify-content-between.align-items-center.mb-4 h1,
.main > .d-flex.justify-content-between.align-items-center.mb-4 h2,
.main > .d-flex.justify-content-between.align-items-center.mb-4 h3,
.main > .d-flex.justify-content-between.align-items-center.mb-4 h4 {
    color: var(--cw-dark) !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
    margin: 0 !important;
}

.card,
.data-card,
.form-card,
.card-custom,
.card-table,
.dashboard-filter,
.form-section,
.filter-bar,
.permission-block,
.print-document {
    background: var(--cw-surface) !important;
    border: 1px solid var(--cw-line) !important;
    border-radius: 2px !important;
    box-shadow: var(--cw-shadow) !important;
}

.card-custom.bg-dark,
.card-custom.bg-primary,
.card-custom.bg-success,
.card-custom.bg-danger,
.card-custom.bg-warning,
.card.bg-dark,
.card.bg-primary,
.card.bg-success,
.card.bg-danger,
.card.bg-warning {
    border: 0 !important;
    box-shadow: var(--cw-shadow) !important;
}

.bg-primary,
.text-bg-primary {
    background-color: var(--cw-primary) !important;
    color: var(--cw-dark) !important;
}

.bg-dark,
.text-bg-dark {
    background-color: var(--cw-dark) !important;
}

.bg-success,
.text-bg-success {
    background-color: var(--cw-success) !important;
}

.bg-danger,
.text-bg-danger {
    background-color: var(--cw-danger) !important;
}

.bg-warning,
.text-bg-warning {
    background-color: #f5c451 !important;
    color: var(--cw-dark) !important;
}

.metric-card,
.dashboard-card,
.stat-card,
.sales-kpi {
    background: var(--cw-surface) !important;
    border: 1px solid var(--cw-line) !important;
    border-left: 6px solid var(--cw-primary) !important;
    border-radius: 2px !important;
    box-shadow: var(--cw-shadow) !important;
    color: var(--cw-ink) !important;
}

.metric-card.success,
.dashboard-card.success,
.stat-card.success,
.sales-kpi.success {
    border-left-color: var(--cw-primary) !important;
}

.metric-card.muted,
.dashboard-card.muted,
.stat-card.muted,
.sales-kpi.muted {
    border-left-color: var(--cw-dark) !important;
}

.metric-card span,
.dashboard-card span,
.stat-card span,
.sales-kpi span,
.card-custom small,
.card small {
    color: var(--cw-muted) !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
    text-transform: uppercase !important;
}

.metric-card strong,
.dashboard-card strong,
.stat-card strong,
.sales-kpi strong {
    color: var(--cw-dark) !important;
    font-weight: 900 !important;
}

.table-responsive {
    border-radius: 2px !important;
}

.table {
    border-color: var(--cw-line) !important;
    margin-bottom: 0 !important;
}

.table thead,
.table thead th,
.table > :not(caption) > * > th {
    background: var(--cw-primary) !important;
    border-color: rgba(255, 255, 255, .75) !important;
    color: var(--cw-dark) !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
    text-transform: uppercase !important;
}

.table tbody td,
.table > :not(caption) > * > td {
    border-color: var(--cw-line-soft) !important;
    color: #1f2937 !important;
    vertical-align: middle !important;
}

.table tbody tr:hover > * {
    background-color: rgba(85, 183, 223, .08) !important;
}

.table tfoot th,
.table tfoot td {
    background: #edf2f7 !important;
    border-top: 2px solid var(--cw-primary) !important;
    color: var(--cw-dark) !important;
    font-weight: 900 !important;
}

.money,
.amount,
td[class*="montant"],
th[class*="montant"] {
    text-align: right !important;
}

.table thead th:last-child,
.table tbody td:last-child:has(.btn),
.table tbody td:last-child:has(a),
.table tbody td:last-child:has(button),
.table tbody td.actions-col,
.table thead th.actions-col {
    text-align: center !important;
}

.table tbody td:last-child .d-flex,
.table tbody td.actions-col .d-flex,
.table tbody td:last-child .client-actions,
.table tbody td.actions-col .client-actions {
    justify-content: center !important;
}

.btn {
    border-radius: 2px !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
    min-height: 38px;
}

.btn-primary,
.btn-info {
    --bs-btn-bg: var(--cw-primary);
    --bs-btn-border-color: var(--cw-primary);
    --bs-btn-color: var(--cw-dark);
    --bs-btn-hover-bg: var(--cw-dark);
    --bs-btn-hover-border-color: var(--cw-dark);
    --bs-btn-hover-color: #ffffff;
    --bs-btn-active-bg: var(--cw-dark);
    --bs-btn-active-border-color: var(--cw-dark);
    --bs-btn-active-color: #ffffff;
}

.btn-success,
.btn-dark {
    --bs-btn-bg: var(--cw-dark);
    --bs-btn-border-color: var(--cw-dark);
    --bs-btn-color: #ffffff;
    --bs-btn-hover-bg: var(--cw-primary);
    --bs-btn-hover-border-color: var(--cw-primary);
    --bs-btn-hover-color: var(--cw-dark);
}

.btn-danger {
    --bs-btn-bg: var(--cw-danger);
    --bs-btn-border-color: var(--cw-danger);
}

.btn-outline-primary,
.btn-outline-info {
    --bs-btn-color: var(--cw-dark);
    --bs-btn-border-color: var(--cw-primary);
    --bs-btn-hover-bg: var(--cw-primary);
    --bs-btn-hover-border-color: var(--cw-primary);
    --bs-btn-hover-color: var(--cw-dark);
}

.form-control,
.form-select {
    background-color: #ffffff !important;
    border-color: var(--cw-line) !important;
    border-radius: 2px !important;
    color: var(--cw-ink) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cw-primary) !important;
    box-shadow: 0 0 0 .2rem rgba(85, 183, 223, .22) !important;
}

label,
.form-label {
    color: var(--cw-dark) !important;
    font-weight: 800 !important;
}

.badge {
    border-radius: 2px !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
}

.alert {
    border-radius: 2px !important;
    border-width: 1px !important;
}

.pagination .page-link {
    border-color: var(--cw-line) !important;
    color: var(--cw-dark) !important;
}

.pagination .active .page-link,
.page-item.active .page-link {
    background: var(--cw-primary) !important;
    border-color: var(--cw-primary) !important;
    color: var(--cw-dark) !important;
    font-weight: 900 !important;
}

.modal-content,
.dropdown-menu {
    border: 1px solid var(--cw-line) !important;
    border-radius: 2px !important;
    box-shadow: 0 18px 40px rgba(0, 32, 80, .18) !important;
}

.dropdown-item.active,
.dropdown-item:active {
    background: var(--cw-primary) !important;
    color: var(--cw-dark) !important;
}

@media (max-width: 768px) {
    .page-head,
    .main > .d-flex.justify-content-between.align-items-center.mb-3,
    .main > .d-flex.justify-content-between.align-items-center.mb-4 {
        align-items: stretch !important;
        flex-direction: column !important;
        padding: 12px !important;
    }
}

/* Unified visual system. Screen rules deliberately exclude thermal/print output. */
:root {
    --cw-primary: #087f8c;
    --cw-primary-strong: #066773;
    --cw-dark: #142d4e;
    --cw-ink: #20334b;
    --cw-muted: #65758b;
    --cw-line: #dce4ee;
    --cw-line-soft: #edf1f6;
    --cw-bg: #f3f6fa;
    --cw-surface-soft: #f8fafc;
    --cw-shadow: 0 6px 24px rgba(20,45,78,.045);
}
@media screen {
    body { font-family: Inter, 'Segoe UI', system-ui, sans-serif; line-height:1.55; }
    body:not(.report-page) { background:var(--cw-bg) !important; }
    body .sidebar { background:linear-gradient(165deg,#142d4e,#102139) !important; padding:22px 16px; box-shadow:none; }
    .sidebar .brand-box { padding-bottom:20px; margin-bottom:18px; }
    .sidebar .brand-link { font-size:17px; letter-spacing:-.02em; }
    .sidebar .user-pill { background:rgba(255,255,255,.045); border:1px solid rgba(255,255,255,.08); border-radius:10px; }
    .sidebar .menu { margin-bottom:3px; }
    .sidebar .menu-header { display:flex; align-items:center; justify-content:space-between; font-size:13px; font-weight:600; padding:11px 12px; border:0; border-radius:8px; color:#c4d1e1; }
    .sidebar .menu-header::after { content:'⌄'; color:#7791ae; font-size:16px; }
    .sidebar .menu-header:hover { background:rgba(255,255,255,.07); }
    .sidebar .submenu { margin:4px 0 8px 12px; padding-left:8px; border-left:1px solid #344760; }
    .sidebar .submenu a { border:0; border-radius:7px; padding:9px 12px; font-size:12px; }
    .sidebar .submenu a.active { background:#087f8c; font-weight:600; }
    body .main { padding:24px 28px; }
    body .topbar { background:white; border:1px solid var(--cw-line); border-radius:12px; padding:14px 18px; box-shadow:var(--cw-shadow); margin-bottom:26px; }
    .topbar h5 { font-weight:650; font-size:17px; letter-spacing:-.025em; }
    .topbar .btn-light { background:#f6f8fb; border-color:#e7ecf2; box-shadow:none !important; color:#53657b; font-size:12px; }
    body .page-head, body .main > .d-flex.justify-content-between.align-items-center.mb-3, body .main > .d-flex.justify-content-between.align-items-center.mb-4 { border:0 !important; background:transparent !important; box-shadow:none !important; padding:4px 0 16px !important; border-radius:0 !important; }
    .main h3, .main h4 { letter-spacing:-.03em; font-weight:700; }
    body .card, body .data-card, body .form-card, body .card-custom, body .card-table, body .dashboard-filter, body .form-section, body .print-document { border:1px solid var(--cw-line) !important; border-radius:14px !important; box-shadow:var(--cw-shadow) !important; }
    .main .card-header { background:#f8fafc; border-bottom:1px solid var(--cw-line); padding:16px 20px; }
    body .data-card, body .form-card, body .form-section { padding:24px; }
    body .filter-bar { border-radius:12px; padding:16px; background:#fff; }
    body .btn { border-radius:8px !important; font-weight:600 !important; font-size:13px; padding:9px 15px; transition:background-color .15s,box-shadow .15s; }
    body .btn-sm { padding:5px 10px; min-height:30px; font-size:12px; }
    body .btn-primary, body .btn-info { --bs-btn-color:#fff; --bs-btn-hover-bg:#066773; --bs-btn-hover-border-color:#066773; --bs-btn-active-bg:#066773; --bs-btn-active-border-color:#066773; --bs-btn-active-color:#fff; }
    body .btn-success { --bs-btn-bg:#087443; --bs-btn-border-color:#087443; --bs-btn-hover-bg:#065c35; --bs-btn-hover-border-color:#065c35; --bs-btn-hover-color:#fff; }
    body .form-control, body .form-select { border-radius:8px !important; min-height:42px; font-size:14px; padding:9px 12px; }
    body label, body .form-label { font-weight:600 !important; font-size:13px; color:#4b5d73 !important; }
    body .form-control:focus, body .form-select:focus { box-shadow:0 0 0 3px rgba(8,127,140,.12) !important; }
    :is(a,button,input,select,textarea,summary):focus-visible { outline:3px solid #33a5b1; outline-offset:3px; }
    body .badge { border-radius:6px !important; padding:5px 8px; font-weight:600 !important; }
    body .alert, body .modal-content, body .dropdown-menu { border-radius:12px !important; }
    body .table { --bs-table-striped-bg:#f8fafc; --bs-table-hover-bg:#eff7f8; border-color:#e5ebf2 !important; font-size:13px; }
    body .table thead th { background:#f3f6fa !important; color:#52657c !important; border-color:#e2e9f1 !important; font-size:11px; font-weight:700 !important; letter-spacing:.035em; padding:14px 12px; }
    body .table tbody td { padding:13px 12px; border-color:#e8edf3 !important; border-style:solid !important; }
    body .table tfoot :is(td,th) { background:#edf5f6 !important; color:#142d4e !important; font-weight:700; padding:14px 12px; }
    body .table :is(.money,.amount,.text-end) { font-variant-numeric:tabular-nums; }
    body .metric-card, body .dashboard-kpi { border:1px solid var(--cw-line) !important; border-top:3px solid #087f8c !important; border-radius:12px !important; background:#fff !important; padding:20px !important; box-shadow:var(--cw-shadow) !important; }
    body .metric-card.success { border-top-color:#087443 !important; }
    body .metric-card.muted { border-top-color:#8798ad !important; }
    body .metric-card span, body .dashboard-kpi span { font-weight:600 !important; font-size:11px; color:#65758b; }
    body .metric-card strong, body .dashboard-kpi strong { font-weight:700 !important; font-size:26px; letter-spacing:-.035em; font-variant-numeric:tabular-nums; }
    body .dashboard-hero { border:0 !important; border-radius:16px !important; background:linear-gradient(115deg,#142d4e,#1e4665) !important; box-shadow:0 10px 28px rgba(20,45,78,.12) !important; margin-bottom:24px; }
    body .dashboard-hero::before { height:3px; background:#4ec4c4; }
    body .dashboard-hero-body { padding:30px !important; }
    body .dashboard-title { color:white; font-weight:700; text-transform:none; }
    body .dashboard-subtitle { color:#c1d4e4; font-weight:400; }
    body .dashboard-date-box { background:rgba(255,255,255,.07); color:#fff; border:1px solid rgba(255,255,255,.12); border-radius:10px; }
    body .dashboard-date-box span { color:#b8ccdd; font-weight:500; }
    body .dashboard-grid { gap:16px; }
    body .dashboard-card { border:1px solid var(--cw-line) !important; border-radius:12px !important; box-shadow:var(--cw-shadow) !important; padding:20px !important; transition:transform .15s,border-color .15s; }
    body .dashboard-card:hover { transform:translateY(-3px); border-color:#087f8c !important; }
    body .dashboard-section-title { font-weight:650; color:#51657d; margin:24px 0 14px; }
    body .print-document-header { border-bottom:2px solid #087f8c; padding-bottom:22px; }
    body .print-info-box { border-radius:10px; border-color:var(--cw-line); background:#f8fafc; }
    body:has(.login-shell) { background:#f3f6fa !important; }
    .login-shell .brand-panel { background:radial-gradient(ellipse at 0 100%,#176476,transparent 70%),#142d4e; }
    .login-shell .brand-panel::after { width:3px; background:#4ec4c4; }
    .login-shell .brand-logo { border-radius:12px; }
    .login-shell .login-card { border:1px solid var(--cw-line); border-radius:18px; box-shadow:0 18px 60px rgba(20,45,78,.07); }
    @media(max-width:768px) {
        body .main { padding:12px; }
        body .topbar { padding:12px; margin-bottom:20px; }
        body .dashboard-hero-body { padding:20px !important; grid-template-columns:1fr; }
        body .dashboard-date-box { min-width:0; text-align:left; }
        body .dashboard-kpis { grid-template-columns:1fr; }
        body .data-card, body .form-card, body .form-section { padding:16px; }
        body .metric-card strong { font-size:22px; }
    }
}
@media print {
    .print-document-header { break-inside:avoid; }
    thead { display:table-header-group; }
    tfoot { display:table-row-group; }
    .print-info-grid, .print-footer { break-inside:avoid; }
    .print-document .table :is(td,th) { border-style:solid !important; border-color:#cbd5e1 !important; }
    /* Browser page counters in normal document flow are not reliable. */
    .report-footer::after { content:none; }
}
@media(prefers-reduced-motion:reduce) {
    *, *::before, *::after { transition:none !important; scroll-behavior:auto !important; }
}
@media screen {
    .login-shell .btn-login { background:#087f8c; border-color:#087f8c; color:white; }
    .login-shell .btn-login:hover { background:#066773; color:white; }
    body .dash-mark { border-radius:10px; font-weight:650; }
    body .tone-blue, body .tone-green { background:#e6f4f4; color:#087f8c; }
    body .tone-red { background:#fceceb; color:#b42318; }
}

/* Keep full labels readable and reserve room for native select arrows. */
@media screen {
    .brand-link span { white-space:normal; overflow:visible; overflow-wrap:anywhere; }
    .brand-logo { flex-shrink:0; }
    body .form-select { padding-right:2.5rem; }
    body .form-control[type="file"] { max-width:100%; }
}
@media screen {
    .audit-filter-bar { grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)) !important; }
    .audit-filter-bar > .d-flex { flex-wrap:wrap; }
    .main form .row > .d-flex, .main form.row > .d-flex { flex-wrap:wrap; }
    .main .page-head > .d-flex, .main > .d-flex > .d-flex { flex-wrap:wrap; }
    .main .cw-actions-cell:not(td) { width:auto; min-width:0; }
}

/* Every column stays inside the available screen width. Narrow tables become records. */
@media screen {
    body .table-responsive { overflow-x:visible; }
    body .table-responsive > table, body .cw-fit-table {
        width:100% !important; min-width:0 !important; max-width:100% !important;
        table-layout:fixed;
    }
    body .cw-fit-table :is(th,td) {
        min-width:0 !important; max-width:none !important;
        white-space:normal !important; overflow-wrap:anywhere !important;
    }
    body .cw-record-table, body .cw-record-table :is(tbody,tfoot) { display:block; }
    body .cw-record-table thead {
        position:absolute; width:1px; height:1px; padding:0; overflow:hidden;
        clip-path:inset(50%); white-space:nowrap;
    }
    body .cw-record-table :is(tbody,tfoot) > tr {
        display:block; width:100%; margin-bottom:14px;
        border:1px solid var(--cw-line); border-radius:8px; overflow:visible;
    }
    body .cw-record-table :is(td,tbody th,tfoot th) {
        display:block; width:100% !important; box-sizing:border-box;
        padding:10px 12px !important; text-align:left !important;
        border-width:0 0 1px !important;
    }
    body .cw-record-table [data-cw-label]::before {
        content:attr(data-cw-label); display:block; margin-bottom:4px;
        font-size:11px; font-weight:700; color:var(--cw-muted);
        white-space:normal; overflow-wrap:anywhere;
    }
    body .cw-record-table .cw-actions { width:100%; }
    body .cw-record-table td:last-child .d-flex { justify-content:flex-start !important; flex-wrap:wrap; }
}
@media screen {
    body .cw-record-table thead th {
        display:block; position:absolute; width:1px !important; height:1px;
        padding:0 !important; border:0 !important; overflow:hidden;
    }
    body .cw-record-table { border-spacing:0 !important; border-collapse:collapse; }
}
@media screen {
    body .cw-fit-table { margin-left:0 !important; margin-right:0 !important; }
}
