:root {
  --navy: #073889;
  --navy-dark: #052a66;
  --orange: #f46015;
  --sky: #009cdc;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #1a2540;
  --muted: #5d6a85;
  --danger: #d93939;
  --warning: #f4a815;
  --success: #2e8b57;
  --shadow: 0 4px 18px rgba(7, 56, 137, 0.08);
  --radius: 10px;
}

@import url('https://fonts.googleapis.com/css2?family=Exo:wght@500;600;700&family=Source+Sans+3:wght@400;500;600&display=swap');

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 { font-family: 'Exo', sans-serif; color: var(--navy); margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; cursor: pointer; border-radius: var(--radius);
  padding: 10px 16px; font-size: 15px; font-weight: 600;
  font-family: inherit; transition: all 0.15s ease;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: #d9510f; }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); border-color: var(--navy); }
.btn-sky { background: var(--sky); color: #fff; }
.btn-sky:hover { background: #0088c2; }

.icon-btn {
  background: transparent; border: none; cursor: pointer; color: var(--navy);
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; font-size: 24px;
}
.icon-btn:hover { background: rgba(7, 56, 137, 0.08); }
.badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--orange); color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* Login */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--sky) 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 14px; padding: 42px 36px;
  width: 100%; max-width: 420px; text-align: center; box-shadow: var(--shadow);
}
.login-logo { height: 50px; margin-bottom: 16px; }
.login-card h1 { font-size: 28px; margin-bottom: 8px; }
.login-sub { color: var(--muted); margin: 0 0 28px 0; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
.login-error { color: var(--danger); margin-top: 16px; font-size: 14px; }

/* Topbar */
.topbar {
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; font-family: 'Exo', sans-serif; font-weight: 600; font-size: 19px; }
.brand img { height: 32px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right .icon-btn { color: #fff; }
.topbar-right .icon-btn:hover { background: rgba(255,255,255,0.12); }
.user-email { color: rgba(255,255,255,0.85); font-size: 14px; }
.topbar-right .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.35); }
.topbar-right .btn-ghost:hover { background: rgba(255,255,255,0.12); border-color: #fff; }

main { padding: 28px; max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

.trend { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; }
.trend-head-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.trend-sub { font-size: 13px; margin: 0; }
.trend-controls {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.trend-controls .filter { flex-direction: column; align-items: flex-start; gap: 4px; }
.trend-controls .filter > span {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700;
}
.trend-chart-wrap {
  position: relative; height: 340px;
  background: linear-gradient(180deg, #fbfcfe 0%, #ffffff 100%);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px 8px;
}
.trend-chart-wrap canvas { max-width: 100%; }
.trend-legend, .customer-trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid #dbe1ec;
  border-radius: 999px;
  color: #1a2540;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
}
.trend-chip:hover { transform: translateY(-1px); border-color: #b7c0d3; }
.trend-chip:focus-visible { outline: 2px solid #073889; outline-offset: 2px; }
.trend-chip .trend-chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px rgba(26, 37, 64, 0.08);
}
.trend-chip.is-off {
  background: #f4f6fb;
  color: #7c8699;
  border-color: #e3e8f0;
  opacity: 0.8;
}
.trend-chip.is-off .trend-chip-dot {
  background: #cfd6e4 !important;
  box-shadow: 0 0 0 2px #f4f6fb, 0 0 0 3px #e3e8f0;
}
.customer-trend-legend .trend-chip { padding: 4px 10px; font-size: 12px; }
.customer-trend-legend .trend-chip .trend-chip-dot { width: 9px; height: 9px; }

.trend-controls-hint { font-size: 12px; margin: 0; align-self: center; }
.trend-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
  background: rgba(255, 255, 255, 0.75); border-radius: 12px;
}
.trend-hint { font-size: 12px; margin: 10px 2px 0; }
.trend-delta {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px; border-radius: 12px;
  background: #f5f7fb; border: 1px solid var(--border);
}
.trend-delta-current { display: flex; flex-direction: column; }
.trend-delta-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700;
}
.trend-delta-value {
  font-family: 'Exo', sans-serif; font-weight: 700;
  font-size: 22px; color: var(--navy); line-height: 1.1;
}
.trend-delta-change { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.trend-delta-arrow {
  font-size: 18px; font-weight: 700; line-height: 1;
  display: inline-block; margin-bottom: 2px;
}
.trend-delta-change-value { font-weight: 700; font-size: 15px; }
.trend-delta-sub { font-size: 12px; color: var(--muted); }
.trend-delta.up .trend-delta-arrow,
.trend-delta.up .trend-delta-change-value { color: var(--danger); }
.trend-delta.up { background: #fdecec; border-color: #f3bdbd; }
.trend-delta.down .trend-delta-arrow,
.trend-delta.down .trend-delta-change-value { color: var(--success); }
.trend-delta.down { background: #ecf6ef; border-color: #b9dfc3; }
.trend-delta.flat .trend-delta-arrow,
.trend-delta.flat .trend-delta-change-value { color: var(--muted); }

.overview { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.section-tools { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.filter { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.filter select {
  font-family: inherit; font-size: 14px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff; color: var(--text); min-width: 170px;
  cursor: pointer;
}
.filter select:focus { outline: 2px solid var(--sky); outline-offset: 1px; }

.scope-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.main-view-head {
  display: flex; flex-direction: column; gap: 0;
  background: var(--panel, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.main-view-head .scope-tabs { margin-bottom: 12px; }
.main-view-head .branch-filter-row { margin-bottom: 6px; }
.main-tabs {
  display: flex; gap: 8px; margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
}
.main-tab {
  font-family: inherit; font-size: 16px; font-weight: 700;
  padding: 12px 22px; background: transparent; color: var(--muted);
  border: none; border-bottom: 3px solid transparent;
  cursor: pointer; transition: color .12s ease, border-color .12s ease, background .12s ease;
  margin-bottom: -2px; border-radius: 8px 8px 0 0;
}
.main-tab:hover { color: var(--navy); background: rgba(15, 23, 42, 0.04); }
.main-tab:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 6px; }
.main-tab.is-active {
  color: var(--navy); border-bottom-color: var(--navy); background: rgba(15, 23, 42, 0.04);
}
main > .view[hidden] { display: none; }
main > .view { display: flex; flex-direction: column; gap: 24px; }
.scope-tab {
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; background: transparent; color: var(--muted);
  border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .12s ease, border-color .12s ease;
  margin-bottom: -1px;
}
.scope-tab:hover { color: var(--navy); }
.scope-tab:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 2px; }
.scope-tab.is-active {
  color: var(--navy); border-bottom-color: var(--navy);
}

.branch-filter-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.branch-filter-row[hidden] { display: none; }
.branch-filter-label {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700;
}
.branch-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.branch-tile {
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; transition: all .12s ease; white-space: nowrap;
}
.branch-tile:hover {
  border-color: var(--navy); background: #f5f7fb; color: var(--navy);
}
.branch-tile:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.branch-tile.active {
  background: var(--navy); color: #fff; border-color: var(--navy);
  box-shadow: 0 2px 8px rgba(17, 30, 76, 0.18);
}
.branch-tile.active:hover {
  background: var(--navy); color: #fff;
  filter: brightness(1.1);
}
.branch-tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: #e8f1fb; color: var(--navy); font-size: 12px; font-weight: 600;
}
.col-branch { white-space: nowrap; }
.section-head h2 { font-size: 22px; }
.totals { color: var(--muted); font-size: 14px; }
.totals strong { color: var(--navy); font-size: 16px; }

.table-wrap { overflow-x: auto; }
.aging-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 880px; }
.aging-table th, .aging-table td { text-align: right; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.aging-table th { font-family: 'Exo', sans-serif; font-weight: 600; color: var(--navy); background: #f9fafd; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; position: sticky; top: 0; z-index: 1; }
.aging-table th.col-customer, .aging-table td.col-customer { text-align: left; }
.aging-table td.col-customer { font-weight: 600; cursor: pointer; }
.aging-table td.col-customer:hover { color: var(--orange); }
.aging-table .col-total { font-weight: 700; color: var(--navy); background: #f9fafd; }

.cell {
  cursor: pointer; border-radius: 6px; transition: background 0.12s ease;
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.cell:hover { background: rgba(244, 96, 21, 0.1); }
.cell.empty { color: var(--muted); cursor: default; }
.cell.empty:hover { background: transparent; }
.cell small { color: var(--muted); font-size: 11px; }
.bucket-warn { color: var(--warning); }
.bucket-danger { color: var(--danger); font-weight: 600; }

.loading { text-align: center; color: var(--muted); padding: 40px; }

/* Betaalgedrag per klant — hergebruikt .aging-table, met eigen kolommen */
.payment-history { margin-top: 0; }
.payment-history-head-main {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.payment-history-sub { font-size: 13px; margin: 0; max-width: 720px; }
.payment-history-hint { font-size: 12px; margin: 14px 0 0 0; color: var(--muted); }
.payment-history-hint code {
  background: #f1f4fa; padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 12px;
}
.payment-history-table td.col-customer { cursor: default; font-weight: 600; }
.payment-history-table td.col-customer:hover { color: inherit; }
.payment-history-table .col-num { text-align: right; white-space: nowrap; }
.payment-history-table td.col-num .cell { cursor: default; }
.payment-history-table td.col-num .cell:hover { background: transparent; }
.payment-history-table .col-late { background: #f9fafd; }
.payment-history-table th.col-late { color: var(--orange); }

/* Panel (fullscreen) */
.panel { position: fixed; inset: 0; z-index: 50; background: var(--bg); }
.panel-content {
  position: absolute; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 32px; background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(7, 56, 137, 0.04); flex-shrink: 0;
}
.panel-head-main { min-width: 0; flex: 1; }
.panel-head h3 { font-size: 22px; }
.panel-head .muted { margin: 4px 0 0 0; color: var(--muted); font-size: 14px; }
.panel-head #panel-close { width: 40px; height: 40px; font-size: 24px; flex-shrink: 0; }

.panel-summary {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 14px 32px; background: #fff; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.summary-total {
  display: flex; flex-direction: column; margin-right: 8px; padding-right: 16px;
  border-right: 1px solid var(--border);
}
.summary-total-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.summary-total-value { color: var(--navy); font-size: 22px; font-weight: 700; font-family: 'Exo', sans-serif; }
.summary-total-sub { color: var(--muted); font-size: 12px; }
.summary-chip {
  display: inline-flex; flex-direction: column; gap: 2px; padding: 8px 14px;
  border-radius: 10px; background: #f5f7fb; border: 1px solid var(--border);
  min-width: 96px; position: relative; user-select: none;
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease;
}
.summary-chip[data-bucket] { cursor: pointer; }
.summary-chip[data-bucket]:hover { border-color: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.summary-chip[data-bucket]:active { transform: translateY(1px); }
.summary-chip[data-bucket]:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.summary-chip-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.summary-chip-value { font-size: 15px; font-weight: 700; color: var(--navy); }
.summary-chip-sub { font-size: 11px; color: var(--muted); }
.summary-chip.warn { background: #fff6e6; border-color: #f4d6a0; }
.summary-chip.warn .summary-chip-value { color: var(--warning); }
.summary-chip.danger { background: #fdecec; border-color: #f3bdbd; }
.summary-chip.danger .summary-chip-value { color: var(--danger); }
.summary-chip.empty { opacity: 0.55; cursor: default; }
.summary-chip.active {
  border-color: var(--navy); border-width: 2px; padding: 7px 13px;
  background: #eaf0fb; box-shadow: 0 2px 10px rgba(17, 30, 76, 0.12);
}
.summary-chip.active.warn { background: #fff0d6; border-color: #d58a1a; }
.summary-chip.active.danger { background: #fbdada; border-color: #c23030; }
.summary-chip.active::after {
  content: '\2713'; position: absolute; top: 4px; right: 6px;
  font-size: 11px; font-weight: 700; color: var(--navy);
  background: #fff; border-radius: 50%; width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--navy);
}
.summary-chip.active.warn::after { color: #b7791f; box-shadow: 0 0 0 2px #d58a1a; }
.summary-chip.active.danger::after { color: #c23030; box-shadow: 0 0 0 2px #c23030; }
.chip-clear {
  margin-left: 8px; padding: 8px 12px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; cursor: pointer; font-size: 12px;
  color: var(--muted); font-weight: 600; transition: all .12s ease;
  align-self: center;
}
.chip-clear:hover { background: #f5f7fb; color: var(--navy); border-color: var(--navy); }

.panel-body {
  display: grid; grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 20px; padding: 20px 32px; overflow: hidden; flex: 1; min-height: 0;
}
.panel-side { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; min-height: 0; }
.panel-main { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.panel-content .block {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; box-shadow: var(--shadow);
}
.panel-main.block { padding: 18px 20px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-content .block h4 { font-size: 14px; margin-bottom: 12px; color: var(--navy); text-transform: uppercase; letter-spacing: 0.5px; }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.block-head h4 { margin-bottom: 0; }
.block-head-actions { display: flex; gap: 6px; }
.btn-small { padding: 6px 10px; font-size: 12px; }

#invoices-list { flex: 1; overflow-y: auto; min-height: 0; padding-right: 4px; }

.comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.comment {
  background: #f5f7fb; border-left: 3px solid var(--sky);
  padding: 10px 32px 10px 12px; border-radius: 6px; font-size: 14px;
  position: relative;
}
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment-delete {
  position: absolute; top: 6px; right: 6px;
  background: transparent; border: none; color: var(--muted);
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease, color .12s ease;
}
.comment-delete:hover { background: #fdecec; color: var(--danger); }
.comment-delete:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; }
.comment-add { display: flex; gap: 8px; align-items: flex-end; }
.comment-add textarea {
  flex: 1; resize: vertical; min-height: 42px; max-height: 150px;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: inherit; font-size: 14px; line-height: 1.4;
}
.comment-add textarea:focus { outline: none; border-color: var(--sky); }

.invoice-card {
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
  background: #fff; transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.invoice-card.expanded { border-color: var(--sky); box-shadow: 0 2px 10px rgba(0, 156, 220, 0.08); }
.invoice-head {
  display: grid; grid-template-columns: auto 1fr auto auto auto;
  gap: 14px; align-items: center; padding: 10px 14px;
}
.invoice-head:hover { background: #f9fafd; }
.invoice-card.expanded .invoice-head { border-bottom: 1px solid var(--border); }
.invoice-select { display: inline-flex; align-items: center; }
.invoice-select input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--sky); cursor: pointer;
}
.invoice-identity { min-width: 0; cursor: pointer; }
.invoice-number { font-weight: 700; color: var(--navy); font-size: 15px; }
.invoice-description { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.invoice-amount { font-weight: 700; font-size: 16px; color: var(--navy); text-align: right; white-space: nowrap; }
.invoice-due { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; line-height: 1.3; }
.invoice-due strong { display: block; font-size: 13px; margin-top: 2px; }
.invoice-toggle {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent;
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; transition: transform 0.2s ease, background 0.15s ease;
  font-size: 18px; line-height: 1;
}
.invoice-toggle:hover { background: var(--bg); color: var(--navy); }
.invoice-card.expanded .invoice-toggle { transform: rotate(180deg); }

.invoice-body { padding: 14px 16px 16px; display: none; }
.invoice-card.expanded .invoice-body { display: block; }
.invoice-body h5 { font-size: 12px; color: var(--muted); text-transform: uppercase; margin: 14px 0 6px 0; letter-spacing: 0.4px; font-family: 'Exo', sans-serif; font-weight: 600; }
.invoice-body h5:first-child { margin-top: 0; }

.customer-trend {
  border: 1px solid var(--border); border-radius: 10px;
  background: linear-gradient(180deg, #fbfcfe 0%, #ffffff 100%);
  padding: 14px 16px; margin-bottom: 14px;
}
.customer-trend-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.customer-trend-head-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.customer-trend-head h4 {
  font-size: 13px; margin: 0; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.customer-trend-sub { font-size: 12px; margin: 0; }
.customer-trend-controls {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; margin-bottom: 10px;
}
.customer-trend-controls .filter { flex-direction: row; gap: 8px; align-items: center; }
.customer-trend-controls .filter > span {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700;
}
.customer-trend-controls .filter select {
  min-width: 130px; padding: 6px 10px; font-size: 13px;
}
.customer-trend-filter-hint {
  font-size: 12px; margin: 0; flex: 1; min-width: 180px;
}
.customer-trend-chart-wrap {
  position: relative; height: 240px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px 4px;
}
.customer-trend-chart-wrap canvas { max-width: 100%; }
.customer-trend-delta {
  display: inline-flex; gap: 14px; align-items: center;
  padding: 6px 12px; border-radius: 8px;
  background: #f5f7fb; border: 1px solid var(--border);
}
.customer-trend-delta-block { display: flex; flex-direction: column; line-height: 1.15; }
.customer-trend-delta-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700;
}
.customer-trend-delta-value {
  font-family: 'Exo', sans-serif; font-weight: 700; font-size: 15px; color: var(--navy);
}
.customer-trend-delta-change { font-weight: 700; font-size: 14px; }
.customer-trend-delta.up { background: #fdecec; border-color: #f3bdbd; }
.customer-trend-delta.up .customer-trend-delta-change { color: var(--danger); }
.customer-trend-delta.down { background: #ecf6ef; border-color: #b9dfc3; }
.customer-trend-delta.down .customer-trend-delta-change { color: var(--success); }
.customer-trend-delta.flat .customer-trend-delta-change { color: var(--muted); }

.reminder-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: #f9fafd; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; flex-wrap: wrap;
}
.reminder-bar .btn { padding: 8px 14px; font-size: 13px; }
.reminder-bar .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.reminder-select-all {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: var(--navy); font-weight: 600;
}
.reminder-select-all input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--sky); cursor: pointer;
}
.reminder-bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reminder-summary { color: var(--muted); font-size: 13px; font-weight: 500; }
.reply-card {
  background: #eef7f0; border-left: 3px solid var(--success);
  padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 6px;
}
.reminder-card {
  background: #fff4ec; border-left: 3px solid var(--orange);
  padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 6px;
}

/* Notification panel */
.notif-panel {
  position: fixed; top: 60px; right: 28px; width: 380px; max-height: 70vh;
  background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  z-index: 40; overflow: hidden; display: flex; flex-direction: column;
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 8px; }
.notif-head h3 { font-size: 16px; }
.notif-head .btn { padding: 6px 10px; font-size: 12px; }
.notif-head-actions { display: flex; align-items: center; gap: 6px; }
.notif-head-actions .icon-btn { width: 32px; height: 32px; font-size: 22px; line-height: 1; }
#notif-list { overflow-y: auto; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 8px; position: relative;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #fff9f3; }
.notif-item.unread::before { content: '•'; color: var(--orange); font-size: 24px; line-height: 0; margin-top: 10px; }
.notif-body { flex: 1; min-width: 0; }
.notif-message { word-wrap: break-word; }
.notif-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.notif-item .notif-type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.notif-meta .branch-tag { font-size: 11px; padding: 2px 8px; }
.notif-dismiss {
  background: transparent; border: none; cursor: pointer; color: var(--muted);
  font-size: 20px; line-height: 1; padding: 0; width: 22px; height: 22px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px; transition: all 0.12s ease;
}
.notif-dismiss:hover { background: rgba(217, 57, 57, 0.12); color: var(--danger); }
.notif-dismiss:disabled { opacity: 0.5; cursor: not-allowed; }
.notif-item.empty { color: var(--muted); text-align: center; padding: 28px; display: block; }

.muted { color: var(--muted); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); z-index: 100;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Danger button */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b82d2d; }

/* Modal (confirm dialog) */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: modal-fade 0.15s ease-out;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(7, 37, 89, 0.55);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(7, 56, 137, 0.3);
  padding: 28px 28px 22px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: modal-pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(217, 57, 57, 0.12);
  color: var(--danger);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.modal-title {
  font-size: 20px; margin: 0 0 8px 0;
}
.modal-message {
  margin: 0 0 22px 0; color: var(--muted); font-size: 15px;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: center;
}
.modal-actions .btn {
  min-width: 120px; justify-content: center;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Hover-samenvatting tooltip */
.summary-tooltip {
  position: absolute;
  width: 260px; max-width: calc(100vw - 24px);
  background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 22px rgba(7, 56, 137, 0.16);
  padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
  z-index: 1200;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: auto;
}
.summary-tooltip.visible { opacity: 1; transform: translateY(0); }
.summary-tooltip-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.summary-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; padding: 3px 8px; border-radius: 999px;
  background: #eef2fb; color: var(--navy);
}
.summary-badge.ai {
  background: linear-gradient(90deg, #073889, #009cdc);
  color: #fff;
}
.summary-tooltip-scope { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary-tooltip-body { color: var(--text); font-size: 13.5px; }
.summary-tooltip-comments {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
}
.summary-tooltip-subhead {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); margin-bottom: 6px;
}
.summary-comment {
  background: #f5f7fb; border-left: 3px solid var(--sky);
  padding: 6px 10px; border-radius: 6px; font-size: 12.5px;
  margin-top: 6px;
}
.summary-comment-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.summary-tooltip-foot {
  font-size: 11px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border); text-align: center;
}
.summary-tooltip-loading {
  font-size: 12.5px; color: var(--muted); font-style: italic;
}

/* Inline uitklap-rij direct onder de geklikte klantregel */
tr.inline-expansion-row > td {
  padding: 0 !important;
  background: linear-gradient(180deg, #f8faff 0%, #ffffff 100%);
  border-top: 0;
}
.inline-expansion {
  position: sticky;
  left: 16px;
  width: calc(min(100vw, 100%) - 32px);
  max-width: 1200px;
  margin: 6px 16px 14px;
  padding: 14px 16px;
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--sky); border-radius: 10px;
  box-shadow: 0 6px 18px rgba(7, 56, 137, 0.06);
  animation: inline-slide .18s ease;
  box-sizing: border-box;
}
@keyframes inline-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.inline-expansion-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.inline-expansion-actions { display: flex; align-items: center; gap: 8px; }
.inline-expansion-body { width: 100%; }
.inline-invoice-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  table-layout: auto;
}
.inline-invoice-table th, .inline-invoice-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top;
}
.inline-invoice-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); font-weight: 700; background: #f5f7fb;
  white-space: nowrap;
}
.inline-invoice-table .col-r { text-align: right; white-space: nowrap; }
.inline-invoice-table td.col-invnr { white-space: nowrap; font-weight: 600; }
.inline-invoice-table td.col-date { white-space: nowrap; color: var(--muted); }
.inline-invoice-table td.col-comments {
  color: var(--text); white-space: normal; word-break: break-word;
  font-size: 13px; line-height: 1.4;
}
.inline-invoice-table td.col-comments .comment-snippet { cursor: help; }
.inline-invoice-table td.col-comments .muted { font-size: 11px; }
.inline-invoice-table tfoot td { background: #fafbff; border-bottom: 0; }
.inline-invoice-table tbody tr:hover { background: #f8faff; }
.days-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eef2fb; color: var(--navy); font-weight: 600; font-size: 12px;
  white-space: nowrap;
}
.days-pill.warn { background: #fff6e6; color: #b7791f; }
.days-pill.danger { background: #fdecec; color: var(--danger); }

/* Selecteer-visualisatie van geklikte cel */
.aging-table .cell.expanded {
  outline: 2px solid var(--sky); outline-offset: -2px;
  background: #eaf4fd;
}

@media (max-width: 1024px) {
  .panel-body {
    grid-template-columns: 1fr;
    padding: 16px 20px;
    overflow-y: auto;
  }
  .panel-side { overflow-y: visible; }
  .panel-main { overflow: visible; }
  #invoices-list { overflow-y: visible; }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .user-email { display: none; }
  main { padding: 16px; }
  .panel-head { padding: 14px 16px; }
  .panel-summary { padding: 12px 16px; gap: 8px; }
  .summary-chip { min-width: 80px; padding: 6px 10px; }
  .panel-body { padding: 12px 16px; }
  .invoice-head {
    grid-template-columns: auto 1fr auto auto;
    gap: 10px;
  }
  .invoice-due { display: none; }
  .invoice-description { max-width: 100%; }
  .notif-panel { right: 12px; left: 12px; width: auto; }
}
