:root {
    --bg: #07070c;
    --bg2: #10101a;
    --panel: rgba(255, 255, 255, .075);
    --panel-strong: rgba(255, 255, 255, .11);
    --line: rgba(255, 255, 255, .12);
    --text: #f8f7fb;
    --muted: rgba(248, 247, 251, .65);
    --muted2: rgba(248, 247, 251, .45);
    --primary: #c80845;
    --primary2: #f8d800;
    --success: #38d996;
    --danger: #ff5c7c;
    --shadow: 0 30px 90px rgba(0, 0, 0, .45);
    --radius: 24px;
    --sidebar: 286px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(200, 8, 69, .22), transparent 34rem),
        radial-gradient(circle at 75% 0%, rgba(248, 216, 0, .12), transparent 30rem),
        linear-gradient(135deg, #07070c, #11111c 52%, #08080e);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

body.modal-open {
    overflow: hidden;
}

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

button,
input,
textarea,
select {
    font: inherit;
}

[hidden] {
    display: none !important;
}

/* ============================================================
   App layout
   ============================================================ */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    border-right: 1px solid var(--line);
    background: rgba(5, 5, 10, .68);
    backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

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

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #ffffff url('/assets/img/wsd-logo.png') center / contain no-repeat;
    color: transparent;
    box-shadow: 0 14px 36px rgba(200, 8, 69, .20);
    overflow: hidden;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark * {
    display: none !important;
    content: none !important;
}

.brand strong {
    display: block;
    font-size: 16px;
    line-height: 1.1;
}

.brand span,
.sidebar-footer span {
    display: block;
    color: var(--muted2);
    font-size: 12px;
    margin-top: 2px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    padding: 13px 14px;
    border-radius: 16px;
    color: var(--muted);
    border: 1px solid transparent;
    transition: .18s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--text);
    background: rgba(255, 255, 255, .08);
    border-color: var(--line);
}

.nav a.active {
    box-shadow: inset 3px 0 0 var(--primary2);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, .055);
}

.sidebar-footer strong {
    display: block;
    margin: 4px 0 12px;
}

.sidebar-footer a {
    color: #fff;
    font-size: 13px;
    opacity: .8;
}

/* ============================================================
   Main layout
   ============================================================ */

.main,
main.main {
    min-width: 0;
    width: 100%;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    align-items: stretch;
}

.topbar,
main.main > header.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-left: auto;
}

.eyebrow {
    color: var(--primary2);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .18em;
    font-weight: 800;
    margin: 0 0 6px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
.topbar h1,
main.main > header.topbar h1 {
    font-size: clamp(26px, 2.8vw, 36px);
    line-height: 1.05;
    letter-spacing: -.045em;
    margin-bottom: 0;
}

h2 {
    font-size: 20px;
    letter-spacing: -.03em;
    margin-bottom: 8px;
}

h3 {
    font-size: 18px;
    letter-spacing: -.03em;
}

.muted {
    color: var(--muted);
    font-size: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    border: 0;
    border-radius: 15px;
    padding: 12px 16px;
    color: #fff;
    cursor: pointer;
    transition: .18s ease;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(200, 8, 69, .98), rgba(248, 216, 0, .92));
    box-shadow: 0 18px 45px rgba(200, 8, 69, .28);
}

.btn-ghost {
    background: rgba(255, 255, 255, .07);
    border: 1px solid var(--line);
    color: var(--muted);
}

.btn-danger {
    border: 1px solid rgba(255, 92, 124, .40) !important;
    background: rgba(255, 92, 124, .12) !important;
    color: #ffd7df !important;
}

.btn-success {
    border: 1px solid rgba(74, 222, 128, .35) !important;
    background: rgba(74, 222, 128, .13) !important;
    color: #dcffe8 !important;
}

.btn:hover,
.small-btn:hover,
.icon-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

#btnNewWorkorder,
#btnNewInvoice,
#btnNewCustomer,
#btnNewEquipment {
    width: auto;
    min-width: 150px;
    height: 48px;
    padding: 0 22px;
    border-radius: 16px;
}

/* ============================================================
   Cards / panels
   ============================================================ */

.kpi-card,
.panel,
.auth-card,
.auth-brand {
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(24px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel,
.customers-panel,
main.main > section.panel,
main.main > section.customers-panel {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 22px;
    min-height: 0;
    height: auto;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.panel-header p,
.empty-state p,
.module-toolbar p {
    color: var(--muted);
    margin-bottom: 0;
}

.panel-grid {
    display: grid;
    grid-template-columns: 1.25fr .75fr;
    gap: 16px;
}

/* ============================================================
   Dashboard
   ============================================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(170px, 1fr));
    gap: 16px;
    margin: 0;
}

.kpi-card {
    padding: 20px 22px;
    min-height: 124px;
}

.kpi-card span,
.kpi-card small {
    display: block;
    color: var(--muted);
}

.kpi-card strong {
    display: block;
    font-size: 32px;
    line-height: 1;
    letter-spacing: -.06em;
    margin: 18px 0 12px;
}

.kpi-card.accent {
    background:
        linear-gradient(135deg, rgba(200, 8, 69, .22), rgba(248, 216, 0, .12)),
        rgba(255, 255, 255, .08);
}

.kpi-card.paid-card {
    background:
        radial-gradient(circle at top right, rgba(74, 222, 128, .13), transparent 45%),
        rgba(255, 255, 255, .055);
    border-color: rgba(74, 222, 128, .22);
}

.kpi-card.paid-card strong {
    color: #dcffe8;
}

.kpi-card.overdue-card {
    background:
        radial-gradient(circle at top right, rgba(255, 92, 124, .16), transparent 45%),
        rgba(255, 255, 255, .055);
    border-color: rgba(255, 92, 124, .26);
}

.kpi-card.overdue-card strong {
    color: #ffd7df;
}

.timeline,
.action-list {
    display: grid;
    gap: 12px;
}

.timeline-item,
.action-row {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .05);
    padding: 16px;
}

.timeline-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.timeline-item span,
.action-row small {
    color: var(--muted);
    font-size: 13px;
}

.timeline-item.done {
    border-color: rgba(56, 217, 150, .35);
    background: rgba(56, 217, 150, .08);
}

.action-row {
    width: 100%;
    text-align: left;
    color: var(--text);
    cursor: pointer;
}

.action-row span,
.action-row small {
    display: block;
}

.action-row small {
    margin-top: 4px;
}

/* ============================================================
   Forms
   ============================================================ */

.form-stack,
.customer-form {
    display: grid;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.field {
    display: grid;
    gap: 7px;
}

.field.wide {
    grid-column: span 2;
}

.field.wide-full {
    grid-column: 1 / -1;
}

.field span {
    color: var(--muted);
    font-size: 13px;
}

.field input,
.field textarea,
.search-input,
.select-input,
.table-input {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, .22);
    color: #fff;
    border-radius: 15px;
    padding: 14px 15px;
    outline: none;
}

.field textarea {
    resize: vertical;
}

.field input:focus,
.field textarea:focus,
.search-input:focus,
.select-input:focus,
.table-input:focus {
    border-color: rgba(200, 8, 69, .68);
    box-shadow: 0 0 0 4px rgba(200, 8, 69, .13);
}

select.select-input,
.field select.select-input {
    width: 100%;
    min-height: 48px;
    cursor: pointer;
}

select.select-input option,
.billing-filterbox select option {
    background: #151522;
    color: #ffffff;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.check-row input {
    width: 18px;
    height: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}

/* ============================================================
   Module toolbars
   ============================================================ */

.module-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    width: 100%;
}

.toolbar-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

.search-input {
    width: min(360px, 42vw);
}

.select-input {
    min-width: 190px;
}

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
    width: 100%;
    overflow: auto;
    max-height: none;
    border: 1px solid var(--line);
    border-radius: 20px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 920px;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    position: sticky;
    top: 0;
    background: rgba(12, 12, 20, .95);
    backdrop-filter: blur(20px);
    z-index: 1;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, .035);
}

.table-title {
    display: grid;
    gap: 3px;
}

.table-title strong {
    font-size: 14px;
}

.table-title span {
    color: var(--muted);
    font-size: 12px;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.small-btn,
.icon-btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .06);
    color: #fff;
    border-radius: 12px;
    padding: 8px 10px;
    cursor: pointer;
}

.small-btn.danger {
    border-color: rgba(255, 92, 124, .35) !important;
    background: rgba(255, 92, 124, .10) !important;
    color: #ffd7df !important;
}

.icon-btn {
    width: 42px;
    height: 42px;
    font-size: 24px;
    line-height: 1;
}

.badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(255, 255, 255, .045);
}

.badge.ok,
.status-pill.done {
    color: #caffea;
    border-color: rgba(56, 217, 150, .32);
    background: rgba(56, 217, 150, .10);
}

.badge.off,
.status-pill.cancelled {
    color: #ffd7df;
    border-color: rgba(255, 92, 124, .32);
    background: rgba(255, 92, 124, .10);
}

.status-pill.draft {
    color: #d7dcff;
    border-color: rgba(130, 150, 255, .35);
    background: rgba(130, 150, 255, .10);
}

.status-pill.in_progress {
    color: #fff0c2;
    border-color: rgba(255, 196, 87, .35);
    background: rgba(255, 196, 87, .10);
}

.status-pill.invoiced {
    color: #fff4b8;
    border-color: rgba(248, 216, 0, .42);
    background: rgba(248, 216, 0, .11);
}

/* ============================================================
   Facturatie pagina
   ============================================================ */

body[data-page="billing"] .panel,
body[data-page="billing"] .customers-panel {
    min-height: 0;
    height: auto;
    max-height: none;
}

.billing-overview-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 220px;
    gap: 14px;
    margin: 18px 0 16px;
    align-items: end;
    width: 100%;
}

.billing-searchbox,
.billing-filterbox {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.billing-searchbox span,
.billing-filterbox span {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .58);
}

.billing-searchbox input,
.billing-filterbox select {
    width: 100%;
    height: 46px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, .13);
    background: rgba(10, 10, 18, .48);
    color: #fff;
    outline: none;
    padding: 0 15px;
}

.billing-searchbox input:focus,
.billing-filterbox select:focus {
    border-color: rgba(200, 8, 69, .68);
    box-shadow: 0 0 0 4px rgba(200, 8, 69, .13);
}

.billing-filterbox select {
    cursor: pointer;
}

/* ============================================================
   Modal base
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(18px);
}

.modal-card {
    width: min(980px, 100%);
    max-height: min(880px, 92vh);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 28px;
    background:
        radial-gradient(circle at top left, rgba(200, 8, 69, .16), transparent 28rem),
        rgba(18, 18, 29, .94);
    box-shadow: 0 30px 120px rgba(0, 0, 0, .6);
    padding: 24px;
}

.modal-card-wide {
    width: min(1320px, 100%);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

/* ============================================================
   Concept factuur modal
   ============================================================ */

.invoice-modal-card {
    width: min(1280px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.invoice-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

.invoice-lines-header,
.invoice-total-grid-sticky,
.invoice-modal-actions {
    flex: 0 0 auto;
}

.invoice-lines-wrap {
    flex: 1 1 auto;
    min-height: 220px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
}

.invoice-lines-table {
    width: 100%;
    min-width: 100%;
}

.invoice-lines-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(12, 12, 20, .95);
    backdrop-filter: blur(20px);
}

.invoice-total-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

/* ============================================================
   Factuur detail modal
   ============================================================ */

#invoiceDetailModal {
    overflow: hidden;
}

#invoiceDetailModal .modal-card.modal-card-wide {
    width: min(1520px, calc(100vw - 48px));
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#invoiceDetailModal .invoice-detail-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

#invoiceDetailModal .form-grid,
#invoiceDetailModal .lines-header,
#invoiceDetailModal .detail-kpis,
#invoiceDetailModal .modal-actions {
    flex: 0 0 auto;
}

#invoiceDetailModal .invoice-detail-lines-wrap {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 38vh;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
}

#invoiceDetailModal .invoice-detail-lines-wrap .data-table {
    min-width: 100%;
}

#invoiceDetailModal .invoice-detail-lines-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: rgba(12, 12, 20, .95);
    backdrop-filter: blur(20px);
}

/* ============================================================
   Workorders pagina
   ============================================================ */

body[data-page="workorders"] .panel,
body[data-page="workorders"] .customers-panel {
    min-height: 0;
    height: auto;
    max-height: none;
}

body[data-page="workorders"] .empty-state {
    min-height: 0;
    padding: 24px;
}

/* ============================================================
   Workorder modal v2
   ============================================================ */

body[data-page="workorders"] #workorderV2Modal {
    inset: 0 0 0 var(--sidebar);
    place-items: start stretch;
    padding: 12px;
}

body[data-page="workorders"] #workorderV2Modal .modal-card-wide {
    width: 100%;
    max-width: none;
    min-height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
    margin: 0;
    border-radius: 24px;
    overflow: auto;
}

body[data-page="workorders"] #workorderV2Modal .modal-header {
    margin-bottom: 12px;
}

.workorder-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    align-items: start;
}

.workorder-main {
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.workorder-side,
.workorder-summary-card {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    position: sticky;
    top: 0;
    align-self: start;
    z-index: 2;
}

.summary-card,
.workorder-summary-card {
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 24px;
    background: rgba(255, 255, 255, .05);
    padding: 16px;
    display: grid;
    gap: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

.summary-card-head h3,
.workorder-summary-card h2 {
    margin: 0;
    font-size: 20px;
}

.summary-list {
    display: grid;
    gap: 10px;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    padding: 11px 12px;
    background: rgba(255, 255, 255, .03);
}

.summary-row span {
    color: var(--muted);
    font-size: 13px;
}

.summary-row strong {
    font-size: 19px;
    letter-spacing: -.03em;
}

.summary-total-box {
    border-radius: 18px;
    padding: 15px;
    background: linear-gradient(135deg, rgba(200, 8, 69, .16), rgba(248, 216, 0, .10));
    border: 1px solid rgba(255, 255, 255, .10);
    display: grid;
    gap: 6px;
}

.summary-total-box span {
    color: rgba(255, 255, 255, .82);
    font-size: 14px;
}

.summary-total-box strong {
    font-size: 30px;
    line-height: 1.1;
    letter-spacing: -.04em;
}

.summary-actions {
    display: grid;
    gap: 10px;
    margin-top: 4px;
}

.summary-actions .btn {
    width: 100%;
}

.workorder-head-grid,
body[data-page="workorders"] #workorderV2Form .form-grid {
    display: grid;
    grid-template-columns:
        minmax(260px, 1.15fr)
        155px
        minmax(280px, 1.35fr)
        170px;
    gap: 10px;
    width: 100%;
    max-width: 100%;
}

.workorder-head-grid .field.wide,
body[data-page="workorders"] #workorderV2Form .field.wide {
    grid-column: auto;
}

.workorder-head-grid .field,
.workorder-head-grid input,
.workorder-head-grid select {
    min-width: 0;
    width: 100%;
}

#woDescription {
    min-height: 72px;
}

.lines-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 20px 0 14px;
}

.lines-header h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.lines-header p {
    margin: 0;
    color: var(--muted);
}

.lines-table-wrap,
.workorder-lines-wrap {
    width: 100%;
    max-height: calc(100vh - 315px);
    min-height: 260px;
    margin-bottom: 0;
}

.lines-table,
.workorder-lines-table {
    min-width: 100%;
    table-layout: fixed;
}

.lines-table th,
.lines-table td,
.workorder-lines-table th,
.workorder-lines-table td {
    padding: 8px 7px;
    vertical-align: middle;
}

.lines-table th:nth-child(1),
.lines-table td:nth-child(1),
.workorder-lines-table th:nth-child(1),
.workorder-lines-table td:nth-child(1) {
    width: 94px;
}

.lines-table th:nth-child(2),
.lines-table td:nth-child(2),
.workorder-lines-table th:nth-child(2),
.workorder-lines-table td:nth-child(2) {
    width: 132px;
}

.lines-table th:nth-child(3),
.lines-table td:nth-child(3),
.workorder-lines-table th:nth-child(3),
.workorder-lines-table td:nth-child(3) {
    width: 180px;
}

.lines-table th:nth-child(4),
.lines-table td:nth-child(4),
.workorder-lines-table th:nth-child(4),
.workorder-lines-table td:nth-child(4) {
    width: auto;
    min-width: 330px;
}

.lines-table th:nth-child(5),
.lines-table td:nth-child(5),
.workorder-lines-table th:nth-child(5),
.workorder-lines-table td:nth-child(5) {
    width: 86px;
}

.lines-table th:nth-child(6),
.lines-table td:nth-child(6),
.workorder-lines-table th:nth-child(6),
.workorder-lines-table td:nth-child(6) {
    width: 86px;
}

.lines-table th:nth-child(7),
.lines-table td:nth-child(7),
.workorder-lines-table th:nth-child(7),
.workorder-lines-table td:nth-child(7) {
    width: 92px;
}

.lines-table th:nth-child(8),
.lines-table td:nth-child(8),
.workorder-lines-table th:nth-child(8),
.workorder-lines-table td:nth-child(8) {
    width: 82px;
}

.table-input {
    min-height: 40px;
    padding: 8px 9px;
    border-radius: 11px;
}

.lines-table td:nth-child(2) .table-input,
.workorder-lines-table td:nth-child(2) .table-input {
    font-size: 15px;
    font-weight: 800;
}

.lines-table td:nth-child(4) .table-input,
.workorder-lines-table td:nth-child(4) .table-input {
    font-size: 15px;
    min-height: 42px;
    padding-left: 12px;
    padding-right: 12px;
}

.lines-table td:nth-child(5) .table-input,
.lines-table td:nth-child(6) .table-input,
.workorder-lines-table td:nth-child(5) .table-input,
.workorder-lines-table td:nth-child(6) .table-input {
    font-size: 13px;
    text-align: right;
    padding-left: 6px;
    padding-right: 6px;
}

.lines-table td:nth-child(7) strong,
.workorder-lines-table td:nth-child(7) strong {
    font-size: 14px;
    white-space: nowrap;
}

.lines-table td:nth-child(8) .small-btn,
.workorder-lines-table td:nth-child(8) .small-btn {
    min-height: 38px;
    padding: 7px 9px;
    border-radius: 11px;
    font-size: 12px;
}

#woStatus,
#workorderFormStatus {
    width: 100%;
    min-width: 0;
}

/* ============================================================
   Detail / sub panels
   ============================================================ */

.detail-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.mini-kpi {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .055);
    padding: 16px;
}

.mini-kpi span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.mini-kpi strong {
    display: block;
    font-size: 22px;
    letter-spacing: -.04em;
}

.mini-kpi.accent {
    background: linear-gradient(135deg, rgba(200, 8, 69, .18), rgba(248, 216, 0, .10));
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.sub-panel {
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, .045);
    padding: 18px;
}

.sub-panel-header {
    margin-bottom: 14px;
}

.sub-panel-header h3 {
    margin: 0;
    font-size: 17px;
}

.entry-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.entry-form .btn {
    grid-column: 1 / -1;
}

.compact-list {
    display: grid;
    gap: 10px;
    max-height: 320px;
    overflow: auto;
}

.compact-row {
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 16px;
    background: rgba(0, 0, 0, .16);
    padding: 12px;
    display: grid;
    gap: 8px;
}

.compact-row-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.compact-row strong {
    display: block;
}

.compact-row small {
    color: var(--muted);
}

.compact-row-actions {
    display: flex;
    justify-content: flex-end;
}

/* ============================================================
   Auth
   ============================================================ */

.auth-body {
    display: grid;
    place-items: center;
    padding: 26px;
}

.auth-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 18px;
}

.auth-brand {
    padding: clamp(28px, 5vw, 56px);
    min-height: 560px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-brand h1 {
    max-width: 660px;
    margin: 22px 0 18px;
}

.auth-brand p:not(.eyebrow) {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.7;
    max-width: 580px;
}

.auth-card {
    padding: 30px;
    align-self: center;
}

.auth-card__header p,
.login-hint {
    color: var(--muted);
}

.login-hint {
    margin: 0;
    font-size: 12px;
}

.alert {
    padding: 13px 14px;
    border-radius: 15px;
    margin-bottom: 16px;
}

.alert-danger {
    color: #fff;
    background: rgba(255, 92, 124, .14);
    border: 1px solid rgba(255, 92, 124, .28);
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 40;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    background: rgba(20, 20, 32, .96);
    box-shadow: var(--shadow);
    color: #fff;
}

.toast.error {
    border-color: rgba(255, 92, 124, .35);
    background: rgba(80, 20, 34, .96);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1500px) {
    body[data-page="workorders"] .workorder-layout {
        grid-template-columns: minmax(0, 1fr) 260px;
    }

    body[data-page="workorders"] .workorder-summary-card,
    body[data-page="workorders"] .workorder-side,
    body[data-page="workorders"] .summary-card {
        width: 260px;
        min-width: 260px;
        max-width: 260px;
    }

    body[data-page="workorders"] .workorder-head-grid,
    body[data-page="workorders"] #workorderV2Form .workorder-head-grid {
        grid-template-columns:
            minmax(240px, 1.1fr)
            145px
            minmax(250px, 1.25fr)
            155px;
    }
}

@media (max-width: 1450px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(190px, 1fr));
    }
}

@media (max-width: 1350px) {
    body[data-page="workorders"] #workorderV2Modal {
        inset: 0;
        padding: 12px;
    }

    .workorder-layout {
        grid-template-columns: 1fr;
    }

    .workorder-side,
    .workorder-summary-card {
        width: auto;
        min-width: 0;
        max-width: none;
        position: static;
    }

    .workorder-head-grid,
    body[data-page="workorders"] #workorderV2Form .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .lines-table,
    .workorder-lines-table {
        min-width: 1050px;
    }
}

@media (max-width: 1250px) {
    body[data-page="workorders"] .workorder-layout {
        grid-template-columns: 1fr;
    }

    body[data-page="workorders"] .workorder-summary-card,
    body[data-page="workorders"] .workorder-side,
    body[data-page="workorders"] .summary-card {
        width: 100%;
        min-width: 0;
        max-width: none;
        position: static;
    }

    body[data-page="workorders"] .workorder-head-grid,
    body[data-page="workorders"] #workorderV2Form .workorder-head-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 1050px) {
    .app-shell,
    .auth-shell,
    .panel-grid,
    .detail-grid,
    .detail-kpis {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        margin-left: 0;
    }

    .entry-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 900px) {
    .module-toolbar,
    .toolbar-controls,
    .lines-header {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-controls {
        margin-left: 0;
    }

    .search-input,
    .select-input {
        width: 100%;
        min-width: 0;
    }

    .billing-overview-toolbar,
    .invoice-total-grid {
        grid-template-columns: 1fr;
    }

    .invoice-modal-card {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }

    .invoice-lines-wrap {
        min-height: 180px;
    }

    #invoiceDetailModal .modal-card.modal-card-wide {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }

    #invoiceDetailModal .invoice-detail-lines-wrap {
        max-height: 30vh;
    }
}

@media (max-width: 820px) {
    .form-grid,
    .workorder-head-grid,
    body[data-page="workorders"] #workorderV2Form .form-grid {
        grid-template-columns: 1fr;
    }

    .field.wide {
        grid-column: auto;
    }

    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .main,
    main.main,
    .sidebar,
    .auth-body {
        padding: 16px;
    }

    .topbar-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
/* ============================================================
   Settings compact layout
   ============================================================ */

body[data-page="settings"] .main,
body[data-page="settings"] main.main {
    gap: 18px;
}

body[data-page="settings"] .settings-panel {
    padding: 18px 20px;
}

body[data-page="settings"] .settings-panel .module-toolbar {
    margin-bottom: 14px;
}

body[data-page="settings"] .settings-panel h2 {
    margin-bottom: 6px;
}

body[data-page="settings"] .settings-form-compact {
    gap: 12px;
}

body[data-page="settings"] .settings-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

body[data-page="settings"] .settings-grid .field.wide {
    grid-column: span 2;
}

body[data-page="settings"] .settings-grid .field.wide-full {
    grid-column: 1 / -1;
}

body[data-page="settings"] .settings-grid .field {
    gap: 6px;
}

body[data-page="settings"] .settings-grid .field span {
    font-size: 12px;
}

body[data-page="settings"] .settings-grid input,
body[data-page="settings"] .settings-grid textarea {
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 14px;
}

body[data-page="settings"] .settings-grid textarea {
    min-height: 96px;
    resize: vertical;
}

body[data-page="settings"] .settings-actions {
    padding-top: 0;
    margin-top: 2px;
}

body[data-page="settings"] .settings-actions .btn {
    min-width: 220px;
}

@media (max-width: 1180px) {
    body[data-page="settings"] .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body[data-page="settings"] .settings-grid .field.wide {
        grid-column: span 2;
    }
}

@media (max-width: 720px) {
    body[data-page="settings"] .settings-grid {
        grid-template-columns: 1fr;
    }

    body[data-page="settings"] .settings-grid .field.wide,
    body[data-page="settings"] .settings-grid .field.wide-full {
        grid-column: auto;
    }

    body[data-page="settings"] .settings-actions .btn {
        min-width: 0;
        width: 100%;
    }
}
/* ============================================================
   Uniforme factuurmodals
   ============================================================ */

.invoice-detail-card {
    width: min(1520px, calc(100vw - 48px));
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.invoice-detail-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

.invoice-detail-kpis,
.invoice-detail-actions {
    flex: 0 0 auto;
}

.invoice-detail-lines-wrap {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 38vh;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
}

.invoice-detail-lines-wrap .data-table {
    min-width: 100%;
}

.invoice-detail-lines-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: rgba(12, 12, 20, .95);
    backdrop-filter: blur(20px);
}

.invoice-detail-actions {
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .invoice-detail-card {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }

    .invoice-detail-lines-wrap {
        max-height: 30vh;
    }
}
/* ============================================================
   Klanten modal compacter
   ============================================================ */

#customerModal .modal-card{
    width: min(920px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    padding: 20px 22px;
    overflow: auto;
}

#customerModal .modal-header{
    margin-bottom: 12px;
}

#customerModal .modal-header h2{
    margin-bottom: 4px;
    font-size: 22px;
}

#customerModal .customer-form{
    gap: 12px;
}

#customerModal .form-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

#customerModal .field{
    gap: 6px;
}

#customerModal .field.wide{
    grid-column: span 2;
}

#customerModal .field.wide-full{
    grid-column: 1 / -1;
}

#customerModal .field span{
    font-size: 12px;
}

#customerModal .field input,
#customerModal .field textarea,
#customerModal .field select{
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 13px;
    font-size: 13px;
}

#customerModal .check-row{
    margin-top: 2px;
    font-size: 13px;
}

#customerModal .modal-actions{
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.08);
}

@media (max-width: 820px){
    #customerModal .modal-card{
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        padding: 16px;
    }

    #customerModal .form-grid{
        grid-template-columns: 1fr;
    }

    #customerModal .field.wide,
    #customerModal .field.wide-full{
        grid-column: auto;
    }
}
/* ============================================================
   Apparatuur modal compacter
   ============================================================ */

#equipmentModal .modal-card{
    width: min(920px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    padding: 20px 22px;
    overflow: auto;
}

#equipmentModal .modal-header{
    margin-bottom: 12px;
}

#equipmentModal .modal-header h2{
    margin-bottom: 4px;
    font-size: 22px;
}

#equipmentModal .customer-form{
    gap: 12px;
}

#equipmentModal .form-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

#equipmentModal .field{
    gap: 6px;
}

#equipmentModal .field.wide{
    grid-column: span 2;
}

#equipmentModal .field.wide-full{
    grid-column: 1 / -1;
}

#equipmentModal .field span{
    font-size: 12px;
}

#equipmentModal .field input,
#equipmentModal .field textarea,
#equipmentModal .field select{
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 13px;
    font-size: 13px;
}

#equipmentModal .check-row{
    margin-top: 2px;
    font-size: 13px;
}

#equipmentModal .modal-actions{
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.08);
}

@media (max-width: 820px){
    #equipmentModal .modal-card{
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        padding: 16px;
    }

    #equipmentModal .form-grid{
        grid-template-columns: 1fr;
    }

    #equipmentModal .field.wide,
    #equipmentModal .field.wide-full{
        grid-column: auto;
    }
}




/* ============================================================
   WSD kleurenthema
   ============================================================ */

:root {
    --primary: #c80845;
    --primary2: #f8d800;
}

/* WSD-rood met subtiel geel accent */
.btn-primary {
    background:
        linear-gradient(
            135deg,
            #a9063a 0%,
            #c80845 68%,
            #f8d800 100%
        );
    box-shadow: 0 18px 45px rgba(200, 8, 69, .28);
    color: #ffffff;
}

/* Actief menu-item */
.nav a.active {
    background:
        linear-gradient(
            90deg,
            rgba(200, 8, 69, .18),
            rgba(248, 216, 0, .055)
        );
    border-color: rgba(200, 8, 69, .32);
    box-shadow: inset 3px 0 0 #f8d800;
}

/* Kopaccenten */
.eyebrow {
    color: #f8d800;
}

/* Focusranden */
.field input:focus,
.field textarea:focus,
.search-input:focus,
.select-input:focus,
.table-input:focus,
.billing-searchbox input:focus,
.billing-filterbox select:focus {
    border-color: rgba(200, 8, 69, .72);
    box-shadow: 0 0 0 4px rgba(200, 8, 69, .14);
}

/* Dashboardaccent */
.kpi-card.accent,
.mini-kpi.accent,
.summary-total-box {
    background:
        radial-gradient(
            circle at top right,
            rgba(248, 216, 0, .12),
            transparent 52%
        ),
        linear-gradient(
            135deg,
            rgba(200, 8, 69, .20),
            rgba(200, 8, 69, .08)
        ),
        rgba(255, 255, 255, .055);
}

/* Modals */
.modal-card {
    background:
        radial-gradient(
            circle at top left,
            rgba(200, 8, 69, .17),
            transparent 28rem
        ),
        radial-gradient(
            circle at top right,
            rgba(248, 216, 0, .055),
            transparent 24rem
        ),
        rgba(18, 18, 29, .94);
}

/* Checkbox/radio */
input[type="checkbox"],
input[type="radio"] {
    accent-color: #c80845;
}

/* Gefactureerd-status in WSD-geel */
.status-pill.invoiced {
    color: #fff4b8;
    border-color: rgba(248, 216, 0, .42);
    background: rgba(248, 216, 0, .11);
}

/* Tekstselectie */
::selection {
    color: #211b00;
    background: rgba(248, 216, 0, .88);
}

/* WSD brand layout fix */

/* Sidebar: alleen "Administratie" onder het logo */
.sidebar .brand {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
}

.sidebar .brand strong {
    display: none !important;
}

.sidebar .brand span {
    display: block !important;
    margin-top: 0 !important;
    font-size: 13px !important;
    color: var(--muted) !important;
}

/* Sidebar-logo compacter zodat het niet overlapt */
.sidebar .brand-mark {
    display: block !important;
    width: 220px !important;
    height: 78px !important;
    max-width: 100% !important;
    margin: 0 !important;

    background-image: url('/assets/img/wsd-logo.png') !important;
    background-position: left center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
    background-color: transparent !important;

    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: 0 !important;
}

/* Loginpagina: logo juist groot houden */
.auth-brand .brand {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
}

.auth-brand .brand-mark {
    display: block !important;
    width: 350px !important;
    height: 135px !important;
    max-width: 95% !important;
    margin: 0 !important;

    background-image: url('/assets/img/wsd-logo.png') !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
    background-color: transparent !important;

    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: 0 !important;
}

.brand-mark::before,
.brand-mark::after {
    display: none !important;
    content: none !important;
}


/* ============================================================
   Servicerapporten
   ============================================================ */

.service-reports-table {
    min-width: 1120px;
}

.service-reports-table td {
    vertical-align: middle;
}

.service-report-confidence {
    display: block;
    margin-top: 5px;
    color: var(--muted2);
    font-size: 11px;
}

.service-report-actions {
    flex-wrap: wrap;
    min-width: 130px;
}

.service-report-status.received {
    color: #d7dcff;
    border-color: rgba(130, 150, 255, .35);
    background: rgba(130, 150, 255, .10);
}

.service-report-status.recognized {
    color: #fff4b8;
    border-color: rgba(248, 216, 0, .40);
    background: rgba(248, 216, 0, .10);
}

.service-report-status.review {
    color: #ffe7be;
    border-color: rgba(255, 172, 72, .38);
    background: rgba(255, 172, 72, .10);
}

.service-report-status.linked {
    color: #caffea;
    border-color: rgba(56, 217, 150, .34);
    background: rgba(56, 217, 150, .10);
}

.service-report-status.emailed {
    color: #d8efff;
    border-color: rgba(74, 173, 255, .35);
    background: rgba(74, 173, 255, .10);
}

.service-report-status.error {
    color: #ffd7df;
    border-color: rgba(255, 92, 124, .35);
    background: rgba(255, 92, 124, .10);
}

.service-report-modal-card {
    width: min(780px, calc(100vw - 40px));
}

.service-report-form-grid {
    grid-template-columns: 220px minmax(0, 1fr);
}

.service-report-file-info {
    display: grid;
    gap: 5px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .045);
}

.service-report-file-info span {
    color: var(--muted);
    font-size: 12px;
}

.service-report-modal-actions {
    align-items: center;
}

.service-report-modal-actions #serviceReportUnlink {
    margin-right: auto;
}

@media (max-width: 760px) {
    .service-report-form-grid {
        grid-template-columns: 1fr;
    }

    .service-report-form-grid .field.wide {
        grid-column: auto;
    }

    .service-report-modal-actions #serviceReportUnlink {
        margin-right: 0;
    }
}


/* ============================================================
   Werkbon servicerapport-koppeling
   ============================================================ */

.service-report-link-field {
    margin-top: 12px;
}

.service-report-link-field .select-input {
    width: 100%;
}

.service-report-link-field small {
    display: block;
    margin-top: 2px;
    line-height: 1.45;
}


/* ============================================================
   Klant tarieven en proforma
   ============================================================ */

.customer-option-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 28px;
    margin-top: 14px;
}

.customer-option-grid .check-row {
    margin: 0;
}

.badge.warn {
    color: #fff2a5;
    border-color: rgba(248, 216, 0, .38);
    background: rgba(248, 216, 0, .11);
}

@media (max-width: 720px) {
    .customer-option-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
}


/* ============================================================
   Factuurdetail compact en schermvullend
   ============================================================ */

#invoiceDetailModal {
    box-sizing: border-box;
    padding: 8px;
    align-items: center;
}

#invoiceDetailModal .invoice-detail-card {
    display: flex;
    flex-direction: column;
    width: min(1520px, calc(100vw - 16px));
    max-width: none;
    height: auto;
    max-height: calc(100dvh - 16px);
    overflow: hidden;
}

#invoiceDetailModal .modal-header {
    flex: 0 0 auto;
    margin-bottom: 12px;
}

#invoiceDetailModal .invoice-detail-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

#invoiceDetailModal .invoice-detail-scroll {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px;
    scrollbar-gutter: stable;
}

#invoiceDetailModal .invoice-detail-header-grid {
    display: grid;
    grid-template-columns:
        minmax(150px, .85fr)
        minmax(170px, .95fr)
        minmax(160px, .8fr)
        minmax(300px, 1.55fr);
    gap: 10px 14px;
    align-items: end;
}

#invoiceDetailModal
.invoice-detail-header-grid
.invoice-detail-date-field,

#invoiceDetailModal
.invoice-detail-header-grid
.invoice-detail-status-field,

#invoiceDetailModal
.invoice-detail-header-grid
.invoice-detail-proforma-field,

#invoiceDetailModal
.invoice-detail-header-grid
.invoice-detail-reference-field {
    grid-column: auto !important;
    min-width: 0;
}

#invoiceDetailModal
.invoice-detail-header-grid
.field.wide-full {
    grid-column: 1 / -1;
}

#invoiceDetailModal
#detailInvoiceNotes {
    min-height: 62px;
    height: 62px;
    max-height: 110px;
    resize: vertical;
}

#invoiceDetailModal
#detailProformaStatus {
    min-height: 48px;
}

#invoiceDetailModal
.invoice-detail-lines-wrap {
    max-height: 235px;
    min-height: 150px;
    overflow: auto;
}

#invoiceDetailModal
.invoice-detail-kpis {
    margin-top: 12px;
    margin-bottom: 4px;
}

#invoiceDetailModal
.invoice-detail-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding: 12px 0 2px;
    border-top: 1px solid rgba(255, 255, 255, .10);
    background: var(--surface, #12111b);
    z-index: 5;
}

#invoiceDetailModal
.invoice-detail-actions
.btn {
    margin: 0;
}

@media (max-width: 1100px) {
    #invoiceDetailModal
    .invoice-detail-header-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    #invoiceDetailModal
    .invoice-detail-header-grid
    .invoice-detail-date-field,

    #invoiceDetailModal
    .invoice-detail-header-grid
    .invoice-detail-status-field,

    #invoiceDetailModal
    .invoice-detail-header-grid
    .invoice-detail-proforma-field,

    #invoiceDetailModal
    .invoice-detail-header-grid
    .invoice-detail-reference-field {
        grid-column: auto !important;
    }
}

@media (max-width: 680px) {
    #invoiceDetailModal {
        padding: 4px;
    }

    #invoiceDetailModal
    .invoice-detail-card {
        width: calc(100vw - 8px);
        max-height: calc(100dvh - 8px);
    }

    #invoiceDetailModal
    .invoice-detail-header-grid {
        grid-template-columns: 1fr;
    }

    #invoiceDetailModal
    .invoice-detail-header-grid
    .field {
        grid-column: 1 / -1 !important;
    }

    #invoiceDetailModal
    .invoice-detail-actions {
        justify-content: stretch;
    }

    #invoiceDetailModal
    .invoice-detail-actions
    .btn {
        flex: 1 1 145px;
    }
}

/* ============================================================
   Gebruikersbeheer
   ============================================================ */

.nav-section-title {
    margin: 16px 12px 7px;
    padding-top: 13px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sidebar-footer small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.users-toolbar-controls {
    display: grid;
    grid-template-columns:
        minmax(260px, 1.8fr)
        minmax(145px, .8fr)
        minmax(145px, .8fr);
    gap: 10px;
}

.user-modal-card {
    width: min(780px, calc(100vw - 24px));
    max-width: 780px;
}

.user-password-help {
    margin: 7px 0 14px;
    font-size: 12px;
}

.badge.user-role-admin {
    color: #ffe7ef;
    border-color: rgba(214, 31, 69, .42);
    background: rgba(214, 31, 69, .16);
}

.small-btn:disabled {
    cursor: not-allowed;
    opacity: .45;
}

@media (max-width: 980px) {
    .users-toolbar-controls {
        grid-template-columns:
            minmax(220px, 1fr)
            repeat(2, minmax(130px, .6fr));
    }
}

@media (max-width: 720px) {
    .users-toolbar-controls {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .user-modal-card {
        width: calc(100vw - 10px);
    }
}

/* ============================================================
   Klantvestigingen
   ============================================================ */

.customer-main-address-note {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 3px 0 -2px;
    padding: 10px 12px;
    border: 1px solid rgba(200, 8, 69, .22);
    border-radius: 13px;
    background: rgba(200, 8, 69, .07);
}

.customer-main-address-note strong {
    color: #fff;
    font-size: 13px;
}

.customer-main-address-note span {
    color: var(--muted);
    font-size: 12px;
}

.customer-branches-card {
    display: grid;
    gap: 11px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 18px;
    background: rgba(255, 255, 255, .025);
}

.customer-branches-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.customer-branches-header h3 {
    margin: 0 0 4px;
    font-size: 17px;
}

.customer-branches-header p {
    max-width: 630px;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.customer-branches-locked {
    padding: 11px 13px;
    border: 1px dashed rgba(255, 255, 255, .14);
    border-radius: 13px;
    color: var(--muted);
    font-size: 12px;
}

.customer-branches-wrap {
    max-height: 230px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 14px;
}

.customer-branches-table th,
.customer-branches-table td {
    padding: 8px 9px;
    font-size: 12px;
}

.customer-branches-table th:nth-child(1) {
    width: 20%;
}

.customer-branches-table th:nth-child(2) {
    width: 38%;
}

.customer-branches-table th:nth-child(3) {
    width: 15%;
}

.customer-branches-table th:nth-child(4) {
    width: 10%;
}

.customer-branches-table th:nth-child(5) {
    width: 17%;
}

.customer-branch-backdrop {
    z-index: 90;
}

.customer-branch-modal-card {
    width: min(820px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
}

.customer-branch-modal-card .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Werkbon: klant, vestiging, datum, titel en status */
body[data-page="workorders"]
#workorderV2Form
.workorder-head-grid {
    grid-template-columns:
        minmax(190px, 1fr)
        minmax(190px, 1fr)
        145px
        minmax(220px, 1.15fr)
        155px;
}

@media (max-width: 1450px) {
    body[data-page="workorders"]
    #workorderV2Form
    .workorder-head-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .customer-branches-header {
        align-items: stretch;
        flex-direction: column;
    }

    .customer-main-address-note {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .customer-branch-modal-card .form-grid {
        grid-template-columns: 1fr;
    }

    .customer-branch-modal-card .field.wide {
        grid-column: auto;
    }

    body[data-page="workorders"]
    #workorderV2Form
    .workorder-head-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Klantenkaart extra breed
   ============================================================ */

#customerModal {
    padding: 12px;
}

#customerModal > .modal-card {
    width: min(1480px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100vh - 24px);
}

/* Meer ruimte voor de klantvelden */
#customerModal > .modal-card > .customer-form > .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Bedrijfsnaam en adres blijven extra breed */
#customerModal > .modal-card .form-grid > .field.wide {
    grid-column: span 2;
}

/* Vestigingentabel beter benutten */
#customerModal .customer-branches-table {
    min-width: 100%;
    table-layout: fixed;
}

#customerModal .customer-branches-table th:nth-child(1) {
    width: 20%;
}

#customerModal .customer-branches-table th:nth-child(2) {
    width: 38%;
}

#customerModal .customer-branches-table th:nth-child(3) {
    width: 15%;
}

#customerModal .customer-branches-table th:nth-child(4) {
    width: 10%;
}

#customerModal .customer-branches-table th:nth-child(5) {
    width: 17%;
}

@media (max-width: 1100px) {
    #customerModal > .modal-card > .customer-form > .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    #customerModal {
        padding: 5px;
    }

    #customerModal > .modal-card {
        width: calc(100vw - 10px);
        max-height: calc(100vh - 10px);
    }

    #customerModal > .modal-card > .customer-form > .form-grid {
        grid-template-columns: 1fr;
    }

    #customerModal > .modal-card .form-grid > .field.wide {
        grid-column: auto;
    }
}

/* ============================================================
   Klantadres en tarieven op één regel
   ============================================================ */

@media (min-width: 1101px) {
    #customerModal
    > .modal-card
    > .customer-form
    > .form-grid {
        grid-template-columns:
            repeat(12, minmax(0, 1fr));
    }

    /* Normale klantvelden: drie per regel */
    #customerModal
    > .modal-card
    > .customer-form
    > .form-grid
    > .field {
        grid-column: span 4;
    }

    /* Brede standaardvelden */
    #customerModal
    > .modal-card
    > .customer-form
    > .form-grid
    > .field.wide {
        grid-column: span 8;
    }

    #customerModal .customer-main-address-note {
        grid-column: 1 / -1;
    }

    /* Adresregel: 6 + 2 + 2 + 2 kolommen */
    #customerModal .customer-address-main-field {
        grid-column: span 6 !important;
    }

    #customerModal .customer-postal-field {
        grid-column: span 2 !important;
    }

    #customerModal .customer-city-field {
        grid-column: span 2 !important;
    }

    #customerModal .customer-country-field {
        grid-column: span 2 !important;
    }

    /* Tarieven: drie gelijke velden op één regel */
    #customerModal .customer-hourly-rate-field,
    #customerModal .customer-travel-hour-rate-field,
    #customerModal .customer-travel-km-rate-field {
        grid-column: span 4 !important;
    }
}

@media (max-width: 1100px) {
    #customerModal
    > .modal-card
    > .customer-form
    > .form-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    #customerModal .customer-address-main-field {
        grid-column: 1 / -1;
    }
}

@media (max-width: 720px) {
    #customerModal
    > .modal-card
    > .customer-form
    > .form-grid {
        grid-template-columns: 1fr;
    }

    #customerModal
    > .modal-card
    > .customer-form
    > .form-grid
    > .field,
    #customerModal .customer-address-main-field,
    #customerModal .customer-postal-field,
    #customerModal .customer-city-field,
    #customerModal .customer-country-field,
    #customerModal .customer-hourly-rate-field,
    #customerModal .customer-travel-hour-rate-field,
    #customerModal .customer-travel-km-rate-field {
        grid-column: auto !important;
    }
}

/* ============================================================
   WSD theme toggle
   ============================================================ */

:root {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;

    --bg: #f1f2f5;
    --surface: #ffffff;
    --panel: #ffffff;
    --card: #ffffff;
    --text: #292930;
    --muted: #70707b;
    --line: rgba(34, 34, 44, .14);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.theme-toggle-icon {
    width: 18px;
    font-size: 18px;
    line-height: 1;
    text-align: center;
}

/* ============================================================
   WSD lichte modus
   ============================================================ */

html[data-theme="light"] body {
    background: #f1f2f5 !important;
    color: #292930 !important;
}

html[data-theme="light"] .main,
html[data-theme="light"] main.main {
    background:
        radial-gradient(
            circle at top right,
            rgba(200, 8, 69, .055),
            transparent 32rem
        ),
        #f1f2f5 !important;
}

html[data-theme="light"] .sidebar {
    background:
        linear-gradient(
            180deg,
            #ffffff 0%,
            #f7f7f9 100%
        ) !important;
    color: #292930 !important;
    border-right-color:
        rgba(34, 34, 44, .12) !important;
}

html[data-theme="light"] .sidebar .brand strong,
html[data-theme="light"] .sidebar-footer strong {
    color: #292930 !important;
}

html[data-theme="light"] .sidebar .brand span,
html[data-theme="light"] .sidebar-footer span,
html[data-theme="light"] .sidebar-footer small,
html[data-theme="light"] .nav-section-title {
    color: #74747e !important;
}

html[data-theme="light"] .sidebar-footer,
html[data-theme="light"] .nav-section-title {
    border-color:
        rgba(34, 34, 44, .10) !important;
}

html[data-theme="light"] .nav a {
    color: #4a4a54 !important;
}

html[data-theme="light"] .nav a:hover {
    color: #292930 !important;
    background:
        rgba(200, 8, 69, .07) !important;
}

html[data-theme="light"] .nav a.active {
    color: #ffffff !important;
}

html[data-theme="light"] .topbar {
    color: #292930 !important;
}

html[data-theme="light"] .topbar h1,
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4,
html[data-theme="light"] strong {
    color: #292930;
}

html[data-theme="light"] .panel,
html[data-theme="light"] .card,
html[data-theme="light"] .modal-card,
html[data-theme="light"] .auth-card,
html[data-theme="light"] .summary-card,
html[data-theme="light"] .workorder-summary-card,
html[data-theme="light"] .mini-kpi,
html[data-theme="light"] .customer-branches-card,
html[data-theme="light"] .service-report-file-info {
    color: #292930 !important;
    border-color:
        rgba(34, 34, 44, .13) !important;
    background:
        radial-gradient(
            circle at top left,
            rgba(200, 8, 69, .055),
            transparent 28rem
        ),
        #ffffff !important;
    box-shadow:
        0 18px 55px
        rgba(40, 40, 55, .09) !important;
}

html[data-theme="light"] .modal-backdrop {
    background:
        rgba(35, 35, 45, .35) !important;
}

html[data-theme="light"] .field span,
html[data-theme="light"] .muted,
html[data-theme="light"] .table-title span,
html[data-theme="light"] .lines-header p,
html[data-theme="light"] .customer-branches-header p,
html[data-theme="light"] .customer-main-address-note span,
html[data-theme="light"] small {
    color: #74747e !important;
}

html[data-theme="light"] .field input,
html[data-theme="light"] .field textarea,
html[data-theme="light"] .field select,
html[data-theme="light"] .search-input,
html[data-theme="light"] .select-input,
html[data-theme="light"] .table-input {
    color: #292930 !important;
    border-color:
        rgba(34, 34, 44, .15) !important;
    background: #ffffff !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
    color: #9797a0 !important;
}

html[data-theme="light"] select option {
    color: #292930;
    background: #ffffff;
}

html[data-theme="light"] .data-table {
    color: #292930 !important;
}

html[data-theme="light"] .data-table th {
    color: #555560 !important;
    border-color:
        rgba(34, 34, 44, .11) !important;
    background: #f2f3f6 !important;
}

html[data-theme="light"] .data-table td {
    color: #292930 !important;
    border-color:
        rgba(34, 34, 44, .09) !important;
}

html[data-theme="light"] .data-table tbody tr:hover {
    background:
        rgba(200, 8, 69, .035) !important;
}

html[data-theme="light"] .btn-ghost,
html[data-theme="light"] .small-btn,
html[data-theme="light"] .icon-btn {
    color: #33333b !important;
    border-color:
        rgba(34, 34, 44, .15) !important;
    background:
        rgba(255, 255, 255, .90) !important;
}

html[data-theme="light"] .btn-ghost:hover,
html[data-theme="light"] .small-btn:hover,
html[data-theme="light"] .icon-btn:hover {
    border-color:
        rgba(200, 8, 69, .30) !important;
    background:
        rgba(200, 8, 69, .07) !important;
}

html[data-theme="light"] .summary-row {
    border-color:
        rgba(34, 34, 44, .11) !important;
    background: #f7f7f9 !important;
}

html[data-theme="light"] .summary-row span {
    color: #70707a !important;
}

html[data-theme="light"] .summary-total-box {
    color: #292930 !important;
    border-color:
        rgba(200, 8, 69, .18) !important;
    background:
        linear-gradient(
            135deg,
            rgba(200, 8, 69, .10),
            rgba(248, 216, 0, .12)
        ) !important;
}

html[data-theme="light"] .customer-main-address-note {
    color: #292930 !important;
    border-color:
        rgba(200, 8, 69, .22) !important;
    background:
        rgba(200, 8, 69, .055) !important;
}

html[data-theme="light"] .customer-branches-locked {
    color: #70707a !important;
    border-color:
        rgba(34, 34, 44, .18) !important;
}

html[data-theme="light"]
#invoiceDetailModal
.invoice-detail-lines-wrap thead th {
    background:
        rgba(242, 243, 246, .97) !important;
}

html[data-theme="light"] .badge.off {
    color: #62626c !important;
    border-color:
        rgba(34, 34, 44, .14) !important;
    background:
        rgba(34, 34, 44, .055) !important;
}

html[data-theme="light"] .badge.ok {
    color: #17633a !important;
}

html[data-theme="light"] .badge.warn {
    color: #725d00 !important;
}

html[data-theme="light"] .status-pill.draft,
html[data-theme="light"] .status-pill.in_progress,
html[data-theme="light"] .status-pill.done,
html[data-theme="light"] .status-pill.cancelled {
    filter: saturate(.85);
}

/* Zachte overgang bij handmatig schakelen */
body,
.sidebar,
.main,
.panel,
.modal-card,
.field input,
.field textarea,
.field select,
.search-input,
.select-input,
.table-input,
.data-table th,
.data-table td {
    transition:
        background-color .18s ease,
        border-color .18s ease,
        color .18s ease;
}

@media (prefers-reduced-motion: reduce) {
    body,
    .sidebar,
    .main,
    .panel,
    .modal-card,
    .field input,
    .field textarea,
    .field select,
    .search-input,
    .select-input,
    .table-input,
    .data-table th,
    .data-table td {
        transition: none;
    }
}
