/* --- Design Tokens --- */
:root {
  /* Typography */
  --font-family-base: 'Lexend', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size: 16px;
  --text-xxs: 10px;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 32px;
  --text-2xl: 48px;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;

  /* shadcn-like color system (light) */
  --background: hsl(0 0% 100%);
  --foreground: hsl(240 10% 3.9%);
  --muted: hsl(240 4.8% 95.9%);
  --muted-foreground: hsl(240 3.8% 46.1%);
  --popover: hsl(0 0% 100%);
  --popover-foreground: hsl(240 10% 3.9%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(240 10% 3.9%);
  --border: hsl(240 5.9% 90%);
  --input: hsl(240 5.9% 90%);
  --input-background: hsl(0 0% 100%);
  --ring: hsl(240 4.9% 35%);
  --accent: hsl(240 4.8% 95.9%);
  --accent-foreground: hsl(240 5.9% 10%);

  /* Semantic */
  --error-color: hsl(0 72% 51%);
  --success-color: hsl(142 71% 45%);
  --success-foreground: #ffffff;
  --success-background: hsl(142 71% 96%);
  --warning: hsl(38 92% 50%);
  --warning-background: hsl(48 96% 89%);
  --warning-bg: hsl(48 96% 89%);
  --warning-border: hsl(48 96% 85%);
  --warning-text: hsl(32 95% 24%);
  --info: hsl(217.2 91.2% 59.8%);
  --info-background: hsl(217.2 91.2% 95%);

  /* Primary */
  --primary-color: hsl(221.2 83.2% 53.3%);
  --primary-color-dark: hsl(221.2 83.2% 46%);

  /* Elevation & Radius */
  --elevation-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --radius: 12px;
  --radius-button: 6px;
  --radius-tag: 18px;

  /* Spacing */
  --spacing: 8px;

  /* Legacy aliases */
  --text-color: var(--foreground);
  --text-color-light: hsl(240 3.8% 46.1%);
  --bg-page: var(--background);
  --bg-subtle: var(--muted);
  --card-bg: var(--card);
  --border-color: var(--border);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: hsl(240 10% 4%);
    --foreground: hsl(0 0% 98%);
    --muted: hsl(240 3.7% 15.9%);
    --muted-foreground: hsl(240 5% 64.9%);
    --popover: hsl(240 10% 4%);
    --popover-foreground: hsl(0 0% 98%);
    --card: hsl(240 10% 4%);
    --card-foreground: hsl(0 0% 98%);
    --border: hsl(240 3.7% 15.9%);
    --input: hsl(240 3.7% 15.9%);
    --input-background: hsl(240 10% 4%);
    --ring: hsl(240 4.9% 65%);
    --accent: hsl(240 3.7% 15.9%);
    --accent-foreground: hsl(0 0% 98%);
  }
}

/* --- Base / Reset --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { font-size: var(--font-size); }
body {
  margin: 0;
  font-family: var(--font-family-base);
  line-height: 1.6;
  color: var(--foreground);
  background: var(--background);
}

img, svg { display: inline-block; vertical-align: middle; }
a { color: inherit; }

/* --- Layout Containers --- */
.container { max-width: 1100px; margin: 0 auto; padding: 40px 20px 64px; }
.app-container { max-width: 860px; margin: 32px auto; padding: 0 16px; }

/* --- Headers --- */
.app-header { text-align: center; margin-bottom: 32px; }
.app-header h1 { font-weight: var(--font-weight-semibold); font-size: var(--text-2xl); color: var(--foreground); margin: 0 0 4px; line-height: 1.2; }
.app-header h2 { font-weight: var(--font-weight-medium); font-size: var(--text-xl); color: var(--muted-foreground); margin: 0 0 8px; line-height: 1.3; }
.app-header p { font-size: var(--text-base); color: var(--muted-foreground); }

/* Global typography */
h1 { font-family: var(--font-family-base); font-size: var(--text-2xl); font-weight: var(--font-weight-semibold); line-height: 1.2; }
h2 { font-family: var(--font-family-base); font-size: var(--text-xl);  font-weight: var(--font-weight-medium);  line-height: 1.3; }
h3 { font-family: var(--font-family-base); font-size: var(--text-lg);  font-weight: var(--font-weight-semibold); line-height: 1.4; }
h4 { font-family: var(--font-family-base); font-size: var(--text-base);font-weight: var(--font-weight-medium);  line-height: 1.5; }
p  { font-family: var(--font-family-base); font-size: var(--text-base);font-weight: var(--font-weight-light);  line-height: 1.5; }
span { font-family: var(--font-family-base); font-size: var(--text-base);font-weight: var(--font-weight-light);  line-height: 1.5; }
label { font-family: var(--font-family-base); font-size: var(--text-sm);  font-weight: var(--font-weight-medium); line-height: 1.5; }
button{ font-family: var(--font-family-base); font-size: var(--text-sm);  font-weight: var(--font-weight-medium); line-height: 1.5; }
input, textarea, select { font-family: var(--font-family-base); font-size: var(--text-base); font-weight: var(--font-weight-light); line-height: 1.5; }

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--elevation-sm);
  padding: 24px;
  margin-bottom: 24px;
}
.card h2 { font-weight: var(--font-weight-semibold); font-size: var(--text-lg); color: var(--foreground); margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }

/* --- Notices --- */
.warning-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--muted);
  border: 1px solid var(--border-color);
  color: var(--muted-foreground);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 24px; font-size: 0.95rem;
  line-height: 1.55;
}
.warning-box::before {
  content: "ℹ️";
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; color: var(--ring);
  border: 1px solid var(--border-color);
  flex: 0 0 28px;
  box-shadow: var(--elevation-sm);
}
.warning-box strong { font-weight: 600; }
.warning-box a.button-secondary { margin-left: auto; background: transparent; border: 0; color: var(--primary-color); text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.warning-box a.button-secondary:hover { color: var(--primary-color-dark); }

/* --- Forms --- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 8px; font-size: 0.95rem; }
input[type="number"], select {
  width: 100%; padding: 10px 12px; font-size: 1rem; font-family: var(--font-family-base);
  border: 1px solid var(--border-color); border-radius: var(--radius-button); 
  background: var(--input-background); color: var(--foreground);
  transition: border-color .2s, box-shadow .2s;
}
input[type="number"]:focus, select:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(32,182,70,.15); }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Select arrow */
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%235a6473' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; }

.input-group { display: flex; align-items: stretch; }
.input-group-prepend { margin-right: -1px; }
.radio-switch { display: flex; border: 1px solid var(--border-color); border-radius: var(--radius-button) 0 0 var(--radius-button); overflow: hidden; background: var(--input); }
.radio-switch input[type="radio"] { display: none; }
.radio-switch label { padding: 10px 12px; margin: 0; cursor: pointer; background: var(--input); color: var(--muted-foreground); border-right: 1px solid var(--border-color); font-size: 0.92rem; transition: background .2s, color .2s; }
.radio-switch label:last-of-type { border-right: 0; }
.radio-switch input[type="radio"]:checked + label { background: var(--primary-color); color: #fff; font-weight: 500; }
.input-group input[type="number"] { border-radius: 0 var(--radius-button) var(--radius-button) 0; flex-grow: 1; min-width: 120px; }

.form-group small { display: block; margin-top: 6px; color: var(--muted-foreground); font-size: 0.85rem; }
.error-message { display: none; color: var(--error-color); font-size: 0.85rem; font-weight: 500; margin-top: 6px; }
.error-message.visible { display: block; }
input.invalid, select.invalid { border-color: var(--error-color); }
input.invalid:focus, select.invalid:focus { box-shadow: 0 0 0 3px rgba(211,47,47,.15); }

/* --- Buttons --- */
.button-primary { background: var(--primary-color); color: #fff; border: 1px solid transparent; border-radius: var(--radius-button); padding: 12px 18px; font-size: 1rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm); transition: background .2s, transform .05s, box-shadow .2s, border-color .2s; }
.button-primary:hover { background: var(--primary-color-dark); box-shadow: var(--shadow-md); }
.button-primary:active { transform: translateY(1px); }
.button-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 30%, transparent); }
.button-primary:disabled { background: #b7c6d9; cursor: not-allowed; }
.button-loader { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin-left: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.button-secondary { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-button); color: var(--text-color); text-decoration: none; font-size: 0.95rem; transition: background .2s, box-shadow .2s; }
.button-secondary:hover { background: var(--bg-subtle); box-shadow: var(--shadow-sm); }
.pdf-button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border: 1px solid var(--primary-color); color: var(--primary-color); border-radius: var(--radius-button); text-decoration: none; font-size: 0.95rem; transition: background .2s, color .2s; }
.pdf-button:hover { background: var(--primary-color); color: #fff; }

/* --- Results --- */
.result-card { opacity: 0; transform: translateY(10px); transition: opacity .35s ease, transform .35s ease; }
.result-card.visible { opacity: 1; transform: translateY(0); }
.result-summary { text-align: center; margin-bottom: 20px; }
.result-summary p { color: var(--muted-foreground); margin-bottom: 8px; }
.result-highlight { font-size: 2.25rem; font-weight: 700; color: var(--primary-color); display: block; }
.result-subtitle { margin: 8px 0 4px 0; font-size: 0.9rem; color: var(--muted-foreground); font-weight: 500; }
.result-footnote { font-size: 0.9rem; color: var(--muted-foreground); margin-top: 16px; text-align: center; }

/* --- Tables --- */
.table-container { overflow-x: auto; margin-top: 8px; }
#verloopTabel { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
#verloopTabel th, #verloopTabel td { border: 1px solid var(--border-color); padding: 10px 12px; text-align: center; vertical-align: middle; }
#verloopTabel thead th { background: var(--bg-subtle); font-weight: 600; padding-top: 12px; padding-bottom: 12px; }
#verloopTabel tbody tr:nth-child(even) { background: var(--bg-subtle); }
#verloopTabel tfoot { font-weight: 700; background: var(--muted); color: var(--foreground); }
#verloopTabel tfoot td:first-child { text-align: right; }

/* --- Footer --- */
.app-footer { text-align: center; margin-top: 32px; font-size: 0.9rem; color: var(--text-color-light); }

/* --- Overview Page (Tiles) --- */
.overview-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.overview-title { font-size: var(--text-xl); font-weight: var(--font-weight-semibold); letter-spacing: 0.2px; color: var(--foreground); }
.overview-subtitle { color: var(--muted-foreground); font-size: var(--text-sm); margin-bottom: 22px; }
.channel-filters { display: flex; gap: 10px; align-items: center; margin: 6px 0 16px; flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; gap: 0; padding: 0; border: 0; border-radius: var(--radius-button); background: transparent; color: var(--text-color); cursor: pointer; font-size: var(--text-sm); }
.filter-chip input { display: none; }
.filter-chip span { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-button); background: var(--input-background); color: var(--text-color); box-shadow: var(--shadow-sm); transition: background .2s, box-shadow .2s, border-color .2s, color .2s; line-height: 1; }
.filter-chip:hover span { background: var(--bg-subtle); box-shadow: var(--shadow-md); border-color: #d5dbe5; }
.filter-chip input:checked + span { background: var(--primary-color); color: #fff; border-color: var(--primary-color); box-shadow: var(--shadow-md); }
.overview-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
@media (max-width: 1024px) { .overview-grid { grid-template-columns: repeat(8, 1fr); } }
@media (max-width: 720px) { .overview-grid { grid-template-columns: repeat(4, 1fr); } }
.overview-tile {
  grid-column: span 4; background: var(--card); color: var(--text-color);
  border: 1px solid var(--border-color); border-radius: var(--radius); padding: 18px; text-decoration: none;
  box-shadow: var(--elevation-sm); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .18s ease;
}
.overview-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #d5dbe5; }
.overview-tile-icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-foreground); margin-bottom: 12px; font-size: 20px; border: 1px solid var(--border-color); }
.overview-tile-title { font-weight: var(--font-weight-semibold); font-size: var(--text-lg); margin: 2px 0 6px; }
.overview-tile-subtitle { color: var(--muted-foreground); font-size: var(--text-sm); display: none; }
.overview-tile-tags { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.channel-tag { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: var(--radius-tag); background: var(--accent); color: var(--accent-foreground); border: 1px solid var(--border-color); font-size: var(--text-xs); font-weight: 600; letter-spacing: .2px; }


/* --- Responsive --- */
@media (max-width: 600px) {
  .warning-box { flex-direction: column; align-items: stretch; gap: 10px; }
  .warning-box a.button-secondary { align-self: flex-start; margin-left: 0; }
  .app-container { margin: 16px auto; padding: 0 12px; }
  .card { padding: 18px; }
  .app-header h1 { font-size: 1.8rem; }
  .overview-title { font-size: 24px; }
}

/* Utilities */
.shadow-sm { box-shadow: var(--elevation-sm); }
.rounded-button { border-radius: var(--radius-button); }
.rounded-tag { border-radius: var(--radius-tag); }


