:root {
  --accent: #2c4f7c; --ink: #1c2129; --muted: #5d6573; --line: #dde2e8; --bg: #f2f4f7; --card: #fff; --soft: #f8f9fb;
  --danger: #b3261e; --radius: 10px; --side: 236px;
  --green: #1f7a4d; --green-bg: #e2f2e9; --red: #a32a21; --red-bg: #f8e4e1; --amber: #8a5a00; --amber-bg: #fcf0d6;
  --orange: #b4530f; --orange-bg: #fde9da; --blue-bg: #e3ebf6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); line-height: 1.5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7ea6dd; --ink: #e6eaf0; --muted: #9aa3b0; --line: #2e3540; --bg: #13171c; --card: #1b2028; --soft: #20262f;
    --green: #8fd6ae; --green-bg: #1b3a2b; --red: #f2a59c; --red-bg: #45201c; --amber: #f1cf86; --amber-bg: #3d3018;
    --orange: #f6b47f; --orange-bg: #432a17; --blue-bg: #1e2c40;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.08rem; margin-bottom: 12px; }
h3 { font-size: .98rem; margin-bottom: 8px; }
a { color: var(--accent); }
p { margin: 0 0 10px; }
code { font-size: .88em; background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
aside.side { background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 8px 16px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
aside nav { display: flex; flex-direction: column; gap: 2px; }
aside nav a { text-decoration: none; color: var(--ink); padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
aside nav a:hover { background: var(--bg); }
aside nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
aside nav a .ico { width: 20px; text-align: center; }
aside .me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; font-size: .86rem; display: flex; flex-direction: column; gap: 6px; }
.mobilebar { display: none; }
main { min-width: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 24px 64px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .actions, .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Kaarten en knoppen */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card.tight { padding: 14px 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.55rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .86rem; }
button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 7px 13px; min-height: 36px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .primary { color: #0f1520; } }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.danger { color: var(--danger); }
@media (prefers-color-scheme: dark) { .danger { color: var(--red); } }
.linkbtn { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; }
.small-btn { min-height: 30px; padding: 3px 10px; font-size: .86rem; }

/* Formulieren */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
label .muted { font-weight: 400; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); min-height: 38px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px 0; cursor: pointer; }
.check input { width: auto; min-height: 0; margin-top: 4px; }
.check b { display: block; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* Lijsten */
.tlist { display: flex; flex-direction: column; gap: 10px; }
.tenant { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--green); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; }
.tenant:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tenant.s-blocked { border-left-color: var(--red); }
.tenant.s-demo { border-left-color: #d4a72c; }
.tenant.s-invoice { border-left-color: var(--orange); }
.tenant .name { font-weight: 700; font-size: 1.02rem; }
.tenant .meta { color: var(--muted); font-size: .86rem; display: flex; gap: 10px; flex-wrap: wrap; }
.tenant .right { text-align: right; font-size: .86rem; color: var(--muted); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: .76rem; padding: 1px 8px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill { font-size: .78rem; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; display: inline-block; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.info { background: var(--blue-bg); color: var(--accent); }
.tasks { border-left: 4px solid var(--orange); }
.tasks li { margin: 4px 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.tablewrap { overflow-x: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.steps li { margin: 3px 0; }
.log { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 280px; overflow: auto; white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--blue-bg); margin-bottom: 14px; }
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.bad { background: var(--red-bg); color: var(--red); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; background: var(--soft); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; user-select: all; display: inline-block; }

/* Inloggen */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { justify-content: center; padding-bottom: 8px; }

/* Dialoog en melding */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(10, 14, 20, .45); }
#modal-body { padding: 22px; }
#modal-body .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); z-index: 50; }
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); color: #fff; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  aside.side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.menu-open aside.side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .wrap { padding: 16px 16px 48px; }
  .tenant { grid-template-columns: 1fr; }
  .tenant .right { text-align: left; }
}
