:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5a6a7e;
  --border: #dde3eb;
  --primary: #1e5a8a;
  --primary-hover: #16466c;
  --accent: #0d9488;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.wrap-wide { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.site-header {
  background: var(--primary);
  color: #fff;
  padding: 0.9rem 0;
  box-shadow: var(--shadow);
}
.site-header .inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-header a { color: #fff; }
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; opacity: 0.95; }
.nav { display: flex; gap: 1rem; align-items: center; font-size: 0.95rem; }
.nav form { display: inline; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; }
.lead { color: var(--muted); margin: 0 0 1.25rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.85rem 0 0.35rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(30, 90, 138, 0.35);
  border-color: var(--primary);
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff !important;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
}
.btn:hover { background: var(--primary-hover); }
.btn-secondary { background: #475569; }
.btn-secondary:hover { background: #334155; }
.btn-ghost {
  background: transparent;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.45);
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); }
.actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid;
}
.alert-ok { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.alert-err { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: var(--primary); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-open { background: #dbeafe; color: #1e40af; }
.badge-in_behandeling { background: #ffedd5; color: #9a3412; }
.badge-wacht_op_klant { background: #fef3c7; color: #92400e; }
.badge-opgelost { background: #dcfce7; color: #166534; }
.badge-gesloten { background: #e2e8f0; color: #334155; }
.badge-laag { background: #e2e8f0; color: #475569; }
.badge-normaal { background: #dbeafe; color: #1e40af; }
.badge-hoog { background: #ffedd5; color: #9a3412; }
.badge-kritiek { background: #fee2e2; color: #991b1b; }

.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}
.filters a.active, .filters a:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  text-decoration: none;
}

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.7rem 0.55rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:hover td { background: #f8fafc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.ticket-number {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--primary);
}

.timeline { display: flex; flex-direction: column; gap: 0.85rem; }
.msg {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #fff;
}
.msg.internal { background: #fffbeb; border-color: #fcd34d; }
.msg.system { background: #f8fafc; color: var(--muted); font-style: italic; }
.msg-meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.msg-body { white-space: pre-wrap; word-break: break-word; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.meta-item { background: #f8fafc; border-radius: 8px; padding: 0.65rem 0.8rem; border: 1px solid var(--border); }
.meta-item .k { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.meta-item .v { font-weight: 600; margin-top: 0.15rem; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem 1rem 2rem;
}

.login-wrap { max-width: 420px; margin: 3rem auto; padding: 0 1rem; }
