:root {
    --green: #54925b;        /* primair — "Refurb" (zachte sage) */
    --green-dark: #2c4a33;   /* forest — koppen, "Market", hover */
    --green-light: #84c489;  /* accent — recycle-mark */
    --ink: #1f2922;
    --muted: #5d6a60;
    --bg: #f3f6f3;
    --card: #ffffff;
    --border: #e1e7e1;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; color: var(--green-dark); }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 1.75rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; gap: 1.25rem;
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 0 1.25rem; height: 56px; position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800;
    font-size: 1.2rem; white-space: nowrap; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--green-light); flex: none; }
.brand .b1 { color: var(--green); }
.brand .b2 { color: var(--green-dark); }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-lg .brand-logo { height: 52px; }
.mainnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a {
    color: var(--muted); padding: .4rem .7rem; border-radius: 7px; font-weight: 500;
}
.mainnav a:hover { background: #eef1f4; text-decoration: none; }
.mainnav a.active { background: var(--green); color: #fff; }
.userbox { display: flex; align-items: center; gap: .8rem; white-space: nowrap; }
.who { font-size: .9rem; color: var(--muted); }
.role-tag {
    display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase;
    padding: .1rem .4rem; border-radius: 5px; background: #eef1f4; color: var(--ink);
    letter-spacing: .03em; margin-left: .25rem;
}
.role-beheer   { background: #e7e0fb; color: #5a3ec8; }
.role-magazijn { background: #fde9cf; color: #9a5b00; }
.role-verkoop  { background: #d7ecfb; color: #14618f; }
.inline { display: inline; }
.link-btn { background: none; border: none; color: var(--green-dark); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.topbar-guest { justify-content: center; }

.container { width: min(1360px, 95%); margin: 1.5rem auto 3rem; }

/* ---------- Alerts ---------- */
.alert { padding: .75rem 1rem; border-radius: 8px; margin: 0 0 1.25rem; }
.alert.success { background: #e7f6ec; color: var(--green-dark); border: 1px solid #b9e3c7; }
.alert.error { background: #fdecea; color: #92301f; border: 1px solid #f3c4bc; }
ul.alert { padding-left: 2rem; }

/* ---------- Buttons ---------- */
.btn, .btn-sm, .btn-ghost, .btn-danger {
    display: inline-block; border: none; border-radius: 8px; cursor: pointer;
    font: inherit; font-weight: 600; text-align: center;
}
.btn { background: var(--green); color: #fff; padding: .6rem 1.2rem; }
.btn:hover { background: var(--green-dark); text-decoration: none; }
.btn-sm { background: var(--green); color: #fff; padding: .35rem .7rem; font-size: .85rem; font-weight: 600; }
.btn-sm:hover { background: var(--green-dark); text-decoration: none; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 30px;
    background: var(--green); color: #fff; border-radius: 7px; }
.btn-icon:hover { background: var(--green-dark); text-decoration: none; }
.btn-ghost { background: #eef1f4; color: var(--ink); padding: .6rem 1.2rem; }
.btn-ghost:hover { background: #e2e6ea; text-decoration: none; }
.btn-danger { background: #b04632; color: #fff; padding: .6rem 1.2rem; }
.btn-danger:hover { background: #8f3727; }

/* ---------- Tables ---------- */
table.data {
    width: 100%; border-collapse: collapse; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); margin-bottom: 1rem;
}
table.data th, table.data td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: #f7f9fb; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfc; }
table.data.compact th, table.data.compact td { padding: .35rem .55rem; font-size: .85rem; }
table.data tfoot td { background: #f7f9fb; padding: .6rem .8rem; }
.table-scroll { overflow-x: auto; }

/* Voorraadtabel: vaste lay-out die exact binnen het scherm past (geen scrollen),
   elke rij op één regel, lange kolommen inkorten met … (volledige tekst bij hover). */
.stock-table { table-layout: fixed; width: 100%; }
.stock-table th, .stock-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-table .trunc { display: inline; max-width: none; }
.stock-table th:nth-child(1), .stock-table td:nth-child(1) { width: 11%; }  /* Code */
.stock-table th:nth-child(2), .stock-table td:nth-child(2) { width: 32%; }  /* Toestel */
.stock-table th:nth-child(3), .stock-table td:nth-child(3) { width: 20%; }  /* Specs */
.stock-table th:nth-child(4), .stock-table td:nth-child(4) { width: 6%; }   /* Grade */
.stock-table th:nth-child(5), .stock-table td:nth-child(5) { width: 10%; }  /* Prijs */
.stock-table th:nth-child(6), .stock-table td:nth-child(6) { width: 9%; }   /* Locatie */
.stock-table th:nth-child(7), .stock-table td:nth-child(7) { width: 12%; }  /* Actie */
input.narrow { width: 130px; }

.empty {
    background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
    padding: 2.5rem; text-align: center; color: var(--muted);
}

/* ---------- Badges & grades ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.st-grey   { background: #eceff2; color: #4b5563; }
.st-amber  { background: #fef0d6; color: #9a5b00; }
.st-green  { background: #e2f5e9; color: var(--green-dark); }
.st-blue   { background: #dcecfa; color: #14618f; }
.st-purple { background: #ece4fb; color: #5a3ec8; }
.st-red    { background: #fbe0db; color: #a13522; }

.grade { display: inline-block; font-weight: 700; padding: .1rem .5rem; border-radius: 6px; color: #fff; font-size: .8rem; white-space: nowrap; }
.grade-A, .gr-green { background: #1f8a4c; }
.grade-B, .gr-amber { background: #c98a00; }
.grade-C, .gr-red   { background: #b04632; }
.gr-blue  { background: #14618f; }
.gr-grey  { background: #5a6472; }
.price-tag { font-weight: 700; font-size: 1.05rem; }

/* ---------- Forms ---------- */
.card-form {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
fieldset { border: none; padding: 0; margin: 0 0 1.25rem; }
legend { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: .6rem; color: var(--green-dark); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem 1.25rem; }
label { display: grid; gap: .3rem; font-size: .9rem; font-weight: 600; }
label.block { display: block; margin-bottom: .9rem; }
label.block input, label.block textarea, label.block select { margin-top: .3rem; }
input, select, textarea {
    width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 7px;
    font: inherit; font-weight: 400; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
input[type="checkbox"] { width: auto; }
.form-actions { display: flex; gap: .6rem; align-items: center; }
label.check { display: flex; flex-direction: row; align-items: center; gap: .5rem; }
.hint { font-size: .82rem; color: var(--muted); margin: .4rem 0 0; }
.ref { font-size: .9rem; color: var(--muted); margin: 0 0 .8rem; padding: .5rem .7rem;
    background: #f3f6f3; border-left: 3px solid var(--green); border-radius: 6px; }
.ref strong { color: var(--ink); }
label.check input { width: auto; }
details.newcustomer, details.demo-accounts { margin-top: .75rem; }
details summary { cursor: pointer; font-weight: 600; color: var(--green-dark); }
details.newcustomer .grid-2 { margin-top: .8rem; }

@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 3rem; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 2rem; width: min(400px, 100%);
    border-top: 4px solid var(--green); }
.login-card h1 { margin-bottom: 0; margin-top: 1rem; }
.brand-lg { font-size: 1.6rem; justify-content: center; }
.brand-lg .brand-mark { width: 34px; height: 34px; }
.stack { display: grid; gap: 1rem; margin-top: 1.25rem; }
.demo-accounts { font-size: .85rem; color: var(--muted); }
.demo-accounts ul { padding-left: 1.2rem; }
.demo-accounts code { background: #f0f2f5; padding: .05rem .3rem; border-radius: 4px; }

/* ---------- Breadcrumb & detail ---------- */
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.detail-badges { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.speclist { display: grid; grid-template-columns: 40% 60%; gap: .35rem 0; margin: 0; }
.speclist dt { color: var(--muted); font-size: .88rem; }
.speclist dd { margin: 0; font-size: .9rem; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .6rem 0 .6rem 1rem; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .85rem; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.tl-type { font-weight: 700; margin-right: .5rem; }
.tl-flow { font-size: .85rem; color: var(--muted); }
.tl-meta { display: block; font-size: .78rem; color: var(--muted); }
.tl-note { font-size: .88rem; margin-top: .15rem; }

/* ---------- Dashboard ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.stat { border-radius: var(--radius); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .2rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat:hover { text-decoration: none; transform: translateY(-1px); transition: transform .1s; }
.stat-n { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-l { font-size: .85rem; font-weight: 600; opacity: .85; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }
.gradebars { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.gradebars li { display: grid; grid-template-columns: 90px 1fr 32px; align-items: center; gap: .6rem; font-size: .88rem; }
.gradebar { background: #eef1f4; border-radius: 999px; height: 10px; overflow: hidden; }
.gradebar span { display: block; height: 100%; background: var(--green); }
.gradebar-n { text-align: right; font-weight: 700; }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Tabel die exact past, elke rij op één regel, lange cellen met … */
.tbl-fit { table-layout: fixed; width: 100%; }
.tbl-fit th, .tbl-fit td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.keuring-wait td:nth-child(1), .keuring-wait th:nth-child(1) { width: 9%; }
.keuring-wait td:nth-child(2), .keuring-wait th:nth-child(2) { width: 16%; }
.keuring-wait td:nth-child(3), .keuring-wait th:nth-child(3) { width: 25%; }
.keuring-wait td:nth-child(4), .keuring-wait th:nth-child(4) { width: 13%; }
.keuring-wait td:nth-child(5), .keuring-wait th:nth-child(5) { width: 11%; }
.keuring-wait td:nth-child(6), .keuring-wait th:nth-child(6) { width: 14%; }
.keuring-wait td:nth-child(7), .keuring-wait th:nth-child(7) { width: 12%; }
.keuring-done td:nth-child(1), .keuring-done th:nth-child(1) { width: 11%; }
.keuring-done td:nth-child(2), .keuring-done th:nth-child(2) { width: 29%; }
.keuring-done td:nth-child(3), .keuring-done th:nth-child(3) { width: 8%; }
.keuring-done td:nth-child(4), .keuring-done th:nth-child(4) { width: 13%; }
.keuring-done td:nth-child(5), .keuring-done th:nth-child(5) { width: 17%; }
.keuring-done td:nth-child(6), .keuring-done th:nth-child(6) { width: 14%; }
.keuring-done td:nth-child(7), .keuring-done th:nth-child(7) { width: 8%; }

/* ---------- Voorraad kop + export ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.export-actions { display: flex; align-items: center; gap: .5rem; }
.export-label { font-size: .85rem; color: var(--muted); }
.btn-excel { background: #1d6f42; }
.btn-excel:hover { background: #155232; }

/* ---------- Voorraad-ouderdom (rapportage) ---------- */
.aging-bars li { grid-template-columns: 160px 1fr 40px; }
.aging-bars .gradebar-label { width: auto; white-space: nowrap; overflow: visible; }

/* ---------- Periode-schakelaar (rapportage) ---------- */
.period-toggle { display: inline-flex; gap: .25rem; background: #eef1f4; border-radius: 8px; padding: .2rem; }
.period-toggle a { padding: .3rem .7rem; border-radius: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.period-toggle a:hover { text-decoration: none; }
.period-toggle a.active { background: var(--green); color: #fff; }

/* ---------- Filterbar ---------- */
.filterbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0 1.25rem; }
.filterbar input, .filterbar select { width: auto; }
.filterbar input[type="search"] { min-width: 240px; }
.brand-filter { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .7rem; }
.brand-filter-label { font-size: .85rem; color: var(--muted); }
.brand-chk { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; font-weight: 500; }
.brand-chk input { width: auto; }

/* ---------- Import mapping ---------- */
.maprows { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .75rem 1.25rem; }
.maprow { display: grid; grid-template-columns: 1fr; gap: .25rem; }
.maprow > span { font-size: .85rem; }

/* ---------- Shipping inline form ---------- */
.ship-form { display: flex; gap: .5rem; align-items: center; }
.ship-form input { width: auto; min-width: 180px; }

/* ---------- 403/404 ---------- */
.notfound { text-align: center; padding: 4rem 1rem; }
