/* Van Ekris Sheets - basis stijl */
:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --border: #e1e1e6;
    --text: #1d1d1f;
    --text-soft: #6e6e73;
    --accent: #0071e3;
    --accent-hover: #0058b9;
    --danger: #b00020;
    --success: #1a8754;
    --warning: #b58100;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.4;
}

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

button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
}
button.primary, .btn.primary {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}
button.primary:hover, .btn.primary:hover { background: #000; }
button.danger, .btn.danger {
    background: #fff;
    color: var(--danger);
    border-color: #e6c2c8;
}
button.ghost, .btn.ghost {
    border-color: transparent;
    background: transparent;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local],
select, textarea {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

/* App-layout */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.sidebar .brand svg { width: 28px; height: 28px; }
.sidebar .brand .name { font-weight: 600; font-size: 14px; }
.sidebar .brand .sub { font-size: 11px; color: var(--text-soft); }
.sidebar .sheets-list { flex: 1; overflow-y: auto; }
.sidebar .sheet-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
}
.sidebar .sheet-item:hover { background: var(--bg); }
.sidebar .sheet-item.active {
    background: #ebf2ff;
    color: var(--accent);
    font-weight: 500;
}
.sidebar .sheet-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar .footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-soft);
}

.main {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.toolbar h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toolbar h1 select {
    font-size: 13px;
    padding: 5px 8px;
    font-weight: 500;
}
.toolbar .actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 24px; flex: 1; }

/* Grid (sheet view) */
.grid-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: calc(100vh - 130px);
}
table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.grid th, table.grid td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
table.grid th {
    background: var(--bg);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-soft);
    position: sticky;
    top: 0;
    z-index: 1;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
table.grid tr:hover td { background: #fafafa; }
table.grid td.editable { cursor: cell; }
table.grid td.editable:hover { background: #f0f6ff; }
table.grid td.selected {
    background: #eaf3ff !important;
    box-shadow: inset 0 0 0 2px var(--accent);
}
.grid-wrap:focus, .grid-wrap:focus-visible { outline: none; }
.grid-hint {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-soft);
}
.grid-hint kbd {
    font-family: inherit;
    font-size: 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
}
table.grid td.editing {
    padding: 0;
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--accent);
}
table.grid td.editing input,
table.grid td.editing select,
table.grid td.editing textarea {
    border: 0;
    width: 100%;
    padding: 6px 10px;
    border-radius: 0;
    outline: none;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: #eef0f3;
    color: var(--text);
}
.pill.success { background: #dff4e7; color: var(--success); }
.pill.warning { background: #fff5d9; color: var(--warning); }
.pill.danger  { background: #ffe2e6; color: var(--danger); }

/* Modal */
.modal-back {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: #fff;
    border-radius: 12px;
    width: 540px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: auto;
    padding: 24px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal label {
    display: block;
    margin-bottom: 12px;
}
.modal label span {
    display: block;
    font-size: 12px;
    color: var(--text-soft);
    margin-bottom: 4px;
}
.modal label input, .modal label select, .modal label textarea {
    width: 100%;
}
.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* Forms in admin */
table.admin {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    border-collapse: collapse;
}
table.admin th, table.admin td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 13px;
}
table.admin th { background: var(--bg); font-weight: 600; font-size: 12px; color: var(--text-soft); }
table.admin tr:last-child td { border-bottom: 0; }

.empty {
    padding: 40px;
    text-align: center;
    color: var(--text-soft);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ===== Zoekbalk (subbar) ===== */
.subbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.subbar:empty { display: none; }
.search-all {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 220px;
    max-width: 460px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 11px;
    color: var(--text-soft);
}
.search-all:focus-within { border-color: var(--accent); background: #fff; }
.search-all svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-all input { border: 0; outline: 0; padding: 0; flex: 1; font-size: 13px; background: transparent; color: var(--text); }
.search-count { font-size: 12px; color: var(--text-soft); margin-left: auto; }

/* ===== Nederlandse kentekenplaat ===== */
.plate-search, .plate-display {
    display: inline-flex;
    align-items: stretch;
    background: #FFCD00;
    border: 2px solid #14110c;
    border-radius: 7px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.plate-eu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: #003399;
    color: #FFCD00;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 6px;
    letter-spacing: .5px;
}
.plate-stars {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 52%, #FFCD00 53%, #FFCD00 70%, transparent 72%);
}
.plate-input {
    border: 0;
    background: transparent;
    color: #14110c;
    font-family: 'Kenteken', 'UKNumberPlate', 'Arial Narrow', Haettenschweiler, Impact, sans-serif;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 4px 12px;
    width: 160px;
    outline: none;
}
.plate-input::placeholder { color: #8a7200; opacity: .7; font-size: 13px; letter-spacing: 1px; }
.plate-display .plate-input { font-size: 26px; width: 190px; padding: 6px 14px; }

/* ===== Grid: sticky actiekolom ===== */
table.grid th.col-actions, table.grid td.col-actions {
    position: sticky;
    right: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -7px 0 9px -7px rgba(0,0,0,.18);
    white-space: nowrap;
    text-align: right;
    width: 1%;
    z-index: 2;
}
table.grid thead th.col-actions { top: 0; z-index: 4; background: var(--bg); }
table.grid tr:hover td.col-actions { background: #fafafa; }
.open-rec {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--text);
    color: #fff;
    border-color: var(--text);
    border-radius: 6px;
}
.open-rec:hover { background: #000; }
.col-actions .del { margin-left: 4px; padding: 4px 9px; }
.grid-empty { padding: 36px; text-align: center; color: var(--text-soft); }

/* ===== Record-paneel ===== */
.modal.modal-record {
    width: min(1180px, 96vw);
    max-width: 96vw;
    height: 88vh;
    max-height: 88vh;
    padding: 0;
    overflow: hidden;
    display: flex;
}
.record-modal { display: flex; flex-direction: column; width: 100%; }
.record-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.record-title { font-size: 17px; font-weight: 600; flex: 1; }
.record-close { font-size: 22px; line-height: 1; padding: 2px 10px; }
.record-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
}
.record-contract {
    border-right: 1px solid var(--border);
    background: #ECECEF;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.record-contract.uploading { opacity: .55; pointer-events: none; }
.contract-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.contract-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contract-actions { display: flex; gap: 4px; flex-shrink: 0; }
.contract-actions button { padding: 4px 10px; font-size: 12px; }
.contract-frame { flex: 1; width: 100%; border: 0; min-height: 0; background: #525659; }
.contract-drop {
    flex: 1;
    margin: 18px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-soft);
    cursor: pointer;
    text-align: center;
    padding: 24px;
    transition: border-color .15s, background .15s, color .15s;
}
.contract-drop:hover, .contract-drop.drag { border-color: var(--accent); color: var(--accent); background: #eef5ff; }
.contract-drop svg { width: 44px; height: 44px; }
.contract-drop-text { font-size: 14px; }
.contract-drop-text span { font-size: 12px; opacity: .8; }
.contract-staged { margin-top: 6px; font-size: 13px; color: var(--success); line-height: 1.5; }
.contract-staged span { color: var(--text-soft); font-size: 12px; }
.record-form { overflow-y: auto; padding: 18px 22px; }
.rec-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px 14px; margin: 0 0 16px; }
.rec-group legend { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); padding: 0 6px; }
.rec-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 16px; }
.rec-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.rec-field span { font-size: 12px; color: var(--text-soft); }
.rec-control input, .rec-control select, .rec-control textarea { width: 100%; }
.rec-field:has(textarea) { grid-column: 1 / -1; }
.record-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.record-meta { font-size: 12px; color: var(--text-soft); }
.record-foot-btns { display: flex; gap: 8px; }

@media (max-width: 860px) {
    .record-body { grid-template-columns: 1fr; overflow-y: auto; }
    .record-contract { border-right: 0; border-bottom: 1px solid var(--border); min-height: 320px; }
    .rec-fields { grid-template-columns: 1fr; }
}
