:root {
  --shell-blue: #006991;
  --shell-blue-hover: #005878;
  --shell-green: #1d624c;
  --shell-focus: #ffcd1c;
  --shell-tint: #bde3f2;
  --shell-surface: #fff;
  --shell-surface-muted: #f7fbfc;
  --shell-text: #17313c;
  --shell-blue-pale: #ecf7fd;
  --shell-blue-dark: #006991;
  --shell-line: #c9d9de;
  --shell-shadow-sm: 0 3px 10px #00384a14;
  --shell-shadow-md: 0 12px 28px #00384a24;
  --shell-radius: 8px;
  --shell-rail-collapsed: 64px;
  --shell-rail-expanded: 214px;
}

/* Centrale basis voor de PHP-applicatieschil. Zelfstandige werkveltemplates
   behouden hun eigen vormgeving en gebruiken alleen het opgeloste lichte/donkere thema. */
.shell-page {
  min-height: 100vh;
  margin: 0;
  color: var(--shell-blue);
  background: #f5f5f5;
  font-family: "Source Sans 3", "Source Sans Pro", Arial, sans-serif;
}

.shell-page *,
.shell-page *::before,
.shell-page *::after { box-sizing: border-box; }

.shell-page .rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.shell-page .rail .bottom { margin-top: auto; }
.shell-page .rail a[aria-current="page"] {
  background: var(--shell-blue-hover);
  box-shadow: inset 4px 0 var(--shell-focus);
}

.shell-page .rail a,
.shell-page .rail button {
  min-height: 52px;
  border: 0;
  color: #fff;
  background: transparent;
  font: inherit;
  font-size: .8em;
  text-decoration: none;
  cursor: pointer;
}

.shell-page .shell-content {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--shell-rail-collapsed);
  transition: margin-left 180ms ease;
}

.shell-page .rail.expanded + .shell-content { margin-left: var(--shell-rail-expanded); }

.shell-page .topbar {
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 8px 22px;
  border-bottom: 1px solid #dcdcdc;
  background: #fff;
}

.shell-page .brand,
.shell-page .brand-path,
.shell-page .menu,
.shell-page .topbar-end {
  display: flex;
  align-items: center;
}

.shell-page .brand { min-width: 0; }
.shell-page .brand-path { min-width: 0; gap: 10px; }
.shell-page .heading-editable { display: flex; min-width: 0; align-items: center; gap: 4px; }
.shell-page .heading-edit-button {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--shell-blue-dark);
  background: transparent;
  cursor: pointer;
  opacity: .62;
}
.shell-page .heading-edit-button[hidden] { display: none; }
.shell-page .heading-edit-button:hover,
.shell-page .heading-edit-button:focus-visible { color: var(--shell-blue); background: var(--shell-blue-pale); opacity: 1; }
.shell-page .heading-edit-button svg { width: 17px; height: 17px; }
.shell-page .heading-edit-input {
  width: min(480px, 52vw);
  min-width: 180px;
  height: 38px;
  border: 1px solid var(--shell-blue);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--shell-text);
  background: var(--shell-surface);
  font: inherit;
  font-size: 1.05em;
  font-weight: 700;
}
.shell-page .product {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  color: var(--shell-blue);
  text-decoration: none;
}
.shell-page .product-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
}
.shell-page .product-wordmark { display: grid; gap: 1px; line-height: 1; }
.shell-page .product-name {
  display: grid;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: -.01em;
}
.shell-page .product-subtitle {
  color: #319b87;
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .08em;
}
.shell-page .product:hover .product-name { color: #004f70; }
.shell-page .product:hover .product-subtitle { color: #237663; }
.shell-page .product:focus-visible { outline: 3px solid var(--shell-focus); outline-offset: 3px; border-radius: 5px; }
.shell-page .brand-divider { color: #8aa7b1; font-size: 1.2em; line-height: 1; }
.shell-page h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 1.2em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-page .topbar-end { justify-content: flex-end; gap: 12px; }
.shell-page .menu { justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.shell-page .page-actionbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 22px;
  border-bottom: 1px solid var(--shell-line);
  background: var(--shell-surface-muted);
  box-shadow: 0 2px 8px #00384a0d;
}
.shell-page .page-actionbar .status {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  color: #4f6e79;
}
.shell-page .page-actionbar .status::before {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #8aa7b1;
  content: "";
  transition: background-color 150ms ease, box-shadow 150ms ease;
}
.shell-page .page-actionbar .status[data-state="progress"]::before {
  background: #00afdc;
  box-shadow: 0 0 0 4px #00afdc24;
  animation: shell-status-pulse 1.2s ease-in-out infinite;
}
.shell-page .page-actionbar .status[data-state="success"]::before { background: #1d624c; }
.shell-page .page-actionbar .status[data-state="error"]::before { background: #bb3f56; }
.shell-page .page-actionbar .menu { flex: 0 0 auto; }
.shell-page .page-actionbar .action-icon {
  display: inline-grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  place-items: center;
  border-radius: 8px;
}
.shell-page .page-actionbar .action-icon svg { width: 19px; height: 19px; }
.shell-page .page-actionbar .action-icon[data-feedback="saving"] svg { animation: shell-save-pulse 900ms ease-in-out infinite; }
.shell-page .page-actionbar .action-icon[data-feedback="saved"] {
  color: #fff;
  background: #1d624c;
  border-color: #1d624c;
  box-shadow: 0 0 0 3px #1d624c20;
}
.shell-page .page-actionbar .action-icon[data-feedback="error"] { color: #bb3f56; border-color: #bb3f56; }

.shell-page .user-menu { position: relative; flex: 0 0 auto; color: var(--shell-blue); }
.shell-page .user-menu > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 4px;
  border-radius: 999px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 140ms ease, box-shadow 140ms ease;
}
.shell-page .user-menu > summary::-webkit-details-marker { display: none; }
.shell-page .user-menu > summary:focus-visible { outline: 3px solid var(--shell-focus); outline-offset: 2px; }
.shell-page .user-menu > summary:hover,
.shell-page .user-menu[open] > summary { background: #eaf7fc; box-shadow: 0 0 0 1px #bde3f2; }
.shell-page .user-name { max-width: 190px; overflow: hidden; font-size: .82em; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.shell-page .avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #00afdc;
  font-size: .72em;
  font-weight: 800;
  letter-spacing: .02em;
  overflow: hidden;
}
.shell-page .avatar img { width: 100%; height: 100%; object-fit: cover; }
.shell-page .user-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: min(290px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid #c9d9de;
  border-radius: 12px;
  color: #234e5e;
  background: #fff;
  box-shadow: 0 14px 34px #00384a2c;
  transform-origin: top right;
  animation: shell-popover-in 140ms ease-out;
}
.shell-page .user-account { display: grid; gap: 2px; padding: 0 3px 12px; border-bottom: 1px solid #dce6e9; }
.shell-page .user-account strong { overflow-wrap: anywhere; color: var(--shell-blue); }
.shell-page .user-account span { overflow-wrap: anywhere; color: #5e7d88; font-size: .78em; }
.shell-page .user-memberships { display: grid; gap: 4px; margin-top: 10px; }
.shell-page .user-memberships strong { font-size: .78em; }
.shell-page .user-memberships ul { display: grid; gap: 2px; margin: 0; padding-left: 18px; font-size: .78em; }
.shell-page .user-memberships li { overflow-wrap: anywhere; }
.shell-page .user-memberships li.empty { margin-left: -18px; color: #5e7d88; list-style: none; }
.shell-page .avatar-controls { display: grid; grid-template-columns: 1fr auto; gap: 7px; padding: 12px 3px; border-bottom: 1px solid #dce6e9; }
.shell-page .avatar-upload,
.shell-page .avatar-controls button {
  padding: 7px 8px;
  border: 1px solid #c9d9de;
  border-radius: 7px;
  color: var(--shell-blue);
  background: #fff;
  font: inherit;
  font-size: .76em;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}
.shell-page .avatar-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.shell-page .avatar-controls span { grid-column: 1 / -1; min-height: 1em; color: #5e7d88; font-size: .7em; }
.shell-page .avatar-upload:hover,
.shell-page .avatar-controls button:hover { border-color: #00afdc; background: #ecf7fd; }
.shell-page .user-setting { display: grid; gap: 7px; padding: 12px 3px; border-bottom: 1px solid #dce6e9; }
.shell-page .user-setting-label { font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.shell-page .user-popover .theme-switch { width: 100%; grid-template-columns: repeat(3, 1fr); }
.shell-page .user-popover .theme-switch label { justify-content: center; }
.shell-page .user-menu-nav { display: grid; padding-top: 7px; }
.shell-page .user-menu-nav a,
.shell-page .user-menu-nav button {
  width: 100%;
  padding: 9px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--shell-blue);
  background: transparent;
  font: inherit;
  font-size: .84em;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.shell-page .user-menu-nav a:hover,
.shell-page .user-menu-nav button:hover { background: #ecf7fd; }

.shell-page .btn {
  min-height: 2rem;
  padding: .4rem .65rem;
  border: 1px solid #dcdcdc;
  border-radius: 5px;
  color: var(--shell-blue);
  background: #fff;
  font: inherit;
  font-size: .8em;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.shell-page .btn:hover {
  transform: translateY(-1px);
  border-color: #00afdc;
  background: #ecf7fd;
  box-shadow: 0 4px 10px #00384a2c;
}
.shell-page .btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px #00384a25;
}
.shell-page .btn:disabled { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }

.shell-page .shell-main { padding: 28px min(38px, 4vw) 76px; }
.shell-page .shell-footer {
  position: fixed;
  z-index: 9;
  right: 0;
  bottom: 0;
  left: var(--shell-rail-collapsed);
  display: flex;
  min-height: 48px;
  padding: 8px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #dcdcdc;
  background: #fff;
  transition: left 180ms ease;
}
.shell-page .rail.expanded + .shell-content .shell-footer { left: var(--shell-rail-expanded); }
.shell-footer .footer-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; font-size: .76rem; }
.shell-footer .footer-meta a { color: var(--shell-blue); font-weight: 700; text-underline-offset: 3px; }
.shell-footer .footer-logo { display: flex; flex: 0 0 auto; align-items: center; }
.shell-page .shell-footer .logo { width: 128px; height: auto; }
.standalone-footer {
  position: fixed;
  z-index: 9;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  min-height: 48px;
  padding: 8px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #dcdcdc;
  color: #006991;
  background: #fff;
  font-family: "Source Sans 3", "Source Sans Pro", Arial, sans-serif;
}
.standalone-footer .logo { width: 128px; height: auto; }
.dark .standalone-footer { color: #e8f2f5; background: #1d3944; border-color: #3f606b; }
.dark .standalone-footer .footer-meta a { color: #d6edf4; }
.shell-page.dark { --shell-surface: #1d3944; --shell-surface-muted: #17313c; --shell-text: #e8f2f5; --shell-blue-pale: #244c59; --shell-blue-dark: #bde3f2; color: #e8f2f5; background: #122a33; }
.shell-page.dark .topbar,
.shell-page.dark .btn,
.shell-page.dark .shell-footer { color: #e8f2f5; background: #1d3944; border-color: #3f606b; }
.shell-page.dark .shell-footer .footer-meta a { color: #d6edf4; }
.shell-page.dark .product-name { color: #f4f8fa; }
.shell-page.dark .product-subtitle { color: #8bd1c3; }
.shell-page.dark .product:hover .product-name { color: #fff; }
.shell-page.dark .product:hover .product-subtitle { color: #b7e3da; }
.shell-page.dark .page-actionbar { color: #e8f2f5; background: #17313b; border-color: #3f606b; }
.shell-page.dark .btn:hover { color: #fff; background: #244c59; border-color: #5b7d88; }
.shell-page.dark .user-menu { color: #e8f2f5; }
.shell-page.dark .user-menu > summary:hover,
.shell-page.dark .user-menu[open] > summary { background: #244c59; box-shadow: 0 0 0 1px #3f606b; }
.shell-page.dark .user-popover { color: #d6edf4; background: #1d3944; border-color: #3f606b; box-shadow: 0 14px 34px #00151d80; }
.shell-page.dark .user-account,
.shell-page.dark .user-setting,
.shell-page.dark .avatar-controls { border-color: #3f606b; }
.shell-page.dark .user-account strong,
.shell-page.dark .user-menu-nav a,
.shell-page.dark .user-menu-nav button { color: #e8f2f5; }
.shell-page.dark .user-account span { color: #a9c4cd; }
.shell-page.dark .user-memberships li.empty { color: #a9c4cd; }
.shell-page.dark .avatar-upload,
.shell-page.dark .avatar-controls button { color: #e8f2f5; background: #1d3944; border-color: #3f606b; }
.shell-page.dark .avatar-upload:hover,
.shell-page.dark .avatar-controls button:hover { background: #244c59; }
.shell-page.dark .user-menu-nav a:hover,
.shell-page.dark .user-menu-nav button:hover { background: #244c59; }

.rail {
  width: var(--shell-rail-collapsed);
  overflow: hidden;
  background: var(--shell-blue);
  transition: width 180ms ease;
}

.rail.expanded { width: var(--shell-rail-expanded); }

.rail a,
.rail button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: var(--shell-rail-expanded);
  padding-inline: 20px;
  white-space: nowrap;
  transition: background-color 150ms ease;
}

.rail a:hover,
.rail button:hover { background: var(--shell-blue-hover); }
.rail a:active,
.rail button:active { background: #004a66; }

.rail .nav-icon {
  display: grid;
  width: 24px;
  flex: 0 0 24px;
  place-items: center;
  text-align: center;
}

.rail .nav-icon svg { width: 20px; height: 20px; }

.rail .nav-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  transform: translateX(-6px);
  transition: opacity 120ms ease, transform 180ms ease, max-width 180ms ease;
}

.rail.expanded .nav-label {
  max-width: 154px;
  opacity: 1;
  visibility: visible;
  transform: none;
}

.logo-dark { display: none; }
body.dark .logo-light { display: none; }
body.dark .logo-dark { display: block; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  margin: 0;
  padding: 3px;
  border: 1px solid #7b9ca8;
  border-radius: 999px;
  background: #e8eef0;
  box-shadow: inset 0 1px 2px #00384a22;
}

.theme-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.theme-switch label {
  display: grid;
  min-width: 32px;
  min-height: 32px;
  padding: 6px;
  place-items: center;
  border-radius: 999px;
  color: #315563;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.theme-switch .theme-icon { width: 16px; height: 16px; }

.theme-switch input:checked + label {
  color: #fff;
  background: var(--shell-green);
  box-shadow: 0 2px 6px #00384a3d;
}

.theme-switch label:hover { color: var(--shell-blue-hover); background: #fff; }
.theme-switch input:checked + label:hover { color: #fff; background: #287b62; }
.dark .theme-switch { border-color: #5b7d88; background: #102a33; }
.dark .theme-switch label { color: #d6edf4; }
.dark .theme-switch label:hover { color: #fff; background: #244c59; }
.dark .theme-switch input:checked + label { color: #fff; background: var(--shell-green); }

.theme-switch input:focus-visible + label,
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--shell-focus);
  outline-offset: 2px;
}

.toolkit-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 240px;
  padding: 6px 9px;
  border: 1px solid #315563;
  border-radius: 6px;
  color: #fff;
  background: #17313b;
  box-shadow: 0 7px 18px #001e292e;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.toolkit-tooltip.visible { opacity: 1; transform: none; }

@keyframes shell-popover-in {
  from { opacity: 0; transform: translateY(-4px) scale(.985); }
}
@keyframes shell-status-pulse {
  50% { box-shadow: 0 0 0 7px #00afdc0d; }
}
@keyframes shell-save-pulse {
  50% { opacity: .55; transform: scale(.92); }
}

@media (max-width: 900px) {
  :root { --shell-rail-collapsed: 52px; }
  .rail .nav-label { display: none; }
  .shell-page .rail.expanded + .shell-content { margin-left: var(--shell-rail-collapsed); }
  .shell-page .rail.expanded + .shell-content .shell-footer { left: var(--shell-rail-collapsed); }
  .shell-page .topbar { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
  .shell-page .brand-path { gap: 7px; }
  .shell-page .brand-divider { display: none; }
  .shell-page .product-logo { width: 44px; height: 44px; flex-basis: 44px; }
  .shell-page h1 { font-size: 1em; }
  .shell-page .topbar-end { min-width: 0; justify-content: space-between; }
  .shell-page .menu { min-width: 0; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding-block: 2px; }
  .shell-page .user-name { display: none; }
  .shell-page .page-actionbar { gap: 10px; padding-inline: 12px; }
  .shell-page .page-actionbar .menu { flex-wrap: nowrap; overflow-x: auto; }
  .shell-page .shell-footer { padding-inline: 12px; }
  .shell-page .shell-footer .logo { width: 116px; }
  .standalone-footer { padding-inline: 12px; }
  .standalone-footer .logo { width: 116px; }
  .theme-switch label { min-width: 32px; padding-inline: 6px; }
}

@media (max-width: 600px) {
  .shell-page:not(.worksheet-page) .brand h1 { display: none; }
  .worksheet-page .product { display: none; }
  .worksheet-page .heading-edit-input { width: min(72vw, 420px); min-width: 150px; }
  .shell-footer .footer-meta { font-size: .69rem; }
}

@media (prefers-reduced-motion: reduce) {
  .rail,
  .rail .nav-label,
  .theme-switch label,
  .shell-page .user-menu > summary { transition: none !important; }
  .shell-page .user-popover,
  .shell-page .page-actionbar .status[data-state="progress"]::before,
  .shell-page .page-actionbar .action-icon[data-feedback="saving"] svg,
  .toolkit-tooltip { animation: none !important; transition: none !important; }
}
