/* Design system for the redesigned pages (see DESIGN_PATTERNS.md).
   Namespaced with "nd-" (new design) so it never collides with style.css. */

:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --text: #0e121a;
  --muted: #4a5263;
  --border: #e3e6eb;
  --accent: #2f6fde;
  --accent-text: #fff;
  --chat-user-bg: #d4e3fb;
  --chat-bot-bg: #eceef2;
  --chat-user-text: #10213d;
  --danger: #c4372b;
  --err-bg: #fdecea;
  --ok: #18794e;
  --ok-bg: #e7f6ec;
  --warn: #a14f00;
  --warn-bg: #fdebd3;
  --info: #1e4fa8;
  --info-bg: #dbeafe;
  --raised: #fff;
  --sunken: #f6f7f9;

  --section-dashboards: #2f6fde;
  --section-documentation: #0e8a7e;
  --section-planning: #7b4fd6;
  --section-improvements: #d08a00;
  --section-business: #1d7f3f;
  --section-master-data: #5b6b82;
  --section-data: #2a7fa8;
  --section-configuration: #6b6f78;
  --section-tasks: #c4572b;
  --section-mail: #3a5bd1;
  --section-help: #8a6b3a;

  --header-h: 56px;
  --header-space: calc(var(--header-h) + 24px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1d2129;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --border: #2e3440;
    --accent: #6b9cf0;
    --accent-text: #0f1218;
    --chat-user-bg: #b9d1fa;
    --chat-bot-bg: #1d2129;
    --chat-user-text: #0f1218;
    --danger: #f07167;
    --err-bg: #3a1d1b;
    --ok: #6fd3a0;
    --ok-bg: #173325;
    --warn: #f5a95b;
    --warn-bg: #3d2a12;
    --info: #8cb4f5;
    --info-bg: #1b2a44;
    --raised: #1d2129;
    --sunken: #14171c;
  }
}

:root[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1d2129;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --border: #2e3440;
  --accent: #6b9cf0;
  --accent-text: #0f1218;
  --chat-user-bg: #b9d1fa;
  --chat-bot-bg: #1d2129;
  --chat-user-text: #0f1218;
  --danger: #f07167;
  --err-bg: #3a1d1b;
  --ok: #6fd3a0;
  --ok-bg: #173325;
  --warn: #f5a95b;
  --warn-bg: #3d2a12;
  --info: #8cb4f5;
  --info-bg: #1b2a44;
  --raised: #1d2129;
  --sunken: #14171c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

a { color: var(--accent); }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- panel look, shared by header / nav / frame ---------- */
.nd-panel {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}

/* ---------- header ---------- */
.nd-header {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  height: var(--header-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  flex-wrap: wrap;
}

.nd-header-left,
.nd-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nd-tile {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 16px;
  transition: transform .15s ease;
}
.nd-tile:hover { transform: scale(1.06); }

.nd-tenant { position: relative; min-width: 0; }

/* template mode (new/base.html, nd_template_mode): header button to start it, and the
   header itself while it is on — blue frame (glowing in dark mode), "TEMPLATE MODE" with
   Versionen / beenden in the middle, the template name in place of the tenant */
.nd-tpl-tile { cursor: pointer; }
.nd-header.is-tpl-mode { border: 2px solid var(--tpl-frame); box-shadow: 0 0 0 1px color-mix(in srgb, var(--tpl-frame) 30%, transparent), 0 8px 28px rgba(0, 0, 0, .25); }
.nd-header.is-tpl-mode .nd-header-search { display: none !important; }
.nd-header.is-tpl-mode .nd-tenant-name { color: var(--tpl-frame); font-weight: 700; }
.nd-tpl-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.nd-tpl-bar form { margin: 0; }
.nd-tpl-label { font-weight: 800; letter-spacing: .14em; font-size: 14px; color: var(--tpl-frame); white-space: nowrap; margin-left: 4px; }
.nd-tpl-dialog tbody tr.is-current { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
:root { --tpl-frame: #2f6fde; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --tpl-frame: #3ea2ff; }
  :root:not([data-theme="light"]) .nd-header.is-tpl-mode { box-shadow: 0 0 6px 1px rgba(62, 162, 255, .85), 0 0 22px 4px rgba(62, 162, 255, .45), 0 8px 28px rgba(0, 0, 0, .25); }
  :root:not([data-theme="light"]) .nd-tpl-label { text-shadow: 0 0 10px rgba(62, 162, 255, .7); }
}
:root[data-theme="dark"] { --tpl-frame: #3ea2ff; }
:root[data-theme="dark"] .nd-header.is-tpl-mode { box-shadow: 0 0 6px 1px rgba(62, 162, 255, .85), 0 0 22px 4px rgba(62, 162, 255, .45), 0 8px 28px rgba(0, 0, 0, .25); }
:root[data-theme="dark"] .nd-tpl-label { text-shadow: 0 0 10px rgba(62, 162, 255, .7); }
@media (max-width: 1100px) {
  .nd-tpl-bar { position: static; transform: none; margin: 0 auto; min-width: 0; }
  .nd-tpl-bar .nd-tenant-btn { max-width: 220px; }
}
.nd-tenant-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  cursor: pointer;
}
.nd-tenant-btn:hover { background: var(--sunken); }
.nd-tenant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-tenant-switch { color: var(--accent); font-size: 15px; flex: none; }
.nd-dialog.nd-tenant-dialog { width: min(1100px, calc(100vw - 32px)); }
.nd-tenant-search { width: 100%; margin-bottom: 10px; }
.nd-tenant-dialog .nd-table-wrap { overflow: hidden; }
.nd-tenant-table { table-layout: fixed; }
.nd-tenant-table th, .nd-tenant-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 22px; }
.nd-tenant-table th:first-child { width: 24%; }
.nd-tenant-table tbody tr.nd-tenant-filler { cursor: default; }
.nd-tenant-table tbody tr.nd-tenant-filler:hover { background: none; }
.nd-tenant-table .nd-tenant-empty-cell { color: var(--muted); text-align: center; }
.nd-tenant-dialog .nd-pagination { margin-top: 12px; }

.nd-lang { display: flex; gap: 4px; }
.nd-lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.nd-lang-btn.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }

.nd-theme-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  width: 34px;
  height: 34px;
}

.nd-user {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.nd-chat-toggle { cursor: pointer; }
.nd-chat-toggle[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--accent); }

/* ---------- nav + frame share one row so their tops always line up ---------- */
.nd-body {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin: 10px;
  margin-top: var(--header-space);
}

/* ---------- navigation panel ---------- */
.nd-nav {
  position: sticky;
  top: var(--header-space);
  flex: none;
  width: 300px;
  max-height: calc(100vh - var(--header-space) - 10px);
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nd-nav-toggle {
  display: flex;
  position: relative;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  font-size: 13px;
  gap: 2px;
}
.nd-nav-toggle button {
  position: relative;
  z-index: 1;
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 6px 0;
  color: var(--muted);
  font-weight: 600;
  transition: color .2s ease;
}
.nd-nav-toggle button.active { color: var(--accent-text); }
.nd-nav-toggle::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 4px);
  background: var(--accent);
  border-radius: 999px;
  transition: transform .2s ease;
}
.nd-nav-toggle:has(button[data-nd-mode="tree"].active)::before {
  transform: translateX(calc(100% + 2px));
}

.nd-nav-search {
  position: relative;
}
.nd-nav-search input {
  width: 100%;
  padding: 8px 10px 8px 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--sunken);
  color: var(--text);
}
.nd-nav-search .nd-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.nd-search-results { display: none; flex-direction: column; gap: 2px; }
.nd-search-results.open { display: flex; }
.nd-search-results .nd-search-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.nd-search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.nd-search-result:hover, .nd-search-result.focused { background: var(--sunken); }
.nd-search-result .nd-search-path { color: var(--muted); font-size: 12px; display: block; }

/* tree */
.nd-tree { display: none; flex-direction: column; gap: 4px; }
.nd-tree.active { display: flex; }
.nd-tree-section > .nd-tree-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.nd-tree-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.nd-tree-single {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}
.nd-tree-single:hover { background: var(--sunken); }
.nd-tree-single.active { background: var(--accent); color: var(--accent-text); }
.nd-tree-single.active .nd-tree-dot { background: var(--accent-text) !important; }
.nd-tree-pages { display: none; flex-direction: column; gap: 2px; padding-left: 24px; }
.nd-tree-section.open > .nd-tree-pages { display: flex; }
.nd-tree-pages a {
  padding: 7px 8px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}
.nd-tree-pages a:hover { background: var(--sunken); }
.nd-tree-pages a.active { background: var(--accent); color: var(--accent-text); }
.nd-tree-subhead {
  margin-top: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
}
.nd-tree-subpage { padding-left: 20px !important; }

/* tiles (level 1/2/3) */
.nd-tiles { display: none; flex-direction: column; gap: 4px; }
.nd-tiles.active { display: flex; }
.nd-tiles-level { display: none; flex-direction: column; gap: 8px; }
.nd-tiles-level.current { display: flex; }
.nd-tiles-back {
  background: none;
  border: none;
  color: var(--accent);
  text-align: left;
  padding: 4px 2px;
  font-size: 13px;
}
.nd-section-tile,
.nd-page-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  border-radius: 10px;
  padding: 10px 12px;
  border: none;
  border-left: 4px solid var(--tile-color, var(--accent));
  background: linear-gradient(90deg, color-mix(in srgb, var(--tile-color, var(--accent)) 18%, var(--surface)), var(--surface));
  color: var(--text);
  text-align: left;
  text-decoration: none;
  width: 100%;
}
.nd-section-tile .nd-tile-icon,
.nd-page-tile .nd-tile-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--tile-color, var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.nd-section-tile .nd-tile-label,
.nd-page-tile .nd-tile-label { font-weight: 600; }
.nd-page-tile.active {
  border-left-color: var(--accent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface));
}
/* entries listed below a menu page (e.g. the services of Dialog Design):
   no icon — green = active, grey = inactive, blue = the one that is open */
.nd-tile-has-children .nd-tile-count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); }
.nd-child-tile {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border-left: 4px solid var(--tile-color);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tile-color) 18%, var(--surface)), var(--surface));
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: transform .12s ease;
}
.nd-child-tile:hover { transform: translateX(2px); }
.nd-child-tile.is-on { --tile-color: var(--ok); }
.nd-child-tile.is-off { --tile-color: var(--muted); color: var(--muted); font-weight: 500; }
.nd-child-tile.active { --tile-color: var(--accent); color: var(--text); background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 28%, var(--surface)), var(--surface)); }
.nd-child-tile.is-overview { --tile-color: var(--accent); color: var(--accent); min-height: 38px; }
.nd-child-tile.is-overview.active { color: var(--text); }
.nd-child-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-tree-pagerow { display: flex; align-items: center; gap: 2px; }
.nd-tree-pagerow > .nd-tree-pagerow-label { flex: 1; min-width: 0; }
.nd-tree-caret {
  flex: none;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition: transform .15s;
}
.nd-tree-caret:hover { background: var(--sunken); color: var(--text); }
.nd-tree-caret[aria-expanded="true"] { transform: rotate(90deg); }
.nd-menu-problem {
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.nd-child-tile .nd-menu-problem { margin-left: 10px; }
.nd-child-tile .nd-child-label { flex: 1; }
.nd-tile-has-children .nd-menu-problem { margin-left: 8px; }
.nd-tree-children a .nd-child-label { flex: 1; }
.nd-tree-pagerow-link { display: flex; align-items: center; gap: 6px; }
.nd-tree-children-empty { padding: 5px 8px; font-size: 13px; color: var(--muted); }
.nd-tree-children { display: none; flex-direction: column; gap: 1px; margin: 1px 0 4px 18px; padding-left: 8px; border-left: 2px solid color-mix(in srgb, var(--muted) 30%, transparent); }
.nd-tree-children.open { display: flex; }
.nd-tree-pages .nd-tree-children a { display: flex; align-items: center; gap: 8px; padding: 5px 8px; font-size: 13px; }
.nd-tree-child-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.nd-tree-children a.is-off:not(.active) { color: var(--muted); }
.nd-tree-children a.is-off .nd-tree-child-dot { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.nd-tree-children a.active .nd-tree-child-dot { background: var(--accent-text); }

.nd-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 104;
}
.nd-nav-backdrop.open { display: block; }

/* mobile overlay nav */
@media (max-width: 800px) {
  .nd-nav {
    position: fixed;
    top: var(--header-space);
    left: -300px;
    width: 280px;
    max-height: calc(100vh - var(--header-space) - 10px);
    transition: left .25s ease;
    z-index: 105;
  }
  .nd-nav.open { left: 10px; }
  .nd-nav-close { display: inline-flex !important; }
  .nd-tile, .nd-theme-btn, a.nd-user { min-width: 44px; min-height: 44px; }
}
.nd-nav-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
}

/* desktop: nav not pinned → overlay too */
body.nd-nav-unpinned .nd-nav {
  position: fixed;
  left: -320px;
  z-index: 105;
  transition: left .25s ease;
}
body.nd-nav-unpinned .nd-nav.open { left: 10px; }
body.nd-nav-unpinned .nd-nav-backdrop.open { display: block; }
.nd-nav-pin {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--muted);
}
.nd-nav-pin.pinned { color: var(--accent); border-color: var(--accent); }

/* ---------- rail: the folded-in menu (wide screens, menu not pinned) ---------- */
.nd-rail { display: none; }
@media (min-width: 801px) {
  body.nd-nav-unpinned .nd-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: none;
    width: 60px;
    margin-right: -14px;
    padding: 10px 0;
    position: sticky;
    top: var(--header-space);
    max-height: calc(100vh - var(--header-space) - 10px);
    overflow-y: auto;
    scrollbar-width: none;
  }
  body.nd-nav-unpinned #nd-burger { display: none; }
  body.nd-nav-unpinned .nd-rail:has(~ .nd-nav.open) { z-index: 106; }
}
.nd-rail-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  text-decoration: none;
  color: var(--tile-color, var(--muted));
}
.nd-rail-svg { width: 21px; height: 21px; }
.nd-rail-menu { --tile-color: var(--text); margin-bottom: 2px; }
.nd-rail-item:hover, .nd-rail-item:focus-visible,
.nd-rail-item:not(.active)[aria-expanded="true"] { background: color-mix(in srgb, var(--tile-color, var(--muted)) 16%, var(--surface)); outline: none; }
.nd-rail-item.active { background: var(--tile-color); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--tile-color) 35%, transparent); }

/* opened from a section icon of the rail: only that section's tiles, beside the icon */
body .nd-nav.nd-nav-compact { width: 260px; transition: none; }
.nd-nav.nd-nav-compact > :not(.nd-tiles) { display: none !important; }
.nd-nav.nd-nav-compact .nd-tiles { display: flex; }
.nd-nav.nd-nav-compact .nd-tiles-back[data-nd-back-to="root"] { display: none; }
body .nd-nav.nd-nav-railed { transition: none; }

/* ---------- menu search in the middle of the header (rail mode) ---------- */
.nd-header-search[hidden] { display: none; }
.nd-header-search { position: relative; flex: 0 1 440px; min-width: 160px; margin: 0 auto; }
.nd-header-search.centered { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; }
.nd-header-search .nd-nav-search input { padding-top: 7px; padding-bottom: 7px; }
.nd-header-search .nd-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 2;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.nd-header-search .nd-search-results:not(.shown) { display: none; }

/* ---------- page frame ---------- */
.nd-frame {
  flex: 1;
  min-width: 0;
  padding: 20px;
  height: calc(100vh - var(--header-space) - 20px);
  display: flex;
  flex-direction: column;
  position: relative;
}
/* a page with a sticky title+save-bar row needs less top inset: the row
   itself already adds visual breathing room above its text */
.nd-frame:has(.nd-page-head) { padding-top: 4px; }

.nd-frame-content {
  flex: 1;
  overflow: auto;
  min-height: 0;
  scroll-behavior: smooth;
}
.nd-frame-footer {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.nd-frame-footer > span { margin-right: auto; }
.nd-frame-footer a { color: var(--muted); text-decoration: none; }
.nd-frame-footer a:hover { color: var(--text); text-decoration: underline; }

@media (max-width: 900px) {
  .nd-body { flex-direction: column; margin-top: var(--header-space); }
  .nd-frame {
    height: auto;
  }
  .nd-frame-content { overflow: visible; }
  body { overflow-y: auto; }
}

/* ---------- home screen ---------- */
.nd-home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) {
  .nd-home-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .nd-home-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .nd-home-grid { grid-template-columns: 1fr; }
}
.nd-home-tile {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-top: 3px solid var(--tile-color, var(--accent));
  border-radius: 14px;
  min-height: 150px;
  padding: 16px;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  background: var(--sunken);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nd-home-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(140px 140px at 100% 100%,
    color-mix(in srgb, var(--tile-color, var(--accent)) 28%, transparent), transparent 70%);
  pointer-events: none;
}
.nd-home-tile .nd-home-tile-icon {
  position: absolute;
  right: -10px;
  bottom: -18px;
  font-size: 76px;
  line-height: 1;
  opacity: .16;
  color: var(--tile-color, var(--accent));
  filter: saturate(1.6);
}
.nd-home-tile .nd-home-tile-badge {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--tile-color, var(--accent));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--tile-color, var(--accent)) 55%, transparent);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.nd-home-tile .nd-home-tile-title { position: relative; font-weight: 700; font-size: 1.4rem; }
.nd-home-tile .nd-home-tile-pages {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}
.nd-home-tile .nd-home-tile-pages span {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: color-mix(in srgb, var(--tile-color, var(--accent)) 22%, var(--surface));
  color: var(--tile-color, var(--accent));
}

/* section dialog: a native <dialog> per section, one view visible at a time
   (data-mv) — click a folder tile to go one level deeper, "back" returns */
.nd-dialog {
  position: fixed;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--raised);
  color: var(--text);
}
.nd-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.nd-dialog .nd-dialog-inner { padding: 18px 20px 20px; }
.nd-dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.nd-dialog-head h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.nd-dialog-badge {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--tile-color, var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.nd-dialog-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
}
/* dialog buttons (Abbrechen / Speichern): plain, no frame — placed in the
   dialog head on the title's line; submit buttons reach the form below via
   their form="..." attribute */
.nd-dialog-actions { display: flex; gap: 6px; flex: none; }
.nd-dialog-actions-end { justify-content: flex-end; margin-top: 12px; }
/* secondary destructive action next to Abbrechen/Speichern (e.g. "Löschen"
   in the area opening-hours popup) — outlined, so it doesn't compete with Speichern */
.nd-btn.nd-btn-danger-ghost { background: none; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.nd-dialog-view[hidden] { display: none; }
.nd-dialog-back {
  background: none;
  border: none;
  color: var(--accent);
  padding: 2px 0 10px;
  font-size: 13px;
  font-weight: 600;
}
.nd-dialog-subhead {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.nd-dialog-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.nd-page-folder { position: relative; }
.nd-folder-count {
  margin-left: auto;
  background: color-mix(in srgb, var(--tile-color, var(--accent)) 20%, var(--surface));
  color: var(--tile-color, var(--accent));
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- forms (§5) ---------- */
.nd-form { max-width: 640px; }
/* generous bottom padding so even a short last section (or a short last
   page, e.g. a one-field "Kurzansage" section) has enough room below it to
   actually scroll up into the scrollspy's active band and under the sticky
   page head — without this, the browser clamps at the natural end of the
   content and a nav click to a trailing section neither scrolls all the way
   nor ever gets marked active, since it can never reach that band. Scoped to
   the top-level form-page layout only — NOT every ".nd-form" (popup dialogs
   on list pages reuse that class too and must stay their natural height). */
.nd-form-layout > .nd-form { padding-bottom: 60vh; }
/* the settings edit area (the stacked section cards): a fixed 832px (the
   former 640px cap + 30%) instead of shrinking to its content, so every
   settings page has the same, wider editing column; still shrinks on narrow
   windows */
.nd-form-layout > .nd-form { flex: 0 1 832px; max-width: 832px; min-width: 0; }
.nd-form h2 { margin: 0 0 14px; }
.nd-field {
  margin-bottom: 0;
  padding: 12px 2px;
  /* fainter than an input's own border: a divider is passive structure, not
     an interactive outline, so it should recede rather than compete with it */
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.nd-field:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.nd-form-section .nd-field:last-child { border-bottom: none; }

/* a form split into a left in-page navigator and stacked section cards */
.nd-form-layout { display: flex; align-items: flex-start; gap: 24px; }
.nd-form-nav {
  position: sticky;
  top: var(--page-head-h, 0px); /* exactly below the sticky .nd-page-head, measured in JS */
  flex: none;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.nd-form-nav a {
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.nd-form-nav a:hover { background: var(--border); }
.nd-form-nav a.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.nd-form-section {
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
  /* leave room so the sticky page head doesn't cover the section's top when
     a nav link scrolls to it */
  scroll-margin-top: calc(var(--page-head-h, 0px) + 12px);
}
.nd-form-section:first-child {
  /* the first section sits right under the head's normal (unstuck) flow
     position, so no extra offset is needed — and adding one would stop the
     scroll short of the very top */
  scroll-margin-top: 0;
}
@media (max-width: 900px) {
  .nd-form-layout { flex-direction: column; }
  .nd-form-nav { position: static; flex-direction: row; flex-wrap: wrap; width: auto; }
}
.nd-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.nd-field input[type="text"],
.nd-field input[type="email"],
.nd-field input[type="password"],
.nd-field input[type="number"],
.nd-field select,
.nd-field textarea,
.nd-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.nd-field input[type="text"]:hover,
.nd-field input[type="email"]:hover,
.nd-field input[type="password"]:hover,
.nd-field input[type="number"]:hover,
.nd-field select:hover,
.nd-field textarea:hover,
.nd-input:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.nd-field input[type="text"]:focus,
.nd-field input[type="email"]:focus,
.nd-field input[type="password"]:focus,
.nd-field input[type="number"]:focus,
.nd-field select:focus,
.nd-field textarea:focus,
.nd-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.nd-field textarea { resize: vertical; }
.nd-static-value { padding: 8px 10px; color: var(--muted); }

/* modern select: flat, custom chevron instead of the OS-default control */
.nd-field select,
select.nd-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 7l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}

/* opening hours: one row per weekday — a "Geöffnet" toggle plus an hour/minute
   time-picker pair (von/bis), each pair built from two plain <select>s (hour,
   minute-in-15-steps) combined by JS into the one hidden input the backend's
   existing ChoiceField formset actually reads — no new widget, no backend
   change, same approach as the §4.2 number-filter operator+value combo. */
.nd-weekday-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 12px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.nd-weekday-row:last-child { border-bottom: none; }
.nd-weekday-label { font-weight: 700; width: 100px; flex: none; }
.nd-day-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); flex: none; }
.nd-time-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nd-time-range-label { color: var(--muted); font-size: 13px; }
.nd-time-field { display: inline-flex; align-items: center; gap: 4px; }
.nd-time-field .nd-time-hour,
.nd-time-field .nd-time-minute { width: auto; min-width: 62px; padding: 6px 28px 6px 10px; }
.nd-time-field select:disabled { opacity: .5; cursor: not-allowed; }
.nd-time-sep { color: var(--muted); font-weight: 600; }
/* von–bis date pair in a popup (e.g. Individuelle Öffnungszeiten): two compact date inputs on one line */
.nd-date-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nd-date-range .nd-input { width: auto; flex: 1 1 150px; }

/* modern toggle switch: the real checkbox, just restyled — no markup/JS change */
.nd-field input[type="checkbox"],
.nd-day-toggle input[type="checkbox"],
.nd-row-toggle input[type="checkbox"],
.nd-fd-flag-input {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 23px;
  min-width: 40px;
  border-radius: 999px;
  background: var(--border);
  border: none;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color .15s ease;
}
.nd-field input[type="checkbox"]::after,
.nd-day-toggle input[type="checkbox"]::after,
.nd-row-toggle input[type="checkbox"]::after,
.nd-fd-flag-input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  transition: left .15s ease;
}
.nd-field input[type="checkbox"]:checked,
.nd-day-toggle input[type="checkbox"]:checked,
.nd-row-toggle input[type="checkbox"]:checked,
.nd-fd-flag-input:checked { background: var(--accent); }
.nd-field input[type="checkbox"]:checked::after,
.nd-day-toggle input[type="checkbox"]:checked::after,
.nd-row-toggle input[type="checkbox"]:checked::after,
.nd-fd-flag-input:checked::after { left: 19px; }
.nd-field input[type="checkbox"]:focus-visible,
.nd-day-toggle input[type="checkbox"]:focus-visible,
.nd-row-toggle input[type="checkbox"]:focus-visible,
.nd-fd-flag-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nd-row-toggle input[type="checkbox"]:disabled { opacity: .6; cursor: progress; }
/* notes list: long free text stays readable without blowing up the row height */
.nd-notes-table td.nd-notes-text { max-width: 360px; white-space: pre-line; }
/* a read-only switch (disabled widget, e.g. "SMS Senden") must not look operable */
.nd-field input[type="checkbox"]:disabled { opacity: .45; cursor: not-allowed; }

/* a field whose control is a toggle reads as a compact settings row: label
   left, switch right, no wasted vertical space (border/hover come from the
   shared .nd-field rule above, same as every other field) */
.nd-field:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.nd-field:has(> input[type="checkbox"]) label {
  margin-bottom: 0;
  font-weight: 500;
  flex: 1;
  min-width: 200px;
}
.nd-field:has(> input[type="checkbox"]) input[type="checkbox"] { margin-left: auto; flex: none; }
.nd-field:has(> input[type="checkbox"]) .nd-help,
.nd-field:has(> input[type="checkbox"]) .nd-error { flex: 1 0 100%; margin-top: 0; }
.nd-help { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.nd-error { margin: 6px 0 0; font-size: 13px; color: var(--danger); }

/* the title and its save bar stay visible together while the content scrolls */
.nd-page-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--raised);
  padding-top: 2px;
  padding-bottom: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.nd-page-head h1 { margin: 0; }
.nd-save-bar {
  flex: none;
  display: flex;
  gap: 6px;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.nd-btn {
  border: none;
  border-radius: 6px;
  padding: 5px 11px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  background: var(--sunken);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nd-btn-primary { background: var(--accent); color: var(--accent-text); }
.nd-key-hint {
  font-size: 11px;
  font-weight: 700;
  opacity: .8;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
}
@media (max-width: 800px) {
  .nd-page-head { position: static; flex-wrap: wrap; }
  .nd-save-bar { position: fixed; left: 10px; right: 10px; bottom: 10px; justify-content: flex-end; z-index: 110; }
}

/* ---------- lists (§4) ---------- */
.nd-list-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.nd-list-search {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
}
.nd-actions {
  position: relative;
  flex: none;
}
.nd-actions-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 7px;
  height: 34px;
  padding: 0 14px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nd-actions-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  padding: 6px;
  z-index: 20;
}
.nd-actions-menu.open { display: block; }
.nd-actions-menu a, .nd-actions-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  border: none;
  background: none;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.nd-actions-menu a:hover, .nd-actions-menu button:hover { background: var(--sunken); }
.nd-actions-menu .sep { height: 1px; background: var(--border); margin: 6px 2px; }

.nd-table-wrap {
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}
.nd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.nd-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.nd-table th .nd-sort-arrow { opacity: .5; font-size: 10px; margin-left: 4px; }
.nd-table th.nd-sorted .nd-sort-arrow { opacity: 1; }
.nd-table th.nd-actions-col, .nd-table td.nd-actions-col { cursor: default; white-space: nowrap; width: 1%; }
.nd-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.nd-table tbody tr { cursor: pointer; }
.nd-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.nd-table tbody tr:last-child td { border-bottom: none; }
.nd-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  margin-left: 6px;
  text-decoration: none;
  font-size: 14px;
}
.nd-row-icon.nd-row-icon-danger { background: var(--danger); }
.nd-row-icon.nd-row-icon-muted { background: var(--muted); }
.nd-row-icon.nd-row-icon-ok { background: var(--ok); }
/* optional selection column (list engine `row_select`): a plain, compact
   checkbox per row plus a select-all box in the header — not the toggle
   switch, which is a form control for a setting, not a row picker */
.nd-table th.nd-select-col, .nd-table td.nd-select-col { width: 1%; padding-right: 4px; cursor: default; text-align: center; }
.nd-table .nd-select-col input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.nd-pill { border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 600; }
.nd-pill-ok { background: var(--ok-bg); color: var(--ok); }
.nd-pill-off { background: var(--err-bg); color: var(--danger); }
.nd-list-empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- lists (§4.2): filter panel as a separate left column, chips, pagination ----------
   Same "sticky column, capped to the viewport, scrolls internally" idea as .nd-help-panel /
   .nd-form-nav in the forms pattern — not an overlay. It sits to the LEFT of the table, is
   always visible (no slide-in/backdrop/toggle), sized by its content up to that cap. */
.nd-list-layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}
.nd-list-main { flex: 1; min-width: 0; }
.nd-filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
}
.nd-filter-panel {
  flex: none;
  width: 280px;
  position: sticky;
  top: var(--page-head-h, 0px);
  max-height: calc(100vh - var(--page-head-h, 0px) - 20px);
  overflow-y: auto;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.nd-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.nd-filter-head h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.nd-filter-head-icon { font-size: 1.1rem; color: var(--accent); }
.nd-filter-close {
  width: 30px;
  height: 30px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nd-filter-close:hover { border-color: var(--accent); color: var(--accent); }

.nd-filter-col {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  padding: 10px 0;
}
.nd-filter-col:last-child { border-bottom: none; }
.nd-filter-col summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
}
.nd-filter-col summary::-webkit-details-marker { display: none; }
.nd-filter-col-right { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.nd-filter-arrow { opacity: .6; font-size: 11px; transition: transform .15s ease; display: inline-block; }
.nd-filter-col[open] .nd-filter-arrow { transform: rotate(90deg); }

.nd-filter-number-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.nd-filter-number-row .nd-filter-op { flex: none; width: auto; }
.nd-filter-number-row .nd-filter-val { flex: 1; min-width: 0; }

.nd-filter-text-add { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.nd-filter-text-add .nd-filter-search { flex: 1; min-width: 0; }

.nd-filter-add-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nd-filter-add-btn:hover { filter: brightness(1.08); }

.nd-filter-values {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.nd-filter-value {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
}
.nd-filter-value:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.nd-filter-value.is-selected {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
  font-weight: 600;
}
.nd-filter-checkbox {
  width: 16px;
  height: 16px;
  flex: none;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--accent-text);
  background: transparent;
}
.nd-filter-value.is-selected .nd-filter-checkbox { background: var(--accent); border-color: var(--accent); }
.nd-filter-value-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-filter-value-count { color: var(--muted); font-size: 12px; }
.nd-filter-clear {
  display: inline-block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
}
.nd-filter-clear:hover { text-decoration: underline; }

.nd-filter-toggle-btn {
  position: relative;
  flex: none;
  height: 34px;
  width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
}
.nd-filter-toggle-btn:hover { filter: brightness(1.08); }
.nd-filter-toggle-btn .nd-filter-badge { position: absolute; top: -6px; right: -6px; }

.nd-list-date-label { color: var(--muted); font-size: 13px; flex: none; }
.nd-list-date { flex: none; width: 150px; }
/* preset select in front of every from/to pair (Heute, letzte 7 Tage, …, Benutzerdefiniert) */
.nd-date-preset { flex: none; width: auto; min-width: 170px; }

/* every button in the list toolbar matches the Aktionen button's height */
.nd-list-filter-row .nd-btn { height: 34px; padding: 0 14px; }

.nd-chips-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 14px; }
.nd-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--sunken);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 12.5px;
}
.nd-chip:hover { border-color: var(--accent); }
.nd-chip-remove { opacity: .7; font-weight: 700; }

.nd-pagination[hidden], .nd-chips-row[hidden], .nd-list-empty[hidden] { display: none; }
.nd-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.nd-pagination-pages { display: flex; align-items: center; gap: 10px; }
.nd-pagination-current { white-space: nowrap; }

@media (max-width: 900px) {
  .nd-list-layout { flex-direction: column; }
  .nd-filter-panel { width: auto; position: static; max-height: none; }
}

/* ---------- field help: an info icon next to the label opens this panel ---------- */
.nd-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  padding: 0;
  vertical-align: -3px;
}
.nd-help-icon:hover { color: var(--accent-text); background: var(--accent); }

/* a third column in .nd-form-layout, next to the nav and the value cards —
   same gap, sticky like the nav, no overlay/backdrop; toggled via [hidden] */
.nd-help-panel {
  flex: none;
  width: 300px;
  position: sticky;
  top: var(--page-head-h, 0px);
  max-height: calc(100vh - var(--page-head-h, 0px) - 20px);
  overflow: auto;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.nd-help-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.nd-help-panel-head h2 { margin: 0; font-size: 1.05rem; }
.nd-help-panel-body { font-size: 14px; line-height: 1.6; color: var(--text); }
@media (max-width: 900px) {
  .nd-help-panel { width: auto; position: static; }
}

/* ---------- small-screen full page scroll ---------- */
@media (max-width: 900px) {
  html, body { height: auto; }
}

/* ---------- code editor page (Monaco on textarea[data-nd-code]) ---------- */
/* the editor fills the frame's remaining height: frame-content → form →
   code section → editor are one flex column chain; the last section keeps
   10px + the footer's 10px margin = the same 20px gap as under the page head */
.nd-frame-content:has(> .nd-code-form) { display: flex; flex-direction: column; }
.nd-code-form { flex: 1 0 auto; min-height: 0; display: flex; flex-direction: column; }
.nd-code-form > .nd-form-section:last-child { margin-bottom: 10px; }
.nd-code-form > #section-code { flex: 1 0 auto; display: flex; flex-direction: column; }
.nd-code-form .nd-form-section h2 { display: flex; align-items: center; gap: 10px; }
.nd-code-hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.nd-code-hint kbd {
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
}
/* fallback before / without Monaco: still a usable monospace textarea */
textarea[data-nd-code] {
  width: 100%; flex: 1 1 0; min-height: 300px; box-sizing: border-box; resize: none;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 4; padding: 10px 12px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.nd-code-host {
  flex: 1 1 0; min-height: 300px; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: var(--surface);
}
.nd-code-status {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.nd-code-status.is-ok { color: var(--ok); background: var(--ok-bg); }
.nd-code-status.is-err { color: var(--danger); background: var(--err-bg); }
.nd-code-output {
  margin: 0; max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.nd-code-output:empty::before { content: attr(data-empty); color: var(--muted); }

/* a field switched off by a dependent select (select[data-enables]) */
.nd-field.nd-field-disabled { opacity: .45; }
.nd-field.nd-field-disabled input, .nd-field.nd-field-disabled label { cursor: not-allowed; }

/* ---------- tabs (Dialog Design) ---------- */
.nd-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.nd-tab {
  padding: 8px 14px;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nd-tab:hover { color: var(--text); }
.nd-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.nd-pill-info { background: var(--info-bg); color: var(--info); }
.nd-pill-muted { background: var(--sunken); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }

/* ---------- Dialog Design / flow designer ---------- */
.nd-fd-head { border-bottom: none; margin-bottom: 12px; }
.nd-fd-titlebar { flex: 1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.nd-fd-current { margin: 0; font-size: 22px; min-width: 0; overflow-wrap: anywhere; }
.nd-fd-current.is-overview { color: var(--muted); font-weight: 600; }
.nd-fd-back { flex: 0 0 100%; color: var(--accent); font-size: 13px; text-decoration: none; margin-bottom: -6px; }
.nd-fd-back:hover { text-decoration: underline; }
.nd-fd-view-tabs { margin-bottom: 18px; }
.nd-fd-home {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.nd-fd-tile { --tile-color: var(--accent); min-height: 160px; transition: transform .12s, box-shadow .12s; }
.nd-fd-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, .12); }
.nd-fd-tile:not(.is-inactive) {
  background: color-mix(in srgb, var(--accent) 5%, var(--raised));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  border-top-color: var(--accent);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 14%, rgba(0, 0, 0, .08));
}
.nd-fd-tile:not(.is-inactive)::after {
  background: radial-gradient(170px 170px at 100% 100%,
    color-mix(in srgb, var(--accent) 38%, transparent), transparent 70%);
}
.nd-fd-tile:not(.is-inactive) .nd-home-tile-icon { opacity: .22; }
.nd-fd-tile:not(.is-inactive):hover {
  border-color: var(--accent);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 24%, rgba(0, 0, 0, .1));
}
.nd-fd-tile.is-inactive {
  --tile-color: var(--muted);
  background: color-mix(in srgb, var(--border) 50%, var(--sunken));
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--muted);
  box-shadow: none;
}
.nd-fd-tile.is-inactive::after { opacity: .35; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nd-fd-tile.is-inactive { background: var(--sunken); }
}
:root[data-theme="dark"] .nd-fd-tile.is-inactive { background: var(--sunken); }
.nd-fd-tile.is-inactive .nd-home-tile-badge { box-shadow: none; filter: grayscale(1); opacity: .55; }
.nd-fd-tile.is-inactive .nd-home-tile-icon { filter: grayscale(1); opacity: .08; }
.nd-fd-tile.is-inactive .nd-home-tile-title { font-weight: 600; }
.nd-fd-tile.is-inactive:hover { color: var(--text); }
.nd-fd-tile-problem { position: absolute; top: 14px; right: 14px; z-index: 1; margin: 0; width: 11px; height: 11px; }
.nd-fd-tile.has-problem { border-top-color: var(--danger); }
/* ⓘ help of the tenant properties: shown inside the card above the fields (no extra column in the flow designer) */
.nd-fd-help-panel { width: auto; position: static; max-height: none; margin: 0 0 14px; background: var(--raised); }
.nd-fd-tile .nd-home-tile-title { font-size: 1.15rem; overflow-wrap: anywhere; }
.nd-fd-tile-meta { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nd-fd-tile-meta { margin-top: auto; padding-top: 6px; }
.nd-fd-tile-add {
  min-height: 160px;
  border: 2px dashed var(--border);
  border-radius: 14px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: color .12s, border-color .12s, background .12s;
}
.nd-fd-tile-add:hover, .nd-fd-tile-add:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.nd-fd-tile-add-plus { font-size: 40px; line-height: 1; font-weight: 300; }

.nd-fd { position: relative; }
.nd-fd-message { margin: -8px 0 14px; }
.nd-fd-current-wrap { display: inline-flex; align-items: center; gap: 14px; min-width: 0; }
.nd-fd-delete-service { margin-left: auto; flex: none; }


.nd-fd-empty { color: var(--muted); font-size: 13.5px; margin: 6px 2px; }

.nd-fd-main { min-width: 0; }

.nd-fd-flow {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
/* flow diagram: phase groups (collapsible) stacked top → bottom, steps as
   nodes joined by arrows; the "Ja" loop of the decision is drawn in JS */
.nd-fd-diagram-wrap { min-width: 0; }
.nd-fd-diagram { position: relative; }
/* "Nur konfigurierte Schritte" switch above the flow (filtering in JS) */
.nd-fd-only { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.nd-fd-only:has(:checked) { color: var(--text); }
.nd-fd-diagram .is-fd-hidden { display: none !important; }
.nd-fd-diagram.is-fd-only .nd-fd-group.is-fd-first,
.nd-fd-diagram.is-fd-only .nd-fd-gstep.is-fd-first { margin-top: 0; }
.nd-fd-diagram.is-fd-only .nd-fd-group.is-fd-first::before,
.nd-fd-diagram.is-fd-only .nd-fd-group.is-fd-first::after,
.nd-fd-diagram.is-fd-only .nd-fd-gstep.is-fd-first::before,
.nd-fd-diagram.is-fd-only .nd-fd-gstep.is-fd-first::after { display: none; }
/* right lane for the "Ja" loop from "Weitere Hilfe" back to the opening question */
.nd-fd-diagram:has(.nd-fd-group[data-group='opening']) { padding-right: 22px; }
/* the "Ja" / "Fehler" loops run inside the Services group's left padding,
   so the groups themselves start flush with the content's left edge */
.nd-fd-group[data-group="services"] .nd-fd-group-body { padding-left: 34px; --fd-arrow-shift: -10px; }
.nd-fd-group {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sunken);
}
.nd-fd-group + .nd-fd-group { margin-top: 30px; }
.nd-fd-group + .nd-fd-group::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -30px;
  width: 2px;
  height: 24px;
  margin-left: -1px;
  background: color-mix(in srgb, var(--muted) 55%, transparent);
}
.nd-fd-group + .nd-fd-group::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom: none;
  border-top: 7px solid color-mix(in srgb, var(--muted) 75%, transparent);
}
.nd-fd-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
}
.nd-fd-group-head:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
/* a group with a single step is itself the clickable node (no sub node) */
.nd-fd-group-link { text-decoration: none; padding: 7px 12px 7px 8px; }
.nd-fd-group-link .nd-fd-gnode-icon { width: 28px; height: 28px; }
.nd-fd-group.is-single.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.nd-fd-group.is-single.is-off .nd-fd-gnode-icon { opacity: .4; filter: grayscale(1); }
.nd-fd-group.is-single.is-empty .nd-fd-group-label, .nd-fd-group.is-single.is-missing:not(.is-filled) .nd-fd-group-label { color: var(--muted); }
.nd-fd-group-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nd-fd-group-caret { font-size: 11px; color: var(--muted); transition: transform .15s ease; }
.nd-fd-group.is-open .nd-fd-group-caret { transform: rotate(90deg); }
.nd-fd-group-label { flex: 1; }
.nd-fd-group.is-off { border-style: dashed; background: transparent; }
.nd-fd-group.is-off .nd-fd-group-label { color: var(--muted); }
.nd-fd-group-body { display: none; list-style: none; margin: 0; padding: 4px 14px 14px; }
.nd-fd-group.is-open .nd-fd-group-body { display: block; }
.nd-fd-group.is-open .nd-fd-group-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.nd-fd-gstep { position: relative; display: flex; justify-content: center; }
.nd-fd-gstep + .nd-fd-gstep { margin-top: 22px; }
.nd-fd-gstep + .nd-fd-gstep::before {
  content: "";
  position: absolute;
  /* on the group's centre line, like the arrows between groups (the Services
     body has extra left padding for the loops, hence the shift) */
  left: calc(50% + var(--fd-arrow-shift, 0px));
  top: -22px;
  width: 2px;
  height: 16px;
  margin-left: -1px;
  background: color-mix(in srgb, var(--muted) 55%, transparent);
}
.nd-fd-gstep + .nd-fd-gstep::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--fd-arrow-shift, 0px));
  top: -7px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom: none;
  border-top: 6px solid color-mix(in srgb, var(--muted) 75%, transparent);
}
.nd-fd-gnode {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.nd-fd-gnode:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-1px); }
.nd-fd-gnode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nd-fd-gnode.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.nd-fd-gnode-icon {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 15px;
  background: var(--sunken);
}
.nd-fd-gnode-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* not configured (empty / missing without content): weaker text, background close to the group's */
.nd-fd-gnode.is-empty, .nd-fd-gnode.is-missing:not(.is-filled) {
  background: transparent; /* same as the surrounding group */
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
}
/* text of not-green nodes: the same grey as a deactivated group's label */
.nd-fd-gnode.is-empty:not(.is-active) .nd-fd-gnode-label, .nd-fd-gnode.is-missing:not(.is-filled):not(.is-active) .nd-fd-gnode-label {
  color: var(--muted);
  font-weight: 500;
}
.nd-fd-gnode.is-empty:not(.is-active) .nd-fd-gnode-icon, .nd-fd-gnode.is-missing:not(.is-filled):not(.is-active) .nd-fd-gnode-icon { opacity: .7; }
.nd-fd-gnode.is-empty:hover .nd-fd-gnode-label, .nd-fd-gnode.is-missing:not(.is-filled):hover .nd-fd-gnode-label,
.nd-fd-gnode.is-active .nd-fd-gnode-label { color: var(--text); }
.nd-fd-gnode.is-off { border-style: dashed; background: transparent; }
.nd-fd-gnode.is-off .nd-fd-gnode-icon { opacity: .4; filter: grayscale(1); }
.nd-fd-gnode.is-off:not(.is-active) .nd-fd-gnode-label { color: var(--muted); font-weight: 500; }
/* dark mode: on the near-black background the grey of inactive nodes and deactivated groups is toned down a little more */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nd-fd-gnode:is(.is-empty, .is-missing:not(.is-filled), .is-off):not(.is-active) .nd-fd-gnode-label,
  :root:not([data-theme="light"]) .nd-fd-group.is-off .nd-fd-group-label,
  :root:not([data-theme="light"]) .nd-fd-group.is-single:is(.is-empty, .is-missing:not(.is-filled)) .nd-fd-group-label {
    color: color-mix(in srgb, var(--muted) 58%, var(--sunken));
  }
}
:root[data-theme="dark"] .nd-fd-gnode:is(.is-empty, .is-missing:not(.is-filled), .is-off):not(.is-active) .nd-fd-gnode-label,
:root[data-theme="dark"] .nd-fd-group.is-off .nd-fd-group-label,
:root[data-theme="dark"] .nd-fd-group.is-single:is(.is-empty, .is-missing:not(.is-filled)) .nd-fd-group-label {
  color: color-mix(in srgb, var(--muted) 58%, var(--sunken));
}
.nd-fd-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nd-fd-gstep:last-child:has(.nd-fd-branch-no) { margin-bottom: 14px; }
.nd-fd-branch-no {
  position: absolute;
  left: calc(50% + var(--fd-arrow-shift, 0px) + 8px);
  top: calc(100% + 2px);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.nd-fd-node-state { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.is-ok > .nd-fd-node-state, .nd-fd-group.is-ok .nd-fd-group-head .nd-fd-node-state, .nd-fd-legend .is-ok { background: var(--ok); }
.is-missing > .nd-fd-node-state, .nd-fd-group.is-missing .nd-fd-group-head .nd-fd-node-state, .nd-fd-legend .is-missing { background: var(--danger); }
.is-empty > .nd-fd-node-state, .nd-fd-group.is-empty .nd-fd-group-head .nd-fd-node-state, .nd-fd-legend .is-empty {
  background: transparent;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--muted) 60%, transparent);
}
.is-off > .nd-fd-node-state, .nd-fd-group.is-off .nd-fd-group-head .nd-fd-node-state, .nd-fd-legend .is-off { background: color-mix(in srgb, var(--muted) 40%, transparent); }
.nd-fd-loop { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.nd-fd-loop path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 4 3; }
.nd-fd-loop polygon { fill: var(--accent); }
.nd-fd-loop text { fill: var(--accent); font-size: 10.5px; font-weight: 700; paint-order: stroke; stroke: var(--sunken); stroke-width: 4px; stroke-linejoin: round; }
.nd-fd-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}
.nd-fd-legend span { display: inline-flex; align-items: center; gap: 5px; }
.nd-fd-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.nd-fd-panel { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
/* independent scrolling of flow and editor (height set in JS); the small
   padding keeps focus rings / active outlines from being clipped */
.nd-fd-scroll-col {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 6px 4px 4px;
  margin: -4px -6px -4px -4px;
  scrollbar-width: thin;
}
.nd-fd-panel.nd-fd-scroll-col > .nd-fd-panel-head {
  position: sticky;
  top: -4px;
  z-index: 3;
  margin-top: -4px;
  padding: 4px 0 8px;
  background: var(--raised);
}
.nd-fd-panel-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 22px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
}
.nd-fd-panel-empty p { margin: 0; font-size: 14px; }
/* autosaving forms: status next to the box title, delete action at the bottom */
.nd-fd-autosave-status { flex: none; font-size: 12.5px; font-weight: 600; color: var(--muted); min-height: 1em; }
.nd-fd-autosave-status.is-saved { color: var(--ok); }
.nd-fd-autosave-status.is-error { color: var(--danger); }
/* invalid field in an autosaving form (e.g. empty service name) */
.nd-field.is-invalid label { color: var(--danger); }
.nd-field.is-invalid input, .nd-field.is-invalid textarea, .nd-field.is-invalid select {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}
.nd-fd-diagram .has-error { border-color: var(--danger) !important; }
.nd-fd-diagram .has-error .nd-fd-node-state { background: var(--danger) !important; box-shadow: none !important; }
/* a box without title: only the save status, top right beside the first field label */
.nd-fd-card:has(> .nd-fd-card-head-bare) { position: relative; }
.nd-fd-card > .nd-fd-card-head.nd-fd-card-head-bare { position: absolute; top: 12px; right: 18px; margin: 0; z-index: 1; pointer-events: none; }

/* step on/off switch at the top of a step editor (Termin / Identifikation) */
.nd-fd-flag { border-left: 4px solid var(--muted); }
.nd-fd-flag.is-on { border-left-color: var(--ok); }
.nd-fd-flag-row { display: flex; align-items: center; gap: 16px; cursor: pointer; }
.nd-fd-flag-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nd-fd-flag-text strong { font-size: 15px; }
.nd-fd-flag-text .nd-help { margin: 0; }
.nd-fd-api .nd-code-host, .nd-fd-api textarea[data-nd-code] { flex: none; height: 460px; min-height: 300px; }
.nd-fd-api .nd-code-hint { margin: 2px 0 0; }
.nd-fd-panel-empty-icon { font-size: 22px; line-height: 1; }
.nd-fd-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nd-fd-panel-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 20px; }
.nd-fd-panel-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--sunken);
  display: grid;
  place-items: center;
  font-size: 17px;
}
.nd-fd-banner {
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13.5px;
}
.nd-fd-banner a { color: inherit; font-weight: 700; margin-left: 6px; }
.nd-fd-card-warning { margin: 0 0 12px; }
.nd-fd-card {
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.nd-fd-panel .nd-fd-card { margin-bottom: 0; }
.nd-fd-card h3 { margin: 0; font-size: 15px; }
/* editor boxes collapse (default collapsed; set up in JS) */
.nd-fd-card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nd-fd-card-toggle:hover { color: var(--accent); }
.nd-fd-card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.nd-fd-card-caret { font-size: 11px; color: var(--muted); transition: transform .15s ease; }
.nd-fd-card.is-collapsible:not(.is-collapsed) .nd-fd-card-caret { transform: rotate(90deg); }
.nd-fd-card.is-collapsed > :not(.nd-fd-card-head),
.nd-fd-card.is-collapsed > .nd-fd-card-head > :not(:first-child),
.nd-fd-card.is-collapsed > .nd-fd-card-head .nd-help { display: none; }
.nd-fd-card.is-collapsed > .nd-fd-card-head { margin-bottom: 0; }
.nd-fd-card.is-collapsed { padding-top: 12px; padding-bottom: 12px; }
.nd-fd-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.nd-fd-card-head .nd-help { margin-top: 2px; }
.nd-fd-card-head > .nd-btn, .nd-fd-card-head > .nd-save-bar { flex: none; white-space: nowrap; }
.nd-fd-card-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.nd-fd-card-note { margin: 0 0 10px; }
.nd-fd-card .nd-table-wrap { background: var(--raised); }
.nd-fd-card .nd-save-bar { box-shadow: none; }
.nd-fd-col-narrow { width: 1%; white-space: nowrap; }
.nd-fd-type-cell { width: 1%; white-space: nowrap; color: var(--muted); font-size: 13px; }
.nd-fd-text-cell { min-width: 240px; }
.nd-fd-text-cell { white-space: pre-line; }
.nd-fd-static-table tbody tr { cursor: default; }
.nd-fd-quote {
  margin: 0 0 4px;
  padding: 8px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
  white-space: pre-line;
}
.nd-fd-fields .nd-field:last-child { border-bottom: none; }
.nd-fd-fields .nd-field[hidden] { display: none; }
.nd-dialog .nd-field[hidden] { display: none; }
.nd-fd-dialog-help { margin: 8px 2px 4px; }
.nd-fd-settings { max-width: 832px; }
.nd-fd-blank { text-align: center; padding: 40px 20px; }
.nd-fd-blank h2 { margin: 0 0 6px; }
.nd-fd-blank .nd-btn { margin-top: 12px; }

/* active switch inside a table row (posts its own small form) */
.nd-fd-switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  vertical-align: middle;
  transition: background .15s;
}
.nd-fd-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.nd-fd-switch.on { background: var(--accent); }
.nd-fd-switch.on::after { transform: translateX(14px); }

/* details: numbered, reorderable sub-steps */
.nd-fd-details { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.nd-fd-detail {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
}
.nd-fd-detail:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 45px;
  top: 100%;
  width: 2px;
  height: 10px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
}
.nd-fd-detail.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.nd-fd-detail.is-inactive .nd-fd-detail-name { opacity: .55; }
.nd-fd-detail-no {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.nd-fd-detail-body {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  color: var(--text);
  text-decoration: none;
}
.nd-fd-detail-name { font-weight: 600; font-size: 14px; }
.nd-fd-detail-meta { grid-column: 1; font-size: 12px; color: var(--muted); }
.nd-fd-detail-tags {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nd-fd-count { font-size: 12px; color: var(--text); white-space: nowrap; }
.nd-fd-count.is-zero { color: var(--muted); opacity: .6; }
.nd-fd-move { display: flex; flex: none; }
/* configuration of the selected detail: indented right below it in the list */
.nd-fd-detail-config {
  position: relative;
  list-style: none;
  margin: -4px 0 4px 36px;
  padding: 12px 0 0 18px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nd-fd-detail-config::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 0;
  width: 14px;
  height: 2px;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}
.nd-fd-detail-config > .nd-fd-card { margin: 0; background: var(--raised); }
.nd-fd-detail-config .nd-table-wrap { background: var(--sunken); }
/* detail "Eigenschaften" / "Typ" boxes side by side, equally tall (the taller
   content sets the height, nothing is cut off), each at most 500px wide;
   on a narrow column "Typ" wraps below */
.nd-fd-detail-scope { display: flex; flex-wrap: wrap; align-items: stretch; gap: 16px; }
.nd-fd-detail-scope > .nd-fd-card { flex: 1 1 320px; min-width: 0; max-width: 500px; margin: 0; box-sizing: border-box; }
/* detail properties in two columns (left: basics, right: format/type + parameters) */
.nd-fd-two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; align-items: start; }
.nd-fd-two-cols .nd-fd-col .nd-field:last-of-type { border-bottom: none; }
@media (max-width: 1250px) { .nd-fd-two-cols { grid-template-columns: minmax(0, 1fr); } }
.nd-fd-move .nd-row-icon { background: var(--sunken); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); margin-left: 4px; }
.nd-fd-move .nd-row-icon:disabled { opacity: .35; }

/* subflow chain */
.nd-fd-chain { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.nd-fd-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}
a.nd-fd-chip:hover { border-color: var(--accent); }
.nd-fd-chip-root { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.nd-fd-chip-ghost { border-style: dashed; color: var(--muted); font-weight: 400; }
.nd-fd-chain-arrow { color: var(--muted); }

/* subflow step: service + subflow chain with their details, 3 blocks per row */
.nd-fd-chainflow-wrap { container-type: inline-size; }
.nd-fd-chainflow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px 30px; align-items: stretch; padding: 0 18px; --fd-chain-line: color-mix(in srgb, var(--muted) 55%, transparent); }
.nd-fd-chainflow-block { position: relative; min-width: 0; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; background: var(--sunken); }
.nd-fd-chainflow-block.is-root { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.nd-fd-chainflow-block.is-inactive { border-style: dashed; }
.nd-fd-chainflow-block.is-from-right::before,
.nd-fd-chainflow-block.is-from-left::before {
  position: absolute;
  top: 9px;
  width: 18px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.nd-fd-chainflow-block.is-from-right::before { content: "→"; left: -24px; }
.nd-fd-chainflow-block.is-from-left::before { content: "←"; right: -24px; }
.nd-fd-chainflow-block.is-turn-right::after,
.nd-fd-chainflow-block.is-turn-left::after {
  content: "";
  position: absolute;
  top: 19px;
  width: 14px;
  height: calc(100% + 26px);
  border: 2px solid var(--fd-chain-line);
  pointer-events: none;
}
.nd-fd-chainflow-block.is-turn-right::after { right: -17px; border-left: 0; border-radius: 0 8px 8px 0; }
.nd-fd-chainflow-block.is-turn-left::after { left: -17px; border-right: 0; border-radius: 8px 0 0 8px; }
.nd-fd-chainflow-block.is-from-down-right::before,
.nd-fd-chainflow-block.is-from-down-left::before {
  content: "";
  position: absolute;
  top: 15px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.nd-fd-chainflow-block.is-from-down-right::before { right: -8px; border-right: 7px solid var(--fd-chain-line); }
.nd-fd-chainflow-block.is-from-down-left::before { left: -8px; border-left: 7px solid var(--fd-chain-line); }
@container (max-width: 640px) {
  .nd-fd-chainflow { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .nd-fd-chainflow-block { grid-row: auto !important; grid-column: 1 !important; }
  .nd-fd-chainflow-block::after { display: none; }
  .nd-fd-chainflow-block[class*="is-from-"]::before {
    content: "↓"; left: 18px; right: auto; top: -24px; width: 18px; border: 0;
    text-align: center; color: var(--muted); font-weight: 700;
  }
}
.nd-fd-chainflow-block[draggable="true"] { cursor: grab; }
.nd-fd-chainflow-block.is-dragging { opacity: .45; }
.nd-fd-chainflow-block.is-drop-target { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.nd-fd-chainflow.is-saving { opacity: .6; pointer-events: none; }
.nd-fd-chainflow-headrow { display: flex; align-items: center; gap: 6px; }
.nd-fd-chainflow-head {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0;
  background: none; border: 0; color: var(--text); font: inherit; font-weight: 700; font-size: 14px; text-align: left; cursor: pointer;
}
.nd-fd-chainflow-head:hover .nd-fd-chainflow-name { text-decoration: underline; }
.nd-fd-chainflow-head .nd-fd-chainflow-name { flex: 1; }
.nd-fd-chainflow-block.is-open .nd-fd-group-caret { transform: rotate(90deg); }
.nd-fd-chainflow-head .nd-fd-node-state { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.nd-fd-chainflow-head .nd-fd-node-state.is-missing { background: var(--danger); }
.nd-fd-chainflow-head .nd-fd-node-state.is-empty { background: color-mix(in srgb, var(--muted) 40%, transparent); }
.nd-fd-chainflow-open { flex: none; color: var(--accent); text-decoration: none; font-weight: 700; padding: 0 4px; border-radius: 4px; }
.nd-fd-chainflow-open:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.nd-fd-chainflow-detach {
  flex: none; padding: 0 4px; border: 0; border-radius: 4px; background: none;
  color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.nd-fd-chainflow-detach:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.nd-fd-chainflow-body { display: none; }
.nd-fd-chainflow-block.is-open .nd-fd-chainflow-body { display: block; }
.nd-fd-chainflow-name { min-width: 0; overflow-wrap: anywhere; }
.nd-fd-chainflow-block .nd-fd-subtree { margin-left: 8px; }
.nd-fd-chainflow-block .nd-fd-subitem { cursor: default; }
.nd-fd-chainflow-empty { margin: 8px 0 0 8px; color: var(--muted); font-size: 13px; }
/* subflow popup: the subflow's own flow designer page in an iframe (?embed=1 = without header / menu) */
.nd-dialog.nd-fd-popup { width: min(1500px, calc(100vw - 32px)); height: calc(100vh - 32px); max-height: none; overflow: hidden; display: none; flex-direction: column; }
.nd-dialog.nd-fd-popup[open] { display: flex; }
.nd-fd-popup-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--border); }
.nd-fd-popup-head h2 { margin: 0; flex: 1; font-size: 1.1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-fd-popup-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
body.nd-embed .nd-header,
body.nd-embed .nd-nav,
body.nd-embed .nd-nav-backdrop,
body.nd-embed .nd-frame-footer { display: none !important; }
body.nd-embed .nd-body { margin: 0; }
body.nd-embed .nd-frame { height: 100vh; border: 0; border-radius: 0; }
.nd-fd-decision { margin: 8px 0; padding-left: 18px; }
.nd-fd-decision li { margin: 4px 0; }

@media (max-width: 1350px) {
  .nd-fd-flow { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .nd-fd-flow { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- searchable select (select[data-nd-searchable]) ---------- */
.nd-combo { position: relative; }
.nd-combo input.nd-combo-input, .nd-field .nd-combo input.nd-combo-input {
  padding-right: 30px;
  background-image: 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='%239aa3b2' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.nd-combo-list {
  position: fixed;
  z-index: 1000;
  margin: 0;
  padding: 4px;
  list-style: none;
  overflow-y: auto;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
}
.nd-combo-list[hidden] { display: none; }
.nd-combo-option { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text); }
.nd-combo-option.is-active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.nd-combo-option.is-selected { font-weight: 700; }
.nd-combo-empty { padding: 8px 10px; color: var(--muted); font-size: 13.5px; }

/* ---------- Dialog Design: details as a tree below the "Details" node ---------- */
.nd-fd-gstep:has(.nd-fd-subtree) { flex-direction: column; align-items: stretch; }
.nd-fd-subtree {
  list-style: none;
  margin: 6px 0 0 22px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid color-mix(in srgb, var(--muted) 40%, transparent);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nd-fd-subitem { position: relative; cursor: grab; }
.nd-fd-subitem::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 15px;
  width: 12px;
  height: 2px;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
}
.nd-fd-subnode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.nd-fd-subnode:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.nd-fd-subnode.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.nd-fd-subnode.is-off { background: transparent; border-style: dashed; }
.nd-fd-subnode.is-off .nd-fd-subnode-label { color: var(--muted); font-weight: 500; }
.nd-fd-subnode-no {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.nd-fd-subnode-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-fd-subnode.is-ok > .nd-fd-node-state { background: var(--ok); }
.nd-fd-subnode.is-off > .nd-fd-node-state { background: color-mix(in srgb, var(--muted) 40%, transparent); }
[data-fd-reorder] > [data-id].is-dragging { opacity: .45; }
.nd-fd-detail { cursor: grab; }
.nd-fd-drag-handle { flex: none; color: var(--muted); font-size: 14px; cursor: grab; user-select: none; }
.nd-fd-crumb { color: var(--accent); text-decoration: none; }
.nd-fd-crumb:hover { text-decoration: underline; }
.nd-fd-crumb-sep { color: var(--muted); margin: 0 2px; font-weight: 400; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nd-fd-subnode.is-off .nd-fd-subnode-label { color: color-mix(in srgb, var(--muted) 58%, var(--sunken)); }
}
:root[data-theme="dark"] .nd-fd-subnode.is-off .nd-fd-subnode-label { color: color-mix(in srgb, var(--muted) 58%, var(--sunken)); }
.nd-fd-subnode.is-missing { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.nd-fd-subnode.is-missing.is-active { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.nd-fd-subnode.is-missing > .nd-fd-node-state { background: var(--danger); }
.nd-fd-banner-error { background: var(--err-bg); color: var(--danger); }

/* decisions in the details tree: Bool - forward (Ja → 📞) / Bool - ask next detail (Nein → Abschluss); the trunk continues downwards */
.nd-fd-dec { position: relative; margin-top: 4px; font-size: 11.5px; --fd-dec: var(--muted); }
.nd-fd-dec.is-forward, .nd-fd-dec.is-inv_forward { --fd-dec: var(--warn); }
.nd-fd-dec.is-ask_next { --fd-dec: var(--info); }
.nd-fd-dec.is-callback { --fd-dec: color-mix(in srgb, var(--section-planning) 70%, var(--text)); }
.nd-fd-dec-diamond {
  position: absolute;
  left: -22px;
  top: 6px;
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  transform: rotate(45deg);
  background: var(--raised);
  border: 2px solid var(--fd-dec);
  border-radius: 2px;
}
.nd-fd-dec-out { display: flex; align-items: center; gap: 4px; height: 26px; margin-left: -5px; min-width: 0; }
.nd-fd-dec-line { flex: none; width: 10px; height: 2px; background: var(--fd-dec); }
.nd-fd-dec-arrow { position: relative; width: 16px; margin-right: 5px; }
.nd-fd-dec-arrow::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -4px;
  border-left: 6px solid var(--fd-dec);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.nd-fd-dec-label { font-weight: 700; color: var(--fd-dec); }
.nd-fd-dec-end {
  min-width: 0;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--fd-dec) 50%, transparent);
  background: color-mix(in srgb, var(--fd-dec) 14%, transparent);
  color: var(--fd-dec);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nd-fd-dec-down { display: block; margin-left: -12px; padding: 0 0 2px; font-weight: 700; color: var(--muted); line-height: 14px; }
.nd-fd-dec-down::before { content: "↓ "; font-weight: 400; }
.nd-fd-detail.has-dec { margin-bottom: 44px; }
.nd-fd-detail.has-dec::after { content: ""; position: absolute; left: 45px; top: 100%; width: 2px; height: 54px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.nd-fd-detail.has-dec:last-child::after { height: 44px; }
.nd-fd-detail > .nd-fd-dec { position: absolute; z-index: 1; left: 61px; top: 100%; margin-top: 0; cursor: default; }
.nd-fd-detail > .nd-fd-dec .nd-fd-dec-diamond { background: var(--panel, var(--raised)); }

/* Flow designer: test chat (right side panel) */
.nd-fd-chat {
  position: fixed; z-index: 40; right: 10px; top: var(--header-space); bottom: 20px;
  width: min(420px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25); padding: 14px;
}
.nd-fd-chat[hidden] { display: none; }
body.nd-fd-chat-open .nd-frame { margin-right: 444px; }
@media (max-width: 1800px) { body.nd-fd-chat-open .nd-fd-flow { grid-template-columns: 250px minmax(0, 1fr); gap: 16px; } }
@media (max-width: 1100px) { body.nd-fd-chat-open .nd-frame { margin-right: 0; } }
.nd-fd-chat-head { display: flex; align-items: center; gap: 10px; }
.nd-fd-chat-head h2 { margin: 0; flex: 1; font-size: 1.05rem; }
.nd-fd-chat-tenant { margin: 0; }
.nd-fd-chat-actions { display: flex; gap: 8px; }
.nd-fd-chat-log {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  background: var(--sunken); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
.nd-fd-chat-empty { margin: auto; color: var(--muted); text-align: center; font-size: 14px; }
.nd-fd-chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.nd-fd-chat-msg.is-bot { align-self: flex-start; background: var(--chat-bot-bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.nd-fd-chat-msg.is-user { align-self: flex-end; background: var(--chat-user-bg); color: var(--chat-user-text); border-bottom-right-radius: 4px; }
.nd-fd-chat-sys { align-self: center; font-size: 12px; color: var(--muted); }
.nd-fd-chat-sys.is-error { color: var(--danger); }
.nd-fd-chat-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; }
.nd-fd-chat-typing { align-self: flex-start; color: var(--muted); font-size: 13px; }
.nd-fd-chat-form { display: flex; gap: 8px; }
.nd-fd-chat-form .nd-input { flex: 1; min-width: 0; }

/* Test chat as standalone app (/test_chat/): header bar + the chat panel filling the window */
.nd-tc-body { height: 100vh; height: 100dvh; margin: 0; padding: 10px; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.nd-tc-header { display: flex; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: wrap; flex: none; }
.nd-tc-brand { display: flex; align-items: center; gap: 10px; }
.nd-tc-brand h1 { margin: 0; font-size: 1.1rem; white-space: nowrap; }
.nd-tc-logo { flex: none; }
.nd-tc-tenant { flex: 1; display: flex; }
.nd-tc-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nd-tc-main { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; }
.nd-fd-chat.nd-tc-panel { position: static; width: 100%; max-width: 920px; box-shadow: none; }
.nd-tc-spacer { flex: 1; }
.nd-tc-denied { align-self: center; }
.nd-tc-denied h2 { margin-top: 0; }
@media (max-width: 560px) {
  .nd-tc-body { padding: 6px; gap: 6px; }
  .nd-tc-header { padding: 6px 8px; gap: 8px; }
  .nd-tc-user { display: none; }
  .nd-tc-tenant { order: 3; flex-basis: 100%; }
  .nd-fd-chat.nd-tc-panel { padding: 10px; }
}

/* Home: test chat launcher, bottom right below the section tiles */
.nd-home { min-height: 100%; display: flex; flex-direction: column; }
.nd-home-corner { margin-top: auto; padding-top: 14px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: flex-end; }
.nd-home-tile.nd-home-chat-tile { --tile-color: var(--accent); width: min(320px, 100%); min-height: 120px; }
.nd-home-tile.nd-home-app-tile { width: min(320px, 100%); min-height: 120px; }

/* Apps: botconfig console and administration app, chosen per browser tab (new/base.html) */
.nd-app-scope { display: contents; }
html[data-nd-app="admin"] [data-nd-app-item="botconfig"],
html:not([data-nd-app="admin"]) [data-nd-app-item="admin"] { display: none !important; }
.nd-app-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  color: var(--section-documentation);
  background: color-mix(in srgb, var(--section-documentation) 16%, transparent);
}
.nd-btn.nd-app-switch { text-decoration: none; white-space: nowrap; }
.nd-dialog.nd-app-chooser { width: min(820px, calc(100vw - 32px)); }
.nd-app-chooser-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 6px; }
.nd-app-chooser-grid .nd-home-tile { cursor: pointer; font: inherit; }
.nd-app-chooser-hint { position: relative; margin: auto 0 0; font-size: 13px; }
@media (max-width: 560px) {
  .nd-app-chooser-grid { grid-template-columns: 1fr; }
  .nd-app-chooser-grid .nd-home-tile { min-height: 110px; }
}
.nd-home-chat-hint { position: relative; margin: 0; padding-right: 64px; font-size: 13px; }

/* Global Config list */
.nd-gc-table td { overflow-wrap: anywhere; }
.nd-gc-table td:first-child { white-space: nowrap; font-weight: 600; }
.nd-fd-chat-target { margin-left: auto; display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.nd-fd-chat-target-btn { border: 0; background: transparent; color: var(--muted); padding: 0 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.nd-fd-chat-target-btn + .nd-fd-chat-target-btn { border-left: 1px solid var(--border); }
.nd-fd-chat-target-btn.is-on { background: var(--accent); color: var(--accent-text); }
.nd-fd-chat-target-btn:disabled { cursor: default; }
.nd-fd-chat-target-btn:disabled:not(.is-on) { opacity: .5; }
.nd-fd-chat-local { margin: 0; }
.nd-fd-chat-send { width: 42px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.nd-fd-chat-export { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.nd-fd-chat-export:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.nd-fd-chat-export:disabled { opacity: .4; cursor: default; }

/* ---------- profile pages (/new/profile_details/, profile_releasenotes/dataprivacy/impressum) ---------- */
/* hint line under a section heading on the profile settings page */
.nd-profile-hint { margin: -6px 0 6px; font-size: 13px; color: var(--muted); }
/* read-only documents from Helpconfig HTML: comfortable reading measure inside the section cards */
.nd-profile-doc-body { line-height: 1.6; font-size: 15px; max-width: 72ch; overflow-wrap: anywhere; }
.nd-profile-doc-body h4 { margin: 18px 0 6px; font-size: 15px; }
.nd-profile-doc-body h4:first-child { margin-top: 0; }
.nd-profile-doc-body ul { margin: 4px 0 10px; padding-left: 22px; }
.nd-profile-doc-body li { margin: 3px 0; }
.nd-profile-doc-body a { color: var(--accent); }
.nd-profile-doc-body table, .nd-profile-doc-body tbody, .nd-profile-doc-body tr, .nd-profile-doc-body td { display: block; border: 0; padding: 0; background: none; }


/* ---------- Monitoring pages (System Status, Monitor Watchdog, AudioCodes Log) ----------
   Status dots use the §7 traffic-light colours: green = ok, red = error,
   grey = no information. */
.nd-mon-section { margin-top: 18px; }
.nd-mon-section + .nd-mon-section { margin-top: 28px; }
.nd-mon-section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.nd-mon-section-head h2 { margin: 0; font-size: 16px; }
.nd-mon-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.nd-mon-legend span { display: inline-flex; align-items: center; gap: 6px; }
.nd-mon-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; background: color-mix(in srgb, var(--muted) 40%, transparent); }
.nd-mon-dot.is-ok { background: var(--ok); }
.nd-mon-dot.is-error { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.nd-mon-dot.is-unknown { background: color-mix(in srgb, var(--muted) 40%, transparent); }
.nd-table th.nd-mon-status-col, .nd-table td.nd-mon-status-col { text-align: center; width: 1%; white-space: nowrap; }
.nd-mon-static-table td .nd-mon-dot { width: 15px; height: 15px; }
.nd-mon-static-table td .nd-mon-dot.is-error { box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger) 22%, transparent); }
.nd-mon-static-table tbody tr { cursor: default; }
.nd-mon-strong { font-weight: 600; }
.nd-mon-nowrap { white-space: nowrap; }
.nd-mon-row-error td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.nd-mon-watchdog { max-width: 720px; margin-top: 14px; }
.nd-mon-detail { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 4px 0 0; font-size: 14px; }
.nd-mon-detail dt { color: var(--muted); }
.nd-mon-detail dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .nd-mon-detail { grid-template-columns: 1fr; gap: 2px; }
  .nd-mon-detail dd { margin-bottom: 8px; }
}


/* ---------- Administration admin pages (new_views_admin.py):
   Bestellungen, Neue Entitäten, LLM Modelle, User Management ---------- */
/* row icon the list engine hides per row via cls_by (e.g. no ✎ on an open
   invitation); visibility keeps the remaining icons aligned in their column */
.nd-row-icon.nd-admin-hide { visibility: hidden; pointer-events: none; }
/* read-only tables (orders, requested resources): rows open nothing */
.nd-table.nd-admin-static tbody tr { cursor: default; }
/* confirm button of the delete popups; --accent-text is dark in dark mode,
   so the label keeps its contrast on the lighter dark-mode --danger */
.nd-btn.nd-admin-danger-btn { background: var(--danger); color: var(--accent-text); }
/* Neue Entitäten detail page: label/value rows instead of form widgets */
.nd-admin-readonly .nd-field.nd-admin-kv { display: grid; grid-template-columns: minmax(160px, 34%) 1fr; align-items: start; gap: 12px; }
.nd-admin-readonly .nd-field.nd-admin-kv > label { padding-top: 8px; }
.nd-admin-readonly .nd-field.nd-admin-kv > .nd-pill { justify-self: start; margin-top: 6px; }
.nd-admin-readonly .nd-admin-value { color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.nd-admin-hours { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .nd-admin-readonly .nd-field.nd-admin-kv { grid-template-columns: 1fr; gap: 2px; }
  .nd-admin-readonly .nd-field.nd-admin-kv > label { padding-top: 0; }
}


/* ---------- Administration › Analytics (Anrufübersicht, Anrufstatistik, Konversationen) ---------- */
/* month picker in the page head (Anrufübersicht) */
.nd-analytics-period { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nd-analytics-period .nd-input { width: auto; height: 34px; padding-top: 0; padding-bottom: 0; }
.nd-analytics-period .nd-btn { height: 34px; padding: 0 12px; }
.nd-analytics-period a.nd-btn { font-size: 16px; }

/* KPI cards: label small and muted, the number large in text ink */
.nd-analytics-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 6px;
}
.nd-analytics-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}
.nd-analytics-kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; opacity: .75; }
.nd-analytics-kpi-value { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.nd-analytics-kpi.is-danger { border-color: var(--danger); }
.nd-analytics-kpi.is-danger .nd-analytics-kpi-value { color: var(--danger); }
.nd-analytics-period-note { margin-bottom: 16px; }
.nd-analytics-tabs { margin-bottom: 16px; }
/* tenant analytics: tab row with "Stand" + refresh button on the right, on the tabs' line */
.nd-analytics-tabbar { display: flex; align-items: flex-end; gap: 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.nd-analytics-tabbar .nd-analytics-tabs { flex: 1; min-width: 0; margin-bottom: -1px; border-bottom: none; flex-wrap: wrap; }
.nd-analytics-refresh { display: flex; align-items: center; gap: 10px; flex: none; padding-bottom: 6px; }
.nd-analytics-loaded { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.nd-analytics-refresh .nd-btn { height: 30px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; }

/* report / list tables: rows are not editable (no row popup) unless they carry a transcript */
.nd-analytics-table td { font-variant-numeric: tabular-nums; }
.nd-analytics-table tbody tr { cursor: default; }
.nd-analytics-table tbody tr[data-conv-id] { cursor: pointer; }
.nd-analytics-table tbody tr.is-current { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.nd-analytics-table tbody tr.nd-analytics-noconv td { color: var(--muted); }
.nd-analytics-table .nd-pill { white-space: nowrap; }

/* Anrufstatistik toolbar + charts */
.nd-analytics-report .nd-input { height: 34px; padding-top: 0; padding-bottom: 0; }
.nd-analytics-report .nd-combo { flex: none; width: 200px; max-width: 100%; }
.nd-analytics-interval { width: auto; }
.nd-analytics-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.nd-analytics-chart-card {
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px 14px;
  min-width: 0;
}
.nd-analytics-chart-card h2 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.nd-analytics-chart-box { position: relative; height: 260px; }
/* tenant analytics (/new/analytics/…): horizontal bar cards, height set per card from its row count */
.nd-analytics-charts-single { grid-template-columns: minmax(0, 1fr); }
/* cards in one grid row share its height: the chart box grows to fill the card, its own
   bar-count height (inline min-height) is the floor; the canvas is absolutely positioned so
   Chart.js sizing can never feed back into the row height */
/* wrapping flex instead of the grid: full rows keep equal card widths, an incomplete last
   row (e.g. one card under three) stretches to the full width, flush with the rows above */
.nd-analytics-charts.nd-analytics-cards { display: flex; flex-wrap: wrap; align-items: stretch; }
.nd-analytics-cards .nd-analytics-chart-card { display: flex; flex-direction: column; flex: 1 1 340px; }
.nd-analytics-table td.nd-analytics-nowrap { white-space: nowrap; }
.nd-analytics-chart-box.nd-analytics-hbar { flex: 1 1 auto; height: auto; }
.nd-analytics-chart-box.nd-analytics-hbar canvas { position: absolute; inset: 0; }
.nd-analytics-chart-card .nd-list-empty { margin: 8px 0 4px; }

/* Konversationen: tenant facet search + transcript popup */
.nd-analytics-facet-search { width: 100%; margin: 4px 0 6px; }
/* table and transcript side by side, each half of the box; the transcript panel stays
   in view (sticky) and scrolls on its own */
.nd-conv-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.nd-conv-list { min-width: 0; }
.nd-conv-list .nd-table-wrap { overflow-x: auto; }
.nd-conv-list .nd-table th, .nd-conv-list .nd-table td { padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.nd-conv-list .nd-table td:nth-child(2) { white-space: normal; min-width: 80px; }
.nd-conv-chat {
  position: sticky;
  top: calc(var(--page-head-h, 0px) + 8px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100vh - var(--page-head-h, 0px) - 140px);
  min-height: 320px;
  padding: 12px 14px 14px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.nd-conv-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.nd-conv-chat-head h2 { margin: 0; font-size: 15px; }
.nd-conv-chat-actions { display: flex; gap: 6px; }
.nd-conv-chat-actions .nd-btn:disabled { opacity: .4; cursor: default; }
.nd-conv-chat .nd-analytics-conv-meta { margin: 0 0 8px; min-height: 1.2em; }
.nd-conv-chat-note { margin: auto; text-align: center; max-width: 36ch; }
@media (max-width: 1100px) {
  .nd-conv-split { grid-template-columns: minmax(0, 1fr); }
  .nd-conv-chat { position: static; height: 60vh; }
}
.nd-analytics-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.nd-analytics-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.nd-analytics-msg-who { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; opacity: .75; }
.nd-analytics-msg.is-bot { align-self: flex-start; background: var(--raised); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.nd-analytics-msg.is-user { align-self: flex-end; background: var(--chat-user-bg); color: var(--chat-user-text); border-bottom-right-radius: 4px; }

/* dark mode: the bot bubble sits on --raised, which equals the dialog background — lift it a little */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nd-analytics-msg.is-bot { background: color-mix(in srgb, var(--text) 8%, var(--raised)); }
}
:root[data-theme="dark"] .nd-analytics-msg.is-bot { background: color-mix(in srgb, var(--text) 8%, var(--raised)); }


/* ---------- Kalender (/new/fullcalendar/) ---------- */
:root { --nd-cal-sel: color-mix(in srgb, var(--accent) 28%, transparent); --nd-cal-hover: color-mix(in srgb, var(--accent) 9%, transparent); }
.nd-cal-head { flex-wrap: wrap; }
.nd-cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nd-cal-tool { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.nd-cal-tool .nd-input, .nd-cal-filter { width: auto; padding: 5px 8px; }
.nd-cal-toolbar .nd-actions { position: relative; }
.nd-cal { display: flex; align-items: flex-start; gap: 20px; }
.nd-cal-side { flex: none; display: flex; flex-direction: column; gap: 10px; }
.nd-cal-side.nd-filter-panel { width: 250px; padding: 14px 16px; }
.nd-cal-side[hidden] { display: none; }
.nd-cal-side .nd-filter-head { margin-bottom: 4px; }
.nd-cal-side .nd-filter-head-icon { filter: grayscale(1); opacity: .6; }
.nd-cal-side > input.flatpickr-input, .nd-cal-side > input.flatpickr-input2 { display: none !important; }
.nd-cal-side .flatpickr-calendar { margin-top: 0 !important; zoom: .7; }
.nd-cal-main { flex: 1; min-width: 0; position: relative; background: var(--sunken); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.nd-cal-picker-btn {
  position: absolute; top: 14px; left: 16px; z-index: 2;
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--raised); font-size: 16px; cursor: pointer;
  filter: grayscale(1); opacity: .6;
}
.nd-cal-picker-btn:hover { opacity: .9; border-color: var(--accent); }
.nd-cal-main .ec-toolbar > :first-child { margin-left: 44px; }
.nd-cal-tooltip {
  display: none; position: fixed; pointer-events: none; z-index: 60;
  padding: 5px 9px; border-radius: 7px; font-size: 13px;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
@media (max-width: 1000px) { .nd-cal { flex-direction: column; } .nd-cal-side.nd-filter-panel { width: 100%; position: static; max-height: none; } }

/* EventCalendar + flatpickr follow the theme tokens */
.nd-cal-main .ec, .nd-cal-dialog .ec {
  --ec-bg-color: var(--raised);
  --ec-bg-fallback-color: var(--raised);
}
.nd-cal-main .ec {
  --ec-bg-color: var(--sunken);
  --ec-bg-fallback-color: var(--sunken);
}
.nd-cal-main .ec, .nd-cal-dialog .ec {
  --ec-text-color: var(--text);
  --ec-border-color: var(--border);
  --ec-accent-color: var(--accent);
  --ec-button-bg-color: var(--sunken);
  --ec-button-border-color: var(--border);
  --ec-button-text-color: var(--text);
  --ec-button-active-bg-color: var(--accent);
  --ec-button-active-border-color: var(--accent);
  --ec-button-active-text-color: var(--accent-text);
  --ec-today-bg-color: color-mix(in srgb, var(--accent) 10%, transparent);
  --ec-list-day-bg-color: var(--sunken);
  --ec-popup-bg-color: var(--raised);
  --ec-highlight-color: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
}
.nd-cal-main .ec-toolbar { margin-bottom: 10px; }
.nd-cal-main .ec-title { font-size: 1.15rem; }
.nd-cal-main .ec-button { font: inherit; font-size: 13px; font-weight: 600; border-radius: 6px; padding: 5px 11px; }
body .flatpickr-calendar { background: var(--raised); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
body .flatpickr-calendar.inline { box-shadow: none; }
body .flatpickr-calendar.arrowTop::before, body .flatpickr-calendar.arrowTop::after, body .flatpickr-calendar.arrowBottom::before, body .flatpickr-calendar.arrowBottom::after { display: none; }
body .flatpickr-months .flatpickr-month, body .flatpickr-current-month .flatpickr-monthDropdown-months, body .flatpickr-current-month input.cur-year,
body span.flatpickr-weekday, body .flatpickr-day, body .flatpickr-months .flatpickr-prev-month, body .flatpickr-months .flatpickr-next-month { color: var(--text); fill: var(--text); background: transparent; }
body .flatpickr-current-month .flatpickr-monthDropdown-months option { background: var(--raised); color: var(--text); }
body .flatpickr-day:hover, body .flatpickr-day:focus { background: var(--sunken); border-color: var(--border); }
body .flatpickr-day.today { border-color: var(--accent); }
body .flatpickr-day.selected, body .flatpickr-day.selected:hover, body .flatpickr-day.startRange, body .flatpickr-day.endRange { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
body .flatpickr-day.inRange { background: var(--nd-cal-hover); border-color: transparent; box-shadow: none; }
body .flatpickr-day.prevMonthDay, body .flatpickr-day.nextMonthDay, body .flatpickr-day.flatpickr-disabled { color: var(--muted); opacity: .55; }

/* entry wizard (#popup1) */
.nd-dialog.nd-cal-dialog { width: min(980px, calc(100vw - 32px)); }
.nd-dialog.nd-cal-upload { width: min(720px, calc(100vw - 32px)); }
.nd-cal-dialog .nd-dialog-head { flex-wrap: wrap; }
.nd-cal-dialog .nd-dialog-actions { flex-wrap: wrap; justify-content: flex-end; }
.nd-btn.nd-cal-next { background: var(--accent); color: var(--accent-text); }
.nd-cal-step h3 { margin: 0 0 12px; font-size: 1rem; }
.nd-cal-step .nd-field { padding: 8px 2px; }
.nd-cal-step .nd-error:empty { display: none; }
.nd-cal-step .nd-field.nd-cal-plain, .nd-cal-step .nd-field:has(+ .nd-cal-plain) { border-bottom: none; }
.nd-cal-search-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.nd-cal-search-row .nd-input { flex: 1; }
.nd-cal-customers { max-height: 52vh; overflow: auto; }
.nd-cal-customers td, .nd-cal-customers th { white-space: nowrap; }
.nd-cal-customers th[data-cust-sort] { cursor: pointer; user-select: none; }
.nd-cal-customers tbody tr, .nd-cal-services tbody tr { cursor: pointer; }
.nd-cal-customers tbody tr.is-selected td, .nd-cal-services tbody tr.is-selected td { background: var(--nd-cal-sel); }
.nd-cust-layout { gap: 14px; }
.nd-cust-layout .nd-filter-panel { width: 240px; position: static; max-height: 62vh; padding: 12px 14px; }
.nd-cust-layout .nd-list-filter-row { margin-bottom: 12px; }
.nd-cust-layout .nd-cust-search { flex: 1; min-width: 160px; }
.nd-cust-layout .nd-filter-value[hidden] { display: none; }
/* CRM page (/new/customer/): same customer list engine as the calendar wizard, full page width */
.nd-crm-search { flex: 1; min-width: 160px; }
#nd-crm-list .nd-filter-value[hidden] { display: none; }
.nd-crm-table th[data-cust-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.nd-crm-table td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.nd-crm-table td.nd-actions-col { overflow: visible; }
.nd-dialog.nd-crm-dialog { width: min(820px, calc(100vw - 32px)); }
.nd-crm-dialog .nd-form { max-width: none; }
.nd-crm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.nd-crm-grid .nd-crm-wide { grid-column: 1 / -1; }
.nd-crm-grid .nd-field input[type="date"] { width: 100%; }
.nd-crm-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nd-crm-switch label { margin-bottom: 0; }
.nd-crm-subhead { margin: 18px 0 4px; font-size: 1rem; }
@media (max-width: 700px) { .nd-crm-grid { grid-template-columns: minmax(0, 1fr); } }
.nd-crm-file { color: var(--text); font: inherit; }
.nd-crm-file::file-selector-button {
  margin-right: 10px; padding: 7px 14px; border: none; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--sunken); color: var(--text); box-shadow: inset 0 0 0 1px var(--border);
}
.nd-crm-file::file-selector-button:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.nd-crm-import-table td { vertical-align: middle; }
.nd-crm-import-table tbody tr { cursor: default; }
.nd-crm-import-table .nd-crm-import-sample { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-crm-import-table select { min-width: 200px; }
.nd-chip-clear-link { font-size: 12.5px; color: var(--accent); text-decoration: none; }
.nd-chip-clear-link:hover { text-decoration: underline; }
.nd-cal-services .nd-cal-svc-check { width: 90px; }
.nd-cal-services tbody tr.is-disabled { cursor: not-allowed; }
.nd-cal-services tbody tr.is-disabled td { color: var(--muted); opacity: .55; }
.nd-cal-services tbody tr.is-disabled:hover td { background: none; }
#id_customer { display: none; }
.nd-cal-pages { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 0; }
.nd-cal-pages button { min-width: 30px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--sunken); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.nd-cal-pages button:disabled { background: var(--accent); border-color: var(--accent); color: var(--accent-text); cursor: default; }
.nd-cal-results { margin-top: 12px; max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--sunken); }
.nd-cal-results:empty { display: none; }
.nd-cal-results .nd-help { margin: 12px; }
.nd-cal-dialog table.customer-table, .nd-cal-dialog table.cal_table, .nd-cal-serviceinfo table { width: 100%; border-collapse: collapse; font-size: 14px; }
.nd-cal-dialog table.customer-table td, .nd-cal-dialog table.cal_table td, .nd-cal-dialog table.cal_table th, .nd-cal-serviceinfo td {
  padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left;
}
.nd-cal-dialog table.cal_table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; opacity: .75; }
.nd-cal-dialog table.customer-table tr:last-child td, .nd-cal-dialog table.cal_table tr:last-child td { border-bottom: none; }
.nd-cal-details > label { display: block; font-weight: 700; margin: 12px 0 6px; }
.nd-cal-details > input, .nd-cal-details > select, .nd-cal-dialog .nd-field input, .nd-cal-dialog .nd-field select,
.nd-cal-time select, .nd-cal-dialog #id_no_of_resources {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--sunken); color: var(--text); font: inherit;
}
.nd-cal-time select { width: auto; margin-left: 6px; }
.nd-cal-dialog .is-invalid { border-color: var(--danger) !important; }
.nd-cal-date-row { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nd-cal-time { font-weight: 600; }
.nd-cal-datepop { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; }
.nd-cal-datepop > input { display: none; }
.nd-cal-serviceinfo { margin: 10px 0; }
.nd-cal-serviceinfo:empty { display: none; }
.nd-cal-serviceinfo .nd-cal-inline { width: auto; min-width: 90px; max-width: 260px; padding: 4px 8px; }
.nd-cal-serviceinfo input.nd-cal-inline { width: 90px; }
.nd-dialog.nd-cal-crm-popup { width: min(980px, calc(100vw - 32px)); height: calc(100vh - 64px); max-height: none; padding: 0; overflow: hidden; }
.nd-cal .ec-list .ec-event-body { flex: 1; min-width: 0; }
.nd-cal .ec-list article.ec-event:nth-of-type(even) { background-color: color-mix(in srgb, var(--text) 5%, transparent); }
.nd-cal .ec-list article.ec-event:hover { background-color: color-mix(in srgb, var(--accent) 12%, transparent); }
.nd-dl-row, .nd-dl-head { display: grid; grid-template-columns: 16px 150px 64px minmax(140px, 1.4fr) minmax(140px, 1.4fr) 150px 32px 32px; gap: 10px; align-items: center; min-width: 800px; }
.nd-dl-head { padding: 6px 14px 6px 26px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--border); }
.nd-dl-row > span { white-space: pre-line; overflow-wrap: anywhere; }
.nd-dl-toggle { color: var(--muted); transition: transform .15s; }
.nd-dl-item.is-open .nd-dl-toggle { transform: rotate(90deg); }
.nd-dl-more { display: none; cursor: default; }
.nd-dl-item.is-open .nd-dl-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 8px; padding: 10px 0 4px 26px; border-top: 1px dashed var(--border); }
.nd-dl-more h4 { margin: 0 0 4px; font-size: 13px; }
.nd-dl-more .cal_table td { padding: 4px 8px; }
.nd-dl-more .nd-help { margin: 0; }
.nd-dialog.nd-crm-appts-dialog { width: min(1100px, calc(100vw - 32px)); }
.nd-crm-appts-dialog .nd-appt-toolbar { flex-wrap: wrap; margin-bottom: 10px; }
.nd-crm-appts-dialog .nd-appt-search { flex: 1 1 220px; }
.nd-crm-appts-dialog .nd-table-wrap { max-height: calc(100vh - 300px); overflow: auto; }
.nd-crm-appts-dialog tbody tr { cursor: pointer; }
/* CRM "Termine" → entry wizard: the outer popup is only an invisible full-screen layer for the
   iframe; the calendar inside shows nothing but its own wizard dialog (no second, larger frame) */
.nd-dialog.nd-crm-wizard-popup { inset: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; padding: 0; overflow: hidden; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.nd-cal-crm-popup iframe, .nd-crm-wizard-popup iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.nd-crm-wizard-popup iframe { background: transparent; }
html:has(body.nd-embed #popup1), body.nd-embed:has(#popup1) { background: transparent; }
body.nd-embed:has(#popup1) #nd-frame, body.nd-embed:has(#popup1) #nd-frame * { visibility: hidden !important; }
body.nd-embed .nd-cal-dialog::backdrop { background: transparent; }
body.nd-embed .nd-cal-head,
body.nd-embed .nd-cal,
body.nd-embed .nd-cal-tooltip { visibility: hidden; }
body.nd-embed .nd-page-head,
body.nd-embed #nd-crm-list { display: none; }
body.nd-embed .nd-dialog.nd-crm-dialog[open] { position: static; margin: 0; width: 100%; max-width: none; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
.nd-cal-info-section { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; }
.nd-cal-info-section > summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
.nd-cal-info-section[open] > summary { border-bottom: 1px solid var(--border); }
.nd-cal-info-section > .nd-help { margin: 8px 12px; }
.nd-cal-info-section tr:last-child td { border-bottom: none; }
.nd-cal-date-step { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.nd-cal-date-left { grid-column: 1; grid-row: 1; min-width: 0; }
.nd-cal-date-right,
.nd-cal-date-left .nd-cal-serviceinfo { background: var(--sunken); border: 1px solid var(--border); border-radius: 10px; }
.nd-cal-date-left .nd-cal-serviceinfo { margin: 0; padding: 6px 12px 12px; }
.nd-cal-date-right { grid-column: 2; grid-row: 1; padding: 12px 14px; min-width: 0; }
.nd-cal-date-right > h3 { margin-top: 0; }
.nd-cal-date-right .ec { margin-top: 10px; }
@media (max-width: 760px) {
  .nd-cal-date-step { grid-template-columns: minmax(0, 1fr); }
  .nd-cal-date-right { grid-column: 1; grid-row: 2; }
}
.nd-cal-map { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 14px; }
.nd-cal-map h4 { margin: 0 0 6px; }
.nd-cal-map select { min-height: 180px; }
.nd-cal-map-btns { display: flex; flex-direction: column; gap: 8px; }
.nd-cal-mappings { margin-top: 14px; }
.nd-cal-upload-form input[type="file"] { color: var(--text); }

/* loading overlay (#nd-loading in new/base.html): shown while a slow server-rendered page
   (e.g. Analytics) is being computed — see the "loading overlay" block in new_design.js */
.nd-loading-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg, #000) 45%, transparent);
  backdrop-filter: blur(1px);
}
.nd-loading-overlay[hidden] { display: none; }
.nd-loading-box {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-radius: 12px;
  background: var(--raised); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35); font-weight: 600;
}
.nd-spinner {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: nd-spin .8s linear infinite;
}
@keyframes nd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nd-spinner { animation-duration: 2.4s; } }


/* ---------- Organisation (/new/organisation/): department tree left, editor right ---------- */
/* same height + gap as the editor head on the right, so the search lines up with the first editor box */
.nd-org-tree-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; margin-bottom: 16px; flex-wrap: wrap; }
.nd-org-tree-col.nd-fd-scroll-col > .nd-org-tree-head { margin-top: -4px; padding: 4px 0 8px; min-height: 46px; }
.nd-org-search { margin-bottom: 12px; }
.nd-org-search .nd-fd-empty { margin-top: 10px; }
.nd-org-item.is-match > .nd-org-node { border-color: var(--accent); }
.nd-org-tree-col [hidden] { display: none !important; }
.nd-org-tree-head h2 { margin: 0; font-size: 15px; }
.nd-org-tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nd-org-tree > .nd-fd-subitem::before { display: none; }
.nd-org .nd-fd-subitem { cursor: default; }
.nd-org-icon { flex: none; width: 20px; text-align: center; font-size: 13px; }
.nd-org-node.is-dept .nd-fd-subnode-label { font-weight: 700; }
.nd-org-node.is-emp .nd-fd-subnode-label { font-weight: 500; }
.nd-org-loose-head { margin: 16px 2px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.nd-org-tree-col .nd-fd-legend { margin-top: 14px; }
.nd-org-crumb { font-size: 14px; color: var(--muted); font-weight: 500; }

/* ---------- organisation picker in phone / e-mail fields (new/_org_pick.html) ---------- */
.nd-org-pick { position: relative; }
.nd-org-pick-row { display: flex; gap: 6px; align-items: stretch; }
.nd-org-pick-row > .nd-input { flex: 1; min-width: 0; }
.nd-org-pick-btn { flex: none; padding: 0 10px; font-size: 15px; line-height: 1; }
.nd-org-pick.is-linked .nd-org-pick-row > .nd-input { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.nd-org-pick-link { margin: 4px 0 0; }
.nd-org-pick-link span { font-weight: 600; color: var(--text); }
.nd-org-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  padding: 8px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
.nd-org-pop-search { flex: none; }
.nd-org-pop-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.nd-org-pop-group { margin: 6px 4px 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.nd-org-pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nd-org-pop-item:hover, .nd-org-pop-item:focus-visible { outline: none; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.nd-org-pop-item.is-current { border-color: var(--accent); }
.nd-org-pop-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nd-org-pop-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-org-pop-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-org-pop-value { flex: none; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nd-org-pop-empty { margin: 8px 4px; font-size: 13px; color: var(--muted); }
.nd-org-pop-manage { flex: none; align-self: flex-end; font-size: 12.5px; color: var(--accent); text-decoration: none; padding: 2px 4px; }
.nd-org-pop-manage:hover { text-decoration: underline; }

/* clear button inside search fields (input[data-nd-clear]) */
.nd-clear-wrap { position: relative; display: block; }
.nd-clear-wrap > .nd-input { padding-right: 34px; }
.nd-clear-wrap > input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.nd-clear-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.nd-clear-btn:hover { color: var(--text); background: color-mix(in srgb, var(--muted) 18%, transparent); }
.nd-clear-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nd-clear-btn[hidden] { display: none; }

/* organisation tree: levels 1 + 2 open by default, deeper branches collapse (▸ on the department) */
.nd-org-item.has-children > .nd-org-node { padding-right: 34px; }
.nd-org-caret {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease;
}
.nd-org-caret:hover { color: var(--text); background: color-mix(in srgb, var(--muted) 18%, transparent); }
.nd-org-caret:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nd-org-caret[aria-expanded="true"] { transform: rotate(90deg); }
.nd-org-tree-col:not(.is-searching) .nd-org-subtree.is-collapsed { display: none; }
.nd-org-tree-col.is-searching .nd-org-caret { visibility: hidden; }

/* ---------- login (/register/) and tenant selection after login (/new/select_tenant/) ---------- */
.nd-login-tools {
  position: fixed;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nd-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 16px 32px;
}
.nd-login-card { width: min(400px, 100%); padding: 24px 24px 20px; }
.nd-login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.nd-login-brand h1 { margin: 0; font-size: 1.3rem; }
.nd-login-brand .nd-help { margin: 2px 0 0; }
.nd-login-logo { width: 42px; height: 42px; font-size: 20px; flex: none; }
.nd-login-logo:hover { transform: none; }
.nd-login-form { display: flex; flex-direction: column; }
.nd-login-form .nd-field { display: flex; flex-direction: column; gap: 6px; padding: 10px 2px; }
.nd-login-form .nd-field:hover { background: none; }
.nd-login-form .nd-field input { width: 100%; }
.nd-login-error {
  margin: 0 0 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--err-bg);
  color: var(--danger);
  font-size: 13px;
}
.nd-login-submit { justify-content: center; margin-top: 16px; padding: 9px 12px; font-size: 14px; }
.nd-login-forgot { align-self: center; margin-top: 12px; font-size: 13px; }
.nd-login-actions { display: flex; justify-content: flex-end; gap: 8px; }
.nd-login-card > p { margin: 0 0 14px; }
.nd-login-card .nd-login-form .nd-login-actions { margin-top: 16px; }
.nd-login-card .nd-login-form > .nd-help { margin: 0 0 8px; }
.nd-2fa-qr { display: block; width: 200px; max-width: 100%; margin: 4px auto 8px; padding: 8px; border-radius: 8px; background: #fff; }
.nd-dialog.nd-2fa-dialog { width: min(420px, calc(100vw - 32px)); }
.nd-2fa-intro { margin: 0 0 12px; }
.nd-2fa-code {
  width: 100%;
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: .35em;
  font-variant-numeric: tabular-nums;
  padding: 10px 12px;
}

/* ---------- help pages (/new/help_*/): document layout + data tables and screenshots ---------- */
.nd-profile-doc-body .nd-help-table-wrap { display: block; margin: 10px 0 14px; overflow-x: auto; }
.nd-profile-doc-body table.nd-help-table { display: table; width: 100%; border-collapse: collapse; }
.nd-profile-doc-body .nd-help-table tbody { display: table-row-group; }
.nd-profile-doc-body .nd-help-table tr { display: table-row; }
.nd-profile-doc-body .nd-help-table th,
.nd-profile-doc-body .nd-help-table td {
  display: table-cell;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.5;
}
.nd-profile-doc-body .nd-help-table td:first-child { font-weight: 600; white-space: nowrap; }
.nd-profile-doc-body .nd-help-table tr:last-child td { border-bottom: none; }
.nd-profile-doc-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
[id^="nd-profile-doc-help_"] .nd-profile-doc-body { max-width: none; }
.nd-profile-doc-body .nd-help-table tbody tr { cursor: default; }
/* help pages: the text cards use the whole width next to the section navigator */
.nd-form-layout > .nd-form[id^="nd-profile-doc-help_"] { flex: 1 1 auto; max-width: none; }
/* help pages: right edge of the cards = right edge of the header content
   (header padding 14px); the scrollbar moves to the frame's edge */
.nd-frame:has(.nd-form[id^="nd-profile-doc-help_"]) { padding-right: 0; }
.nd-frame:has(.nd-form[id^="nd-profile-doc-help_"]) .nd-frame-content { padding-right: 14px; }
.nd-frame:has(.nd-form[id^="nd-profile-doc-help_"]) .nd-frame-footer { margin-right: 14px; }

/* list cell with long free text (e.g. Ansagen): readable width, keeps line breaks */
.nd-table td.nd-cell-text { max-width: 480px; white-space: pre-line; }

/* wizard (Tenant klonen, /new/profile_new_entity/clone/): progress bar with numbered steps
   above one centred form column; the bar stripes while the server creates the tenant */
.nd-wizard-progress { max-width: 832px; margin: 4px 0 18px; }
.nd-wizard-bar { height: 6px; border-radius: 999px; background: var(--sunken); border: 1px solid var(--border); overflow: hidden; }
.nd-wizard-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
.nd-wizard-progress.is-ready .nd-wizard-bar-fill { transition: width .3s ease; }
.nd-wizard-progress.is-running .nd-wizard-bar-fill {
  width: 100% !important;
  background-image: linear-gradient(45deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%);
  background-size: 24px 24px;
  animation: nd-wizard-stripes .8s linear infinite;
}
@keyframes nd-wizard-stripes { to { background-position: 24px 0; } }
.nd-wizard-steps { display: flex; justify-content: space-between; gap: 8px; list-style: none; margin: 10px 0 0; padding: 0; }
.nd-wizard-steps li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.nd-wizard-num {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface);
}
.nd-wizard-steps li.is-done .nd-wizard-num { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); border-color: var(--accent); color: var(--text); }
.nd-wizard-steps li.is-current { color: var(--text); font-weight: 700; }
.nd-wizard-steps li.is-current .nd-wizard-num { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.nd-wizard-running { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.nd-wizard-form { max-width: 832px; }
.nd-wizard-source { font-weight: 400; font-size: .7em; color: var(--muted); }
.nd-wizard-summary { display: flex; flex-direction: column; }
.nd-wizard-row {
  display: flex; justify-content: space-between; gap: 16px; padding: 10px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.nd-wizard-row > span:first-child { font-weight: 700; flex: none; }
.nd-wizard-count { color: var(--muted); text-align: right; }
.nd-wizard-sub { padding: 0 2px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.nd-wizard-summary > :last-child { border-bottom: none; }
@media (max-width: 640px) {
  .nd-wizard-label { display: none; }
  .nd-wizard-steps li.is-current .nd-wizard-label { display: inline; }
}
.nd-save-bar .nd-btn[hidden] { display: none; }

/* list column type "clip": one line, cut off with …, full text in the tooltip */
.nd-cell-clip { display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tenant-Zuordnung (profile_tenant_users.html): shared popup with a searchable checkbox list */
.nd-tu-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.nd-tu-toolbar .nd-input { flex: 1; min-width: 0; }
.nd-tu-only { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 400; color: var(--muted); }
.nd-tu-list {
  max-height: min(50vh, 420px); overflow-y: auto; border: 1px solid var(--border);
  border-radius: 6px; background: var(--sunken); padding: 4px 0;
}
.nd-tu-item { display: flex; align-items: center; gap: 10px; padding: 4px 12px; min-height: 34px; }
.nd-tu-item[hidden] { display: none; }
.nd-tu-item:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.nd-tu-list .nd-tu-check { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 400; margin: 0; }
.nd-tu-list .nd-tu-check input { flex: none; }
.nd-tu-role { flex: 0 0 210px; }
.nd-tu-role .nd-combo[hidden], .nd-tu-role select[hidden], .nd-tu-fixed[hidden] { display: none; }
.nd-tu-role .nd-input { padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.nd-tu-fixed { font-size: 13px; color: var(--muted); }
.nd-tu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.nd-tu-meta { flex: none; font-size: 12px; color: var(--muted); }
.nd-tu-badge { flex: none; font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); }
.nd-tu-empty { padding: 6px 12px; margin: 0; }
.nd-tu-empty[hidden] { display: none; }
@media (max-width: 640px) {
  .nd-tu-toolbar { flex-direction: column; align-items: stretch; }
  .nd-tu-meta { display: none; }
  .nd-tu-item { flex-wrap: wrap; }
  .nd-tu-role { flex-basis: 100%; padding-left: 24px; }
}

/* User Management (new/profile_users.html): tenant popup in the tenant-switch
   look with a switch and a role per tenant */
.nd-pu-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  vertical-align: middle;
  cursor: pointer;
  transition: background .15s;
}
.nd-pu-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.nd-pu-switch:checked { background: var(--accent); }
.nd-pu-switch:checked::after { transform: translateX(14px); }
.nd-pu-switch:disabled { opacity: .5; cursor: default; }
.nd-pu-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nd-field label.nd-pu-switch-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.nd-field input[data-pu-active]:disabled { opacity: .5; cursor: default; }
.nd-pu-tenant-dialog .nd-tu-toolbar { margin-bottom: 10px; }
.nd-pu-tenant-table th.nd-pu-col-switch, .nd-pu-tenant-table th.nd-pu-col-switch:first-child { width: 56px; }
.nd-pu-tenant-table th:nth-child(2) { width: 20%; }
.nd-pu-tenant-table th.nd-pu-col-role { width: 200px; }
.nd-pu-tenant-table td.nd-pu-col-switch { text-overflow: clip; }
.nd-pu-tenant-table td.nd-pu-col-role { overflow: visible; padding-top: 2px; padding-bottom: 2px; }
.nd-pu-tenant-table td.nd-pu-col-role .nd-input { padding-top: 3px; padding-bottom: 3px; font-size: 13px; }
.nd-pu-tenant-table td.nd-pu-col-role .nd-combo[hidden], .nd-pu-tenant-table td.nd-pu-col-role select[hidden] { display: none; }
.nd-pu-tenant-table tbody tr.nd-pu-trow { cursor: pointer; }
.nd-pu-badge { margin-left: 8px; }
@media (max-width: 760px) {
  .nd-pu-tenant-table th:nth-child(n+3):nth-child(-n+8), .nd-pu-tenant-table td:nth-child(n+3):nth-child(-n+8) { display: none; }
}

/* --- neuer Bot-Stack: Kontextleiste (Template-Modus / Instanz / Clone), Code-Felder --- */
.nd-ng-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--border); }
.nd-ng-context p { margin: 0; }
.nd-ng-context-actions { display: flex; gap: 8px; }
.nd-ng-context-actions form { margin: 0; }
.nd-ng-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
/* neuer Bot-Stack: Stammdaten / Öffnungszeiten */
.nd-ng-area-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.nd-ng-day { padding: 8px 0; border-bottom: 1px solid var(--border); }
/* both rows of a day ("Geöffnet" / "Zeitraum 2") keep their time fields aligned on one line */
.nd-ng-day .nd-weekday-row { flex-wrap: nowrap; gap: 10px 12px; }
.nd-ng-day .nd-weekday-label { width: 90px; }
.nd-ng-day .nd-day-toggle { width: 124px; }
@media (max-width: 800px) { .nd-ng-day .nd-weekday-row { flex-wrap: wrap; } }
.nd-ng-day:last-child { border-bottom: 0; }
.nd-ng-inline-form { display: flex; align-items: flex-end; gap: 12px; margin-top: 12px; }
.nd-ng-inline-form .nd-field { margin: 0; flex: 1 1 auto; }
.nd-ng-time-optional { padding: 0; }
/* neuer Bot-Stack: Template-Updates */
.nd-ng-update-detail td { padding-top: 0; }
.nd-ng-update-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; }
.nd-ng-update-cols h4 { margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.nd-ng-diff { margin: 0; padding-left: 0; list-style: none; font-size: 13.5px; }
.nd-ng-diff .is-added { color: var(--ok); }
.nd-ng-diff .is-removed { color: var(--danger); }
.nd-ng-radio label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.nd-ng-radio .nd-input[type="datetime-local"] { max-width: 260px; }
