/* =====================================================================
   GatePortal design system
   Bootstrap 5.3 + tokens. The tenant color arrives as --portal-primary /
   --portal-primary-rgb (see Pages/Shared/_Head.cshtml) and is mapped onto
   Bootstrap's primary so every .btn-primary, .text-primary, focus ring,
   link, ... follows the tenant branding.
   ===================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../lib/inter/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../lib/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */
:root,
[data-bs-theme="light"] {
  --portal-primary: #0E3A2F;
  --portal-primary-rgb: 14, 58, 47;
  /* Secondary brand color for highlights (active nav, glows, dark-mode charts). Tenant themes override it. */
  --portal-accent: color-mix(in srgb, var(--portal-primary) 45%, #7ee2b8);

  --ui-radius-sm: .5rem;
  --ui-radius: .75rem;
  --ui-radius-lg: 1rem;
  --ui-sidebar-w: 268px;
  --ui-sidebar-w-collapsed: 76px;
  --ui-topbar-h: 64px;
  --ui-ease: cubic-bezier(.2, .7, .2, 1);

  --ui-bg: #f4f6fa;
  --ui-surface: #ffffff;
  --ui-surface-2: #f8fafc;
  --ui-border: #e6e9f0;
  --ui-border-strong: #d5dae4;
  --ui-text: #172033;
  --ui-text-muted: #64708a;
  --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --ui-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --ui-shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .08);

  /* Sidebar: deep slate tinted with the tenant color, in both themes. */
  --ui-sidebar-bg: color-mix(in srgb, var(--portal-primary) 22%, #0b1220);
  --ui-sidebar-fg: rgba(255, 255, 255, .72);
  --ui-sidebar-fg-strong: #fff;
  --ui-sidebar-hover: rgba(255, 255, 255, .07);
  --ui-sidebar-active: rgba(255, 255, 255, .12);
  --ui-sidebar-accent: var(--portal-accent);

  --ui-primary-soft: color-mix(in srgb, var(--portal-primary) 10%, transparent);
  --ui-primary-strong: color-mix(in srgb, var(--portal-primary) 85%, black);
}

[data-bs-theme="dark"] {
  --ui-bg: #0d1117;
  --ui-surface: #151b23;
  --ui-surface-2: #1b222c;
  --ui-border: #262f3b;
  --ui-border-strong: #33404f;
  --ui-text: #e6eaf2;
  --ui-text-muted: #94a0b4;
  --ui-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --ui-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  --ui-shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .7);
  --ui-sidebar-bg: color-mix(in srgb, var(--portal-primary) 14%, #080c12);
  /* Dark tenant colors are too dim on dark surfaces: lift them for text and accents. */
  --ui-primary-soft: color-mix(in srgb, var(--portal-primary) 30%, transparent);
  --ui-primary-strong: color-mix(in srgb, var(--portal-primary) 40%, white);
}

/* Map onto Bootstrap */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-primary: var(--portal-primary);
  --bs-primary-rgb: var(--portal-primary-rgb);
  --bs-primary-bg-subtle: var(--ui-primary-soft);
  --bs-primary-border-subtle: color-mix(in srgb, var(--portal-primary) 30%, transparent);
  --bs-primary-text-emphasis: var(--ui-primary-strong);
  --bs-body-bg: var(--ui-bg);
  --bs-body-color: var(--ui-text);
  --bs-secondary-color: var(--ui-text-muted);
  --bs-tertiary-bg: var(--ui-surface-2);
  --bs-border-color: var(--ui-border);
  --bs-border-radius: var(--ui-radius-sm);
  --bs-border-radius-lg: var(--ui-radius);
  --bs-border-radius-xl: var(--ui-radius-lg);
  --bs-link-color: var(--ui-primary-strong);
  --bs-link-color-rgb: var(--portal-primary-rgb);
  --bs-link-hover-color: var(--portal-primary);
  --bs-focus-ring-color: rgba(var(--portal-primary-rgb), .25);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .9375rem;
}
[data-bs-theme="dark"] {
  --bs-link-color: var(--ui-primary-strong);
  --bs-link-hover-color: color-mix(in srgb, var(--portal-primary) 25%, white);
  --bs-link-color-rgb: 160, 220, 200;
}

html { font-size: 15px; }
body {
  background: var(--ui-bg);
  color: var(--ui-text);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 650; letter-spacing: -.015em; color: var(--ui-text); }
::selection { background: rgba(var(--portal-primary-rgb), .2); }
a { text-underline-offset: .2em; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--portal-primary) 70%, #3b82f6); outline-offset: 2px; }
.text-muted { color: var(--ui-text-muted) !important; }

/* =====================================================================
   App shell
   ===================================================================== */
.app-skip { position: fixed; z-index: 2000; top: .5rem; left: .5rem; background: var(--ui-surface); padding: .5rem 1rem; border-radius: var(--ui-radius-sm); }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  width: var(--ui-sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--ui-sidebar-bg);
  color: var(--ui-sidebar-fg);
  transition: width .25s var(--ui-ease), transform .25s var(--ui-ease), box-shadow .25s;
  overflow: hidden;
}
.app-sidebar::before { /* subtle glow */
  content: "";
  position: absolute; inset: -40% -60% auto auto;
  width: 360px; height: 360px;
  background: radial-gradient(closest-side, rgba(var(--portal-primary-rgb), .55), transparent);
  opacity: .5; pointer-events: none;
}

.app-brand {
  display: flex; align-items: center; gap: .75rem;
  height: var(--ui-topbar-h);
  padding: 0 1.25rem;
  color: var(--ui-sidebar-fg-strong);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  flex-shrink: 0; position: relative;
}
.app-brand:hover { color: #fff; }
.app-brand-logo { height: 32px; width: 32px; object-fit: contain; border-radius: .5rem; background: #fff; padding: 2px; flex-shrink: 0; }
.app-brand-mark {
  width: 36px; height: 36px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: .7rem;
  font-weight: 800; font-size: 1.05rem; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--portal-primary) 55%, var(--portal-accent)), var(--portal-primary));
  box-shadow: 0 6px 16px -6px rgba(var(--portal-primary-rgb), .9), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.app-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.app-brand-title { font-weight: 650; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-brand-sub { font-size: .72rem; color: var(--ui-sidebar-fg); white-space: nowrap; }

.app-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .75rem .75rem 1rem; position: relative; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.app-nav-heading {
  margin: 1.1rem .75rem .4rem;
  font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255, 255, 255, .42);
  white-space: nowrap;
}
.app-nav-link, .app-nav-sublink {
  display: flex; align-items: center; gap: .75rem;
  width: 100%;
  padding: .55rem .75rem;
  border: 0; background: none;
  border-radius: .6rem;
  color: var(--ui-sidebar-fg);
  font-size: .9rem; font-weight: 500;
  text-decoration: none; text-align: left;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
  position: relative;
}
.app-nav-link > .bi:first-child { font-size: 1.1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }
.app-nav-link:hover, .app-nav-sublink:hover { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-fg-strong); }
.app-nav-link.active { background: var(--ui-sidebar-active); color: #fff; }
.app-nav-link.active::before {
  content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--ui-sidebar-accent);
}
.app-nav-link.active-parent { color: #fff; }
.app-nav-caret { margin-left: auto; font-size: .7rem; transition: transform .2s var(--ui-ease); opacity: .6; }
.app-nav-link:not(.collapsed) .app-nav-caret { transform: rotate(90deg); }
.app-nav-sub { margin: .15rem 0 .35rem; padding-left: 1.6rem; position: relative; }
.app-nav-sub::before { content: ""; position: absolute; left: 1.35rem; top: .25rem; bottom: .25rem; width: 1px; background: rgba(255, 255, 255, .1); }
.app-nav-sublink { padding: .42rem .75rem; font-size: .86rem; gap: .6rem; }
.app-nav-sublink .bi { font-size: .9rem; opacity: .75; }
.app-nav-sublink.active { color: #fff; background: var(--ui-sidebar-active); }
.app-nav-sublink.active .bi { color: var(--ui-sidebar-accent); opacity: 1; }
.app-sidebar-footer { padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .06); position: relative; }

.app-main {
  min-height: 100vh;
  margin-left: var(--ui-sidebar-w);
  display: flex; flex-direction: column;
  transition: margin-left .25s var(--ui-ease);
}
.app-no-sidebar .app-main { margin-left: 0; }

.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--ui-topbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--ui-bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ui-border);
}
.app-topbar-brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; color: var(--ui-text); text-decoration: none; }
.app-search { position: relative; align-items: center; width: min(440px, 40vw); }
.app-search > .bi { position: absolute; left: .85rem; color: var(--ui-text-muted); pointer-events: none; }
.app-search .form-control { padding-left: 2.4rem; padding-right: 2.4rem; background: var(--ui-surface); border-radius: 999px; height: 40px; }
.app-search-kbd { position: absolute; right: .6rem; font-size: .7rem; padding: .1rem .4rem; background: var(--ui-surface-2); color: var(--ui-text-muted); border: 1px solid var(--ui-border); border-radius: .35rem; }

.app-user { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem .3rem .3rem; border-radius: 999px; }
.avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: .8rem; font-weight: 650; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--portal-primary) 65%, #60a5fa), var(--portal-primary));
}
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

.app-content { flex: 1; padding: 1.75rem 1.5rem 2.5rem; width: 100%; max-width: 1680px; margin: 0 auto; }
.app-footer {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
  padding: 1rem 1.5rem; font-size: .8rem; color: var(--ui-text-muted);
  border-top: 1px solid var(--ui-border);
}
.app-footer a { color: inherit; }

.app-backdrop { display: none; }

/* theme toggle icons */
[data-bs-theme="light"] .theme-icon-dark,
[data-bs-theme="dark"] .theme-icon-light { display: none; }

/* desktop: collapsible icon rail that expands on hover */
@media (min-width: 992px) {
  .sidebar-collapsed .app-sidebar { width: var(--ui-sidebar-w-collapsed); }
  .sidebar-collapsed .app-main { margin-left: var(--ui-sidebar-w-collapsed); }
  .sidebar-collapsed .app-sidebar:not(:hover) .app-brand-text, .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-brand-text,
  .sidebar-collapsed .app-sidebar:not(:hover) .app-nav-link > span, .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-nav-link > span,
  .sidebar-collapsed .app-sidebar:not(:hover) .app-nav-caret, .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-nav-caret,
  .sidebar-collapsed .app-sidebar:not(:hover) .app-nav-sub , .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-nav-sub { display: none; }
  .sidebar-collapsed .app-sidebar:not(:hover) .app-nav-heading , .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-nav-heading { visibility: hidden; height: .25rem; margin: .5rem 0; }
  .sidebar-collapsed .app-sidebar:not(:hover) .app-nav-link , .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-nav-link { justify-content: center; }
  .sidebar-collapsed .app-sidebar:not(:hover) .app-brand , .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-brand { justify-content: center; padding: 0; }
  .sidebar-collapsed:not(.sidebar-hover-lock) .app-sidebar:hover { width: var(--ui-sidebar-w); box-shadow: var(--ui-shadow-lg); }
}

/* mobile: off-canvas */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-main { margin-left: 0; }
  .sidebar-open .app-sidebar { transform: none; box-shadow: var(--ui-shadow-lg); }
  .sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(8, 12, 20, .5); backdrop-filter: blur(2px); }
  .app-topbar { padding: 0 1rem; }
  .app-content { padding: 1.25rem 1rem 2rem; }
}

/* =====================================================================
   Page header
   ===================================================================== */
.ui-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.ui-page-header-icon {
  width: 48px; height: 48px; flex-shrink: 0; display: inline-grid; place-items: center;
  border-radius: var(--ui-radius); font-size: 1.35rem;
  color: var(--ui-primary-strong); background: var(--ui-primary-soft);
}
.ui-page-pretitle { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-text-muted); margin-bottom: .2rem; }
.ui-page-title { font-size: 1.6rem; margin: 0; }
.ui-page-subtitle { color: var(--ui-text-muted); margin: .25rem 0 0; }
.ui-page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Pages that still use the plain "h1.h3" header get the same weight. */
.app-content > h1.h3, .app-content > .d-flex > h1.h3 { font-size: 1.6rem; }

/* =====================================================================
   Cards
   ===================================================================== */
.card {
  --bs-card-bg: var(--ui-surface);
  --bs-card-border-color: var(--ui-border);
  --bs-card-border-radius: var(--ui-radius);
  --bs-card-inner-border-radius: calc(var(--ui-radius) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-cap-padding-y: .9rem;
  --bs-card-cap-padding-x: 1.25rem;
  --bs-card-spacer-x: 1.25rem;
  --bs-card-spacer-y: 1.15rem;
  box-shadow: var(--ui-shadow);
}
.card + .card { margin-top: 1.25rem; }
.card-header { font-weight: 600; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-header > .bi:first-child { color: var(--ui-text-muted); }
.card-footer { background: var(--ui-surface-2); color: var(--ui-text-muted); }
.card-title { font-weight: 650; }
.ui-card-subtitle { font-weight: 400; font-size: .82rem; color: var(--ui-text-muted); }
.ui-card-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; font-weight: 400; }
.card-hover { transition: transform .2s var(--ui-ease), box-shadow .2s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--ui-shadow-lg); }
.list-group { --bs-list-group-bg: var(--ui-surface); --bs-list-group-border-color: var(--ui-border); }

/* Stat card */
.ui-stat { position: relative; display: flex; gap: 1rem; align-items: flex-start; height: 100%; padding: 1.15rem 1.25rem; color: inherit; text-decoration: none; overflow: hidden; }
a.ui-stat:hover { color: inherit; }
.ui-stat-icon {
  width: 44px; height: 44px; flex-shrink: 0; display: inline-grid; place-items: center;
  border-radius: .8rem; font-size: 1.25rem;
  color: var(--ui-stat-color); background: color-mix(in srgb, var(--ui-stat-color) 13%, transparent);
}
.ui-stat-label { font-size: .8rem; font-weight: 500; color: var(--ui-text-muted); margin-bottom: .15rem; }
.ui-stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ui-stat-hint { font-size: .78rem; color: var(--ui-text-muted); margin-top: .25rem; display: flex; gap: .35rem; align-items: center; }
.ui-stat-arrow { position: absolute; right: 1rem; top: 1rem; color: var(--ui-text-muted); opacity: 0; transition: opacity .2s, transform .2s; }
a.ui-stat:hover .ui-stat-arrow { opacity: 1; transform: translate(2px, -2px); }
.ui-stat-primary { --ui-stat-color: var(--ui-primary-strong); }
.ui-stat-success { --ui-stat-color: var(--bs-success); }
.ui-stat-warning { --ui-stat-color: #d97706; }
.ui-stat-danger { --ui-stat-color: var(--bs-danger); }
.ui-stat-info { --ui-stat-color: #0284c7; }
.ui-stat-secondary { --ui-stat-color: var(--ui-text-muted); }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  --bs-btn-font-weight: 550;
  --bs-btn-padding-x: .95rem;
  --bs-btn-padding-y: .5rem;
  --bs-btn-border-radius: .6rem;
  --bs-btn-font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { --bs-btn-padding-x: .7rem; --bs-btn-padding-y: .3rem; --bs-btn-font-size: .82rem; --bs-btn-border-radius: .5rem; gap: .35rem; }
.btn-lg { --bs-btn-padding-x: 1.25rem; --bs-btn-padding-y: .7rem; --bs-btn-font-size: 1rem; --bs-btn-border-radius: .75rem; }
.btn-group > .btn { gap: .4rem; }
.btn-group-vertical > .btn { justify-content: flex-start; }
.btn-primary {
  --bs-btn-bg: var(--portal-primary);
  --bs-btn-border-color: var(--portal-primary);
  --bs-btn-hover-bg: var(--ui-primary-strong-solid, color-mix(in srgb, var(--portal-primary) 85%, black));
  --bs-btn-hover-border-color: color-mix(in srgb, var(--portal-primary) 85%, black);
  --bs-btn-active-bg: color-mix(in srgb, var(--portal-primary) 75%, black);
  --bs-btn-active-border-color: color-mix(in srgb, var(--portal-primary) 75%, black);
  --bs-btn-disabled-bg: var(--portal-primary);
  --bs-btn-disabled-border-color: var(--portal-primary);
  --bs-btn-focus-shadow-rgb: var(--portal-primary-rgb);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-outline-primary {
  --bs-btn-color: var(--ui-primary-strong);
  --bs-btn-border-color: color-mix(in srgb, var(--portal-primary) 50%, transparent);
  --bs-btn-hover-bg: var(--portal-primary);
  --bs-btn-hover-border-color: var(--portal-primary);
  --bs-btn-active-bg: var(--portal-primary);
  --bs-btn-active-border-color: var(--portal-primary);
  --bs-btn-focus-shadow-rgb: var(--portal-primary-rgb);
}
.btn-outline-secondary {
  --bs-btn-color: var(--ui-text);
  --bs-btn-bg: var(--ui-surface);
  --bs-btn-border-color: var(--ui-border-strong);
  --bs-btn-hover-color: var(--ui-text);
  --bs-btn-hover-bg: var(--ui-surface-2);
  --bs-btn-hover-border-color: var(--ui-border-strong);
  --bs-btn-active-color: var(--ui-text);
  --bs-btn-active-bg: var(--ui-border);
  --bs-btn-active-border-color: var(--ui-border-strong);
  box-shadow: var(--ui-shadow-sm);
}
.btn-ghost {
  --bs-btn-color: var(--ui-text-muted);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--ui-text);
  --bs-btn-hover-bg: color-mix(in srgb, var(--ui-text) 7%, transparent);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--ui-text);
  --bs-btn-active-bg: color-mix(in srgb, var(--ui-text) 12%, transparent);
  --bs-btn-active-border-color: transparent;
}
/* soft = tinted background, colored text */
.btn-soft-primary, .btn-soft-secondary, .btn-soft-success, .btn-soft-danger, .btn-soft-warning, .btn-soft-info {
  --bs-btn-color: var(--soft-fg);
  --bs-btn-bg: color-mix(in srgb, var(--soft) 12%, transparent);
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--soft-fg);
  --bs-btn-hover-bg: color-mix(in srgb, var(--soft) 20%, transparent);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--soft-fg);
  --bs-btn-active-bg: color-mix(in srgb, var(--soft) 28%, transparent);
  --bs-btn-active-border-color: transparent;
}
.btn-soft-primary { --soft: var(--portal-primary); --soft-fg: var(--ui-primary-strong); }
.btn-soft-secondary { --soft: #64748b; --soft-fg: var(--ui-text); }
.btn-soft-success { --soft: var(--bs-success); --soft-fg: var(--bs-success-text-emphasis); }
.btn-soft-danger { --soft: var(--bs-danger); --soft-fg: var(--bs-danger-text-emphasis); }
.btn-soft-warning { --soft: var(--bs-warning); --soft-fg: var(--bs-warning-text-emphasis); }
.btn-soft-info { --soft: var(--bs-info); --soft-fg: var(--bs-info-text-emphasis); }
.btn-icon { --bs-btn-padding-x: 0; width: 38px; height: 38px; padding-left: 0; padding-right: 0; }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-icon.btn-lg { width: 48px; height: 48px; }
.btn-pill { --bs-btn-border-radius: 999px; }
.btn.is-loading { pointer-events: none; opacity: .85; }

/* =====================================================================
   Forms
   ===================================================================== */
.form-control, .form-select {
  border-color: var(--ui-border-strong);
  background-color: var(--ui-surface);
  border-radius: .6rem;
  padding: .55rem .85rem;
  font-size: .92rem;
  box-shadow: var(--ui-shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.form-select { padding-right: 2.25rem; }
.form-control-sm, .form-select-sm { padding: .32rem .65rem; font-size: .84rem; border-radius: .5rem; }
.form-select-sm { padding-right: 2rem; }
.form-control-lg, .form-select-lg { padding: .75rem 1rem; font-size: 1rem; border-radius: .75rem; }
.form-control:hover:not(:focus):not(:disabled), .form-select:hover:not(:focus):not(:disabled) { border-color: color-mix(in srgb, var(--ui-border-strong) 60%, var(--ui-text-muted)); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: color-mix(in srgb, var(--portal-primary) 70%, #3b82f6);
  box-shadow: 0 0 0 4px rgba(var(--portal-primary-rgb), .14);
}
.form-control::placeholder { color: color-mix(in srgb, var(--ui-text-muted) 75%, transparent); }
.form-control:disabled, .form-select:disabled, .form-control[readonly].ui-readonly { background-color: var(--ui-surface-2); }
.form-label { font-size: .84rem; font-weight: 550; color: var(--ui-text); margin-bottom: .35rem; }
.form-text { color: var(--ui-text-muted); font-size: .8rem; }
.ui-required { color: var(--bs-danger); margin-left: .15rem; }
.input-group-text { background: var(--ui-surface-2); border-color: var(--ui-border-strong); color: var(--ui-text-muted); }
.input-group > .form-control, .input-group > .form-select { box-shadow: none; }
.input-group { border-radius: .6rem; box-shadow: var(--ui-shadow-sm); }
.input-group:focus-within { box-shadow: 0 0 0 4px rgba(var(--portal-primary-rgb), .14); border-radius: .6rem; }
.input-group:focus-within .form-control:focus { box-shadow: none; }
.input-group:focus-within > .input-group-text { border-color: color-mix(in srgb, var(--portal-primary) 70%, #3b82f6); }
.input-group > .input-group-text:first-child { border-top-left-radius: .6rem; border-bottom-left-radius: .6rem; }
.input-group > :last-child { border-top-right-radius: .6rem !important; border-bottom-right-radius: .6rem !important; }
/* Icon inside the input instead of a boxed add-on */
.ui-input-icon { position: relative; }
.ui-input-icon > .bi { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--ui-text-muted); pointer-events: none; z-index: 5; }
.ui-input-icon > .form-control, .ui-input-icon > .form-select, .ui-input-icon > .flatpickr-input { padding-left: 2.4rem; }
.ui-input-icon > .ui-input-clear { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); z-index: 5; }
.ui-input-icon.has-clear > .form-control { padding-right: 2.25rem; }
.form-control-sm ~ .bi, .ui-input-icon.ui-sm > .bi { left: .65rem; font-size: .85rem; }
.ui-input-icon.ui-sm > .form-control { padding-left: 2rem; }

.form-check-input { border-color: var(--ui-border-strong); width: 1.1em; height: 1.1em; margin-top: .2em; }
.form-check-input:checked { background-color: var(--portal-primary); border-color: var(--portal-primary); }
.form-check-input:indeterminate { background-color: var(--portal-primary); border-color: var(--portal-primary); }
.form-switch .form-check-input { width: 2.25em; height: 1.25em; margin-top: .1em; }
.form-check-label { font-size: .92rem; }
.form-check-card {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .85rem 1rem; padding-left: 2.6rem;
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm);
  background: var(--ui-surface); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.form-check-card .form-check-input { margin-left: -1.6rem; }
.form-check-card:has(.form-check-input:checked) { border-color: var(--portal-primary); background: var(--ui-primary-soft); }
.btn-check + .btn { box-shadow: none; }
.btn-check:checked + .btn-outline-secondary, .btn-check:checked + .btn-outline-primary {
  background: var(--portal-primary); border-color: var(--portal-primary); color: #fff;
}
.ui-fieldset { min-width: 0; }
.ui-fieldset > legend { font-size: .84rem; font-weight: 550; line-height: 1.5; margin-bottom: .35rem; }

/* ASP.NET validation classes */
.input-validation-error, .form-control.is-invalid, .form-select.is-invalid { border-color: var(--bs-danger) !important; }
.input-validation-error:focus { box-shadow: 0 0 0 4px rgba(var(--bs-danger-rgb), .15) !important; }
.field-validation-error { display: flex; align-items: center; gap: .3rem; color: var(--bs-danger); font-size: .8rem; margin-top: .3rem; }
.field-validation-error::before { content: "\F33A"; font-family: "bootstrap-icons"; font-size: .8rem; }
.field-validation-valid { display: none; }
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.ui-field { margin-bottom: 0; }

/* =====================================================================
   Tables
   ===================================================================== */
.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: color-mix(in srgb, var(--portal-primary) 4%, transparent);
  --bs-table-striped-bg: var(--ui-surface-2);
  --bs-table-border-color: var(--ui-border);
  --bs-table-color: var(--ui-text);
  font-size: .9rem;
}
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table-sm > :not(caption) > * > * { padding: .4rem .6rem; }
.table > thead > tr > th, .table > thead.table-light > tr > th {
  background: var(--ui-surface-2);
  color: var(--ui-text-muted);
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  border-bottom-color: var(--ui-border);
  white-space: nowrap;
}
.table > thead.table-light { --bs-table-bg: var(--ui-surface-2); --bs-table-color: var(--ui-text-muted); --bs-table-border-color: var(--ui-border); }
.card > .table, .card > .table-responsive > .table, .card > .table-responsive { margin-bottom: 0; }
.card > .table-responsive:first-child > .table > thead > tr:first-child > th:first-child { border-top-left-radius: calc(var(--ui-radius) - 1px); }
.card > .table-responsive:first-child > .table > thead > tr:first-child > th:last-child { border-top-right-radius: calc(var(--ui-radius) - 1px); }
.table > tbody > tr:last-child > * { border-bottom-width: 0; }
.table td { vertical-align: middle; }
.table a:not(.btn) { font-weight: 550; text-decoration: none; }
.table a:not(.btn):hover { text-decoration: underline; }
.table-projects td { vertical-align: middle; }
.table-primary { --bs-table-bg: var(--ui-primary-soft); --bs-table-color: var(--ui-text); }

.ui-table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--ui-border); }
.ui-table-title { font-weight: 650; margin-right: auto; display: flex; align-items: center; gap: .5rem; }
.ui-table-search { width: min(280px, 100%); }
.ui-table-footer { padding: .7rem 1.25rem; font-size: .8rem; color: var(--ui-text-muted); background: var(--ui-surface-2); border-top: 1px solid var(--ui-border); border-radius: 0 0 var(--ui-radius) var(--ui-radius); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: "\F127"; font-family: "bootstrap-icons"; margin-left: .35rem; opacity: .35; font-size: .7rem; }
th[data-sort][aria-sort="ascending"]::after { content: "\F148"; opacity: 1; }
th[data-sort][aria-sort="descending"]::after { content: "\F128"; opacity: 1; }
th[data-sort]:hover { color: var(--ui-text); }
tr.ui-row-hidden { display: none; }

/* priority stripe for project rows: 1 findet statt (green), 2 geplant (orange), 3 abgesagt (grey) */
.prio-1 > td:first-child { box-shadow: inset 3px 0 0 #16a34a; }
.prio-2 > td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.prio-3 > td:first-child { box-shadow: inset 3px 0 0 var(--ui-border-strong); }
.ui-prio { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--ui-text-muted); }
.ui-prio::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.ui-prio-1 { color: #16a34a; }
.ui-prio-2 { color: #d97706; }
.ui-prio-3 { color: var(--ui-text-muted); }

/* =====================================================================
   Badges, alerts, nav, dropdowns, accordion
   ===================================================================== */
.badge { font-weight: 600; letter-spacing: .01em; padding: .38em .6em; border-radius: .45rem; }
.badge-soft { border: 1px solid transparent; }
.ui-dot::before { content: ""; display: inline-block; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; margin-right: .35rem; vertical-align: .08em; }

.alert { border-radius: var(--ui-radius); border-width: 1px; display: flex; gap: .75rem; align-items: flex-start; }
.alert > .ui-alert-icon { font-size: 1.15rem; line-height: 1.3; flex-shrink: 0; }
.alert.validation-summary-errors, .alert.validation-summary-valid { display: block; }
.alert.validation-summary-valid { display: none; }
.alert-heading { font-size: .95rem; font-weight: 650; margin-bottom: .15rem; }

.nav-tabs {
  --bs-nav-tabs-border-color: var(--ui-border);
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-border-color: transparent;
  --bs-nav-tabs-link-hover-border-color: transparent;
  gap: .25rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.nav-tabs .nav-link {
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--ui-text-muted); font-weight: 550; font-size: .9rem; padding: .7rem .9rem; white-space: nowrap;
  display: inline-flex; gap: .45rem; align-items: center;
}
.nav-tabs .nav-link:hover { color: var(--ui-text); border-bottom-color: var(--ui-border-strong); }
.nav-tabs .nav-link.active { color: var(--ui-primary-strong); border-bottom-color: var(--portal-primary); background: transparent; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { border-bottom-color: var(--ui-primary-strong); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--portal-primary); --bs-nav-pills-border-radius: .6rem; }
/* Selected entry of list menus (Auswahllisten, E-Mail-Vorlagen …): light tint of the tenant color with a bar on the left,
   text stays as dark as in the other entries (instead of Bootstrap's blue / a dark fill with white text) */
.list-group {
  --bs-list-group-active-bg: color-mix(in srgb, var(--portal-primary) 9%, var(--ui-surface));
  --bs-list-group-active-border-color: var(--ui-border);
  --bs-list-group-active-color: var(--ui-text);
}
.list-group-item.active { box-shadow: inset 3px 0 0 var(--portal-primary); font-weight: 600; z-index: 1; }
.list-group-item.active .text-body-secondary, .list-group-item.active .text-muted, .list-group-item.active small { color: var(--ui-text-muted) !important; }
[data-bs-theme="dark"] .list-group { --bs-list-group-active-bg: color-mix(in srgb, var(--portal-primary) 30%, var(--ui-surface)); }
.nav-pills .nav-link { color: var(--ui-text-muted); font-weight: 550; }
.nav-segmented { display: inline-flex; padding: .25rem; gap: .25rem; background: var(--ui-surface-2); border: 1px solid var(--ui-border); border-radius: .7rem; }
.nav-segmented .nav-link { padding: .35rem .8rem; border-radius: .5rem; font-size: .85rem; color: var(--ui-text-muted); }
.nav-segmented .nav-link.active { background: var(--ui-surface); color: var(--ui-text); box-shadow: var(--ui-shadow); }

.dropdown-menu {
  --bs-dropdown-bg: var(--ui-surface);
  --bs-dropdown-border-color: var(--ui-border);
  --bs-dropdown-border-radius: var(--ui-radius);
  --bs-dropdown-link-hover-bg: var(--ui-surface-2);
  --bs-dropdown-link-active-bg: var(--ui-primary-soft);
  --bs-dropdown-link-active-color: var(--ui-primary-strong);
  --bs-dropdown-item-padding-x: .75rem;
  --bs-dropdown-font-size: .9rem;
  padding: .4rem; box-shadow: var(--ui-shadow-lg); min-width: 13rem;
  animation: ui-pop .14s var(--ui-ease);
}
.dropdown-item { border-radius: .45rem; display: flex; align-items: center; gap: .6rem; padding-top: .45rem; padding-bottom: .45rem; }
.dropdown-item > .bi { color: var(--ui-text-muted); width: 1rem; }
.dropdown-item.text-danger > .bi { color: inherit; }
.dropdown-header { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: .5rem .75rem .25rem; }
.dropdown-header .text-body { text-transform: none; letter-spacing: 0; font-size: .9rem; }
.dropdown-toggle::after { border: 0; content: "\F282"; font-family: "bootstrap-icons"; font-size: .7em; vertical-align: 0; margin-left: .1rem; }
.dropdown-toggle-split::after { margin-left: 0; }
.ui-no-caret::after { display: none; }

.accordion {
  --bs-accordion-bg: var(--ui-surface);
  --bs-accordion-border-color: var(--ui-border);
  --bs-accordion-border-radius: var(--ui-radius);
  --bs-accordion-inner-border-radius: calc(var(--ui-radius) - 1px);
  --bs-accordion-btn-padding-y: 1rem;
  --bs-accordion-active-bg: var(--ui-surface);
  --bs-accordion-active-color: var(--ui-text);
  --bs-accordion-btn-focus-box-shadow: inset 0 0 0 2px rgba(var(--portal-primary-rgb), .25);
}
.accordion:not(.accordion-flush) { box-shadow: var(--ui-shadow); border-radius: var(--ui-radius); }
.accordion-button { font-weight: 600; gap: .75rem; }
.accordion-button:not(.collapsed) { box-shadow: inset 0 -1px 0 var(--ui-border); }
.ui-accordion-icon { width: 34px; height: 34px; flex-shrink: 0; display: inline-grid; place-items: center; border-radius: .6rem; color: var(--ui-primary-strong); background: var(--ui-primary-soft); }
.ui-accordion-sub { display: block; font-weight: 400; font-size: .82rem; color: var(--ui-text-muted); }
.accordion-button::after { width: 1rem; height: 1rem; background-size: 1rem; }

.modal { --bs-modal-bg: var(--ui-surface); --bs-modal-border-color: var(--ui-border); --bs-modal-border-radius: var(--ui-radius-lg); }
.modal-content { box-shadow: var(--ui-shadow-lg); }
.modal-header { border-bottom-color: var(--ui-border); }
.dealer-picker-header {
  background: linear-gradient(135deg, rgba(var(--portal-primary-rgb), .08), rgba(var(--portal-primary-rgb), .03));
  border-bottom-color: var(--ui-border);
}
.dealer-picker-header .modal-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
}
.dealer-picker-body { padding-top: 1rem; }
.dealer-search-wrap .input-group-text {
  background: var(--ui-surface-2);
  color: var(--ui-text-muted);
  border-color: var(--ui-border);
}
.dealer-search-btn {
  white-space: nowrap;
}
.dealer-picker-empty {
  border: 1px dashed var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface-2);
  color: var(--ui-text-muted);
  padding: .9rem 1rem;
  font-size: .88rem;
}
.dealer-picker-result {
  display: block;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  color: var(--ui-text);
  padding: .8rem .9rem;
  text-align: left;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease, transform .15s ease;
}
.dealer-picker-result:hover,
.dealer-picker-result:focus-visible {
  border-color: color-mix(in srgb, var(--portal-primary) 55%, var(--ui-border));
  background: var(--ui-primary-soft);
  box-shadow: 0 0 0 3px rgba(var(--portal-primary-rgb), .12);
  transform: translateY(-1px);
  outline: none;
}
.dealer-picker-result + .dealer-picker-result { margin-top: .55rem; }
.dealer-picker-result strong { display: block; margin-bottom: .15rem; }
.dealer-picker-result .small { color: var(--ui-text-muted); }
.dealer-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}
.dealer-selected-name {
  min-height: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dealer-choice-row {
  --dealer-control-height: calc(1.5em + .4rem + 2px);
}
.dealer-choice-row {
  position: relative;
  padding-right: 0;
}
.dealer-field-col {
  transition: transform .15s ease-in-out;
}

.dealer-number {
  height: 30.5px;
  border-top-left-radius: .75rem;
  border-bottom-left-radius: .75rem;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.dealer-picker-btn {
  height: 30.5px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: .75rem;
  border-bottom-right-radius: .75rem;
}
.dealer-add-row,
.dealer-remove-btn {
  min-width: 2.25rem;
}
.dealer-remove-btn {
  width: 30.5px;
  height: 30.5px;
  padding: 0;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease-in-out;
  z-index: 2;
}

.offcanvas { --bs-offcanvas-bg: var(--ui-surface); }
.progress { --bs-progress-bar-bg: var(--portal-primary); --bs-progress-bg: var(--ui-surface-2); border-radius: 999px; }
.page-link { --bs-pagination-active-bg: var(--portal-primary); --bs-pagination-active-border-color: var(--portal-primary); }
.tooltip { --bs-tooltip-bg: #0f172a; --bs-tooltip-border-radius: .45rem; --bs-tooltip-font-size: .78rem; }
.popover { --bs-popover-border-radius: var(--ui-radius); }

dl.facts dt { font-weight: 500; color: var(--ui-text-muted); font-size: .86rem; }
dl.facts dd { margin-bottom: .55rem; }
code { color: var(--ui-primary-strong); }
pre.ui-code { background: #0f172a; color: #e2e8f0; padding: 1rem 1.15rem; border-radius: var(--ui-radius-sm); font-size: .8rem; margin: 0; white-space: pre-wrap; }
[data-bs-theme="dark"] pre.ui-code { background: #0a0e14; border: 1px solid var(--ui-border); }

/* Empty state */
.ui-empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--ui-text-muted); }
.ui-empty-icon { width: 56px; height: 56px; margin: 0 auto 1rem; display: grid; place-items: center; font-size: 1.5rem; border-radius: 50%; background: var(--ui-surface-2); color: var(--ui-text-muted); border: 1px solid var(--ui-border); }
.ui-empty-title { font-weight: 650; color: var(--ui-text); margin-bottom: .25rem; }

/* Toasts */
.ui-toasts { z-index: 1090; margin-top: var(--ui-topbar-h); }
.ui-toast { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow-lg); overflow: hidden; position: relative; }
.ui-toast::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; }
.ui-toast-success::before { background: var(--bs-success); }
.ui-toast-success .ui-toast-icon { color: var(--bs-success); }
.ui-toast-danger::before { background: var(--bs-danger); }
.ui-toast-danger .ui-toast-icon { color: var(--bs-danger); }
.ui-toast-icon { font-size: 1.2rem; line-height: 1.2; }
.btn-close-sm { font-size: .65rem; margin-top: .2rem; }

/* =====================================================================
   Fade-in / motion
   ===================================================================== */
/* Dropdowns are positioned by Popper through `transform`; animating `transform` here would replace that position while the
   animation runs (menu flashes at the top left of the page, then jumps). `translate` / `scale` add to it instead. */
@keyframes ui-pop { from { opacity: 0; translate: 0 -4px; scale: .98; } to { opacity: 1; translate: none; scale: none; } }
@keyframes ui-fade-up { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
.ui-fade-in { animation: ui-fade-up .5s var(--ui-ease) both; }
/* JS-driven reveal on scroll: hidden only when JS runs, so content never disappears without it. */
.js [data-ui-fade] { opacity: 0; transition: opacity .6s var(--ui-ease), transform .6s var(--ui-ease); transition-delay: var(--ui-fade-delay, 0ms); }
.js [data-ui-fade="up"] { transform: translate3d(0, 16px, 0); }
.js [data-ui-fade="down"] { transform: translate3d(0, -16px, 0); }
.js [data-ui-fade="left"] { transform: translate3d(16px, 0, 0); }
.js [data-ui-fade="right"] { transform: translate3d(-16px, 0, 0); }
.js [data-ui-fade="zoom"] { transform: scale(.96); }
.js [data-ui-fade].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .js [data-ui-fade] { opacity: 1; transform: none; }
}

/* =====================================================================
   Date & time pickers (flatpickr themed with the tokens)
   ===================================================================== */
.flatpickr-input[readonly] { background-color: var(--ui-surface); cursor: pointer; }
.flatpickr-calendar {
  background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-lg); font-family: inherit; width: 312px; padding: .35rem;
}
.flatpickr-calendar.hasTime.noCalendar { width: 200px; }
.flatpickr-calendar::before, .flatpickr-calendar::after { display: none; }
.flatpickr-months { padding: .25rem 0 .35rem; }
.flatpickr-months .flatpickr-month { color: var(--ui-text); fill: var(--ui-text); height: 38px; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { color: var(--ui-text-muted); fill: var(--ui-text-muted); top: .5rem; padding: 8px 12px; border-radius: .5rem; }
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--portal-primary); }
.flatpickr-current-month { font-size: 1rem; font-weight: 650; }
.flatpickr-current-month .flatpickr-monthDropdown-months { font-weight: 650; background: transparent; }
.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month { background: var(--ui-surface); color: var(--ui-text); }
.flatpickr-current-month input.cur-year { font-weight: 650; color: var(--ui-text); }
span.flatpickr-weekday { color: var(--ui-text-muted); font-weight: 600; font-size: .75rem; }
.flatpickr-days, .dayContainer { width: 100%; min-width: 0; max-width: none; }
.flatpickr-day { color: var(--ui-text); border-radius: .5rem; max-width: none; height: 38px; line-height: 38px; font-size: .88rem; }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--ui-surface-2); border-color: var(--ui-surface-2); }
.flatpickr-day.today { border-color: color-mix(in srgb, var(--portal-primary) 50%, transparent); }
.flatpickr-day.today:hover { background: var(--ui-primary-soft); color: var(--ui-text); }
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange,
.flatpickr-day.selected:hover, .flatpickr-day.startRange:hover, .flatpickr-day.endRange:hover,
.flatpickr-day.selected.prevMonthDay, .flatpickr-day.selected.nextMonthDay {
  background: var(--portal-primary); border-color: var(--portal-primary); color: #fff; box-shadow: none;
}
.flatpickr-day.inRange, .flatpickr-day.week.selected { background: var(--ui-primary-soft); border-color: transparent; box-shadow: -5px 0 0 var(--ui-primary-soft), 5px 0 0 var(--ui-primary-soft); border-radius: 0; color: var(--ui-text); }
.flatpickr-day.week.selected { background: var(--portal-primary); color: #fff; box-shadow: -5px 0 0 var(--portal-primary), 5px 0 0 var(--portal-primary); }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover { color: color-mix(in srgb, var(--ui-text-muted) 55%, transparent); }
.flatpickr-weekwrapper .flatpickr-weeks { box-shadow: 1px 0 0 var(--ui-border); }
.flatpickr-weekwrapper span.flatpickr-day { color: var(--ui-text-muted); font-size: .72rem; }
.flatpickr-time { border-top: 1px solid var(--ui-border) !important; }
.flatpickr-calendar.noCalendar .flatpickr-time { border-top: 0 !important; }
.flatpickr-time input, .flatpickr-time .flatpickr-time-separator, .flatpickr-time .flatpickr-am-pm { color: var(--ui-text); font-weight: 600; font-size: 1.05rem; }
.flatpickr-time input:hover, .flatpickr-time input:focus, .flatpickr-time .flatpickr-am-pm:hover { background: var(--ui-surface-2); }
.flatpickr-time .numInputWrapper span.arrowUp::after { border-bottom-color: var(--ui-text-muted); }
.flatpickr-time .numInputWrapper span.arrowDown::after { border-top-color: var(--ui-text-muted); }
.numInputWrapper:hover { background: var(--ui-surface-2); }
.flatpickr-monthSelect-months { margin: .5rem; }
.flatpickr-monthSelect-month { color: var(--ui-text); border-radius: .5rem; padding: .55rem; width: 33.3%; }
.flatpickr-monthSelect-month:hover { background: var(--ui-surface-2); }
.flatpickr-monthSelect-month.selected { background: var(--portal-primary) !important; color: #fff !important; }
.flatpickr-monthSelect-theme-light, .flatpickr-calendar.flatpickr-monthSelect-theme-light { background: var(--ui-surface); }
.ui-picker-shortcuts { display: flex; gap: .35rem; flex-wrap: wrap; padding: .5rem .35rem .25rem; border-top: 1px solid var(--ui-border); margin-top: .35rem; }
.ui-picker-shortcuts button { font-size: .75rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--ui-border); background: var(--ui-surface-2); color: var(--ui-text); }
.ui-picker-shortcuts button:hover { border-color: var(--portal-primary); color: var(--ui-primary-strong); }

/* =====================================================================
   Dashboard bits
   ===================================================================== */
.ui-greeting { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.ui-hero {
  border-radius: var(--ui-radius-lg); padding: 1.5rem 1.75rem; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--portal-primary) 45%, var(--portal-accent)) 0%, transparent 55%),
              linear-gradient(135deg, var(--portal-primary), color-mix(in srgb, var(--portal-primary) 55%, #0b1220));
  box-shadow: var(--ui-shadow-lg);
}
.ui-hero h1, .ui-hero .h1 { color: #fff; }
.ui-hero-sub { color: rgba(255, 255, 255, .75); }
.ui-hero .btn-light { --bs-btn-bg: rgba(255,255,255,.95); --bs-btn-border-color: transparent; --bs-btn-color: var(--portal-primary); }
.ui-hero .btn-ghost { --bs-btn-color: rgba(255,255,255,.85); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: rgba(255,255,255,.12); --bs-btn-active-bg: rgba(255,255,255,.18); --bs-btn-active-color: #fff; }

.ui-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; align-items: end; height: 190px; padding-top: 1rem; position: relative; }
.ui-bars-grid { position: absolute; inset: 1rem 0 0 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.ui-bars-grid > span { border-top: 1px dashed var(--ui-border); height: 0; }
.ui-bar { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.ui-bar-fill { width: min(26px, 70%); border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--portal-primary) 75%, var(--ui-surface)); transition: background-color .15s, opacity .15s; min-height: 2px; }
[data-bs-theme="dark"] .ui-bar-fill { background: color-mix(in srgb, var(--portal-accent) 55%, var(--ui-surface)); }
.ui-bar.is-current .ui-bar-fill { background: var(--portal-primary); }
[data-bs-theme="dark"] .ui-bar.is-current .ui-bar-fill { background: var(--portal-accent); }
.ui-bars:hover .ui-bar:not(:hover) .ui-bar-fill { opacity: .45; }
.ui-bar-tip {
  position: absolute; bottom: calc(var(--h) + 8px); left: 50%; transform: translateX(-50%);
  background: var(--ui-text); color: var(--ui-surface); font-size: .75rem; padding: .3rem .55rem; border-radius: .4rem;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; font-variant-numeric: tabular-nums;
}
.ui-bar:hover .ui-bar-tip, .ui-bar:focus .ui-bar-tip { opacity: 1; }
.ui-bars-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: .4rem; font-size: .72rem; color: var(--ui-text-muted); text-align: center; }

.ui-timeline { list-style: none; margin: 0; padding: 0; }
.ui-timeline > li { display: flex; gap: .9rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--ui-border); align-items: center; }
.ui-timeline > li:last-child { border-bottom: 0; }
.ui-date-chip { width: 48px; flex-shrink: 0; text-align: center; border-radius: .6rem; border: 1px solid var(--ui-border); background: var(--ui-surface-2); overflow: hidden; line-height: 1.1; }
.ui-date-chip-m { display: block; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .2rem 0; background: var(--ui-primary-soft); color: var(--ui-primary-strong); }
.ui-date-chip-d { display: block; font-size: 1.1rem; font-weight: 700; padding: .25rem 0; font-variant-numeric: tabular-nums; }

/* =====================================================================
   Auth (login) layout
   ===================================================================== */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-hero {
  position: relative; color: #fff; overflow: hidden;
  background: radial-gradient(90% 70% at 85% 10%, color-mix(in srgb, var(--portal-primary) 40%, var(--portal-accent)) 0%, transparent 60%),
              radial-gradient(70% 60% at 0% 100%, color-mix(in srgb, var(--portal-primary) 60%, #60a5fa) 0%, transparent 60%),
              linear-gradient(160deg, var(--portal-primary), color-mix(in srgb, var(--portal-primary) 35%, #070b12));
}
.auth-hero-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 3rem; gap: 2rem; }
.auth-brand { display: flex; align-items: center; gap: .75rem; font-weight: 650; font-size: 1.1rem; }
.auth-hero-title { color: #fff; font-size: clamp(1.75rem, 2.6vw, 2.5rem); font-weight: 700; line-height: 1.15; max-width: 30rem; }
.auth-hero-text { color: rgba(255,255,255,.75); font-size: 1.05rem; max-width: 28rem; }
.auth-hero-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .75rem; }
.auth-hero-list li { display: flex; gap: .75rem; align-items: center; color: rgba(255,255,255,.9); }
.auth-hero-list .bi { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: .6rem; background: rgba(255,255,255,.12); backdrop-filter: blur(4px); }
.auth-hero-foot { font-size: .8rem; color: rgba(255,255,255,.6); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--ui-bg); }
.auth-panel { width: 100%; max-width: 400px; }
.auth-tools { display: flex; gap: 1rem; align-items: center; margin-top: 2rem; }
@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* =====================================================================
   Page-specific (kept from before)
   ===================================================================== */
.stage-grid th, .stage-grid td { min-width: 2.2rem; font-size: .75rem; white-space: nowrap; padding: .35rem .3rem !important; }
.stage-grid td.booked { max-width: 2.2rem; overflow: hidden; text-overflow: ellipsis; }
.stage-grid .sticky-col { position: sticky; left: 0; background: var(--ui-surface); z-index: 1; }
.stage-grid thead th { position: sticky; top: 0; z-index: 2; }
.stage-grid thead th.sticky-col { z-index: 3; }
/* Day plan: narrow day columns, a booking is one cell spanning its days; the three header rows stick together. */
.stage-days thead { position: sticky; top: 0; z-index: 2; }
.stage-days thead th { position: static; }
.stage-days thead th.sticky-col { position: sticky; left: 0; z-index: 3; }
.stage-days .sticky-col { min-width: 9.5rem; }
/* Month name stays readable while its month is scrolled past the stage column. */
.stage-days .stage-month span { position: sticky; left: 10rem; }
.stage-days th.stage-day, .stage-days td { min-width: 1.75rem; max-width: 1.75rem; padding: .25rem .1rem !important; text-align: center; }
.stage-days th.stage-day div { font-size: .65rem; color: var(--bs-secondary-color); }
.stage-days .stage-month, .stage-days .stage-week { padding: .2rem .4rem !important; }
.stage-days .weekend { --bs-table-bg-state: rgba(var(--bs-emphasis-color-rgb), .05); }
.stage-days thead th.today { --bs-table-bg-state: var(--bs-primary); --bs-table-color-state: #fff; color: #fff; }
.stage-days thead th.today div { color: inherit; }
.stage-days td.today { --bs-table-bg-state: rgba(var(--bs-primary-rgb), .12); }
.stage-days td.booked { max-width: none; text-align: left; overflow: hidden; text-overflow: ellipsis; padding: .25rem .35rem !important; }
/* width:0 + min-width:100%: the title never widens the day columns, it is cut to the booked days (full text in the tooltip). */
.stage-days td.booked a { display: block; width: 0; min-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* Yearly plan: limited height on the page, the whole screen in fullscreen mode. */
.stage-scroll { max-height: 22rem; }
.stage-year:fullscreen { display: flex; flex-direction: column; border-radius: 0; background: var(--ui-surface); }
.stage-year:fullscreen .stage-scroll { max-height: none; flex: 1; }
/* Open projects (left) are exactly as tall as demand + stages (right, stacked, incl. gap): the right column sets the row
   height and the left card is laid over its column, so only its table scrolls. Below xl the cards stack with fixed heights. */
.stage-list-tall { max-height: 36rem; overflow-y: auto; }
.stage-list-short { max-height: 13rem; overflow-y: auto; }
/* Demand and stages: same card height; the list inside takes whatever room header, footer and form leave. */
.stage-side { height: 24rem; }
/* Gap between the two right cards = the row's column gutter, i.e. the same distance as to the left card. */
.stage-side-col { gap: var(--bs-gutter-x); }
.stage-side-col > .card + .card { margin-top: 0; }
/* Booking bar and "new stage" form keep their natural height (Bootstrap lets every .card-body grow). */
.stage-open .card-body, .stage-side > .card-body { flex: none; }
.stage-side > .stage-list-short { flex: 1; min-height: 0; max-height: none; }
@media (min-width: 1200px) {
  .stage-open-col { position: relative; }
  .stage-open { position: absolute; inset: 0 calc(var(--bs-gutter-x) * .5); display: flex; flex-direction: column; }
  .stage-open > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .stage-open .stage-list-tall { max-height: none; flex: 1; min-height: 0; }
}
.login-card { max-width: 420px; margin: 3rem auto; }

/* Photo gallery popup (ui.js initGallery): dark stage, photo fitted to the window. */
.ui-gallery .modal-content { background: #111; color: #fff; border: 0; }
.ui-gallery .carousel-item { height: 75vh; }
.ui-gallery .carousel-item img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ui-gallery .carousel-control-prev, .ui-gallery .carousel-control-next { width: 10%; }
a[data-ui-gallery] { cursor: zoom-in; }

/* Public dealer forms */
.public-header { background: linear-gradient(135deg, var(--portal-primary), color-mix(in srgb, var(--portal-primary) 55%, #0b1220)); color: #fff; }
/* public pages (wish links, forms): footer at the bottom of the window, also when the content is short */
.public-body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.public-body > .public-main { flex: 1 0 auto; width: 100%; } /* width: auto margins would shrink a flex item */
.public-body > .app-footer { margin-top: auto; }

@media print {
  .app-sidebar, .app-topbar, .app-footer, .ui-toasts, .ui-page-actions, .app-backdrop { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .card { box-shadow: none; }
}

/* Sticky save bar at the bottom of long forms */
.ui-form-actions {
  position: sticky; bottom: 0; z-index: 1020;
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
  margin: 1.5rem -1.5rem -2.5rem; padding: .9rem 1.5rem;
  background: color-mix(in srgb, var(--ui-surface) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--ui-border);
}
@media (max-width: 991.98px) { .ui-form-actions { margin: 1.25rem -1rem -2rem; padding: .75rem 1rem; } }

/* Project header (shared by all project tabs) */
.ui-entity-header { margin-bottom: 1.5rem; }
.ui-entity-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; color: var(--ui-text-muted); font-size: .86rem; margin-top: .35rem; }
.ui-entity-meta .bi { margin-right: .3rem; }
.ui-entity-header .nav-tabs { margin-top: 1.1rem; }

/* UI-Kit catalog */
.ui-kit-toc { position: sticky; top: calc(var(--ui-topbar-h) + 1.25rem); }
.ui-kit-toc .nav-link { color: var(--ui-text-muted); font-size: .88rem; padding: .35rem .75rem; border-left: 2px solid var(--ui-border); border-radius: 0; }
.ui-kit-toc .nav-link:hover { color: var(--ui-text); border-left-color: var(--ui-border-strong); }
.ui-kit-toc .nav-link.active { color: var(--ui-primary-strong); border-left-color: var(--portal-primary); font-weight: 600; background: none; }
.ui-kit-section { scroll-margin-top: calc(var(--ui-topbar-h) + 1rem); }
.ui-kit-code { margin-top: 1.25rem; border-top: 1px dashed var(--ui-border); padding-top: .75rem; }
.ui-kit-code > summary { cursor: pointer; font-size: .8rem; font-weight: 600; color: var(--ui-text-muted); list-style: none; display: inline-flex; align-items: center; gap: .35rem; }
.ui-kit-code > summary::-webkit-details-marker { display: none; }
.ui-kit-code > summary::before { content: "\F2EE"; font-family: "bootstrap-icons"; }
.ui-kit-code[open] > summary { margin-bottom: .6rem; color: var(--ui-text); }
.ui-kit-swatch { height: 56px; border-radius: var(--ui-radius-sm); border: 1px solid var(--ui-border); }

/* Clear button only while the picker holds a value */
.ui-input-icon.has-clear:has(.form-control:placeholder-shown) > .ui-input-clear { display: none; }
.ui-input-icon.has-clear:has(.form-control:placeholder-shown) > .form-control { padding-right: .85rem; }

/* Definition lists: keep label/value rows aligned when a value is missing */
dl.facts dd:empty::before { content: "–"; color: var(--ui-text-muted); }
dl.facts dt, dl.facts dd { padding-top: .2rem; padding-bottom: .2rem; }

/* Segmented radio/checkbox buttons fill their field evenly */
.btn-group.ui-segmented { display: flex; width: 100%; }
.btn-group.ui-segmented > .btn { flex: 1 1 auto; --bs-btn-padding-x: .6rem; white-space: nowrap; }

/* .card is a column flexbox – stat tiles are rows (icon left of the figure) */
.card.ui-stat { flex-direction: row; }

/* Range highlight: opaque tint so the gap-filling shadows don't stack into stripes */
.flatpickr-day.inRange {
  --ui-range: color-mix(in srgb, var(--portal-primary) 12%, var(--ui-surface));
  background: var(--ui-range); box-shadow: -5px 0 0 var(--ui-range), 5px 0 0 var(--ui-range);
}
[data-bs-theme="dark"] .flatpickr-day.inRange { --ui-range: color-mix(in srgb, var(--portal-primary) 35%, var(--ui-surface)); }

/* Server-side sortable headers (<th ui-sort="…">) */
th.ui-sort { padding: 0 !important; }
.ui-sort-link { display: flex; align-items: center; gap: .35rem; padding: .75rem 1rem; color: inherit; text-decoration: none !important; font-weight: inherit !important; }
.table-sm th.ui-sort .ui-sort-link { padding: .4rem .6rem; }
.ui-sort-link:hover { color: var(--ui-text); background: color-mix(in srgb, var(--ui-text) 4%, transparent); }
.ui-sort-icon { font-size: .8rem; opacity: .35; transition: opacity .15s; }
.ui-sort-link:hover .ui-sort-icon { opacity: .7; }
th.ui-sort.is-sorted { color: var(--ui-primary-strong); }
th.ui-sort.is-sorted .ui-sort-icon { opacity: 1; }

/* Tenant wordmark (themes/{key}/logo.svg, inline SVG with fill="currentColor") */
.app-brand-wordmark { display: inline-flex; align-items: center; color: inherit; line-height: 0; }
.app-brand-wordmark svg { height: 16px; width: auto; display: block; }
.app-brand.has-wordmark .app-brand-mark { display: none; }
.app-brand.has-wordmark .app-brand-text { gap: .45rem; }
.app-brand-divider { width: 1px; height: 1.1em; background: currentColor; opacity: .35; }
.auth-brand, .app-topbar-brand { display: inline-flex; align-items: center; gap: .75rem; }
.auth-brand .app-brand-wordmark svg { height: 20px; }
.app-topbar-brand { color: var(--ui-primary-strong); }
.app-topbar-brand .app-brand-logo { height: 26px; width: auto; background: none; padding: 0; }
.auth-brand-mobile { color: var(--ui-primary-strong); margin-bottom: 2rem; font-weight: 650; }
@media (min-width: 992px) {
  .sidebar-collapsed .app-sidebar:not(:hover) .app-brand.has-wordmark .app-brand-mark , .sidebar-collapsed.sidebar-hover-lock .app-sidebar .app-brand.has-wordmark .app-brand-mark { display: inline-grid; }
}

/* Bootstrap's fixed light helpers (bg-white, bg-light, table-light) ignore dark mode – map them onto the theme surfaces. */
.table-light, .table > :not(caption) > tr.table-light > * {
  --bs-table-bg: var(--ui-surface-2);
  --bs-table-color: var(--ui-text);
  --bs-table-border-color: var(--ui-border);
  --bs-table-striped-bg: var(--ui-surface-2);
  --bs-table-hover-bg: var(--ui-surface-2);
  color: var(--ui-text);
}
[data-bs-theme="dark"] .bg-white { background-color: var(--ui-surface) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--ui-surface-2) !important; color: var(--ui-text); }
[data-bs-theme="dark"] .border-light { border-color: var(--ui-border) !important; }

/* Project calendar (Intern/Projects/Calendar) – theme-aware month grid */
.ui-calendar .table { table-layout: fixed; min-width: 56rem; --bs-table-bg: var(--ui-surface); }
.ui-calendar .table > :not(caption) > * > * { padding: .4rem; }
.ui-calendar thead th { text-align: center; }
.ui-calendar td { height: 7.5rem; vertical-align: top; }
.ui-calendar td.is-weekend { --bs-table-bg: color-mix(in srgb, var(--ui-surface-2) 60%, var(--ui-surface)); }
.ui-calendar td.is-outside { --bs-table-bg: var(--ui-surface-2); }
.ui-calendar td.is-outside .ui-calendar-day { color: var(--ui-text-muted); font-weight: 400; opacity: .7; }
.ui-calendar td.is-today { --bs-table-bg: var(--ui-primary-soft); box-shadow: inset 0 0 0 2px var(--portal-primary); }
[data-bs-theme="dark"] .ui-calendar td.is-today { box-shadow: inset 0 0 0 2px var(--ui-primary-strong); }
.ui-calendar-day { font-size: .8rem; font-weight: 600; margin-bottom: .3rem; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; }
.ui-calendar td.is-today .ui-calendar-day { background: var(--portal-primary); color: #fff; }
[data-bs-theme="dark"] .ui-calendar td.is-today .ui-calendar-day { background: var(--ui-primary-strong); color: var(--ui-bg); }
.ui-calendar-event {
  --prio: var(--portal-primary);
  display: block; margin-bottom: .25rem; padding: .2rem .45rem;
  border-radius: .35rem; border-left: 3px solid var(--prio);
  background: color-mix(in srgb, var(--prio) 18%, var(--ui-surface));
  color: var(--ui-text) !important; font-size: .76rem; font-weight: 400 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none !important;
  transition: background-color .15s;
}
/* the tile takes the priority color (same colors as in the project list) */
.ui-calendar-event.prio-1 { --prio: #16a34a; }
.ui-calendar-event.prio-2 { --prio: #f59e0b; }
.ui-calendar-event.prio-3 { --prio: #94a3b8; }
.ui-calendar-event:hover { background: color-mix(in srgb, var(--prio) 32%, var(--ui-surface)); }
[data-bs-theme="dark"] .ui-calendar-event { background: color-mix(in srgb, var(--prio) 28%, var(--ui-surface)); }
[data-bs-theme="dark"] .ui-calendar-event:hover { background: color-mix(in srgb, var(--prio) 42%, var(--ui-surface)); }

/* Tenant symbol (themes/{key}/logo-mark.svg) in the collapsed sidebar instead of the first letter */
.app-brand-mark.has-symbol svg { width: 62%; height: 62%; display: block; }

/* Rich text from the portal editor (PortalContent) – client portal and editor share these rules */
.ui-richtext { line-height: 1.6; overflow-wrap: anywhere; }
.ui-richtext > :last-child { margin-bottom: 0; }
.ui-richtext h1, .ui-richtext h2, .ui-richtext h3 { margin: 1.25rem 0 .6rem; }
.ui-richtext h1 { font-size: 1.6rem; } .ui-richtext h2 { font-size: 1.3rem; } .ui-richtext h3 { font-size: 1.1rem; }
.ui-richtext img { max-width: 100%; height: auto; }
/* columns of the editor ("Spalten"): outlined while editing so they can be found and filled */
/* columns in texts: Bootstrap pulls a .row up by its vertical gutter (negative margin-top) – that put the columns over
   the text above and out of reach in the editor. Here the vertical gap is a row-gap instead (also when stacked on phones). */
.ui-richtext .row { --bs-gutter-y: 0; row-gap: 1.25rem; margin-top: 0; margin-bottom: 1rem; }
.jodit-wysiwyg .row > [class*="col-"] { outline: 1px dashed var(--ui-border-strong); outline-offset: -1px; min-height: 2.5rem; padding-top: .25rem; }
.ui-richtext table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .92rem; }
.ui-richtext th, .ui-richtext td { border: 1px solid var(--ui-border-strong); padding: .5rem .7rem; vertical-align: top; }
.ui-richtext th, .ui-richtext thead td { background: var(--ui-surface-2); font-weight: 600; }
.ui-richtext blockquote { border-left: 3px solid var(--portal-accent); padding-left: 1rem; color: var(--ui-text-muted); }
.ui-richtext a { font-weight: 550; }
/* Handbooks (Pages/Hilfe): tips as boxes, screenshots framed */
.ui-help { max-width: 52rem; }
.ui-help h1 { margin-top: 0; }
.ui-help blockquote { color: var(--ui-text); background: color-mix(in srgb, var(--portal-primary) 6%, var(--ui-surface)); border-left: 4px solid var(--portal-primary); border-radius: 0 var(--ui-radius-sm) var(--ui-radius-sm) 0; padding: .7rem 1rem; margin: 1rem 0; }
.ui-help blockquote > :last-child { margin-bottom: 0; }
.ui-help img { border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow-sm, 0 1px 3px rgba(0,0,0,.08)); margin: .5rem 0 1rem; }
.ui-help ol > li, .ui-help ul > li { margin-bottom: .35rem; }
.ui-content-preview { max-height: 320px; overflow: hidden; position: relative; font-size: .9rem; }
.ui-content-preview::after { content: ""; position: absolute; inset: auto 0 0 0; height: 80px; background: linear-gradient(transparent, var(--ui-surface)); }
.ui-welcome-greeting { font-weight: 600; margin-bottom: .75rem; }

/* Jodit editor in the portal look */
.ui-editor-card { overflow: hidden; }
.ui-editor-card .jodit-container:not(.jodit_inline) { border: 0; border-radius: 0; background: var(--ui-surface); }
.ui-editor-card .jodit-toolbar__box:not(:empty) { background: var(--ui-surface-2); border-bottom: 1px solid var(--ui-border); }
.ui-editor-card .jodit-workplace, .ui-editor-card .jodit-wysiwyg { background: var(--ui-surface); color: var(--ui-text); }
.ui-editor-card .jodit-wysiwyg { padding: 1.25rem 1.5rem !important; font-family: var(--bs-body-font-family); font-size: .95rem; }
.ui-editor-card .jodit-status-bar { background: var(--ui-surface-2); border-top: 1px solid var(--ui-border); }

/* Table border variants from the editor ("Rahmen" in the table cell popup) */
.ui-richtext table.ui-borders-none th, .ui-richtext table.ui-borders-none td { border: 0; }
.ui-richtext table.ui-borders-none th, .ui-richtext table.ui-borders-none thead td { background: transparent; }
.ui-richtext table.ui-borders-rows th, .ui-richtext table.ui-borders-rows td { border-left: 0; border-right: 0; }
.ui-richtext table.ui-borders-rows tr:first-child > * { border-top: 0; }
.ui-richtext table.ui-borders-rows tr:last-child > * { border-bottom: 0; }
/* While editing, borderless tables keep a faint dashed grid so the cells stay findable */
.ui-editor-card .jodit-wysiwyg table.ui-borders-none td,
.ui-editor-card .jodit-wysiwyg table.ui-borders-none th { outline: 1px dashed color-mix(in srgb, var(--ui-text-muted) 45%, transparent); outline-offset: -1px; }

/* Pager under paged tables (<ui-pagination for="…" />) */
.ui-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .75rem 1rem; border-top: 1px solid var(--bs-border-color); font-size: .875rem; }
.ui-pagination-info { color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.ui-pagination .pagination { flex-wrap: wrap; }
/* on .page-link itself: the global .page-link rule sets the active colours there, so inherited values would lose.
   Soft tenant colour like the sorted column: readable for light (Škoda green) and dark primaries. */
.ui-pagination .page-link {
  --bs-pagination-color: var(--ui-text);
  --bs-pagination-bg: var(--ui-surface);
  --bs-pagination-border-color: var(--ui-border);
  --bs-pagination-hover-color: var(--ui-primary-strong);
  --bs-pagination-hover-bg: var(--ui-surface-2);
  --bs-pagination-hover-border-color: var(--ui-border);
  --bs-pagination-disabled-color: var(--ui-text-muted);
  --bs-pagination-disabled-bg: var(--ui-surface-2);
  --bs-pagination-disabled-border-color: var(--ui-border);
  --bs-pagination-active-bg: var(--ui-primary-soft);
  --bs-pagination-active-color: var(--ui-primary-strong);
  --bs-pagination-active-border-color: var(--ui-primary-soft);
  --bs-pagination-focus-box-shadow: 0 0 0 .2rem var(--ui-primary-soft);
}
.ui-pagination .page-item.active .page-link { font-weight: 600; }
.ui-pagination .page-link { min-width: 2rem; text-align: center; font-variant-numeric: tabular-nums; }
.ui-pagination-size { display: flex; align-items: center; gap: .5rem; margin: 0; }
.ui-pagination-size .form-select { width: auto; }

/* Tour planning / dealer wishes: dark table header and bold action links in the tenant colour */
.table.ui-table-brand > thead > tr > th { background: var(--portal-primary); color: #fff; border-bottom-color: var(--portal-primary); }
.table.ui-table-brand > thead > tr > th .ui-sort-link { color: #fff; }
.ui-action-link { color: var(--ui-primary-strong); font-weight: 600; text-decoration: none; }
.ui-action-link:hover { text-decoration: underline; }

/* Scaled-down mail preview (E-Mail-Vorlagen) */
.mail-thumb { overflow: hidden; background: #fff; }

/* Test environment: "Feedback" button (Pages/Shared/_TestFeedback.cshtml) */
.test-feedback-button { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1040; border-radius: 2rem; font-weight: 600; }
.test-checklist textarea { min-height: 2.1rem; }
@media print { .test-feedback-button { display: none; } }

/* ---------- Public event pages (Pages/Event): registration and check-in as one block for phones ---------- */
.event-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--ui-bg); }
.event-column { width: 100%; max-width: 34rem; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }
/* header image, event and content in one box of the same width */
.event-shell { width: 100%; max-width: 34rem; margin: 1.5rem auto; background: var(--ui-surface); border-radius: var(--ui-radius, 1rem);
  overflow: hidden; box-shadow: var(--ui-shadow-md, 0 6px 24px rgba(15, 23, 42, .08)); flex: none; }
@media (max-width: 575.98px) { .event-shell { margin: 0 auto 1rem; border-radius: 0; box-shadow: none; } }
.event-header { background: linear-gradient(135deg, var(--portal-primary), color-mix(in srgb, var(--portal-primary) 55%, #0b1220)); color: #fff; }
.event-header .auth-brand { color: #fff; display: block; margin-bottom: 1rem; }
.event-banner { display: block; width: 100%; height: auto; }
.event-head { padding: 1.1rem 1.25rem 1.25rem; }
.event-title { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.event-meta { opacity: .85; font-size: .9rem; margin-top: .25rem; }
.event-main { padding: 1.25rem; flex: 1; }
@media (max-width: 575.98px) { .event-main { padding: 1rem; } }
/* cards inside the block: flat with a border, the block itself carries the shadow */
.event-card, .event-stat { border: 1px solid var(--ui-border); box-shadow: none; }
.event-icon { font-size: 2.6rem; display: block; margin-bottom: .5rem; }
.event-text { white-space: pre-line; }
.event-pin { letter-spacing: .5em; font-size: 1.6rem; }
.event-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.event-stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.event-footer { margin-top: auto; padding: 1.25rem 0; font-size: .82rem; color: var(--ui-text-muted); }
.event-footer a { color: inherit; }
/* result of a scanned ticket: big and unmistakable at the door */
.event-result { border-radius: var(--ui-radius, 1rem); padding: 2rem 1.25rem; text-align: center; color: #fff; }
.event-result > i { font-size: 4rem; display: block; line-height: 1; margin-bottom: .75rem; }
.event-result h1 { font-size: 1.8rem; font-weight: 800; margin: 0 0 .5rem; color: inherit; }
.event-result p { margin: .25rem 0 0; }
.event-result .event-guest { font-size: 1.35rem; font-weight: 700; }
.event-result.is-valid { background: #16a34a; }
.event-result.is-used { background: #f59e0b; color: #1f1300; }
.event-result.is-invalid { background: #dc2626; }
/* ticket design editor (Intern/Admin/Events/Design) */
.ticket-preview { display: flex; justify-content: center; padding: 1rem; background: var(--ui-surface-2); border-radius: var(--ui-radius-sm); overflow: auto; }
.ticket-preview iframe { width: 105mm; height: 187mm; border: 0; background: #fff; box-shadow: 0 6px 24px rgba(15, 23, 42, .18); flex: none; }
.min-w-0 { min-width: 0; }
/* check-in: tabs "Gästeliste" / "Gast hinzufügen" sit on top of their card */
.event-tabs { border-bottom: 0; }
.event-tabs .nav-link { font-weight: 600; }
.event-tab-content { border-top-left-radius: 0; border-top-right-radius: 0; }

/* Searchable selects (ui.js initSelect, Tom Select).
   Closed: the wrapper keeps the select's classes (.form-select, -sm), so border, radius, colors and the chevron come from
   the same rules as every other select, including the tenant theme; the inner control only lays out the text.
   Open: looks like the portal's .dropdown-menu (surface, radius, shadow, rounded items). */
.ts-wrapper.form-select { padding: 0 !important; height: auto; min-height: 0; box-shadow: var(--ui-shadow-sm); }
.ts-wrapper.form-select .ts-control,
.ts-wrapper.form-select.single.input-active .ts-control {
  background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: inherit;
  min-height: 0; padding: .55rem 2.25rem .55rem .85rem !important; font-size: inherit !important; line-height: 1.5; color: var(--ui-text); cursor: pointer;
}
.ts-wrapper.form-select-sm .ts-control,
.ts-wrapper.form-select-sm.single.input-active .ts-control { padding: .32rem 2rem .32rem .65rem !important; font-size: inherit !important; }
.ui-input-icon > .ts-wrapper .ts-control { padding-left: 2.4rem !important; }
.ui-input-icon.ui-sm > .ts-wrapper .ts-control { padding-left: 2rem !important; }
.ts-wrapper .ts-control .item { color: var(--ui-text); }
.ts-wrapper.form-select:hover:not(.focus):not(.disabled) { border-color: color-mix(in srgb, var(--ui-border-strong) 60%, var(--ui-text-muted)); }
.ts-wrapper.form-select.focus { border-color: color-mix(in srgb, var(--portal-primary) 70%, #3b82f6); box-shadow: 0 0 0 4px rgba(var(--portal-primary-rgb), .14); }
.ts-wrapper.form-select.disabled { background-color: var(--ui-surface-2); opacity: 1; }

.ts-dropdown, .ts-dropdown.form-select {
  background: var(--ui-surface); color: var(--ui-text); border: 1px solid var(--ui-border); border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-lg); padding: .4rem; margin-top: .3rem; font-size: .9rem; z-index: 1060;
  animation: ui-pop .14s var(--ui-ease);
}
.ts-dropdown .ts-dropdown-content { padding: 0; max-height: 18rem; }
.ts-dropdown .option, .ts-dropdown .no-results { padding: .45rem .75rem; border-radius: .45rem; }
.ts-dropdown .option.active { background: var(--ui-surface-2); color: var(--ui-text); }
.ts-dropdown .option.selected { background: var(--ui-primary-soft); color: var(--ui-primary-strong); font-weight: 550; }
.ts-dropdown .no-results { color: var(--ui-text-muted); }
.ts-dropdown .highlight { background: var(--ui-primary-soft); color: inherit; border-radius: 2px; }
.ts-dropdown .dropdown-input-wrap { padding: 0 0 .4rem; margin-bottom: .3rem; border-bottom: 1px solid var(--ui-border); }
.ts-dropdown .dropdown-input {
  width: 100%; background: var(--ui-surface); color: var(--ui-text); border: 1px solid var(--ui-border-strong);
  border-radius: .5rem; padding: .32rem .65rem; font-size: .84rem; box-shadow: none;
}
.ts-dropdown .dropdown-input::placeholder { color: color-mix(in srgb, var(--ui-text-muted) 75%, transparent); }
.ts-dropdown .dropdown-input:focus, .ts-wrapper.plugin-dropdown_input.focus .ts-dropdown .dropdown-input { outline: 0; border-color: color-mix(in srgb, var(--portal-primary) 70%, #3b82f6); box-shadow: 0 0 0 3px rgba(var(--portal-primary-rgb), .14); }
