/* ═══════════════════════════════════════════════════════
   Pi Platform — Design System CSS
   Pi-huisstijl: rood (#CC0000), Segoe UI, strak & zakelijk
   ═══════════════════════════════════════════════════════ */

/* ── Reset & base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Eén palet voor platform, desktop en app: koel-neutraal grijs + Pi-rood.
   Alle randen/achtergronden lopen via deze tokens, zodat inline stijlen in de
   pagina's (var(--border), var(--text), ...) overal dezelfde waarde krijgen. */
:root {
  --pi-red:        #CC0000;
  --pi-red-mid:    #D92B2B;
  --pi-red-dark:   #A80000;
  --pi-red-pale:   #FEF3F3;
  --pi-red-border: #F5C6C6;
  --pi-red-10:     rgba(204,0,0,.10);
  --pi-green:      #0F7A5A;
  --pi-amber:      #8A5A0B;

  --gray-900: #16181D;
  --gray-700: #3F444C;
  --gray-500: #6B7280;
  --gray-300: #C9CED6;
  --gray-200: #E6E8EC;
  --gray-100: #F4F5F7;
  --gray-50:  #FAFAFB;
  --white:    #FFFFFF;

  --sidebar-w:    232px;
  --header-h:     56px;
  --radius:       6px;
  --radius-lg:    10px;
  --shadow-sm:    0 1px 2px rgba(16,24,40,.05);
  --shadow-md:    0 8px 24px rgba(16,24,40,.12);
  --transition:   .12s ease;
  --focus-ring:   0 0 0 3px var(--pi-red-10);

  /* Aliassen voor achterwaartse compatibiliteit (ook gebruikt in inline stijlen) */
  --pi-teal:         #4b6d7a;
  --pi-teal-mid:     #76a0ad;
  --pi-teal-light:   #b2cad1;
  --pi-teal-pale:    #EAF4F7;
  --bg:              #F4F5F7;
  --bg-alt:          #E6E8EC;
  --bg-secondary:    #F7F8FA;
  --card-bg:         #FFFFFF;
  --text:            #16181D;
  --text-primary:    #16181D;
  --text-secondary:  #6B7280;
  --text-muted:      #9AA0A8;
  --border:          #E3E6EA;
  --border-strong:   #CFD4DB;
  --divider:         #ECEEF1;
  --success:         #0F7A5A;
  --warning:         #8A5A0B;
  --danger:          #CC0000;
  --info:            #4b6d7a;
  --sidebar-width:   232px;
  --topbar-height:   56px;
  --font:            'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius-sm:       5px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:focus-visible { outline: 2px solid var(--pi-red); outline-offset: 2px; }
::selection { background: var(--pi-red-border); }
* { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.18) transparent; }
.tabular, .stat-value, td { font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Layout ────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

.app-header  { grid-column: 1/-1; grid-row: 1; }
.app-sidebar { grid-column: 1;    grid-row: 2; }
.app-main    { grid-column: 2;    grid-row: 2; overflow-y: auto; }

/* Ondersteuning voor oud #app-shell layout (flex-gebaseerd) */
#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
#main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}
#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 32px;
}
/* Inhoud niet eindeloos breed op grote schermen */
#page-content > * { max-width: 1680px; margin-left: auto; margin-right: auto; }

/* ── Header / Topbar ───────────────────────────────────── */
.app-header,
#topbar {
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
  height: var(--header-h);
  z-index: 100;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  /* Dunne merkstreep bovenaan i.p.v. zware rode onderrand. Bewust geen
     position:relative — dan zouden de dropdowns onder kaarten (Leaflet) vallen. */
  box-shadow: inset 0 2px 0 var(--pi-red);
}
.header-logo  { height: 40px; width: auto; }
.header-divider { width: 1px; height: 32px; background: var(--divider); }
.header-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.header-sub   { font-size: 11px; color: var(--text-secondary); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.header-user  { font-size: 13px; color: var(--text-primary); }
.header-btn {
  background: var(--gray-100,#F5F5F5);
  border: 1px solid var(--divider);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.header-btn:hover { background: var(--gray-200,#EBEBEB); }

/* Topbar logo */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.topbar-logo img,
.topbar-logo svg { width: 30px; height: 30px; flex-shrink: 0; }
.topbar-logo-name { color: var(--pi-red); font-weight: 700; }
.topbar-logo-name span { color: var(--text-secondary); font-weight: 400; }
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.topbar-user:hover { background: var(--gray-100); border-color: var(--border); }
.topbar-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--pi-red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.topbar-user-role { font-size: 11px; color: var(--text-secondary); }
#topbar-hamburger {
  display: flex;
  cursor: pointer;
  background: none;
  border: none;
  padding: 7px;
  color: var(--text-secondary);
  border-radius: var(--radius);
}
#topbar-hamburger:hover { background: var(--gray-100); color: var(--text); }

/* Topbar: icoonknop (notificatiebel) + dropdowns */
.topbar-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.topbar-icon-btn:hover { background: var(--gray-100); color: var(--text); }
.topbar-icon-btn svg { width: 16px; height: 16px; }
.topbar-badge {
  display: none;
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  background: var(--pi-red); color: #fff;
  border-radius: 9px; border: 2px solid #fff;
  font-size: 9px; font-weight: 700; line-height: 1;
  align-items: center; justify-content: center;
}
.dropdown-panel {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.dropdown-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
}
.dropdown-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: none; border: none;
  font-size: 13px; text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--gray-100); }
.dropdown-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-secondary); }
.dropdown-item.danger, .dropdown-item.danger svg { color: var(--pi-red); }
.dropdown-sep { height: 1px; background: var(--divider); margin: 4px 0; }

/* ── Sidebar ────────────────────────────────────────────── */
.app-sidebar,
#sidebar {
  background: white;
  border-right: 1px solid var(--border);
  padding: 6px 0 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  width: var(--sidebar-w);
  transition: transform 0.25s ease, margin-left 0.25s ease;
}

/* Desktop: zijbalk in-/uitklappen via de menuknop */
@media (min-width: 769px) {
  body.sidebar-collapsed #sidebar {
    margin-left: calc(-1 * var(--sidebar-w));
    border-right: none;
  }
  /* Ruimte voor het aanpas-paneel rechts, zodat alle widgets bereikbaar blijven */
  body.dashboard-edit-mode #page-content { padding-right: 344px; }
}

/* Scrollbar sidebar */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 2px; }

.sidebar-section { padding: 20px 0 8px; }
.sidebar-label,
.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: 14px 20px 6px;
  display: block;
}

/* Sidebar links — nieuw systeem */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}
.sidebar-link:hover { background: var(--pi-red-pale); color: var(--pi-red); }
.sidebar-link.active {
  background: var(--pi-red-pale);
  color: var(--pi-red);
  border-left-color: var(--pi-red);
  font-weight: 600;
}
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }
.sidebar-badge {
  margin-left: auto;
  background: var(--pi-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

/* Nav items — oud systeem */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  margin: 1px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--gray-100); color: var(--text); }
.nav-item.active {
  background: var(--pi-red-pale);
  color: var(--pi-red);
  font-weight: 600;
}
/* Actief-indicator zonder dat de tekst verspringt */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 7px; bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--pi-red);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .65; }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }
.nav-badge {
  display: none;
  margin-left: auto;
  background: var(--pi-red);
  color: #fff;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
}
.nav-divider {
  height: 1px;
  background: var(--divider);
  margin: 8px 20px 0;
}

/* ── Page content ───────────────────────────────────────── */
.page { padding: 24px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--gray-900); letter-spacing: -.01em; line-height: 1.25; }
.page-sub   { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.page-header-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Stat cards ─────────────────────────────────────────── */
.stats-grid,
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
/* Kleur zit in het icoon; de kaart zelf blijft rustig */
.stat-card:hover { border-color: var(--border-strong); }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.red    { background: var(--pi-red-pale);  color: var(--pi-red); }
.stat-icon.green  { background: #F0FDF4;              color: var(--pi-green); }
.stat-icon.amber  { background: #FFFBEB;              color: var(--pi-amber); }
.stat-icon.blue   { background: #EEF5FB;              color: #1B3A5C; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: 5px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1; letter-spacing: -.01em; }
.stat-trend { font-size: 11px; color: var(--gray-500); margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
  height: 34px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary  { background: var(--pi-red);  color: white; border-color: var(--pi-red); }
.btn-primary:hover:not(:disabled)  { background: var(--pi-red-dark); border-color: var(--pi-red-dark); }

.btn-success  { background: var(--pi-green); color: white; border-color: var(--pi-green); }
.btn-success:hover:not(:disabled)  { background: #0A5C44; border-color: #0A5C44; }

.btn-outline,
.btn-secondary  { background: white; color: var(--gray-900); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-outline:hover:not(:disabled),
.btn-secondary:hover:not(:disabled)  { background: var(--gray-50); border-color: var(--gray-300); }

.btn-ghost    { background: transparent; color: var(--gray-700); border-color: var(--border); }
.btn-ghost:hover:not(:disabled)    { background: var(--gray-100); color: var(--text); }

.btn-danger   { background: white; color: var(--pi-red); border-color: var(--pi-red-border); }
.btn-danger:hover:not(:disabled)   { background: var(--pi-red-pale); }

/* Teal-knop (achterwaartse compatibiliteit) */
.btn-teal { background: #4b6d7a; color: white; border-color: #4b6d7a; }
.btn-teal:hover:not(:disabled) { background: #3d5a65; border-color: #3d5a65; }

.btn-sm   { padding: 0 10px; font-size: 12px; height: 28px; }
.btn-lg   { padding: 0 22px; font-size: 14px; height: 42px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-right { margin-left: auto; }
.toolbar-divider { width: 1px; height: 24px; background: #e8e8e8; }

/* ── Search & filters ───────────────────────────────────── */
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--gray-500);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  height: 34px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--pi-red); box-shadow: var(--focus-ring); }

.filter-select {
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: white;
  color: var(--gray-900);
  cursor: pointer;
  transition: var(--transition);
  height: 34px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.filter-select:focus { border-color: var(--pi-red); box-shadow: var(--focus-ring); }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  height: 36px;
  padding: 0 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); border-bottom-color: var(--gray-300); }
.tab-btn.active { color: var(--pi-red); border-bottom-color: var(--pi-red); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap,
.datagrid-wrapper { background: white; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: auto; }
table,
.datagrid { width: 100%; border-collapse: collapse; font-size: 13px; }
/* Rustige tabelkop: lichtgrijs met kleine hoofdletters i.p.v. vol rood */
thead th {
  background: var(--gray-50);
  color: var(--gray-500);
  padding: 9px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
.datagrid th {
  background: var(--gray-50);
  color: var(--gray-500);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
thead th:hover { background: var(--gray-100); color: var(--text); }
thead th.sort-asc,
thead th.sort-desc { color: var(--pi-red); }
thead th.sort-asc::after  { content: ' ↑'; }
thead th.sort-desc::after { content: ' ↓'; }
tbody tr { border-bottom: 1px solid var(--divider); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); cursor: pointer; }
tbody tr.selected { background: var(--pi-red-pale); }
td { padding: 9px 14px; vertical-align: middle; }
.datagrid td { height: 40px; padding: 0 12px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.td-muted { color: var(--gray-500); font-size: 12px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  border: 1px solid var(--border);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-900); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}
.badge-active   { background: #ecf9f4; color: var(--pi-green); }
.badge-locked   { background: var(--pi-red-pale); color: var(--pi-red); }
.badge-inactive { background: var(--gray-100); color: var(--gray-500); }
.badge-invited  { background: #FFF8E1; color: #7B5800; }
.badge-mfa      { background: #ecf9f4; color: var(--pi-green); }
.badge-no-mfa   { background: var(--pi-red-pale); color: var(--pi-red); }
.badge-role {
  background: var(--pi-red-pale);
  color: var(--pi-red-dark);
  border: 1px solid var(--pi-red-border);
}
.badge-success  { background: #ecf9f4; color: var(--pi-green); }
.badge-warning  { background: #FFF8E1; color: var(--pi-amber); }
.badge-info     { background: #EEF5FB; color: #1B3A5C; }
.badge-danger   { background: var(--pi-red-pale); color: var(--pi-red); }
.badge-neutral  { background: var(--gray-100); color: var(--gray-500); }
.badge-purple   { background: #F5F3FF; color: #7C3AED; }
.badge-teal     { background: #E3F7FC; color: #4b6d7a; }
.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--gray-500);
  flex-wrap: wrap;
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
  color: var(--gray-900);
  font-family: inherit;
  height: 28px;
  min-width: 28px;
}
.page-btn:hover  { background: var(--gray-100); border-color: var(--border-strong); }
.page-btn.active { background: var(--pi-red); border-color: var(--pi-red); color: white; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  box-shadow: 0 20px 48px rgba(16,24,40,.22);
  overflow: hidden;
  transform: scale(.97);
  transition: transform .18s;
  display: flex;
  flex-direction: column;
  border-top: 3px solid var(--pi-red);
}
.modal-lg { max-width: 800px; }
.modal-overlay.open .modal { transform: scale(1); }
/* Witte kop met dunne rode bovenrand i.p.v. volledig rood vlak */
.modal-header {
  background: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  width: 28px; height: 28px;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--divider);
  background: var(--gray-50);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Forms ──────────────────────────────────────────────── */
/* Nieuw systeem: .field */
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-900);
  outline: none;
  transition: border-color var(--transition);
  background: white;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--pi-red);
  box-shadow: var(--focus-ring);
}
.field select,
select.form-control {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
select[multiple].form-control, .field select[multiple] { background-image: none; padding-right: 10px; height: auto; }
.field input::placeholder, .field textarea::placeholder,
.form-control::placeholder { color: var(--text-muted); }
.field input:disabled, .field select:disabled, .field textarea:disabled,
.form-control:disabled { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }
.field input.is-error { border-color: var(--pi-red); background: var(--pi-red-pale); }
.field-error { font-size: 11px; color: var(--pi-red); margin-top: 4px; }
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 11px; color: var(--gray-500); margin-top: 4px; }

/* Oud systeem: .form-group / .form-control */
.form-group,
.form-row    { margin-bottom: 14px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-900);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:hover:not(:focus):not(:disabled),
.field input:hover:not(:focus):not(:disabled),
.field select:hover:not(:focus):not(:disabled),
.field textarea:hover:not(:focus):not(:disabled) { border-color: #B4BAC3; }
.form-control:focus {
  border-color: var(--pi-red);
  box-shadow: var(--focus-ring);
}
textarea.form-control { height: auto; padding: 8px 10px; resize: vertical; }
select.form-control   { cursor: pointer; }

/* ── Alert / toast ──────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error   { background: var(--pi-red-pale); color: var(--pi-red-dark); border: 1px solid var(--pi-red-border); }
.alert-success { background: #ecf9f4; color: var(--pi-green); border: 1px solid #b8e8d8; }
.alert-info    { background: #EEF5FB; color: #1B3A5C; border: 1px solid #c9dff0; }
.alert-warn    { background: #FFF8E1; color: var(--pi-amber); border: 1px solid #FFE082; }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  max-width: 380px;
  pointer-events: all;
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gray-300);
  animation: toast-in 0.25s ease;
}
.toast.success { border-left-color: var(--pi-green); }
.toast.error   { border-left-color: var(--pi-red); }
.toast.info    { border-left-color: #1B3A5C; }
.toast.warning { border-left-color: var(--pi-amber); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading / Spinner ──────────────────────────────────── */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--pi-red-border);
  border-top-color: var(--pi-red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
  gap: 10px;
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state svg  { width: 36px; height: 36px; opacity: 0.35; }
.empty-state h3   { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state p    { font-size: 13px; }

/* ── Back Button ────────────────────────────────────────── */
.back-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  background: white;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
}
.back-btn:hover { background: var(--gray-100); color: var(--text); }

/* ── Detail Header ──────────────────────────────────────── */
.detail-header {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-left: 3px solid var(--pi-red);
}
.detail-header-info { flex: 1; min-width: 200px; }
.detail-object-name { font-size: 20px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.detail-meta { font-size: 12px; color: var(--gray-500); display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.detail-meta span { display: flex; align-items: center; gap: 4px; }
.detail-header-actions { display: flex; gap: 8px; align-items: flex-start; }

/* ── MFA warning ────────────────────────────────────────── */
.mfa-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #FFF8E1;
  border: 1px solid #FFE082;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--pi-amber);
  margin-bottom: 16px;
}

/* ── Timeline ───────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px; top: 24px; bottom: 0;
  width: 2px;
  background: #f0f0f0;
}
.timeline-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #ddd;
  background: white;
  flex-shrink: 0;
  margin-top: 2px;
}
.timeline-dot.done   { background: var(--pi-green); border-color: var(--pi-green); }
.timeline-dot.active { background: var(--pi-red);   border-color: var(--pi-red); }
.timeline-dot.danger { background: var(--pi-red);   border-color: var(--pi-red); }
.timeline-content { flex: 1; }
.timeline-label { font-size: 13px; font-weight: 600; }
.timeline-time  { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* ── Key-Value List ─────────────────────────────────────── */
.kv-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.kv-item {
  display: flex;
  flex-direction: column;
  padding: 9px 12px;
  border-bottom: 1px solid var(--divider);
}
.kv-item:nth-child(odd) { border-right: 1px solid var(--divider); }
.kv-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 2px;
  letter-spacing: 0.05em;
}
.kv-value { font-size: 13px; color: var(--gray-900); }

/* ── Section divider ────────────────────────────────────── */
.section-divider { height: 1px; background: var(--divider); margin: 20px 0; }

/* ── Info Banner ────────────────────────────────────────── */
.info-banner {
  background: var(--pi-red-pale);
  border: 1px solid var(--pi-red-border);
  border-left: 3px solid var(--pi-red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--pi-red-dark);
  margin-bottom: 16px;
}

/* ── Map ────────────────────────────────────────────────── */
#map-container {
  height: 340px;
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--pi-red-dark) 0%, var(--pi-red) 50%, var(--pi-red-mid) 100%);
  background-size: cover;
  background-position: center;
  padding: 20px;
}
/* Donker overlay zodat de kaart leesbaar blijft over foto's */
.login-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  pointer-events: none;
}
.login-card {
  background: white;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 32px;
}
.login-logo svg,
.login-logo img { width: 64px; height: 64px; }
.login-logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--pi-red);
  letter-spacing: -0.02em;
}
.login-logo-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: -4px;
  letter-spacing: 0.02em;
}
.login-title    { font-size: 17px; font-weight: 600; margin-bottom: 5px; color: var(--gray-900); }
.login-subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }
.login-error {
  background: var(--pi-red-pale);
  color: var(--pi-red-dark);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--pi-red);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-btn {
  width: 100%;
  height: 44px;
  background: var(--pi-red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}
.login-btn:hover { background: var(--pi-red-dark); box-shadow: 0 4px 12px rgba(204,0,0,.35); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.login-card .form-control:focus {
  border-color: var(--pi-red);
  box-shadow: 0 0 0 3px rgba(204,0,0,.1);
}

/* ── Checkbox Toggle ────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; gap: 10px; height: 36px; }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: 10px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--pi-red); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; --sidebar-width: 240px; }
  .app-sidebar { display: none; }
  .app-layout  { grid-template-columns: 1fr; }
  .app-main    { grid-column: 1; }

  #topbar-hamburger { display: flex; }
  #sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.20);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 140;
  }
  #sidebar-overlay.visible { display: block; }
  #page-content { padding: 16px; }
  .stats-grid, .stats-bar { grid-template-columns: 1fr 1fr; }
  .field-row, .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kv-list { grid-template-columns: 1fr; }
  .kv-item:nth-child(odd) { border-right: none; }
  .login-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stats-grid, .stats-bar { grid-template-columns: 1fr; }
  .detail-header { flex-direction: column; }
}
#dash-grid{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  grid-auto-rows:140px;
  grid-auto-flow:dense;
  gap:16px;
  align-items:start;
}

.dash-widget{
  min-height:100%;
  position:relative;
}

.drag-handle{
  display:none !important;
}

.widget-resize-ctrl{
  display:none !important;
}

.dashboard-edit-mode .drag-handle{
  display:flex !important;
}

.dashboard-edit-mode .widget-resize-ctrl{
  display:flex !important;
}

.dashboard-edit-mode .dash-widget{
  outline:2px dashed #d9d9d9;
  outline-offset:2px;
}

/* ======================================================
   Topbar installaties toggle
   ====================================================== */

/* Segmentknop: één omlijst blok, actieve keuze als witte "pil" */
.topbar-installation-toggle{
  display:flex;
  align-items:center;
  gap:2px;
  padding:2px;
  margin-right:8px;
  background:var(--gray-100);
  border:1px solid var(--border);
  border-radius:var(--radius);
}

.topbar-toggle-btn{
  height:28px;
  padding:0 12px;
  border-radius:4px;
  border:none;
  background:transparent;
  color:var(--text-secondary);
  font-size:12px;
  font-weight:600;
  cursor:pointer;
  transition:background var(--transition), color var(--transition);
}
.topbar-toggle-btn:hover{ color:var(--text); }

.topbar-toggle-btn.active{
  background:#fff;
  color:var(--pi-red);
  box-shadow:0 1px 2px rgba(16,24,40,.10);
}
@media (max-width: 900px) {
  .topbar-user-meta, .topbar-user > svg { display:none !important; }
  .topbar-logo-name { display:none; }
  .topbar-toggle-btn { padding:0 8px; }
}

/* Tegel-icoon in sidebar-sectiekoppen (Adviseurs/Backoffice) */
.sidebar-section-label .sec-ico{vertical-align:-2px;margin-right:6px;opacity:.75}
