/* ─── Design tokens (Shave Energy-inspired) ─────────────────────── */
:root {
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --surface-alt: #F1F3F5;
  --fg: #212529;
  --fg-soft: rgba(33, 37, 41, 0.65);
  --fg-faint: rgba(33, 37, 41, 0.45);

  --accent: #243062;           /* donker indigo — primary brand */
  --accent-hover: #2F3E7D;
  --accent-faint: #EEF0F8;

  --highlight: #E0DE09;        /* limoengeel — voor live-indicators / CTAs */
  --highlight-text: #212529;

  --border: #E5E7EB;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.08);

  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  max-width: 1080px;
  margin: 2rem auto;
  padding: 0 1.25rem;
  line-height: 1.55;
  font-weight: 400;
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }
h2 { font-size: 1.5rem; margin: 1.5rem 0 1rem; }
h3 { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }

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

/* ─── Header ──────────────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
}
header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
header h1 a { color: var(--accent); }

nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-top: 0.5rem; }
nav a {
  color: var(--fg-soft);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
}
nav a:hover { background: var(--accent-faint); color: var(--accent); text-decoration: none; }

footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 0.85rem;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 120ms ease;
}
button:hover { background: var(--accent-hover); }
button[type="submit"]:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.btn-secondary, button.btn-secondary {
  background: var(--surface-alt);
  color: var(--fg-soft);
  border: 1px solid var(--border);
}
.btn-secondary:hover, button.btn-secondary:hover {
  background: var(--border);
  color: var(--fg);
}

/* ─── Tabellen ────────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.92rem;
}
tr:last-child td { border-bottom: 0; }
th {
  background: var(--accent-faint);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tfoot { background: var(--accent-faint); }

/* ─── Forms ───────────────────────────────────────────────────────── */
form { margin: 1rem 0; }
label {
  display: block;
  margin: 0.75rem 0 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-soft);
}
input, select, textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  font: inherit;
  background: var(--surface);
  color: var(--fg);
  transition: border 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
}

code {
  background: var(--surface-alt);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Monaco, monospace;
  font-size: 0.85em;
  color: var(--fg);
}

/* ─── Portal dashboard ────────────────────────────────────────────── */
.portal-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.portal-head h2 { margin: 0; }
.portal-head-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge {
  background: var(--accent-faint);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 120px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 150ms ease, transform 150ms ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card--wide       { grid-column: span 2; }
.stat-card--accent     {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  position: relative;
  overflow: hidden;
}
.stat-card--accent::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--highlight) 0%, transparent 60%);
  opacity: 0.18;
  pointer-events: none;
}
.stat-card--placeholder {
  background: var(--surface-alt);
  border-style: dashed;
  box-shadow: none;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--fg-soft);
  margin-bottom: 0.5rem;
}
.stat-card--accent .stat-label { color: rgba(255, 255, 255, 0.75); }

.big-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.big-value.muted { color: var(--fg-faint); font-weight: 500; }
.big-unit {
  font-size: 1rem;
  font-weight: 400;
  color: var(--fg-soft);
  margin-left: 0.15rem;
}
.stat-card--accent .big-unit { color: rgba(255, 255, 255, 0.7); }

.stat-sub {
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--fg-soft);
  padding-top: 0.6rem;
  line-height: 1.45;
}
.stat-card--accent .stat-sub { color: rgba(255, 255, 255, 0.75); }
.stat-sub.muted { color: var(--fg-faint); font-style: italic; }

.stat-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.15rem 0;
  font-size: 0.95rem;
}
.stat-row-label { color: var(--fg-soft); width: 2.5rem; font-weight: 500; }
.stat-row-value { font-weight: 600; }
.stat-row-time { color: var(--fg-faint); font-size: 0.82rem; margin-left: auto; }

/* ─── Phase load bars ────────────────────────────────────────────── */
.stat-row .phase-bar {
  flex: 1;
  height: 4px;
  background: var(--surface-alt);
  border-radius: var(--radius-pill);
  margin-left: 0.5rem;
  overflow: hidden;
  min-width: 50px;
  max-width: 80px;
}
.stat-row .phase-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--highlight) 100%);
  transition: width 300ms ease;
}

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

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

@media (max-width: 640px) {
  .stat-card--wide { grid-column: span 1; }
  body { margin: 1rem auto; }
}

/* ─── Chart card + tabs ──────────────────────────────────────────── */
.stat-card--chart { grid-column: 1 / -1; }

.stat-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.range-tabs { display: flex; gap: 0.3rem; }
.range-tab {
  background: transparent;
  color: var(--fg-soft);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
}
.range-tab:hover { color: var(--accent); border-color: var(--accent); }
.range-tab.is-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
  margin: 0.75rem 0 0.5rem;
}

/* ─── Live-indicator badge ───────────────────────────────────────── */
.live-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(224, 222, 9, 0.18);
  color: var(--highlight);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.55rem 0.15rem 0.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(224, 222, 9, 0.4);
}
.stat-card--accent .live-badge { background: rgba(224, 222, 9, 0.25); color: var(--highlight); }

.stat-stale {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}

/* ─── Live-indicator dot (geel highlight, sparingly) ─────────────── */
.live-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--highlight);
  box-shadow: 0 0 0 3px rgba(224, 222, 9, 0.25);
  animation: livePulse 2s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(224, 222, 9, 0.25); }
  50%      { box-shadow: 0 0 0 6px rgba(224, 222, 9, 0.0); }
}

/* ─── Alerts / error banners ─────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border-left: 4px solid;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert--error { background: #FDF1F2; border-left-color: #DC3545; color: #6B0F18; }
.alert--info  { background: var(--accent-faint); border-left-color: var(--accent); color: var(--accent); }

/* ─── Broker: producer-group ──────────────────────────────────────── */
.producer-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.producer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.chip {
  display: inline-block;
  background: var(--accent-faint);
  color: var(--accent);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 500;
  margin-right: 0.3rem;
}
.balance-fail {
  background: #FDF1F2; color: #6B0F18;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.producer-balance {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-alt);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.balance-item {
  flex: 1;
  min-width: 140px;
}
.balance-item--strong { background: white; padding: 0.5rem 0.75rem; border-radius: var(--radius); border: 1px solid var(--border); }
.balance-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-soft);
  margin-bottom: 0.25rem;
}
.balance-value {
  font-size: 1.2rem;
  font-weight: 700;
}
.balance-value .muted { font-size: 0.85rem; font-weight: 400; }
.balance-arrow {
  font-size: 1.25rem;
  color: var(--fg-faint);
  font-weight: 300;
}
.balance-eq {
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 720px) {
  .producer-balance { flex-direction: column; align-items: stretch; }
  .balance-arrow, .balance-eq { text-align: center; }
}

.totaal-row { font-weight: 700; background: var(--accent-faint); color: var(--accent); }
.totaal-row td { color: var(--accent); }
