/* =====================================================================
   Machinedashboard - opmaak
   Eén stijlblad, geen framework. Kleuren staan als variabele bovenaan,
   zodat een huisstijlwijziging op één plek zit.
   ===================================================================== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e7ec;
  --border-strong: #cbd3dc;
  --text: #16202b;
  --text-soft: #5b6b7c;
  --text-faint: #8998a8;

  --accent: #0b6bcb;
  --accent-soft: #e6f0fb;

  --good: #17795e;
  --good-soft: #e3f3ee;
  --warn: #9a6512;
  --warn-soft: #fbf0dd;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;

  /* Vaste betekenis per tijdsoort, overal in het dashboard hetzelfde */
  --t-running: #0b6bcb;
  --t-idle: #7aa7d9;
  --t-stop: #e0a33c;
  --t-error: #c0453c;
  --t-pause: #9aa7b4;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, 0.06), 0 4px 12px rgba(16, 32, 48, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c;
    --surface: #1a2027;
    --surface-2: #212933;
    --border: #2b343e;
    --border-strong: #3b4753;
    --text: #e8edf2;
    --text-soft: #a3b1c0;
    --text-faint: #7d8c9c;

    --accent: #5ba4f0;
    --accent-soft: #17293d;

    --good: #5fc9a6;
    --good-soft: #14302a;
    --warn: #e0b269;
    --warn-soft: #332a16;
    --bad: #f08079;
    --bad-soft: #3a1f1d;

    --t-running: #5ba4f0;
    --t-idle: #37628c;
    --t-stop: #d9a24f;
    --t-error: #e0645b;
    --t-pause: #6b7885;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

/* ---------------------------------------------------------------------
   Inlogscherm
   --------------------------------------------------------------------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.login-card .sub {
  margin: 0 0 24px;
  color: var(--text-soft);
  font-size: 14px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: 0.6; cursor: default; filter: none; }
.btn.block { width: 100%; }

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn.ghost:hover { background: var(--surface-2); filter: none; }

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent);
}

.alert.ok {
  background: var(--good-soft);
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 25%, transparent);
}

.hidden { display: none !important; }

/* Het hidden-attribuut verliest het anders van display:flex op .control */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------------
   Kop van de applicatie
   --------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 17px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand span {
  font-weight: 400;
  font-size: 13px;
  color: var(--text-faint);
}

.spacer { flex: 1; }

.control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
}

.control select,
.control input[type="date"] {
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
}

.usermenu {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-soft);
}

.linkbtn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Tabbladen */
.tabs {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
}

.tab {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------------------------------------------------------------------
   Inhoud
   --------------------------------------------------------------------- */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 20px 64px;
}

.periodbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.kpi .label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.kpi .value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi .value .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 3px;
}

.kpi .delta {
  margin-top: 5px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.delta .up { color: var(--good); font-weight: 600; }
.delta .down { color: var(--bad); font-weight: 600; }
.delta .flat { color: var(--text-faint); font-weight: 600; }

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(12, 1fr);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
  min-width: 0;
}

.card.span12 { grid-column: span 12; }
.card.span8 { grid-column: span 8; }
.card.span6 { grid-column: span 6; }
.card.span4 { grid-column: span 4; }

@media (max-width: 1000px) {
  .card.span8, .card.span6, .card.span4 { grid-column: span 12; }
}

.card h2 {
  margin: 0 0 2px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.card .hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-soft);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

/* Tabellen */
.tablewrap {
  overflow: auto;
  max-height: 560px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  text-align: right;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}

thead th:first-child,
tbody td:first-child { text-align: left; }

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

tbody tr:hover td { background: var(--surface-2); }

td.desc {
  text-align: left;
  white-space: normal;
  min-width: 260px;
  color: var(--text-soft);
}

.codechip {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

.bar-cell {
  position: relative;
  min-width: 120px;
}

.bar-cell .fill {
  position: absolute;
  inset: 4px auto 4px 0;
  background: var(--accent-soft);
  border-radius: 4px;
}

.bar-cell span { position: relative; }

.muted { color: var(--text-faint); }
.right { text-align: right; }

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

svg { display: block; max-width: 100%; overflow: visible; }

.tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.12s;
}

.tip.show { opacity: 1; }
.tip b { font-weight: 700; }

footer.note {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 40px;
  font-size: 12.5px;
  color: var(--text-faint);
}
