/* ==========================================================================
   Vrijmaking — layer on top of NiceAdmin (niceadmin.css) and the
   CustomsMateWorld v2 design system (cmw-v2.css). Same shell, tokens and
   rules (R1 one action blue, R2 mono for machine data, R4 status = badge),
   branded with the Licores Maduro mark.
   The views contain no conditionals: everything below renders values the API
   decided (tones, empty lists) — see CLAUDE.md "VrijmakingWeb makes no decisions".
   ========================================================================== */

:root {
    --vm-brand: #7b2a2f;        /* Licores Maduro burgundy (logo) */
    --vm-brand-gold: #8c7a45;   /* Licores Maduro gold (logo frame) */
}

/* --------------------------------------------------------------------------
   Header lockup — the Licores Maduro mark is portrait, the CMW rules assume a square mark
   -------------------------------------------------------------------------- */
body.cmw-v2 .logo img.vm-brand-mark {
    width: auto;
    height: 46px;
    max-height: 46px;
    margin: 0 10px 0 2px;
}
body.cmw-v2 .logo .vm-wordmark { margin-left: 0; display: inline-flex; flex-direction: column; line-height: 1.05; }
body.cmw-v2 .logo .vm-wordmark small {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--vm-brand);
    margin-top: 3px;
}

/* Profile: initials avatar instead of a photo */
body.cmw-v2 .vm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cmw-primary-tint);
    color: var(--cmw-primary);
    font-weight: 700;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
body.cmw-v2 .header .vm-user-role { font-size: 11px; color: var(--cmw-muted); }

/* --------------------------------------------------------------------------
   Page furniture
   -------------------------------------------------------------------------- */
body.cmw-v2 .vm-pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
body.cmw-v2 .vm-pagehead .pagetitle { margin-bottom: 0; }
body.cmw-v2 .pagetitle h1 .vm-code { font-size: inherit; font-weight: 700; letter-spacing: 0; }
body.cmw-v2 .vm-pagehead-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.cmw-v2 .vm-pagehead-actions form { margin: 0; }
body.cmw-v2 .vm-lead { color: var(--cmw-muted); margin: -10px 0 18px; font-size: 13px; }
body.cmw-v2 .card-title .vm-card-hint { font-weight: 400; color: var(--cmw-muted); font-size: 12px; }
body.cmw-v2 .vm-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
body.cmw-v2 .vm-card-head .card-title { margin-bottom: 0; }

/* Fact lists (label / value) */
.vm-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 12.5px; }
.vm-facts dt { color: var(--cmw-muted); font-weight: 500; white-space: nowrap; }
.vm-facts dd { margin: 0; color: var(--cmw-text); font-weight: 600; }

/* Dashboard step tiles (NiceAdmin info-card) */
body.cmw-v2 .info-card .vm-step-no {
    font-family: var(--cmw-font-mono);
    font-size: 11px;
    color: var(--cmw-muted);
    font-weight: 600;
}
body.cmw-v2 .info-card a.stretched-link { z-index: 1; }

/* --------------------------------------------------------------------------
   Grids — the CMW DataTables spec applied to server-rendered tables
   -------------------------------------------------------------------------- */
body.cmw-v2 .vm-grid-wrap { border: 1px solid var(--cmw-border); border-radius: 8px; overflow: auto; background: var(--cmw-surface); }
body.cmw-v2 .vm-grid { width: 100%; margin: 0; font-size: 12.5px; color: var(--cmw-text); border-collapse: separate; border-spacing: 0; }
body.cmw-v2 .vm-grid > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--cmw-table-head-bg);
    color: var(--cmw-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--cmw-border);
    padding: 9px 12px;
    white-space: nowrap;
}
body.cmw-v2 .vm-grid > tbody > tr > td { padding: 8px 12px; border-bottom: 1px solid var(--cmw-row-divider); vertical-align: middle; background: var(--cmw-surface); }
body.cmw-v2 .vm-grid > tbody > tr:last-child > td { border-bottom: 0; }
body.cmw-v2 .vm-grid > tbody > tr:hover > td { background: var(--cmw-row-hover); }
body.cmw-v2 .vm-grid > tfoot > tr > td { padding: 9px 12px; font-weight: 700; background: var(--cmw-table-head-bg); border-top: 1px solid var(--cmw-border-strong); }
body.cmw-v2 .vm-grid > tbody.vm-subtotal > tr > td,
body.cmw-v2 .vm-grid tr.vm-subtotal > td { background: var(--cmw-zebra); font-weight: 600; }
body.cmw-v2 .vm-grid a { font-weight: 600; text-decoration: none; }
body.cmw-v2 .vm-grid td.vm-actions { text-align: right; white-space: nowrap; }
body.cmw-v2 .vm-grid td.vm-actions form { display: inline; margin: 0; }
body.cmw-v2 .vm-grid .form-control-sm { min-width: 110px; }
/* The 17-column check grid: tighter cells so it fits next to the sidebar */
body.cmw-v2 .vm-grid-dense { font-size: 11.5px; }
body.cmw-v2 .vm-grid-dense > thead > tr > th { padding: 8px 7px; font-size: 10px; letter-spacing: .02em; }
body.cmw-v2 .vm-grid-dense > tbody > tr > td,
body.cmw-v2 .vm-grid-dense > tfoot > tr > td { padding: 7px 7px; }
body.cmw-v2 .vm-grid-dense .vm-num, body.cmw-v2 .vm-grid-dense .vm-code { font-size: 11px; }
body.cmw-v2 .vm-grid-dense .vm-wrap { min-width: 11rem; }
body.cmw-v2 .vm-grid .vm-declarant span { display: block; line-height: 1.3; font-size: 10.5px; }

.vm-num, .vm-code { font-family: var(--cmw-font-mono); font-variant-numeric: tabular-nums; font-size: 12px; }
th.vm-num, td.vm-num { text-align: right; white-space: nowrap; }
.vm-wrap { white-space: normal; min-width: 14rem; }
.vm-small { font-size: 11.5px; color: var(--cmw-muted); }

/* Empty states: the placeholder body shows only while the data body has no rows */
tbody.vm-rows:has(tr) + tbody.vm-empty { display: none; }
body.cmw-v2 .vm-grid > tbody.vm-empty > tr > td { text-align: center; color: var(--cmw-muted); padding: 26px 12px; background: var(--cmw-surface); }
.vm-hide-empty:not(:has(*)) { display: none; }

/* Number / code tones decided by the API */
.vm-tone-danger { color: var(--cmw-danger) !important; font-weight: 600; }
.vm-tone-muted { color: var(--cmw-muted); }

/* --------------------------------------------------------------------------
   Notices (API ResponseNoticeDto) — tone → colour + icon
   -------------------------------------------------------------------------- */

body.cmw-v2 .alert.vm-notice,
.vm-notice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.45;
}
.vm-notice ul { margin: 4px 0 0; padding-left: 18px; }
.vm-notice ul:not(:has(li)) { display: none; }
.vm-notice strong:empty { display: none; }
.vm-notice-body { flex: 1; }
.vm-notice .btn-close { font-size: 10px; margin-top: 3px; }
body.cmw-v2 .alert.vm-notice--success, .vm-notice--success { background: var(--cmw-success-bg); border-color: #bfe3cf; color: var(--cmw-success); }
body.cmw-v2 .alert.vm-notice--info, .vm-notice--info { background: var(--cmw-info-bg); border-color: #c7dcf7; color: var(--cmw-info); }
body.cmw-v2 .alert.vm-notice--warning, .vm-notice--warning { background: var(--cmw-warning-bg); border-color: #f1d9a8; color: var(--cmw-warning); }
body.cmw-v2 .alert.vm-notice--danger, .vm-notice--danger { background: var(--cmw-danger-bg); border-color: #f3c2c2; color: var(--cmw-danger); }
body.cmw-v2 .alert.vm-notice--neutral, .vm-notice--neutral { background: var(--cmw-neutral-bg); border-color: var(--cmw-border); color: var(--cmw-text-2); }
.vm-icon { font-family: bootstrap-icons !important; font-style: normal; font-size: 16px; line-height: 1.2; }
.vm-icon-success::before { content: "\f26a"; }
.vm-icon-info::before    { content: "\f430"; }
.vm-icon-warning::before { content: "\f33a"; }
.vm-icon-danger::before  { content: "\f336"; }
.vm-icon-neutral::before { content: "\f430"; }

/* Mati notice (empty states, calculation result) — one Mati per screen, secondary to the task */
.vm-mati { display: flex; gap: 16px; align-items: center; border: 1px solid var(--cmw-border); border-left: 4px solid; border-radius: 8px; background: var(--cmw-surface); padding: 14px 18px; margin-bottom: 16px; }
.vm-mati img { flex: 0 0 auto; }
.vm-mati-title { font-weight: 700; color: var(--cmw-ink); margin-bottom: 2px; }
.vm-mati ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--cmw-text-2); }
.vm-mati ul:not(:has(li)) { display: none; }
.vm-mati--success { border-left-color: var(--cmw-success); }
.vm-mati--warning { border-left-color: var(--cmw-warning-icon); }
.vm-mati--danger  { border-left-color: var(--cmw-danger); }
.vm-mati--info    { border-left-color: var(--cmw-info); }
.vm-mati--neutral { border-left-color: var(--cmw-border-strong); }

/* Inline action forms */
body.cmw-v2 .vm-inline-form { display: inline; margin: 0; }
body.cmw-v2 .vm-form-panel { border-top: 1px solid var(--cmw-border); margin-top: 16px; padding-top: 16px; }
body.cmw-v2 .vm-input-qty { width: 7rem; margin-left: auto; text-align: right; font-family: var(--cmw-font-mono); }

/* --------------------------------------------------------------------------
   Auth (login) — same CMW split screen, Licores Maduro mark
   -------------------------------------------------------------------------- */
.cmw-auth-brand-lockup img.vm-auth-mark { width: auto; height: 112px; margin: 0 22px 0 0; }
.cmw-auth-brand-lockup .vm-auth-wordmark { display: flex; flex-direction: column; }
.cmw-auth-brand-lockup .vm-auth-name { white-space: nowrap; }
.cmw-auth-brand-lockup .vm-auth-wordmark small {
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--vm-brand);
    margin-top: 8px;
}
.cmw-auth-form-logo.vm-auth-form-mark { width: auto; height: 132px; margin: 0 auto 6px; }
.cmw-auth-chip.vm-chip-brand { border-color: rgba(123, 42, 47, .25); color: var(--vm-brand); }
.cmw-auth-notice { font-size: 12.5px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; border: 1px solid; }
.cmw-auth-notice--danger  { color: #b32d2d; background: #fdecec; border-color: #f3c2c2; }
.cmw-auth-notice--warning { color: #8a5507; background: #fdf3e2; border-color: #f1d9a8; }
.cmw-auth-notice--success { color: #157347; background: #e4f5ec; border-color: #bfe3cf; }
.cmw-auth-notice--info    { color: #1268c3; background: #e8f2ff; border-color: #c7dcf7; }

/* --------------------------------------------------------------------------
   Printed reports
   -------------------------------------------------------------------------- */
body.vm-print { background: #fff; font-family: var(--cmw-font-ui); color: var(--cmw-text); }
.vm-print-toolbar { display: flex; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--cmw-border); background: var(--cmw-bg); }
.vm-report { padding: 22px 26px; }
.vm-report-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; border-bottom: 2px solid var(--vm-brand); padding-bottom: 12px; margin-bottom: 16px; }
.vm-report-brand { display: flex; align-items: center; gap: 14px; }
.vm-report-brand img { height: 64px; width: auto; }
.vm-report-title { font-size: 17px; font-weight: 800; color: var(--cmw-ink); letter-spacing: .01em; }
.vm-report-sub { font-size: 11.5px; color: var(--cmw-muted); }
.vm-report-meta { text-align: right; font-size: 12px; }
.vm-report-meta dt { display: inline; color: var(--cmw-muted); font-weight: 600; }
.vm-report-meta dd { display: inline; margin: 0 0 0 6px; font-family: var(--cmw-font-mono); font-weight: 600; }
.vm-report table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.vm-report th { background: var(--cmw-table-head-bg); color: var(--cmw-muted); text-transform: uppercase; font-size: 9.5px; letter-spacing: .04em; font-weight: 700; padding: 6px 7px; border-bottom: 1px solid var(--cmw-border-strong); text-align: left; }
.vm-report td { padding: 5px 7px; border-bottom: 1px solid var(--cmw-row-divider); }
.vm-report tr.vm-subtotal td { background: var(--cmw-zebra); font-weight: 700; border-bottom: 1px solid var(--cmw-border); }
.vm-report tfoot td { font-weight: 800; border-top: 2px solid var(--cmw-ink); border-bottom: 0; }
.vm-report-foot { margin-top: 18px; font-size: 11px; color: var(--cmw-muted); display: flex; justify-content: space-between; }
.vm-report-pay { margin-top: 26px; font-weight: 700; font-size: 13px; }
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    .vm-print-toolbar { display: none; }
    .vm-report { padding: 0; }
}

/* ---- Two-factor authentication (Mfa/Index, Mfa/RecoveryCodes, Settings/Users) ---- */
.vm-mfa-form { gap: 16px; }
.vm-mfa-form .cmw-auth-form-logo.vm-auth-form-mark { height: 84px; }
.vm-mfa-title-icon { color: var(--cmw-primary); margin-right: 8px; font-size: .9em; }
/* The API sends no setup steps once the authenticator is set up: the whole setup block disappears. */
.vm-mfa-setup:not(:has(li)) { display: none; }
.vm-mfa-setup { border: 1px solid var(--cmw-border); border-radius: var(--cmw-radius-card); padding: 14px 16px; background: var(--cmw-bg); }
.vm-mfa-steps { margin: 0 0 12px; padding-left: 20px; font-size: 13px; color: var(--cmw-text-2); line-height: 1.5; }
.vm-mfa-steps li + li { margin-top: 4px; }
.vm-mfa-qr { display: flex; gap: 16px; align-items: center; }
.vm-mfa-qr img { flex: none; width: 180px; height: 180px; padding: 8px; background: #fff; border: 1px solid var(--cmw-border); border-radius: 8px; image-rendering: pixelated; }
.vm-mfa-key { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.vm-mfa-key-value { display: block; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 14px; line-height: 1.7; letter-spacing: .04em;
    color: var(--cmw-text); background: var(--cmw-surface); border: 1px solid var(--cmw-border); border-radius: 8px; padding: 8px 10px;
    word-spacing: .2em; overflow-wrap: anywhere; user-select: all; }
.vm-mfa-code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 20px; letter-spacing: .3em; text-align: center; }
.vm-mfa-code::placeholder { letter-spacing: .3em; opacity: .35; }
.vm-mfa-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--cmw-muted); }
.vm-mfa-code-form { display: flex; flex-direction: column; gap: 14px; }
.vm-mfa-cancel { text-align: center; font-size: 13px; }
.vm-mfa-cancel .btn-link { color: var(--cmw-muted); text-decoration: none; font-size: 13px; border: 0; background: none; box-shadow: none; }
.vm-mfa-cancel .btn-link:hover { color: var(--cmw-primary); }
@media (max-width: 520px) { .vm-mfa-qr { flex-direction: column; align-items: stretch; } .vm-mfa-qr img { margin: 0 auto; } }

.vm-recovery-card { max-width: 640px; }
.vm-recovery-codes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
.vm-recovery-codes li { font-size: 16px; letter-spacing: .08em; padding: 8px 12px; border: 1px dashed var(--cmw-border-strong); border-radius: 6px; text-align: center; }
/* Reload after the codes were shown: no codes, show the explanation and hide the print button. */
.vm-recovery-gone { display: none; color: var(--cmw-muted); margin: 0; }
.vm-recovery-codes:not(:has(li)) { display: none; }
.vm-recovery-card .card-body:not(:has(.vm-recovery-codes li)) .vm-recovery-gone { display: block; }
.vm-recovery-card .card-body:not(:has(.vm-recovery-codes li)) .vm-recovery-print { display: none; }
@media print {
    #header, #sidebar, .vm-pagehead, .vm-notice, .vm-recovery-card .btn { display: none !important; }
    #main { margin: 0 !important; padding: 0 !important; }
}

body.cmw-v2 .vm-grid td.vm-actions form + form { margin-left: 6px; }

/* Mati on the sign-in pages (as on CustomsMateWorld); hidden when the brand column is short. */
.cmw-auth-mati { width: 110px; height: auto; align-self: flex-start; margin-bottom: 4px; }
@media (max-height: 820px) { .cmw-auth-mati { display: none; } }

/* Import panel: "Import files" opens a side panel with one drop zone per allowed import.
   No drop zones (no rights) = no button. The file input covers the whole box, so click and drop are native. */
.vm-import:not(:has(.vm-drop)) { display: none; }
.vm-import-panel { --bs-offcanvas-width: 460px; }
.vm-import-panel .offcanvas-header { align-items: flex-start; gap: 14px; border-bottom: 1px solid var(--cmw-border); }
.vm-import-panel .offcanvas-header img { flex: 0 0 auto; }
.vm-import-head { flex: 1 1 auto; }
.vm-import-head h2 { font-size: 18px; font-weight: 700; color: var(--cmw-ink); margin: 2px 0 4px; }
.vm-import-head p { font-size: 13px; color: var(--cmw-text-2); margin: 0; }
.vm-import-panel .offcanvas-body { display: flex; flex-direction: column; gap: 18px; }
.vm-drop { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.vm-drop-zone { position: relative; display: flex; gap: 14px; align-items: flex-start; margin: 0; padding: 16px;
    border: 1.5px dashed var(--cmw-border-strong, #c5cce0); border-radius: 10px; background: var(--cmw-surface);
    cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.vm-drop-zone:hover, .vm-drop-zone.is-over, .vm-drop-zone:focus-within { border-color: var(--cmw-primary); background: var(--cmw-primary-tint); }
.vm-drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.vm-drop-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--cmw-primary-tint); color: var(--cmw-primary); font-size: 20px; }
.vm-drop-text { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--cmw-text-2); min-width: 0; }
.vm-drop-text b { font-size: 14px; color: var(--cmw-ink); }
.vm-drop-files { font-weight: 600; color: var(--cmw-primary); overflow-wrap: anywhere; }
.vm-drop-files:empty::before { content: "No file chosen"; font-weight: 400; color: var(--cmw-text-3, #8a93a8); }
.vm-drop-zone.has-files { border-style: solid; border-color: var(--cmw-primary); }
.vm-drop-submit { align-self: flex-end; min-width: 120px; }
.vm-drop.is-busy .vm-drop-submit { pointer-events: none; opacity: .7; }
.vm-search-card { padding-top: 20px; }
