/* ── Fonts ─────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&display=swap');

@font-face { font-family: 'Maven Pro'; font-weight: 400; font-display: swap;
  src: url('/public/fonts/MavenPro-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Maven Pro'; font-weight: 500; font-display: swap;
  src: url('/public/fonts/MavenPro-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Maven Pro'; font-weight: 700; font-display: swap;
  src: url('/public/fonts/MavenPro-Bold.ttf') format('truetype'); }
@font-face { font-family: 'Maven Pro'; font-weight: 900; font-display: swap;
  src: url('/public/fonts/MavenPro-Black.ttf') format('truetype'); }
@font-face { font-family: 'Lato'; font-weight: 300; font-display: swap;
  src: url('/public/fonts/Lato-Light.ttf') format('truetype'); }
@font-face { font-family: 'Lato'; font-weight: 400; font-display: swap;
  src: url('/public/fonts/Lato-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Lato'; font-weight: 700; font-display: swap;
  src: url('/public/fonts/Lato-Bold.ttf') format('truetype'); }
@font-face { font-family: 'Lato'; font-weight: 900; font-display: swap;
  src: url('/public/fonts/Lato-Black.ttf') format('truetype'); }

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --wd-orange:   #F9981C;
  --wd-blue:     #283583;
  --wd-link:     #009FE3;
  --wd-sportief: #00A2BF;
  --wd-warmte:   #DB6245;
  --wd-natuur:   #4FAF68;
  --wd-terra:    #9F9985;
  --wd-zand:     #D0C8AC;
  --wd-sand-20:  #F7F5EF;
  --wd-sand-40:  #EDE9DD;
  --wd-blue-20:  #D3D6E6;
  --wd-blue-40:  #A8ADCA;
  --wd-blue-60:  #7E85B5;
  --wd-blue-100: #283583;

  --fg-1:   #283583;
  --fg-2:   #1E1E28;
  --fg-3:   #5A5F7A;
  --surface: #FFFFFF;
  --bg-soft: #F7F5EF;
  --border:  #E5E2D6;
  --border-strong: #C9C4B1;

  /* legacy compat for admin pages */
  --bg: var(--bg-soft);
  --text: var(--fg-2);
  --text-muted: var(--fg-3);
  --accent: var(--wd-blue);
  --accent-hover: #1d276e;
  --danger:  #C53030;
  --success: #4FAF68;
  --radius:  8px;

  --shadow-card: 0 1px 2px rgba(40,53,131,.06), 0 8px 24px rgba(40,53,131,.08);
  --shadow-lift: 0 2px 4px rgba(40,53,131,.08), 0 20px 40px rgba(40,53,131,.14);

  --font-display: 'Maven Pro', 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'Lato', 'Helvetica Neue', Arial, sans-serif;
  --font-hand:    'Caveat', cursive;

  /* Type scale (lifted from the design system's colors_and_type.css) */
  --fs-display:   56px;
  --fs-h1:        40px;
  --fs-h2:        30px;
  --fs-h3:        22px;
  --fs-intro:     20px;
  --fs-body:      17px;
  --fs-small:     14px;
  --fs-micro:     12px;

  --lh-tight:     1.1;
  --lh-snug:      1.25;
  --lh-body:      1.55;
  --lh-loose:     1.7;

  --radius-sm:    4px;
  --radius-md:    10px;
  --radius-lg:    18px;
  --radius-pill:  999px;

  /* 8pt spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* Optional warm paper background for form-heavy modules */
  --bg-paper: #EDE7D6;

  --sidebar-w: 264px;
  --topbar-h:  56px;
}

html.sidebar-collapsed { --sidebar-w: 72px; }

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; }

body {
  font-family: var(--font-body);
  background: var(--bg-soft);
  color: var(--fg-2);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--fg-1);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.005em;
}

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

/* Visible keyboard focus; mouse/touch focus stays quiet via :focus-visible. */
:focus-visible { outline: 2px solid var(--wd-link); outline-offset: 2px; }
#mwd-sidebar :focus-visible { outline-color: #fff; outline-offset: -2px; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#mwd-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--wd-blue);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 280ms cubic-bezier(.22,1,.36,1);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  min-height: 60px; flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--wd-orange); border-radius: 8px;
  display: grid; place-items: center; color: #fff;
}
.sidebar-brand-icon svg { width: 22px; height: 22px; }
.sidebar-logo-mark { width: 26px; height: 26px; object-fit: contain; filter: brightness(0) invert(1); display: block; }
.sidebar-brand-text { min-width: 0; overflow: hidden; }
.sidebar-brand-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: 17px; line-height: 1.05; color: #fff;
  letter-spacing: -.01em; white-space: nowrap;
}
.sidebar-brand-org {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(255,255,255,.45); font-weight: 700; margin-top: 3px;
  white-space: nowrap;
}

.sidebar-section-label {
  flex-shrink: 0;
  margin: 14px 24px 1px;
  font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; font-weight: 700;
  color: rgba(255,255,255,.42);
  font-family: var(--font-display);
  white-space: nowrap; line-height: 1.4;
}
.sidebar-divider + .sidebar-section-label      { margin-top: 4px; }
.sidebar-nav-section + .sidebar-section-label  { margin-top: 14px; }

.sidebar-nav-section {
  padding: 0 10px;
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;
}

.sidebar-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  font-family: var(--font-body);
  white-space: nowrap;
  min-height: 32px;
  transition: background 160ms, color 160ms, box-shadow 160ms;
  box-shadow: inset 3px 0 0 transparent;
}
.sidebar-item:hover                     { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-item.active                    { background: linear-gradient(90deg, rgba(249,152,28,.18), rgba(255,255,255,.08) 65%);
                                          color: #fff; font-weight: 600;
                                          box-shadow: inset 3px 0 0 var(--wd-orange); }
.sidebar-item.active .sidebar-item-icon { color: var(--wd-orange); }
.sidebar-item--muted                    { opacity: .55; pointer-events: none; }

.sidebar-item-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 15px; line-height: 1;
}
.sidebar-item-icon svg, .sidebar-mod-icon { width: 20px; height: 20px; }
.sidebar-item-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }

.sidebar-divider { height: 1px; margin: 6px 18px; background: rgba(255,255,255,.10); flex-shrink: 0; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }

.sidebar-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  display: flex; justify-content: flex-end;
}
.sidebar-collapse-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  background: transparent; border: none;
  color: rgba(255,255,255,.5); cursor: pointer;
  border-radius: 6px; display: grid; place-items: center;
  transition: background 160ms, color 160ms;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }
.sidebar-collapse-btn svg { width: 18px; height: 18px; }

/* Collapsed overrides */
html.sidebar-collapsed .sidebar-brand      { padding: 18px; justify-content: center; }
html.sidebar-collapsed .sidebar-brand-text,
html.sidebar-collapsed .sidebar-section-label,
html.sidebar-collapsed .sidebar-item-label { display: none; }
html.sidebar-collapsed .sidebar-item        { justify-content: center; padding: 10px;
                                              box-shadow: inset 0 4px 0 transparent; }
html.sidebar-collapsed .sidebar-item.active { box-shadow: inset 0 4px 0 var(--wd-orange); }
html.sidebar-collapsed .sidebar-footer     { justify-content: center; }

/* Mobile overlay */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 199; }

/* ── Top bar ───────────────────────────────────────────────────────────────── */
#mwd-topbar {
  position: fixed; top: 0;
  left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: #ffffff;
  z-index: 100;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px 0 20px;
  border-bottom: 1px solid var(--border);
  transition: left 280ms cubic-bezier(.22,1,.36,1);
}

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
  flex: 1; max-width: 480px;
}
.topbar-search-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--fg-3); }
.topbar-search-icon svg { width: 16px; height: 16px; }
.topbar-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--font-body); font-size: 13px; color: var(--fg-2);
}
.topbar-search input::placeholder { color: var(--fg-3); }
.topbar-search-kbd {
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  color: var(--fg-3); background: var(--wd-sand-20);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
button.topbar-search { cursor: pointer; font: inherit; text-align: left; }
button.topbar-search:hover { border-color: var(--border-strong); }
.topbar-search-text { flex: 1; color: var(--fg-3); font-size: 13px; white-space: nowrap; }

.topbar-spacer { flex: 1; }

.topbar-lang {
  display: flex; background: #fff;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px; font-size: 12px;
  font-family: var(--font-display); font-weight: 700;
}
.topbar-lang-btn {
  border: none; padding: 4px 12px; border-radius: 999px;
  background: transparent; color: var(--fg-3);
  cursor: pointer; font: inherit; letter-spacing: .04em;
  transition: background 150ms, color 150ms;
}
.topbar-lang-btn.active { background: var(--wd-blue); color: #fff; }

.topbar-icon-btn {
  position: relative; width: 34px; height: 34px;
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; color: var(--fg-2);
}
.topbar-icon-btn svg { width: 18px; height: 18px; }

.topbar-user { position: relative; }
.topbar-user-btn {
  display: flex; align-items: center; gap: 4px;
  background: transparent; border: none; padding: 0;
  cursor: pointer;
}
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg,#DB6245 0%,#F9981C 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 12px;
  font-family: var(--font-display);
  transition: transform 120ms ease;
}
.topbar-user-btn:hover .topbar-avatar { transform: translateY(-1px); }
.topbar-user-caret { width: 14px; height: 14px; color: var(--fg-3); transition: transform 160ms; }
.topbar-user-btn[aria-expanded="true"] .topbar-user-caret { transform: rotate(180deg); }

.topbar-user-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 248px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 6px;
  box-shadow: var(--shadow-lift);
  z-index: 300;
}
.topbar-user-menu-header { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.topbar-user-menu-name {
  font-size: 13px; font-weight: 700; color: var(--fg-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user-menu-email {
  font-size: 12px; color: var(--fg-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user-menu-role { font-size: 11px; color: var(--fg-3); margin-top: 3px; }
.topbar-user-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  background: transparent; border: none; border-radius: 8px;
  font-family: var(--font-body); font-size: 13px; color: var(--fg-2);
  text-decoration: none; text-align: left; cursor: pointer;
}
.topbar-user-menu-item:hover { background: var(--wd-sand-20); text-decoration: none; }
.topbar-user-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--fg-3); }
.topbar-user-menu-lang {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; font-size: 13px; color: var(--fg-2);
}
.topbar-user-menu-divider { height: 1px; background: var(--border); margin: 6px 4px; }

.sidebar-toggle {
  display: none; width: 34px; height: 34px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  flex-direction: column; gap: 4px; align-items: center; justify-content: center;
}
.sidebar-toggle span { display: block; width: 16px; height: 2px; background: var(--fg-2); border-radius: 2px; }

/* ── Main / iframe ─────────────────────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left 280ms cubic-bezier(.22,1,.36,1);
}

/* Iframe-hosting page — pin shell to exactly 100vh, iframe owns scrolling. */
body.iframe-shell { height: 100vh; overflow: hidden; }
body.iframe-shell #main-content {
  height: calc(100vh - var(--topbar-h));
  min-height: 0;
  position: relative;
}

#module-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Overview / dashboard ──────────────────────────────────────────────────── */
.overview { padding: 32px 32px 64px; max-width: 1400px; margin: 0 auto; }

.overview-announcements { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.announce { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: 12px; font-size: 14.5px; line-height: 1.5; border: 1px solid; }
.announce-info { background: #eef0f8; border-color: #cfd5ee; color: var(--fg-1); }
.announce-warning { background: #fcefe9; border-color: #f3c9bb; color: #8a3b22; }
.announce-body { flex: 1; }
.announce-x { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; opacity: .5; padding: 0 2px; }
.announce-x:hover { opacity: 1; }

.overview-kicker { font-size: 13px; color: var(--fg-3); font-weight: 500; margin-bottom: 6px; }
.overview-kicker strong { color: var(--fg-1); font-weight: 700; }
.overview-title { font-size: 40px; margin: 0 0 16px; }
.overview-lead { font-size: 16px; line-height: 1.55; color: var(--fg-3); max-width: 600px; }
.overview-hand {
  font-family: var(--font-hand);
  font-weight: 700; font-size: 32px;
  color: var(--wd-orange); line-height: 1;
  display: inline-block;
  transform: rotate(-3deg); transform-origin: left center;
}

.modules-section { margin-bottom: 40px; }
.modules-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.modules-section-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--fg-1); letter-spacing: -.005em; }
.modules-section-count { font-size: 13px; color: var(--fg-3); }

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Category-pill tabs above the overview grid */
.overview-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 6px 0 22px;
}
.overview-tab {
  padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff; color: var(--fg-2);
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  letter-spacing: -.005em; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.overview-tab:hover { background: var(--bg-soft); }
.overview-tab.active {
  background: var(--wd-blue); color: #fff;
  border-color: var(--wd-blue);
}

/* Subtitle line inside module tile (small category name under tile name) */
.module-tile-cat {
  font-size: 11px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: .08em;
  font-family: var(--font-display); font-weight: 700;
  margin-top: 2px;
}

/* List-row variant used on /modules and /recently-used */
.modules-listrows { list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px; }
.modules-listrow {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: 12px;
  background: #fff; border: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.modules-listrow:hover {
  border-color: var(--tile-color, var(--wd-blue));
  box-shadow: 0 4px 14px -10px rgba(40,53,131,.30);
  transform: translateY(-1px);
  text-decoration: none;
}
.modules-listrow-icon {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--tile-tint, rgba(40,53,131,.08));
  color: var(--tile-color, var(--wd-blue));
}
.modules-listrow-icon svg { width: 22px; height: 22px; }
.modules-listrow-body { flex: 1; min-width: 0; }
.modules-listrow-name {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: 15px; color: var(--fg-1); letter-spacing: -.005em;
}
.modules-listrow-desc {
  display: block; font-size: 12.5px; color: var(--fg-3); margin-top: 2px;
}
.modules-listrow-cta {
  flex-shrink: 0; font-family: var(--font-display); font-weight: 700;
  font-size: 12.5px; color: var(--tile-color, var(--wd-blue));
}

/* Module tile */
.module-tile {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  text-decoration: none; color: inherit;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(40,53,131,.04);
  transition: transform 240ms cubic-bezier(.22,1,.36,1), box-shadow 240ms;
}
.module-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); text-decoration: none; color: inherit; }

/* Theme colour tokens — set on .module-tile */
.module-tile.theme-orange  { --tile-color: var(--wd-orange);   --tile-tint: rgba(249,152,28,.10); }
.module-tile.theme-blue    { --tile-color: var(--wd-blue);     --tile-tint: rgba(40,53,131,.08);  }
.module-tile.theme-sportief{ --tile-color: var(--wd-sportief); --tile-tint: rgba(0,162,191,.10);  }
.module-tile.theme-warmte  { --tile-color: var(--wd-warmte);   --tile-tint: rgba(219,98,69,.10);  }
.module-tile.theme-natuur  { --tile-color: var(--wd-natuur);   --tile-tint: rgba(79,175,104,.10); }
.module-tile.theme-terra   { --tile-color: var(--wd-terra);    --tile-tint: rgba(159,153,133,.16);}
.module-tile.theme-zand    { --tile-color: var(--wd-zand);     --tile-tint: rgba(208,200,172,.30);}

.module-tile-stripe { height: 4px; background: var(--tile-color, var(--wd-blue)); }

.module-tile-body { padding: 20px 22px 18px; flex: 1; display: flex; flex-direction: column; }

.module-tile-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 10px; }

.module-tile-icon-wrap {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: var(--tile-tint, rgba(40,53,131,.08));
  display: grid; place-items: center; font-size: 22px; line-height: 1;
}
.module-tile-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: 17px; color: var(--fg-1); line-height: 1.2;
  letter-spacing: -.005em; margin: 6px 0 0;
}
.module-tile-desc { font-size: 13px; line-height: 1.5; color: var(--fg-3); flex: 1; margin-top: 4px; }

.module-tile-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.module-tile-open  { font-size: 12px; font-weight: 700; color: var(--tile-color, var(--wd-blue));
                     font-family: var(--font-display); letter-spacing: .02em;
                     display: inline-flex; align-items: center; gap: 4px; }
.tile-arrow { display: inline-block; transition: transform 200ms; }
.module-tile:hover .tile-arrow { transform: translateX(3px); }

.empty-state { padding: 64px 32px; text-align: center; color: var(--fg-3); }

/* ── Login ─────────────────────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--wd-blue);
  background-image: radial-gradient(circle at 30% 40%, rgba(249,152,28,.12) 0%, transparent 60%),
                    radial-gradient(circle at 70% 60%, rgba(255,255,255,.05) 0%, transparent 60%);
}
.login-card {
  background: var(--surface); border-radius: 16px;
  padding: 2.5rem 2.75rem; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-mark {
  display: flex; justify-content: center; margin: 0 auto 20px;
}
.login-mark img { max-width: 220px; height: auto; }
.login-title { text-align: center; font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--fg-1); margin-bottom: 4px; }
.login-sub   { text-align: center; font-size: 11px; color: var(--fg-3); margin-bottom: 28px;
               letter-spacing: .12em; text-transform: uppercase; font-family: var(--font-display); font-weight: 700; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; color: var(--fg-2); }
.req { color: var(--danger); }
.form-hint  { font-size: .75rem; color: var(--fg-3); margin-top: .3rem; }

.form-control {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: .875rem; font-family: var(--font-body);
  color: var(--fg-2); background: var(--surface);
  transition: border-color .12s, box-shadow .12s; appearance: auto;
}
.form-control:focus { outline: none; border-color: var(--wd-blue); box-shadow: 0 0 0 3px rgba(40,53,131,.12); }
.form-control[type="file"] { padding: .45rem .6rem; }
.radio-group  { display: flex; gap: 1.5rem; flex-wrap: wrap; padding: .4rem 0; }
.radio-label  { display: flex; align-items: center; gap: .4rem; font-size: .875rem; cursor: pointer; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; align-items: center; }
.form-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .9rem 1rem 1rem; margin: 1.4rem 0; }
.form-fieldset legend { padding: 0 .4rem; font-size: .82rem; font-weight: 600; color: var(--fg-2); }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem .8rem; }
.permission-row { display: flex; align-items: flex-start; gap: .55rem; padding: .35rem .4rem; border-radius: 6px; cursor: pointer; }
.permission-row:hover { background: var(--bg-soft); }
.permission-mod { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.permission-meta { font-size: .72rem; color: var(--fg-3); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 8px;
  font-size: .875rem; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none; transition: all 160ms; line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--wd-blue);   color: #fff; border-color: var(--wd-blue); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface);   color: var(--fg-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--wd-sand-20); }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-warning   { background: var(--wd-orange); color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: 10px; padding: 1.5rem; box-shadow: var(--shadow-card); border: 1px solid var(--border); }

/* ── Page layout ───────────────────────────────────────────────────────────── */
.page-content { padding: 1.75rem 2rem; }

/* ── Admin settings shell ───────────────────────────────────────────────────── */
.settings-shell { display: flex; gap: 28px; align-items: flex-start; padding: 28px 32px 64px; max-width: 1280px; margin: 0 auto; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); flex: 0 0 196px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item { padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--fg-3); text-decoration: none; font-family: var(--font-body); white-space: nowrap; }
.settings-nav-item:hover { background: var(--bg-soft); color: var(--fg-2); text-decoration: none; }
.settings-nav-item.active { background: var(--wd-blue-20); color: var(--wd-blue); font-weight: 700; }
.settings-content { flex: 1; min-width: 0; }
.settings-shell .page-content { padding: 0; }
@media (max-width: 860px) {
  .settings-shell { flex-direction: column; gap: 12px; padding: 16px; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; flex: 0 0 auto; width: 100%; }
}

/* Access matrix (members × modules) */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
table.matrix { border-collapse: collapse; font-size: 13px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 8px 10px; }
table.matrix tr:last-child th, table.matrix tr:last-child td { border-bottom: none; }
table.matrix thead th { background: var(--wd-sand-20); vertical-align: bottom; }
.matrix-col { height: 132px; padding: 8px 6px; }
.matrix-col span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 700; color: var(--fg-2); }
.matrix-corner { text-align: left; position: sticky; left: 0; background: var(--wd-sand-20); }
.matrix-rowhead { text-align: left; position: sticky; left: 0; background: #fff; min-width: 160px; }
.matrix-user { display: block; font-weight: 700; color: var(--fg-1); }
.matrix-tier { display: block; font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; }
.matrix-cell { text-align: center; }
.matrix-toggle { width: 16px; height: 16px; cursor: pointer; accent-color: var(--wd-blue); }
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title   { font-size: 1.35rem; font-weight: 700; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.section-title  { font-size: 1rem; font-weight: 600; }

/* ── Stats (admin dashboard) ───────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card  { background: var(--surface); border-radius: 10px; padding: 1.25rem 1.5rem;
              box-shadow: var(--shadow-card); border: 1px solid var(--border); text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--wd-blue); font-family: var(--font-display); line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--fg-3); margin-top: .25rem; text-transform: uppercase; letter-spacing: .04em; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-card); border: 1px solid var(--border); }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--wd-sand-20); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-3); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9fbfd; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .875rem; }
.alert-error   { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }
.alert-success { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-admin    { background: var(--wd-blue-20); color: var(--wd-blue); }
.badge-user     { background: #e9d8fd; color: #553c9a; }
.badge-static   { background: #c6f6d5; color: #276749; }
.badge-proxy    { background: #fefcbf; color: #744210; }
.badge-active   { background: #c6f6d5; color: #276749; }
.badge-inactive { background: #fed7d7; color: #9b2c2c; }

/* ── Permissions ───────────────────────────────────────────────────────────── */
.module-selector { display: flex; flex-wrap: wrap; gap: .5rem; }
.module-selector-item {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .45rem .85rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft); color: var(--fg-2); text-decoration: none;
  font-size: .84rem; transition: background .12s, border-color .12s;
}
.module-selector-item:hover { background: var(--wd-blue-20); border-color: var(--wd-blue); text-decoration: none; }
.module-selector-item.active { background: var(--wd-blue); color: #fff; border-color: var(--wd-blue); }
.module-selector-item.active span { color: #fff !important; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  html.sidebar-collapsed { --sidebar-w: 0px; }

  #mwd-sidebar {
    width: 264px !important;
    transform: translateX(-100%);
    transition: transform 280ms cubic-bezier(.22,1,.36,1);
  }
  #mwd-sidebar.is-open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }

  #mwd-topbar    { transition: none; }
  #main-content  { transition: none; }

  .sidebar-close  { display: block; }
  .sidebar-overlay.is-open { display: block; }
  .sidebar-toggle { display: flex !important; }
  .sidebar-collapse-btn { display: none !important; }

  .stats-grid    { grid-template-columns: 1fr 1fr; }
  .dashboard-grid{ grid-template-columns: 1fr; }
  .form-row      { grid-template-columns: 1fr; }
  .page-content  { padding: 1rem; }
  .overview      { padding: 20px 16px 48px; }
  .topbar-search { flex: 0 0 auto; max-width: none; padding: 8px; }
  .topbar-search-text, .topbar-search-kbd { display: none; }
}

@media (max-width: 480px) {
  .login-card { margin: 1rem; padding: 1.5rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── SVG tile icon ──────────────────────────────────────────────────────────── */
.module-tile-icon-wrap { font-size: 0; } /* suppress emoji baseline gap */
.tile-icon { width: 24px; height: 24px; color: var(--tile-color, var(--wd-blue)); }

/* ── List-row mobile tightening ─────────────────────────────────────────────── */
@media (max-width: 560px) {
  .modules-listrow { padding: 10px 12px; gap: 10px; }
  .modules-listrow-icon { width: 32px; height: 32px; }
  .modules-listrow-icon svg { width: 18px; height: 18px; }
  .modules-listrow-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .modules-listrow-cta { display: none; }
  .overview-title { font-size: 28px; }
}

/* ── Quick-switcher modal (Cmd-K / Ctrl-K) ──────────────────────────────────── */
.qs-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 22, 40, .35);
  display: grid; place-items: start center;
  padding-top: 10vh;
}
.qs-backdrop[hidden] { display: none; }
.qs-panel {
  width: min(560px, 92vw);
  background: #fff; border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(20,22,40,.40);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.qs-input {
  width: 100%; padding: 14px 18px;
  border: none; outline: none;
  font-family: var(--font-display); font-size: 15px;
  border-bottom: 1px solid var(--border);
  background: #fff; color: var(--fg-1);
}
.qs-input::placeholder { color: var(--fg-3); }
.qs-results {
  list-style: none; margin: 0; padding: 6px;
  max-height: min(420px, 50vh); overflow-y: auto;
}
.qs-result {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 12px; border-radius: 8px;
  cursor: pointer; color: var(--fg-1);
}
.qs-result.active { background: var(--bg-soft); }
.qs-result-name { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.qs-result-cat {
  font-size: 11px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}
.qs-empty { padding: 14px; text-align: center; color: var(--fg-3); font-size: 13px; }
.qs-hint {
  padding: 8px 14px; border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 11px; color: var(--fg-3);
  display: flex; gap: 6px; align-items: center;
}
.qs-hint kbd {
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-size: 10px; font-family: inherit;
}

/* ── Print ──────────────────────────────────────────────────────────────────── */
@media print {
  #mwd-sidebar, #sidebar-overlay, #mwd-topbar { display: none !important; }
  #main-content { margin-left: 0 !important; margin-top: 0 !important; }
  #module-iframe { position: static !important; width: 100% !important; height: auto !important; min-height: 100vh; border: none !important; }
  body { overflow: visible !important; }
}
