:root {
  --bg: #f4f5f6;
  --card: #ffffff;
  --text: #14181b;
  --text-secondary: #4d565f;
  --text-label: #8a939d;
  --text-disabled: #a8b0b8;
  --divider: #e6e9ec;
  --blue: #2B84AE;
  --green: #81BB80;
  --green-text: #4f9a4e;
  --green-text-on-white: #3f7f3e;
  --red: #C4342A;
  --red-flat: #fdf2f1;
  --orange: #C2761A;
  --amber: #E3A008;
  --neutral-fill: #c9ced4;
  --neutral-border: #dfe3e7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text);
}

.frame {
  width: 100vw;
  height: 100vh;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
  transition: filter 400ms ease;
}

.frame.offline .card {
  filter: saturate(0.35);
}

.card {
  background: var(--card);
  border-radius: 14px;
}

.section-label {
  font-size: 18px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-label);
}

[class*="-value"],
.donut-pct,
.header-clock {
  font-variant-numeric: tabular-nums;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.header {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--blue);
  flex-shrink: 0;
}

.brand-logo {
  max-height: 44px;
  max-width: 160px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-name {
  font-size: 30px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-center {
  display: flex;
  align-items: baseline;
  gap: 22px;
}

.header-date {
  font-size: 26px;
  font-weight: 400;
  color: var(--text-secondary);
}

.header-clock {
  font-size: 46px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  color: var(--text-secondary);
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green-text-on-white);
  flex-shrink: 0;
}

.frame.offline .live-dot { background: var(--red); }
.frame.offline #live-text { color: var(--red); font-weight: 500; }

/* ── Instellingen (tandwiel + popover) ─────────────────────────────── */
.header-settings {
  position: relative;
  flex-shrink: 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-button svg { width: 22px; height: 22px; }

.icon-button:hover { background: var(--divider); color: var(--text); }

.settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 24, 27, 0.16);
  z-index: 100;
  max-height: min(700px, 90vh);
}

/* [hidden] en een class-selector hebben gelijke CSS-specificiteit — zonder
   deze :not()-guard zou display:flex hier altijd winnen van [hidden], en zou
   de popover na het sluiten toch zichtbaar blijven (eerder al eens fout
   gegaan op het vorige wallboard-ontwerp). */
.settings-popover:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.settings-popover-header {
  font-size: 16px;
  font-weight: 600;
  padding: 16px 18px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.settings-popover-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  min-height: 0;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-field-hint {
  font-size: 12px;
  color: var(--text-disabled);
}

.settings-error {
  font-size: 12px;
  color: var(--red);
}

.settings-select,
.settings-input {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--divider);
  background: var(--bg);
  color: var(--text);
}

.settings-select:focus,
.settings-input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-preview-frame {
  width: 56px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--divider);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.logo-preview-frame img {
  max-width: 48px;
  max-height: 36px;
  object-fit: contain;
}

.logo-empty {
  font-size: 11px;
  color: var(--text-disabled);
}

.logo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-small { padding: 5px 10px; font-size: 12px; }

.btn-secondary {
  background: var(--bg);
  border-color: var(--divider);
  color: var(--text);
}

.btn-secondary:hover { background: var(--divider); }

.btn-primary {
  background: var(--blue);
  color: #ffffff;
}

.btn-primary:hover { filter: brightness(0.92); }

.settings-popover-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
}

.settings-toast {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: var(--text);
  color: #ffffff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.settings-toast-error { background: var(--red); }

/* ── Middenrij ──────────────────────────────────────────────────────── */
.middle-row {
  flex: 1;
  display: flex;
  gap: 20px;
  min-height: 0;
}

.col-left {
  flex: 1.55;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

.col-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

/* ── Tellers ────────────────────────────────────────────────────────── */
/* ── Infrastructuur gezondheid ──────────────────────────────────────────
   Compacter dan voorheen (146px → 92px ring) om ruimte te maken voor het
   nieuwe "Apparaatgezondheid"-blok eronder, zonder de kaart zelf groter te
   maken dan nodig — flex-shrink:0, geen flex:1 meer (die ruimte gaat nu
   naar Apparaatgezondheid, dat door zijn 17 items meer baat heeft bij de
   extra hoogte). */
.health-card {
  flex-shrink: 0;
  height: 220px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.donut-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
}

.donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.donut-ring {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-ring-inner {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-pct {
  font-size: 24px;
  font-weight: 600;
}

.donut-nodata-dash {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: var(--text-disabled);
}

.donut-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.donut-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: center;
}

.donut-sub.is-problem { color: var(--red); font-weight: 500; }
.donut-sub.is-nodata { color: var(--text-disabled); }

/* ── Apparaatgezondheid ─────────────────────────────────────────────────
   1-op-1 nabouw van NinjaOne's eigen "Gezondheidsproblemen apparaat"-
   widget — alle 17 items altijd individueel zichtbaar, geen categorie-
   totalen/samenvattingen. Eén kolom per severity (rood/oranje/groen) via
   CSS Grid (3 vaste kolommen, elke kolom een eigen flex-child met zijn
   eigen rijen) i.p.v. CSS multi-column: column-count berekent zijn
   kolomhoogte op basis van de beschikbare ruimte van de container, en gaf
   bij een flex-item zonder vaste hoogte een onvoorspelbaar resultaat. */
.device-health-card {
  flex-shrink: 0;
  padding: 6px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Ongezond/Aandacht vereist naast elkaar (2 kolommen); Gezond staat er
   los onder — met nu 1 item ("Lage kwetsbaarheden") verdiende dat geen
   hele derde kolom naast zich meer, gaf alleen lege ruimte. */
.device-health-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-health-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 0 24px;
}

.device-health-column {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-health-healthy-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Categorie blijft herkenbaar via een linker accentlijn + icoonkleur, geen
   apart categorieblok. Bij count === 0 blijft de kleur zichtbaar maar
   gedempt (opacity) — bij count > 0 ("actief") wordt hij vol getoond; dit
   volgt hetzelfde rustig/luid-principe als de rest van het dashboard
   (KPI-tegels, onderhoudsstrip). "Gezond" krijgt nooit een volle/luide
   kleur, ongeacht de waarde — NinjaOne classificeert dat zelf al als
   acceptabel. */
.device-health-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px 0 14px;
  border-left: 3px solid var(--neutral-border);
  min-width: 0;
}

.device-health-row[data-severity="critical"] { border-left-color: var(--red); }
.device-health-row[data-severity="warning"] { border-left-color: var(--orange); }
.device-health-row[data-severity="success"] { border-left-color: var(--green-text-on-white); }

.device-health-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-disabled);
}

.device-health-row[data-severity="critical"] .device-health-icon { color: var(--red); opacity: 0.5; }
.device-health-row[data-severity="warning"] .device-health-icon { color: var(--orange); opacity: 0.5; }
.device-health-row[data-severity="success"] .device-health-icon { color: var(--green-text-on-white); opacity: 0.7; }
.device-health-row[data-active] .device-health-icon { opacity: 1; }

.device-health-label {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-health-count {
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-disabled);
}

.device-health-row[data-active="critical"] .device-health-count { color: var(--red); }
.device-health-row[data-active="warning"] .device-health-count { color: var(--orange); }
.device-health-count.is-nodata { font-weight: 400; }

@media (max-width: 900px) {
  .device-health-columns { grid-template-columns: 1fr; }
}

/* ── Samenvatting gezondheid apparaat ──────────────────────────────────
   1-op-1 nabouw van NinjaOne's eigen widget (screenshot van de gebruiker) —
   vervangt de oude onderhoudsstrip (Schijfruimte/Patch failures/Reboot
   required/Backup failures) op verzoek. Bron: healthStatus-verdeling over
   alle apparaten met health-data (services/wallboard.py::
   build_device_health_summary), zelfde 4 categorieën als NinjaOne toont. */
.health-summary-card {
  flex-shrink: 0;
  padding: 6px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.health-summary-pct {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.health-summary-pct .health-summary-pct-label {
  font-weight: 400;
  color: var(--text-secondary);
}

.health-summary-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--neutral-fill);
}

.health-summary-segment[data-color="healthy"] { background: var(--green-text-on-white); }
.health-summary-segment[data-color="attention"] { background: var(--amber); }
.health-summary-segment[data-color="unhealthy"] { background: var(--red); }
.health-summary-segment[data-color="unknown"] { background: var(--neutral-fill); }

.health-summary-legend {
  display: flex;
  gap: 24px;
}

.health-summary-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.health-summary-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-summary-legend-item[data-color="healthy"] .health-summary-dot { background: var(--green-text-on-white); }
.health-summary-legend-item[data-color="attention"] .health-summary-dot { background: var(--amber); }
.health-summary-legend-item[data-color="unhealthy"] .health-summary-dot { background: var(--red); }
.health-summary-legend-item[data-color="unknown"] .health-summary-dot { background: var(--neutral-fill); }

/* ── Server offline ─────────────────────────────────────────────────── */
.servers-offline {
  flex-shrink: 0;
  background: var(--red-flat);
  border: 3px solid var(--red);
  padding: 16px 22px;
  gap: 10px;
}

/* [hidden] en een class-selector hebben gelijke CSS-specificiteit — zonder
   deze :not()-guard bleef dit blok altijd zichtbaar (leeg, met "0"), ook
   wanneer er geen offline servers zijn en JS het hidden-attribuut correct
   zette. Zelfde bugpatroon als eerder al gevonden bij .settings-popover. */
.servers-offline:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.servers-offline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.servers-offline-label { color: var(--red); }

.servers-offline-count {
  font-size: 28px;
  font-weight: 600;
  color: var(--red);
}

.servers-offline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.servers-offline-row {
  font-size: 21px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.servers-offline-row .device-name {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.servers-offline-more {
  font-size: 20px;
  color: var(--text-disabled);
}

/* ── Ticketsysteem (open/wachten/niet toegewezen) ─────────────────────
   Drie tellers uit dezelfde ticket-samenvatting als de tickets-kaart
   eronder (services/tickets.py::build_ticket_summary) — geen nieuwe
   databron. "Wachten" = ticketstatus WAITING/"Wacht op klant" (parentId
   3000), "Niet toegewezen" = open ticket zonder assignedAppUser (bestond
   al als "waitingForEngineer", hergebruikt onder een duidelijker label
   hier). Zelfde hoogte als .health-card (220px) op verzoek — leesbaarder,
   en geeft een consistente linkerkolom/rechterkolom-balans bovenaan. */
.ticket-status-card {
  flex-shrink: 0;
  height: 220px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.ticket-status-row {
  display: flex;
  justify-content: center;
  gap: 56px;
}

.ticket-status-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.ticket-status-accent {
  width: 6px;
  height: 56px;
  border-radius: 3px;
  background: var(--neutral-border);
  flex-shrink: 0;
}

.ticket-status-item[data-accent="orange"] .ticket-status-accent { background: var(--orange); }
.ticket-status-item[data-accent="blue"] .ticket-status-accent { background: var(--blue); }

.ticket-status-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticket-status-label {
  font-size: 22px;
  color: var(--text-secondary);
}

.ticket-status-item[data-accent="orange"] .ticket-status-label { color: var(--orange); }
.ticket-status-item[data-accent="blue"] .ticket-status-label { color: var(--blue); }

.ticket-status-value {
  font-size: 46px;
  font-weight: 600;
  color: var(--text);
}

/* ── Tickets ────────────────────────────────────────────────────────── */
.tickets-card {
  flex: 1;
  min-height: 0;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tickets-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.tickets-counts {
  font-size: 21px;
  font-weight: 500;
  color: var(--text-secondary);
}

.tickets-sublabel-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.tickets-oldest {
  font-size: 18px;
  font-weight: 500;
  color: var(--orange);
}

.tickets-oldest[data-severity="critical"] { color: var(--red); }
.tickets-oldest[data-severity="success"] { color: var(--green-text-on-white); }

/* Was justify-content:space-between — verdeelde de rijen over de volle
   kaarthoogte, wat er bij een wisselend aantal tickets (weinig = grote
   kloven, veel = juist gedrongen) inconsistent uitzag. Vaste gap geeft een
   rustige lijst, ongeacht het aantal. */
.ticket-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.ticket-row {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  border-top: 1px solid var(--divider);
}

.ticket-row:first-child { border-top: none; }

.ticket-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ticket-customer {
  font-size: 22px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-status {
  font-size: 17px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.ticket-status[data-status="new"] { color: var(--blue); }
.ticket-status[data-status="waiting"] { color: var(--orange); }
.ticket-status[data-status="open"] { color: var(--text-label); }

.ticket-subject {
  font-size: 21px;
  font-weight: 400;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-list-empty {
  font-size: 20px;
  color: var(--text-disabled);
  margin: auto 0;
  text-align: center;
}

/* ── Activiteitenregel ──────────────────────────────────────────────── */
.activity-line {
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 19px;
  color: var(--text-secondary);
}

.activity-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-label);
}

.activity-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-disabled);
  flex-shrink: 0;
}

.activity-dot[data-severity="critical"] { background: var(--red); }
.activity-dot[data-severity="warning"] { background: var(--orange); }
.activity-dot[data-severity="success"] { background: var(--green-text-on-white); }
.activity-dot[data-severity="info"] { background: var(--blue); }

.activity-message {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-meta {
  flex-shrink: 0;
  color: var(--text-disabled);
  font-size: 17px;
}
