/* Eras Interieurs CRM  ·  De Wouw Factor Internet */
:root {
    --ink: #1c1b1a;
    --ink-2: #4a4744;
    --muted: #8a8580;
    --line: #e7e2dc;
    --line-2: #f1ede8;
    --bg: #f7f5f2;
    --card: #ffffff;
    --accent: #b41f1f;
    --accent-dark: #8f1717;
    --accent-soft: #f8e9e7;
    --green: #2f7a4f;
    --green-soft: #e6f2ea;
    --amber: #a86a12;
    --amber-soft: #fbf0dc;
    --blue: #2c5d8a;
    --blue-soft: #e5eef7;
    --grey-soft: #eeebe7;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(28, 27, 26, .05), 0 4px 16px rgba(28, 27, 26, .04);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }
small, .muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .brand { display: block; padding: 4px 10px 22px; }
.sidebar .brand img { width: 128px; height: auto; display: block; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 16px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; font-size: .7rem; border-radius: 10px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--line); font-size: .85rem; }
.sidebar-foot .who { font-weight: 600; }
.sidebar-foot form { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

.main { padding: 28px 36px 60px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px; }
.card > h2:first-child, .card-head { margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 18px 22px 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 420px); gap: 20px; align-items: start; }

.stat { padding: 18px 20px; }
.stat .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat .value { font-size: 1.7rem; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.stat.accent { border-top: 3px solid var(--accent); }

dl.facts { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover { background: #fcfbf9; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 600; border-top: 2px solid var(--line); padding: 12px 14px; }
.table a.rowlink { color: var(--ink); font-weight: 600; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; background: var(--grey-soft); color: var(--ink-2); }
.badge-concept { background: var(--grey-soft); color: var(--ink-2); }
.badge-openstaand, .badge-open { background: var(--blue-soft); color: var(--blue); }
.badge-geaccepteerd, .badge-betaald { background: var(--green-soft); color: var(--green); }
.badge-geweigerd, .badge-vervallen { background: var(--accent-soft); color: var(--accent); }
.badge-gecrediteerd, .badge-verlopen { background: var(--amber-soft); color: var(--amber); }
.badge-credit { background: var(--amber-soft); color: var(--amber); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: 5px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
    width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d9d3cc; border-radius: 8px; padding: 9px 11px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(180, 31, 31, .12); }
.is-invalid { border-color: var(--accent) !important; }
.error { color: var(--accent); font-size: .82rem; margin-top: 4px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; font-size: .92rem; color: var(--ink); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row-3-1 { display: grid; gap: 14px; grid-template-columns: 3fr 1fr; }
.row-1-3 { display: grid; gap: 14px; grid-template-columns: 1fr 3fr; }
fieldset { border: 0; padding: 0; margin: 0; }
.segmented { display: inline-flex; border: 1px solid #d9d3cc; border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.segmented label { margin: 0; padding: 8px 14px; cursor: pointer; font-weight: 500; color: var(--ink-2); border-right: 1px solid #d9d3cc; }
.segmented label:last-child { border-right: 0; }
.segmented input { display: none; }
.segmented input:checked + span { color: var(--accent); }
.segmented label:has(input:checked) { background: var(--accent-soft); }
.searchbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.searchbar input[type=search] { max-width: 360px; }
.searchbar select { width: auto; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { padding: 6px 12px; border-radius: 20px; color: var(--ink-2); border: 1px solid var(--line); background: #fff; font-size: .88rem; }
.filters a.active { background: var(--ink); color: #fff; border-color: var(--ink); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 600; font-size: .9rem; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.2; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-light { background: #fff; color: var(--ink); border-color: #d9d3cc; }
.btn-light:hover { border-color: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--accent); padding-left: 6px; padding-right: 6px; }
.btn-danger { background: #fff; color: var(--accent); border-color: #e6bcbc; }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }
.inline-form { display: inline; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; font-size: .93rem; }
.alert-success { background: var(--green-soft); border-color: #c6e0ce; color: #1f5636; }
.alert-error { background: var(--accent-soft); border-color: #edc9c6; color: var(--accent-dark); }
.alert-info { background: var(--blue-soft); border-color: #c7d9eb; color: #1f4568; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Lines editor ---------- */
.lines-table td { padding: 6px 6px; border-bottom: 0; vertical-align: top; }
.lines-table th { padding: 8px 6px; }
.lines-table input, .lines-table select, .lines-table textarea { padding: 7px 9px; }
.lines-table textarea { min-height: 38px; height: 38px; }
.lines-table .col-qty { width: 90px; }
.lines-table .col-price { width: 130px; }
.lines-table .col-vat { width: 90px; }
.lines-table .col-total { width: 120px; text-align: right; padding-top: 14px; font-variant-numeric: tabular-nums; }
.lines-table .col-del { width: 38px; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; }

/* ---------- Customer picker ---------- */
.picker { position: relative; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .1); margin-top: 4px; max-height: 300px; overflow-y: auto; display: none; }
.picker-results.open { display: block; }
.picker-results button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: 9px 12px; cursor: pointer; font: inherit; }
.picker-results button:hover, .picker-results button.focus { background: var(--accent-soft); }
.picker-results small { display: block; color: var(--muted); }
.picked { display: flex; justify-content: space-between; align-items: center; background: var(--line-2); border-radius: 8px; padding: 10px 12px; }

/* ---------- Zoekvelden met suggesties ---------- */
.search-fields { display: grid; grid-template-columns: 1.3fr 1.3fr .8fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.search-fields.with-number { grid-template-columns: .9fr 1.3fr 1.3fr .8fr 1fr auto; }
.search-fields label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.search-actions { display: flex; gap: 6px; padding-bottom: 2px; }
.suggest { position: relative; }
.suggest .picker-results button { padding: 8px 12px; }
.suggest .picker-results mark { background: var(--accent-soft); color: inherit; padding: 0; }
.results-count { font-size: .85rem; margin: -4px 0 8px; }
#customer-results.loading { opacity: .55; transition: opacity .15s; }
@media (max-width: 860px) { .search-fields, .search-fields.with-number { grid-template-columns: 1fr 1fr; } .search-actions { grid-column: 1 / -1; } }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .when { color: var(--muted); font-size: .8rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: .88rem; }
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .disabled { color: var(--muted); }

/* ---------- Auth / public ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 36px 34px; }
.auth-card .logo { display: block; margin: 0 auto 24px; width: 150px; }
.auth-card h1 { font-size: 1.25rem; text-align: center; }
.auth-card .intro { text-align: center; color: var(--muted); margin-bottom: 22px; }
.qr { display: flex; justify-content: center; margin: 10px 0 14px; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--line-2); padding: 8px; border-radius: 6px; text-align: center; letter-spacing: .05em; font-size: .9rem; }
.code-input { text-align: center; font-size: 1.5rem !important; letter-spacing: .4em; font-variant-numeric: tabular-nums; }

.public { max-width: 860px; margin: 0 auto; padding: 32px 20px 60px; }
.public-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
.public-head img { width: 140px; }
.sigpad { border: 1px dashed #c9c1b8; border-radius: 8px; background: #fffdfb; width: 100%; height: 180px; touch-action: none; display: block; cursor: crosshair; }
.smileys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.smiley { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-weight: 600; font-size: .9rem; text-align: center; }
.smiley:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.smiley .face { font-size: 2.4rem; line-height: 1; }
.smiley.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .layout-side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
    .sidebar.open { transform: none; }
    .topbar { display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
    .topbar img { width: 90px; }
    .main { padding: 20px 16px 50px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .row-3-1, .row-1-3 { grid-template-columns: 1fr; }
    dl.facts { grid-template-columns: 110px 1fr; }
    .smileys { grid-template-columns: repeat(2, 1fr); }
    .lines-table thead { display: none; }
    .lines-table, .lines-table tbody, .lines-table tr, .lines-table td { display: block; width: 100% !important; }
    .lines-table tr { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; }
    .lines-table td.col-desc { grid-column: 1 / -1; }
    .lines-table td.col-total { text-align: left; }
}
@media (max-width: 560px) {
    .grid-4 { grid-template-columns: 1fr; }
    .auth-card { padding: 28px 20px; }
}
@media print {
    .sidebar, .topbar, .actions, .no-print { display: none !important; }
    .app { display: block; }
}
