/* ===== AVG Toolkit — design system ===== */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8f0;
  --border-strong: #cdd5e1;
  --text: #16213a;
  --text-2: #55617a;
  --text-3: #8a94ab;
  --accent: #3552c7;
  --accent-hover: #2a43a8;
  --accent-soft: #eaeefb;
  --accent-soft-2: #dbe3f8;
  --green: #167c4c;
  --green-soft: #e3f5ec;
  --amber: #92600a;
  --amber-soft: #fdf2dc;
  --orange: #b4530a;
  --orange-soft: #feeada;
  --red: #b42332;
  --red-soft: #fde7ea;
  --sidebar-bg: #131c33;
  --sidebar-text: #9aa7c4;
  --sidebar-active: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 33, 58, .05), 0 4px 16px rgba(22, 33, 58, .06);
  --shadow-lg: 0 4px 12px rgba(22, 33, 58, .08), 0 12px 40px rgba(22, 33, 58, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ===== App-shell ===== */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.brand-icon svg { width: 30px; height: 30px; color: #7d97f0; }
.brand-name { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--sidebar-text); margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #dbe2f2; }
.nav-item.active { background: rgba(93, 122, 226, .22); color: var(--sidebar-active); }
.nav-item .icon svg { width: 19px; height: 19px; }

.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, .09); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #5d7ae2, #3552c7);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; flex-shrink: 0;
}
.user-name { color: #e8ecf6; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.user-role { font-size: 11.5px; color: var(--sidebar-text); }
.tenant-name { font-size: 12px; color: #6b7897; padding: 0 6px; }
.logout-btn {
  width: 100%; justify-content: flex-start; gap: 10px;
  color: var(--sidebar-text) !important; font-size: 13.5px;
  padding: 8px 10px;
}
.logout-btn:hover { background: rgba(255, 255, 255, .06); color: #dbe2f2 !important; }
.logout-btn .icon svg { width: 17px; height: 17px; }

.main { flex: 1; padding: 32px 40px 64px; max-width: 1240px; min-width: 0; }

/* ===== Koppen & pagina-structuur ===== */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-head .subtitle { color: var(--text-2); font-size: 14px; margin-top: 3px; }
.page-actions { display: flex; gap: 10px; flex-shrink: 0; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 500;
  margin-bottom: 10px;
}
.back-link:hover { color: var(--accent); }
.back-link .icon svg { width: 15px; height: 15px; }

section { margin-bottom: 28px; }
.section-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--text-3); font-weight: 600; }

/* ===== Cards & panelen ===== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 22px 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .stat-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.stat .stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.stat .stat-sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.stat.stat-red .stat-value { color: var(--red); }
.stat.stat-amber .stat-value { color: var(--orange); }
.stat.stat-green .stat-value { color: var(--green); }

/* ===== Waarschuwingen ===== */

.alerts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.alert-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; border-radius: var(--radius);
  font-size: 14px; border: 1px solid;
}
.alert-item .icon { flex-shrink: 0; margin-top: 1px; }
.alert-item .icon svg { width: 18px; height: 18px; }
.alert-item a { color: inherit; font-weight: 600; }
.alert-red { background: var(--red-soft); color: var(--red); border-color: #f5c6cc; }
.alert-amber { background: var(--amber-soft); color: var(--amber); border-color: #edd9ae; }
.alert-blue { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-soft-2); }

.flash {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
  font-size: 14px; font-weight: 500; border: 1px solid;
  animation: slideDown .25s ease;
}
.flash-success { background: var(--green-soft); color: var(--green); border-color: #bfe8d2; }
.flash-error { background: var(--red-soft); color: var(--red); border-color: #f5c6cc; }
.flash-info { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-soft-2); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ===== Tabellen ===== */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-2); padding: 11px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.row-link { cursor: pointer; transition: background .12s; }
tbody tr.row-link:hover { background: var(--accent-soft); }
td .td-main { font-weight: 600; color: var(--text); }
td .td-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

/* ===== Badges ===== */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-notice { background: var(--accent-soft); color: var(--accent-hover); }
.badge-warning { background: var(--amber-soft); color: var(--amber); }
.badge-critical { background: var(--orange-soft); color: var(--orange); }
.badge-overdue { background: var(--red-soft); color: var(--red); }
.badge-neutral { background: #eef1f6; color: var(--text-2); }
.badge-type { background: var(--accent-soft); color: var(--accent-hover); }

/* ===== Countdown-balk ===== */

.countdown { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.countdown-bar { height: 6px; border-radius: 3px; background: #e8ecf3; overflow: hidden; }
.countdown-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.fill-ok { background: var(--green); }
.fill-notice { background: var(--accent); }
.fill-warning { background: #d99b1e; }
.fill-critical { background: #e0680f; }
.fill-overdue { background: var(--red); }

/* ===== Knoppen ===== */

.btn, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  padding: 9px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
  line-height: 1.4;
}
.btn { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(53, 82, 199, .3); }
.btn:hover { background: var(--accent-hover); }
.btn .icon svg { width: 16px; height: 16px; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: #b6c0d1; }
.btn-secondary .icon svg { width: 16px; height: 16px; }
.btn-danger { background: var(--surface); color: var(--red); border-color: #eec4c9; }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 8px 12px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 13px; font-size: 13px; }

/* ===== Formulieren ===== */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
.field .req { color: var(--red); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"],
select, textarea {
  width: 100%;
  font-family: var(--font); font-size: 14.5px; color: var(--text);
  padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53, 82, 199, .14);
}
textarea { resize: vertical; min-height: 90px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2355617a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-actions { display: flex; gap: 10px; margin-top: 22px; align-items: center; }

.checkbox-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.checkbox-row input { width: auto; margin-top: 3px; accent-color: var(--accent); }

/* ===== Login / setup ===== */

body.bare {
  background: linear-gradient(160deg, #131c33 0%, #1d2c54 55%, #27397023 100%), var(--bg);
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 38px 38px 34px;
}
.auth-card.wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand .icon svg { width: 34px; height: 34px; color: var(--accent); }
.auth-brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.auth-brand-sub { font-size: 13px; color: var(--text-2); margin-top: -2px; }
.auth-card h1 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.auth-card .auth-intro { color: var(--text-2); font-size: 14px; margin-bottom: 22px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .btn { width: 100%; padding: 11px; margin-top: 6px; }
.auth-error {
  background: var(--red-soft); color: var(--red); border: 1px solid #f5c6cc;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; margin-bottom: 16px;
}
.setup-step { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }

/* ===== Detailpagina verzoek ===== */

.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 1080px) { .detail-grid { grid-template-columns: 1fr; } }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; font-size: 14px; }
.dl dt { color: var(--text-2); font-weight: 500; }
.dl dd { font-weight: 500; }

.deadline-panel { text-align: center; padding: 26px 22px; }
.deadline-days { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.deadline-label { font-size: 13px; color: var(--text-2); margin-top: 6px; font-weight: 500; }
.deadline-date { font-size: 13.5px; color: var(--text-3); margin-top: 2px; }
.deadline-days.c-ok { color: var(--green); }
.deadline-days.c-notice { color: var(--accent); }
.deadline-days.c-warning { color: #c4880f; }
.deadline-days.c-critical { color: #e0680f; }
.deadline-days.c-overdue { color: var(--red); }

.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.task-item .task-body { flex: 1; min-width: 220px; }
.task-item .task-title { font-weight: 600; font-size: 14.5px; }
.task-item .task-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.task-note { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; margin-top: 8px; width: 100%; }

/* ===== Auditlog / tijdlijn ===== */

.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 1px; }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-soft-2); border: 2px solid var(--accent);
}
.timeline-action { font-size: 14px; font-weight: 600; }
.timeline-details { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.timeline-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===== Brief-preview ===== */

.letter-paper {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 48px 52px;
  font-size: 14.5px; line-height: 1.7; white-space: pre-wrap;
  max-width: 760px;
}

/* ===== Lege staat ===== */

.empty {
  text-align: center; padding: 46px 24px; color: var(--text-3);
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty .icon svg { width: 34px; height: 34px; color: #b9c2d4; margin-bottom: 10px; }
.empty p { font-size: 14px; }
.empty .btn { margin-top: 16px; }

/* ===== Filters ===== */

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; min-width: 160px; }
.filter-bar input[type="search"] {
  font-family: var(--font); font-size: 14px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); min-width: 220px;
}

.tabs { display: inline-flex; background: #e8ecf3; border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 18px; }
.tab {
  padding: 7px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  color: var(--text-2); text-decoration: none; transition: all .15s;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(22,33,58,.12); }
.tab:hover:not(.active) { color: var(--text); }

/* ===== Icons algemeen ===== */
.icon { display: inline-flex; align-items: center; }
.icon svg { width: 18px; height: 18px; }

.muted { color: var(--text-3); }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ===== Instellingen-lijsten ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .settings-grid { grid-template-columns: 1fr; } }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 150px; }

/* ===== Print (antwoordbrief) ===== */
@media print {
  .sidebar, .page-actions, .back-link, .flash, .no-print { display: none !important; }
  .main { padding: 0; max-width: none; }
  .letter-paper { border: none; box-shadow: none; padding: 0; max-width: none; }
  body { background: #fff; }
}

/* ===== Mobiel ===== */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; padding: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { padding: 8px 12px; }
  .sidebar-footer { flex-direction: row; align-items: center; justify-content: space-between; border-top: none; padding-top: 8px; }
  .tenant-name { display: none; }
  .main { padding: 20px 16px 48px; }
  .letter-paper { padding: 24px 20px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 8px; }
}
