:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8f9fb;
    --text: #15171a;
    --muted: #69707a;
    --line: #e2e6eb;
    --line-strong: #ccd3db;
    --dark: #15171a;
    --dark-soft: #25292e;
    --success: #18723a;
    --success-bg: #eef9f2;
    --danger: #9f1d1d;
    --danger-bg: #fff1f1;
    --warning: #805b00;
    --warning-bg: #fff8dd;
    background: var(--bg);
    color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-height: 100vh; background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(100%, 440px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 22px 60px rgba(15, 20, 28, .07);
}

.auth-brand,
.brand {
    font-size: 28px;
    font-weight: 820;
    letter-spacing: -.03em;
}

.auth-card h1 {
    margin: 24px 0 6px;
    font-size: 24px;
    letter-spacing: -.02em;
}

.muted { color: var(--muted); }
.auth-card > .muted { margin: 0 0 4px; }

.field {
    display: grid;
    gap: 7px;
    margin: 18px 0;
}

.field label {
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    padding: 11px 13px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus {
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(21, 23, 26, .08);
}

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--dark);
    color: #fff;
    font-weight: 750;
    line-height: 1;
}

.btn-block { width: 100%; }
.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--line-strong);
}
.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: #efcaca;
}
.btn-small {
    min-height: 36px;
    padding: 8px 11px;
    font-size: 13px;
}

.error,
.success,
.notice {
    padding: 11px 13px;
    border-radius: 10px;
    margin: 14px 0;
    font-size: 14px;
}
.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #ffd0d0; }
.success { background: var(--success-bg); color: var(--success); border: 1px solid #ccebd7; }
.notice { background: var(--warning-bg); color: var(--warning); border: 1px solid #f0dfa5; }

.qr-wrap {
    margin: 22px 0;
    display: grid;
    justify-items: center;
    gap: 14px;
}

.qr-box {
    width: 230px;
    max-width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
}
.qr-box svg { display: block; width: 100%; height: auto; }

.secret-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: stretch;
}

.code {
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    padding: 11px 12px;
    border-radius: 10px;
    word-break: break-all;
    user-select: all;
    font-size: 13px;
}

.auth-help {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #111315;
    color: #fff;
    border-right: 1px solid #22262a;
    z-index: 30;
}

.sidebar-brand {
    padding: 25px 22px 20px;
    font-size: 22px;
    font-weight: 820;
    letter-spacing: -.03em;
}

.sidebar-brand span {
    display: block;
    margin-top: 3px;
    color: #8e969f;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
}

.sidebar-nav {
    padding: 4px 12px 18px;
    overflow-y: auto;
    flex: 1;
}

.nav-section {
    padding: 18px 10px 7px;
    color: #777f88;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 11px;
    margin: 2px 0;
    border-radius: 9px;
    color: #cbd0d5;
    font-size: 14px;
    font-weight: 650;
}

.nav-link:hover { background: #1d2024; color: #fff; }
.nav-link.active { background: #fff; color: #15171a; }

.sidebar-user {
    padding: 14px 14px 16px;
    border-top: 1px solid #272b30;
}

.user-chip {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    gap: 10px;
    align-items: center;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #2a2f34;
    color: #fff;
    font-weight: 800;
}

.user-meta { min-width: 0; }
.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 750;
}
.user-role { color: #818a94; font-size: 11px; margin-top: 2px; }

.logout-form { margin: 0; }
.logout-button {
    border: 0;
    background: transparent;
    color: #8e969f;
    padding: 8px;
    font-size: 12px;
}
.logout-button:hover { color: #fff; }

.main-shell { min-width: 0; }
.topbar {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 30px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    font-size: 16px;
    font-weight: 780;
}

.menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
}

.content {
    width: 100%;
    padding: 30px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-head h1 {
    margin: 0 0 5px;
    font-size: clamp(26px, 3vw, 34px);
    letter-spacing: -.04em;
}

.page-head p { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.grid {
    display: grid;
    gap: 18px;
}
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 15px;
}
.panel { padding: 22px; }

.panel h2,
.panel h3 { margin-top: 0; }
.panel h2 { font-size: 18px; }
.panel p:last-child { margin-bottom: 0; }

.stat-card { padding: 20px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-value { margin-top: 8px; font-size: 24px; font-weight: 820; letter-spacing: -.03em; }
.stat-note { margin-top: 5px; color: var(--muted); font-size: 12px; }

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}
.status:before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.status-success { color: var(--success); background: var(--success-bg); }
.status-muted { color: #656d76; background: #f0f2f4; }
.status-warning { color: var(--warning); background: var(--warning-bg); }

.list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line);
}
.list-row {
    display: grid;
    grid-template-columns: minmax(170px, .8fr) minmax(0, 1.2fr) auto;
    gap: 18px;
    align-items: center;
    min-height: 64px;
    border-bottom: 1px solid var(--line);
    padding: 11px 0;
}
.list-row:last-child { border-bottom: 0; }
.list-label { font-weight: 700; font-size: 14px; }
.list-value { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.empty-state {
    min-height: 300px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 40px;
}
.empty-state-inner { max-width: 470px; }
.empty-state h2 { margin: 0 0 8px; font-size: 21px; }
.empty-state p { margin: 0; color: var(--muted); line-height: 1.55; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }

.security-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}
.security-card-head h2 { margin: 0 0 5px; }
.security-card-head p { margin: 0; color: var(--muted); }

.sidebar-overlay { display: none; }

@media (max-width: 980px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 270px;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .admin-shell.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(10, 12, 15, .42);
        z-index: 25;
    }
    .admin-shell.sidebar-open .sidebar-overlay { display: block; }
    .menu-toggle { display: grid; place-items: center; }
    .topbar { padding: 0 20px; }
    .content { padding: 24px 20px; }
}

@media (max-width: 680px) {
    .auth-shell { padding: 14px; }
    .auth-card { padding: 24px 20px; border-radius: 15px; }
    .content { padding: 20px 14px; }
    .topbar { padding: 0 14px; }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .list-row { grid-template-columns: 1fr; gap: 4px; padding: 14px 0; }
    .list-row > :last-child { justify-self: start; margin-top: 5px; }
    .security-card-head { flex-direction: column; }
    .secret-row { grid-template-columns: 1fr; }
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.panel-narrow { max-width: 560px; }
.mt-18 { margin-top: 18px; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 2px;
    color: var(--muted);
    font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    height: 1px;
    flex: 1;
    background: var(--line);
}

.btn-passkey {
    margin-top: 20px;
}

.inline-status {
    min-height: 20px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.inline-status.is-error {
    color: var(--danger);
}

.passkey-list {
    margin-top: 20px;
}

.passkey-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.small-text {
    margin-top: 4px;
    font-size: 12px;
}

.auth-help a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* v0.4: compact beheer + klanten */
.topbar { display: none; }

select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    padding: 11px 13px;
    background: #fff;
    color: var(--text);
    outline: none;
    font: inherit;
}

select { min-height: 46px; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
select:focus,
textarea:focus {
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(21, 23, 26, .08);
}

.status-danger { color: var(--danger); background: var(--danger-bg); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}
.section-head h2 { margin: 0 0 4px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}
.field-span-2 { grid-column: 1 / -1; }
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.customer-stats { margin-bottom: 18px; }
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
}
.filter-bar > div { min-width: 180px; }
.filter-search { flex: 1; }
.filter-search input { min-width: 260px; }

.customer-title-link {
    display: inline-grid;
    gap: 3px;
}
.customer-title-link:hover strong,
.table-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.customer-title-link span { color: var(--muted); font-size: 11px; }
.table-link { color: #34475b; }
.table-actions { width: 1%; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.customer-meta-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin: -8px 0 18px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .topbar {
        height: 58px;
        display: flex;
        padding: 0 20px;
    }
}

@media (max-width: 680px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .field-span-2 { grid-column: auto; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .filter-bar > div,
    .filter-search input { min-width: 0; width: 100%; }
    .filter-bar .btn { width: 100%; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
}
