/* =========================================================
   Winst Tracker: simpel, leesbaar, werkt op telefoon
   ========================================================= */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #e2e5ea;
    --border-strong: #cbd2db;
    --text: #16202c;
    --muted: #6b7785;

    --accent: #2563eb;
    --accent-soft: #eff4ff;
    --ok: #15803d;
    --ok-soft: #eaf7ee;
    --warn: #b45309;
    --warn-soft: #fdf4e7;
    --danger: #dc2626;
    --danger-soft: #fdecec;

    --mick: #7c3aed;
    --lars: #0e7490;
    --bank: #b45309;

    --radius: 10px;
    --gap: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.neg { color: var(--danger); }
.strong { font-weight: 650; }
.warn-text { color: var(--warn); }
.muted-text { color: var(--muted); }

/* ================= Topbar ================= */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px 10px 20px; /* 20px links = begin van de tabtekst (8px tabs + 12px tab) */
}

.brand {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 0 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: 0 0 auto;
    border: 0;
    background: none;
    font: inherit;
    font-size: 14px;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ================= Layout ================= */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 16px 64px;
}

.pane { display: none; }
.pane.active { display: block; }

.pane-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.scope {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 2px 9px;
}

.section-title {
    font-size: 15px;
    font-weight: 650;
    margin-top: 28px;
}
.pane-title + .cards,
.pane-title + .hint { margin-top: 14px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 28px;
}
.section-head:first-child { margin-top: 0; }
.section-head .section-title { margin-top: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; }
[data-verkoop-dor-row] { margin-bottom: 14px; }

.hint {
    font-size: 13px;
    color: var(--muted);
    margin: 8px 0 14px;
    max-width: 74ch;
}

.empty, .empty-box {
    color: var(--muted);
    font-size: 14px;
}
.empty { text-align: center; padding: 20px 8px; }
.empty-box {
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
}

/* ================= Knoppen & velden ================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 9px 14px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s;
}
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.ghost {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .3);
}

.icon-btn {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

.field {
    font: inherit;
    font-size: 15px;
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 10px;
    min-height: 40px;
    transition: border-color .15s, box-shadow .15s, background-color .3s;
}
.field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
select.field {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7785' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.field.saving { border-color: var(--accent); }
.field.saved { background: var(--ok-soft); border-color: var(--ok); }
.field.failed { background: var(--danger-soft); border-color: var(--danger); }

.select-sm {
    width: auto;
    min-width: 0;
    max-width: 160px;
    font-size: 13px;
    padding: 6px 28px 6px 9px;
    min-height: 34px;
}

label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
label .field { margin-top: 4px; }
label .opt { font-weight: 400; opacity: .75; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    margin-top: 10px;
}
.check input { width: 17px; height: 17px; margin-top: 1px; flex: 0 0 auto; accent-color: var(--accent); }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 6px 12px 6px 10px;
}
.switch input { width: 17px; height: 17px; accent-color: var(--ok); }

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

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--gap);
    margin: 14px 0;
}
.cards.small { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.card-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-value { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.card-note { font-size: 11.5px; color: var(--muted); }

.card.accent { border-left-color: var(--accent); background: var(--accent-soft); }
.card.warn   { border-left-color: var(--warn); }
.card.mick   { border-left-color: var(--mick); }
.card.lars   { border-left-color: var(--lars); }
.card.bank   { border-left-color: var(--bank); }

/* ================= Panels & formulieren ================= */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 14px 0;
}
.panel-title { font-size: 15px; font-weight: 650; margin-bottom: 12px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
}
.form-grid.inner { gap: var(--gap); margin: 0; }
.form-grid + [data-action="add-product"],
.form-grid + [data-action="add-item"] { margin-top: 12px; }
.span2 { grid-column: 1 / -1; }
/* Verkoopkaart heeft maar twee velden; die hoeven niet over drie kolommen. */
.form-grid.pair { max-width: 520px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.inline-form {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}
.inline-form .field { flex: 1; }

/* ================= Items (inkoop / verkoop / uitgaven) ================= */

.items { display: flex; flex-direction: column; gap: var(--gap); }

.item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}
.inkoop-groep.vergrendeld { background: var(--surface-2); }
.inkoop-groep.vergrendeld .field:disabled { color: var(--muted); }

.item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.item-title { min-width: 0; flex: 1; }
.item-title strong { font-size: 15.5px; display: block; }
.item-title .meta { font-size: 12.5px; color: var(--muted); }
.item-title .meta strong { display: inline; font-size: inherit; color: var(--text); }

.item-id {
    display: inline-block;
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    margin-bottom: 3px;
}
.product-naam .item-id { margin-bottom: 2px; }

.field-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 15px;
}

.badge {
    flex: 0 0 auto;
    font-size: 11.5px;
    font-weight: 650;
    border-radius: 99px;
    padding: 3px 9px;
    white-space: nowrap;
}
.badge.ok    { background: var(--ok-soft); color: var(--ok); }
.badge.warn  { background: var(--warn-soft); color: var(--warn); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.calc-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 12px;
}
.calc-strip > div { display: flex; flex-direction: column; }
.calc-strip span { font-size: 11.5px; color: var(--muted); }
.calc-strip b { font-size: 15px; font-weight: 650; }

.item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.payouts { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.tag.mick  { color: var(--mick); border-color: #e2d6fb; background: #f7f3ff; }
.tag.lars  { color: var(--lars); border-color: #c9e8ef; background: #eefafd; }
.tag.bank  { color: #334155; border-color: #cbd5e1; background: #f1f5f9; }
.tag.btw   { color: var(--warn); border-color: #f2ddbd; background: #fdf6ea; }
.tag.muted { color: var(--muted); }

/* ================= Bonnetjes ================= */

.bon-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.bon-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    max-width: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    background: var(--accent-soft);
    border: 1px solid #d5e2fb;
    border-radius: 8px;
    padding: 7px 11px;
}
.bon-link:hover { background: #e3ecfd; }
.bon-link > span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bon-icoon { flex: 0 0 auto; font-size: 14px; }
.bon-grootte { flex: 0 0 auto; font-weight: 400; color: var(--muted); font-size: 12px; }

.bon-knop {
    display: inline-flex;
    align-items: center;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 7px 11px;
    cursor: pointer;
    white-space: nowrap;
}
.bon-knop:hover { background: var(--surface-2); }

.bon-bezig { font-size: 12.5px; color: var(--muted); }
.bon-gekozen { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bon-gekozen.gekozen { color: var(--ok); font-weight: 600; }

/* ================= Inkoop: producten per transactie, verklaring & bijlagen ================= */

.subtitle {
    font-size: 12.5px;
    font-weight: 650;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin: 18px 0 8px;
}

.inkoop-totaal { flex: 0 0 auto; font-size: 15px; white-space: nowrap; }

.product-lines { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.product-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.product-line .field { flex: 1 1 150px; min-width: 0; }
.product-line input[name="inkoop"] { flex: 0 1 110px; }
.product-line input[name="serienummer"] { flex: 1 1 120px; }
.product-line-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1 1 100%; }
.product-line-head .item-id { margin-bottom: 0; }

.verkoop-product-line input[name="verkoop"] { flex: 0 1 110px; }
.product-line .btw-select { flex: 0 1 100px; }
.verkoop-product-line.is-retour .calc-mini { text-decoration: line-through; opacity: .6; }
.retour-panel { margin: 10px 0; }
.inkoop-retour { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.inkoop-retour-kop { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.retour-panel [data-retour-actie] { flex: 0 1 220px; }

.expense-line input[name="bedrag"] { flex: 0 1 130px; }
.expense-line select[name="btw_pct"] { flex: 0 1 90px; }
.expense-line .item-calc { flex: 1 1 180px; font-size: 12.5px; color: var(--muted); text-align: right; }
.expense-line .item-calc b { color: var(--text); font-weight: 650; }
.product-naam { flex: 1 1 140px; min-width: 0; font-size: 14px; }
.product-naam strong { display: block; }
.product-naam-rij { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.product-sn { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); }
.calc-mini { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.calc-mini b { font-weight: 650; color: var(--text); }
.calc-mini b.neg { color: var(--danger); }
.switch.compact { font-size: 12.5px; padding: 5px 10px 5px 8px; }
.switch.compact input { width: 15px; height: 15px; }

.icon-btn.ok:hover {
    background: var(--ok-soft);
    border-color: var(--ok);
    color: var(--ok);
}

.inkoop-bijlagen { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload-label { flex: 0 0 auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.bijlagen-lijst { display: flex; flex-wrap: wrap; gap: 8px; }
.bijlage-chip { padding: 5px 6px 5px 11px; }
.bijlage-chip a { display: inline-flex; align-items: center; gap: 7px; color: inherit; text-decoration: none; }
.bijlage-chip .icon-btn { width: 22px; height: 22px; border: 0; font-size: 11px; background: transparent; }

.veldlabel { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* ================= Tabellen ================= */

.scroll-x {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.table th, .table td {
    padding: 10px 12px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.table th:first-child, .table td:first-child { text-align: left; }
/* Kwartaal- en jaartabel hebben veel kolommen: compacter zodat ze op een laptop passen. */
#kwartaal-table, #jaar-table { font-size: 13px; }
#kwartaal-table th, #kwartaal-table td, #jaar-table th, #jaar-table td { padding: 8px 7px; }
#kwartaal-table .btn-sm, #jaar-table .btn-sm { padding: 5px 9px; }
.table thead th {
    font-size: 11.5px;
    font-weight: 650;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    background: var(--surface-2);
    position: sticky;
    top: 0;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td {
    background: var(--surface-2);
    border-top: 2px solid var(--border-strong);
    border-bottom: 0;
    font-weight: 650;
}

/* ================= Grafiek ================= */

.chart-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.pill {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 99px;
    padding: 6px 13px;
    cursor: pointer;
}
.pill:hover { background: var(--surface-2); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-panel { padding: 8px; }
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart { display: block; }
.chart-bar.pos { fill: var(--accent); }
.chart-bar.neg { fill: var(--danger); }
.chart-baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-value { font: 600 11px var(--font); fill: var(--text); }
.chart-label { font: 500 11px var(--font); fill: var(--muted); }
.chart-empty { font: 500 13px var(--font); fill: var(--muted); }

/* ================= Koper & factuur ================= */

.invoice-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.invoice-hint { font-size: 12.5px; color: var(--muted); }
.invoice-nr {
    font-size: 12px;
    font-weight: 650;
    color: var(--ok);
    background: var(--ok-soft);
    border-radius: 6px;
    padding: 4px 8px;
}
/* ================= Verkopen log ================= */

/* Begrensde hoogte met eigen scroll, zodat een lange historie het dashboard
   niet eindeloos lang maakt. */
.log-scroll {
    max-height: 460px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 8px;
}
.log-scroll .log-group:last-child { margin-bottom: 0; }
.log-scroll .empty-box { border: 0; }

.log-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
}
.log-head {
    position: sticky;
    top: -8px;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    font-weight: 650;
}
.log-row {
    display: grid;
    grid-template-columns: 54px 1fr auto;
    gap: 8px;
    align-items: baseline;
    padding: 9px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: 0; }
.log-date { color: var(--muted); font-size: 12px; }
.log-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-koper { color: var(--muted); font-size: 12px; }
.log-btw { display: none; color: var(--muted); font-size: 12px; }
.log-winst { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

/* ================= Chips (modellen) ================= */

.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.chip-list li {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 4px 6px 4px 12px;
    font-size: 13px;
}
.chip-list .icon-btn { width: 24px; height: 24px; border: 0; font-size: 12px; }

/* ================= Uitleg ================= */

.explain { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.explain li { padding-left: 14px; position: relative; color: var(--muted); }
.explain li::before {
    content: "";
    position: absolute;
    left: 0; top: 8px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--border-strong);
}
.explain strong { color: var(--text); }

/* ================= Bevestigingsvenster ================= */

.modal {
    border: 0;
    padding: 0;
    background: transparent;
    max-width: 400px;
    width: calc(100% - 32px);
    margin: auto;              /* horizontaal én verticaal gecentreerd */
    color: var(--text);
    overflow: visible;
}
.modal::backdrop {
    background: rgba(16, 32, 44, .45);
    backdrop-filter: blur(2px);
}

.modal-inner {
    background: var(--surface);
    border-radius: 14px;
    padding: 22px 20px 18px;
    box-shadow: 0 16px 40px rgba(16, 32, 44, .22);
}
.modal-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.modal-text {
    font-size: 14px;
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.modal-actions .btn { flex: 0 1 auto; }

/* Op smalle schermen knoppen op volle breedte, bevestigen bovenaan zodat je
   duim niet per ongeluk de verkeerde raakt. */
@media (max-width: 420px) {
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; padding: 11px; }
}

/* Zachte intro; wie bewegingsreductie aan heeft krijgt die niet. */
.modal[open] { animation: modal-in .14s ease-out; }
@keyframes modal-in {
    from { opacity: 0; transform: translateY(6px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .modal[open] { animation: none; }
}

.busy-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 30px 20px;
    text-align: center;
}
.busy-inner .modal-text { margin-top: 0; }
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spinner-rotate .8s linear infinite;
}
@keyframes spinner-rotate { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

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

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translate(-50%, 20px);
    background: #16202c;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 11px 18px;
    border-radius: 99px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 100;
    max-width: calc(100vw - 32px);
    text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ================= Login ================= */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 4px 20px rgba(16, 32, 44, .06);
}
.auth-card h1 { font-size: 20px; font-weight: 700; }
.auth-card .subtitle { color: var(--muted); font-size: 13.5px; margin: 4px 0 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; }
.auth-card label.check { flex-direction: row; align-items: flex-start; }
.auth-card label.check input[type="checkbox"] {
    width: 17px;
    height: 17px;
    min-height: 0;
    flex: 0 0 auto;
    margin: 2px 0 0;
    padding: 0;
    border-radius: 4px;
    accent-color: var(--accent);
}
.auth-card input {
    font: inherit;
    font-size: 15px;
    margin-top: 5px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 10px;
    min-height: 42px;
}
.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.auth-card .btn { margin-top: 4px; padding: 11px; }
.alert {
    font-size: 13.5px;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 14px 0;
}
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.notice { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ================= Inkoopverklaring ondertekenen (publieke pagina) ================= */

.auth-card.wide { max-width: 640px; text-align: left; }
.auth-card.wide .hint { color: var(--muted); font-size: 13px; }

.declaration-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 14px 0;
    font-size: 13.5px;
}
.declaration-box p { margin-bottom: 10px; }
.declaration-box p:first-child { margin-top: 0; }
.declaration-box p:last-child { margin-bottom: 0; }

.sig-label { font-size: 13px; font-weight: 600; margin-top: 4px; display: block; }
.sig-pad-wrap {
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    margin-top: 6px;
}
.sig-pad { display: block; width: 100%; height: 160px; touch-action: none; cursor: crosshair; }
.check-akkoord { margin-top: 14px; }

.privacy-box {
    margin-top: 22px;
    font-size: 12.5px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.privacy-box summary { cursor: pointer; font-weight: 600; color: var(--text); }
.privacy-box p { margin: 8px 0 0; }

/* ================= Breder scherm ================= */

@media (min-width: 620px) {
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .log-btw { display: block; text-align: right; }
    .log-row { grid-template-columns: 60px 1fr 110px 110px; }
    .topbar-row, .tabs { padding-left: 24px; padding-right: 24px; }
    .container { padding: 20px 24px 80px; }
    .select-sm { max-width: none; }
}

@media (min-width: 900px) {
    body { font-size: 15px; }
    .form-grid { grid-template-columns: repeat(3, 1fr); }
    .form-grid.inner { grid-template-columns: repeat(2, 1fr); }
    .pane-title { font-size: 22px; }
}

/* Zoekbalk en filterknoppen als één balk */
.inkoop-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
    padding: 4px 6px 4px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 99px;
    transition: border-color .15s, box-shadow .15s;
}
.inkoop-toolbar:focus-within { border-color: var(--accent); }
.inkoop-toolbar #inkoopZoek {
    flex: 1 1 220px;
    min-width: 0;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: 0;
    padding: 6px 0;
}
.inkoop-toolbar-filters { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 619px) {
    .inkoop-toolbar {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
        gap: 0;
        padding: 0;
        border-radius: 12px;
        overflow: hidden;
    }
    .inkoop-toolbar #inkoopZoek {
        flex: none;
        width: 100%;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 16px; /* voorkomt inzoomen op iOS */
    }
    .inkoop-toolbar-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        padding: 8px 10px;
        border-top: 1px solid var(--border);
        background: var(--surface-2);
    }
    .inkoop-toolbar-filters .pill { flex: 0 0 auto; white-space: nowrap; }
}

/* iOS: een datumveld heeft een eigen minimumbreedte en duwt anders de kaart uit beeld */
.form-grid > * { min-width: 0; }
input[type="date"].field {
    display: block;
    min-width: 0;
    max-width: 100%;
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
}
input[type="date"].field::-webkit-date-and-time-value { text-align: left; }

/* Logo-upload in Instellingen */
.logo-panel { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.logo-preview { flex: 0 0 auto; width: 96px; height: 64px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid rgba(128,128,128,.3); border-radius: 8px; padding: 6px; }
.logo-preview[hidden] { display: none; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-body { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.logo-body .form-actions { margin-top: 6px; padding: 0; gap: 8px; justify-content: flex-start; }

/* Logo (assets/img/logo.png) */
.brand-logo { display: block; height: 34px; width: auto; }
.brand { display: flex; align-items: center; }
.auth-logo { margin: 0 0 8px; }
.auth-logo .brand-logo { height: 64px; margin: 0 auto; }
