:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #62717f;
  --accent: #2b5797;
  --accent-text: #ffffff;
  --user: #dce9f9;
  --assistant: #ffffff;
  --border: #d9dee3;
  --error: #b42318;
  --banner: #fff4cc;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg);
}
.wrap { max-width: 780px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
p { margin: .4rem 0 .8rem; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: .92rem; }
.error { color: var(--error); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-top: 24px; }
.code-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.code-form input { font-size: 1.4rem; letter-spacing: .15em; text-transform: uppercase; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
button, .button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 16px;
}
button.secondary, .button.secondary { background: var(--card); color: var(--accent); }
button.small { padding: 6px 10px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline-block; margin: 4px 8px 4px 0; }
table.sessions { width: 100%; border-collapse: collapse; margin: 12px 0; }
table.sessions th, table.sessions td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: .95rem; }

/* chat */
body.chat-page .wrap { display: flex; flex-direction: column; min-height: 100vh; padding-bottom: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 0 12px; border-bottom: 1px solid var(--border); }
.chat-header h1 { margin-bottom: 0; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.counter { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.banner { background: var(--banner); border: 1px solid #e6d28a; border-radius: 8px; padding: 8px 12px; font-size: .9rem; }
details.tips { margin: 10px 0; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; }
details.tips summary { cursor: pointer; font-weight: 600; }
details.tips ul { padding-left: 18px; margin: 6px 0; }
details.tips li { margin: 4px 0; }
button.tip { background: none; border: none; color: var(--accent); padding: 2px 0; text-align: left; font-weight: 400; }
button.tip:hover { text-decoration: underline; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px 0; }
.messages.static { padding-bottom: 40px; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.who { font-size: .8rem; color: var(--muted); margin: 0 6px 3px; }
.time { margin-left: 4px; }
.bubble { padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid var(--border); background: var(--assistant); }
.msg.user .bubble { background: var(--user); border-color: #c5d8f2; }
.msg.error .bubble { color: var(--error); background: #fff0ee; border-color: #f2c2bd; }
.bubble.typing:empty::after { content: "…"; color: var(--muted); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.chat-form { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0 12px; background: var(--bg); border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; resize: vertical; min-height: 44px; }
.status { min-height: 1.2em; margin: 0 0 8px; }
@media (max-width: 600px) {
  .wrap { padding: 12px; }
  .chat-header { flex-direction: column; }
  .header-right { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .msg { max-width: 96%; }
}

/* beheer */
.wrap.wide { max-width: 1140px; }
.adminnav { display: flex; align-items: center; gap: 18px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.adminnav .brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: 8px; }
.adminnav a { text-decoration: none; }
.adminnav form { margin-left: auto; }
.flash { background: #e6f4ea; border: 1px solid #b7e1c1; border-radius: 8px; padding: 8px 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi strong { font-size: 1.5rem; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: 4px; }
.row input, .row select, .inline input[type=text] { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th, table.grid td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; }
.actions form { display: inline; margin: 0; }
button.danger { background: #fff; color: var(--error); border-color: #e4a29b; }
.pill { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: #eef1f4; color: var(--muted); }
.pill.ok { background: #e6f4ea; color: #1e6b3a; }
.pill.bad { background: #fdecea; color: var(--error); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--border); }
textarea.code { width: 100%; min-height: 65vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
pre.memo { white-space: pre-wrap; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: .9rem; }
code { background: #eef1f4; padding: 1px 4px; border-radius: 4px; }
