/* =====================================================================
   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; }
/* plain Bootstrap alerts (no icon) hold running text with <strong>, <code> …: as flex items those would become columns */
.alert:not(:has(> .ui-alert-icon)) { display: block; }
.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; }
.ui-toast-info::before { background: var(--bs-primary); }
.ui-toast-info .ui-toast-icon { color: var(--bs-primary); }

/* Notifications (bell in the top bar, list page) */
.notification-count { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--bs-danger); color: #fff; font-size: .65rem; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--ui-surface); }
.notification-menu { width: min(23rem, calc(100vw - 2rem)); }
.notification-list { max-height: 24rem; overflow-y: auto; }
.notification-item { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem 1rem; color: var(--ui-text); text-decoration: none; border-bottom: 1px solid var(--ui-border); }
.notification-list .notification-item:last-child { border-bottom: 0; }
.notification-item:hover { background: var(--ui-surface-2); color: var(--ui-text); }
.notification-item .notification-icon { font-size: 1.1rem; color: var(--ui-text-muted); margin-top: .1rem; }
.notification-item.unread { background: rgba(var(--bs-primary-rgb), .06); }
.notification-item.unread .notification-icon { color: var(--bs-primary); }
.notification-item:not(.unread) .fw-semibold { font-weight: 500 !important; }
.notification-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Verwaltung → Export-Spalten */
.export-columns .export-column { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; }
.export-columns .export-column::before { min-width: 1.6rem; color: var(--ui-text-muted); font-size: .8rem; }
.export-column .drag-handle { cursor: grab; }
.export-column .export-column-name { flex: 0 0 34%; font-size: .875rem; }
.export-column input.form-control { flex: 1 1 auto; min-width: 0; }
.export-column.dragging { opacity: .5; }
.mail-preview-frame { width: 100%; height: 70vh; min-height: 520px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: #fff; }
.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; }
/* project opened from its details page */
.stage-grid td.stage-focus { outline: 3px solid var(--bs-primary); outline-offset: -3px; font-weight: 600; }
.stage-open-row.stage-focus > td { --bs-table-bg-state: rgba(var(--bs-primary-rgb), .14); }
.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-help h2[id], .ui-help h3[id] { scroll-margin-top: 5rem; }
mark.help-mark, .help-results mark, .help-search-snippet mark { background: color-mix(in srgb, #facc15 45%, transparent); color: inherit; padding: 0; border-radius: .15em; }

/* handbook search (Pages/Hilfe/_SearchBox, js/help-search.js) */
.help-search { position: relative; display: flex; align-items: center; }
.help-search > .bi { position: absolute; left: .9rem; color: var(--ui-text-muted); pointer-events: none; }
.help-search .form-control { padding-left: 2.5rem; padding-right: 4.5rem; height: 44px; border-radius: 999px; background: var(--ui-surface); }
.help-search-kbd { position: absolute; right: .7rem; 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; }
.help-search-menu { position: absolute; top: calc(100% + .35rem); left: 0; right: 0; z-index: 1060; max-height: min(70vh, 34rem); overflow-y: auto;
  background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow-lg); padding: .35rem; }
.col-xl-3 .help-search-menu { left: auto; width: min(30rem, 90vw); }
.help-search-option { display: block; padding: .55rem .7rem; border-radius: calc(var(--ui-radius) - .25rem); color: var(--ui-text); text-decoration: none; }
.help-search-option:hover, .help-search-option.active { background: color-mix(in srgb, var(--portal-primary) 9%, var(--ui-surface)); color: var(--ui-text); }
.help-search-title { display: block; font-weight: 600; }
.help-search-section { font-weight: 400; color: var(--ui-text-muted); }
.help-search-book { display: block; font-size: .75rem; color: var(--ui-text-muted); }
.help-search-snippet { display: block; font-size: .82rem; color: var(--ui-text-muted); margin-top: .15rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.help-search-all { border-top: 1px solid var(--ui-border); margin-top: .25rem; border-radius: 0 0 calc(var(--ui-radius) - .25rem) calc(var(--ui-radius) - .25rem); font-size: .875rem; font-weight: 600; color: var(--portal-primary); }
.help-search-hint, .help-search-empty { padding: .55rem .7rem; font-size: .875rem; color: var(--ui-text-muted); }
.help-result-section { display: block; margin-top: .6rem; padding: .45rem .7rem; border-left: 3px solid var(--ui-border); color: var(--ui-text); text-decoration: none; border-radius: 0 var(--ui-radius-sm) var(--ui-radius-sm) 0; }
.help-result-section:hover { border-left-color: var(--portal-primary); background: var(--ui-surface-2); }
.help-result-section .bi-hash { color: var(--ui-text-muted); }
.help-search-tips code { white-space: nowrap; }
.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); }

/* E-Mail-Layout (Pages/Intern/Admin/MailLayout): preview stays in view while the style controls scroll; phone width on demand. */
@media (min-width: 1200px) { .mail-preview-card { position: sticky; top: 76px; } }
.mail-preview-stage { background: var(--ui-surface-2); padding: 12px; border-radius: 0 0 var(--ui-radius) var(--ui-radius); }
.mail-preview-stage iframe { width: 100%; height: calc(100vh - 170px); min-height: 640px; background: #fff; transition: width .2s var(--ui-ease); }
.mail-preview-stage iframe.is-mobile { width: 390px; max-width: 100%; border-radius: 18px !important; box-shadow: 0 0 0 8px #1f2937, var(--ui-shadow-lg); }
.mail-color .form-control-color { max-width: 2.6rem; padding: .2rem; }
.mail-layout-actions { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(transparent, var(--ui-bg) 35%); z-index: 2; }
/* Sliders in the tenant colour (Bootstrap draws them in its own blue). */
.form-range { accent-color: var(--portal-primary); }
.form-range::-webkit-slider-thumb { background-color: var(--portal-primary); }
.form-range::-moz-range-thumb { background-color: var(--portal-primary); }
.form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--ui-surface), 0 0 0 4px rgba(var(--portal-primary-rgb), .25); }
.form-range:focus::-moz-range-thumb { box-shadow: 0 0 0 1px var(--ui-surface), 0 0 0 4px rgba(var(--portal-primary-rgb), .25); }

/* vehicle damages (Pages/Intern/Vehicles/_DamageRow) */
.damage-item.is-repaired { background: var(--ui-surface-2); }
.damage-photos { display: flex; flex-wrap: wrap; gap: .5rem; }
.damage-photo { position: relative; margin: 0; }
.damage-photo img { width: 112px; height: 84px; object-fit: cover; border-radius: var(--ui-radius-sm); border: 1px solid var(--ui-border); display: block; }
.damage-photo-delete { position: absolute; top: .2rem; right: .2rem; width: 1.5rem; height: 1.5rem; line-height: 1; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 1rem; opacity: 0; transition: opacity .15s; }
.damage-photo:hover .damage-photo-delete, .damage-photo-delete:focus-visible { opacity: 1; }
@media (hover: none) { .damage-photo-delete { opacity: 1; } }

.vehicle-photo { max-height: 14rem; object-fit: cover; }

/* driver page behind the vehicle QR code (Pages/Fahrzeug, js/driver.js) – made for the phone */
.driver-page { max-width: 34rem; margin: 0 auto; padding-bottom: 2rem; }
.driver-page h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }

.driver-done { display: flex; gap: .85rem; align-items: flex-start; padding: 1rem; margin-bottom: 1rem; border-radius: var(--ui-radius);
  background: color-mix(in srgb, var(--bs-success) 12%, var(--ui-surface)); border: 1px solid color-mix(in srgb, var(--bs-success) 35%, transparent); }
.driver-done-icon { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; background: var(--bs-success); color: #fff; font-size: 1.4rem; }
.driver-done-title { font-weight: 700; font-size: 1.05rem; }
.driver-done-text { color: var(--ui-text-muted); font-size: .92rem; }

.driver-hero { display: flex; gap: .9rem; align-items: center; padding: .75rem; margin-bottom: .75rem; border-radius: var(--ui-radius);
  background: var(--ui-surface); border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow-sm); }
.driver-hero-photo { flex: none; width: 6.5rem; height: 6.5rem; object-fit: cover; border-radius: calc(var(--ui-radius) - .2rem); }
.driver-hero-placeholder { display: grid; place-items: center; background: var(--ui-surface-2); color: var(--ui-text-muted); font-size: 2.4rem; }
.driver-hero-body { min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.driver-plate { align-self: flex-start; font-family: "DIN 1451", "Arial Narrow", Arial, sans-serif; font-weight: 700; font-size: 1.2rem; letter-spacing: .04em;
  white-space: nowrap; padding: .1rem .5rem .1rem .95rem; border: 2px solid #111; border-radius: .35rem; color: #111;
  background: linear-gradient(90deg, #1d4ed8 0, #1d4ed8 .5rem, #fff .5rem); }
.driver-model { font-weight: 700; }
.driver-meta { font-size: .82rem; color: var(--ui-text-muted); }
.driver-status { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; }
.driver-status .bi-circle-fill { font-size: .55rem; }
.driver-status.is-free .bi-circle-fill { color: var(--bs-success); }
.driver-status.is-out .bi-circle-fill { color: var(--bs-warning); }
.driver-km { margin-left: auto; font-weight: 400; color: var(--ui-text-muted); }

.driver-damages { margin-bottom: .75rem; padding: .6rem .8rem; border-radius: var(--ui-radius); font-size: .9rem;
  background: color-mix(in srgb, var(--bs-warning) 14%, var(--ui-surface)); border: 1px solid color-mix(in srgb, var(--bs-warning) 40%, transparent); }
.driver-damages summary { cursor: pointer; font-weight: 600; }
.driver-damages .bi { color: var(--bs-warning); }
.driver-damages ul { margin: .5rem 0 0; padding-left: 1.1rem; }

.driver-actions { display: grid; gap: .6rem; margin-bottom: 1rem; }
.driver-primary { display: flex; align-items: center; gap: .9rem; text-align: left; padding: 1rem 1.1rem; border-radius: var(--ui-radius); font-size: 1rem; }
.driver-primary > .bi { font-size: 1.7rem; }
.driver-primary strong { display: block; font-size: 1.1rem; }
.driver-primary small { display: block; opacity: .85; }
.driver-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .6rem; }
.driver-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 5rem; padding: .6rem;
  border-radius: var(--ui-radius); border: 1px solid var(--ui-border); background: var(--ui-surface); color: var(--ui-text); font-weight: 600; font-size: .92rem; }
.driver-tile .bi { font-size: 1.5rem; color: var(--portal-primary); }
.driver-tile.is-danger .bi { color: var(--bs-danger); }
.driver-tile[aria-expanded="true"] { border-color: var(--portal-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--portal-primary) 35%, transparent); }

.driver-sheet { scroll-margin-top: 4.5rem; }
.driver-sheet form { padding: 1rem; margin-bottom: 1rem; border-radius: var(--ui-radius); background: var(--ui-surface); border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow); }
.driver-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.driver-hint { font-size: .88rem; color: var(--ui-text-muted); margin-bottom: .5rem; }
.driver-label { display: block; font-size: .85rem; font-weight: 600; margin: .85rem 0 .3rem; }
.driver-page .form-control, .driver-page .form-select { min-height: 3rem; font-size: 1rem; }
.driver-input-lg { font-size: 1.4rem !important; font-weight: 600; letter-spacing: .02em; }
.driver-km-feedback { min-height: 1.2rem; margin-top: .3rem; font-size: .85rem; color: var(--ui-text-muted); }
.driver-km-feedback.is-ok { color: var(--bs-success); font-weight: 600; }
.driver-km-feedback.is-warning { color: var(--bs-danger); font-weight: 600; }
.driver-chips, .driver-toggles { display: flex; flex-wrap: wrap; gap: .45rem; }
.driver-toggles { margin-top: 1rem; }
.driver-chips .btn, .driver-toggles .btn { border-radius: 999px; min-height: 2.6rem; padding: .4rem .95rem; }
.driver-chips .btn-check:checked + .btn, .driver-toggles .btn-check:checked + .btn { background: var(--portal-primary); border-color: var(--portal-primary); color: #fff; opacity: 1; }
.driver-more { margin-top: 1rem; border-top: 1px solid var(--ui-border); padding-top: .75rem; }
.driver-more summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--portal-primary); }
.driver-more summary span { font-weight: 400; color: var(--ui-text-muted); }
.driver-submit { width: 100%; min-height: 3.2rem; margin-top: 1.25rem; font-size: 1.05rem; font-weight: 700; border-radius: var(--ui-radius); }

.driver-photo-picker { margin-bottom: .5rem; }
.driver-camera { display: flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; min-height: 3.4rem; border-style: dashed; font-weight: 600; border-radius: var(--ui-radius); }
.driver-camera .bi { font-size: 1.3rem; }
.driver-camera.has-photos { border-style: solid; }
.driver-photo-picker.is-busy .driver-camera { opacity: .6; pointer-events: none; }
.driver-previews { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.driver-preview { position: relative; width: 4.5rem; height: 4.5rem; border-radius: .5rem; overflow: hidden; border: 1px solid var(--ui-border);
  display: grid; place-items: center; background: var(--ui-surface-2); font-size: 1.6rem; color: var(--ui-text-muted); }
.driver-preview img { width: 100%; height: 100%; object-fit: cover; }
.driver-preview-remove { position: absolute; top: .15rem; right: .15rem; width: 1.6rem; height: 1.6rem; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; line-height: 1; font-size: 1.1rem; }

.driver-history { margin-top: 1.5rem; }
.driver-history h2 { font-size: .95rem; margin-bottom: .5rem; }
.driver-history ul { list-style: none; padding: 0; margin: 0; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: var(--ui-surface); }
.driver-history li { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; padding: .6rem .8rem; font-size: .9rem; }
.driver-history li + li { border-top: 1px solid var(--ui-border); }
.driver-history li strong { margin-left: auto; }
.driver-history li small { flex-basis: 100%; color: var(--ui-text-muted); }
.driver-footer { margin-top: 1.25rem; font-size: .82rem; color: var(--ui-text-muted); text-align: center; }

/* vehicle calendar (Pages/Intern/Vehicles/Calendar), on top of the stage plan grid */
.vcal tbody.vcal-vehicle { border-top: 2px solid var(--ui-border-strong); }
.vcal .vcal-trip-lane td, .vcal .vcal-trip-lane th { padding-top: .1rem !important; padding-bottom: .1rem !important; }
.vcal td.vcal-trip { background: color-mix(in srgb, var(--bs-success) 22%, var(--ui-surface)); font-size: .7rem; }
.vcal td.vcal-trip a { color: var(--ui-text); }
.vcal td.vcal-trip.is-open { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bs-warning) 35%, var(--ui-surface)) 0 6px, var(--ui-surface) 6px 10px); }
.vcal .vcal-focus th.sticky-col, .vcal tbody.vcal-focus th.sticky-col { box-shadow: inset 4px 0 0 var(--bs-primary); }
.vcal-weeks td { text-align: center; }
.vcal-dot { display: inline-block; width: .5rem; height: .5rem; margin-left: .2rem; border-radius: 50%; background: var(--bs-success); vertical-align: middle; }
.vcal-scroll { max-height: 70vh; }
.vcal-swatch { display: inline-block; width: 12px; height: 12px; margin-right: .3rem; vertical-align: -1px; border: 1px solid var(--ui-border); }
.vcal-swatch-plan { background: #cfe2ff; }
.vcal-swatch-trip { background: color-mix(in srgb, var(--bs-success) 22%, var(--ui-surface)); }
.vcal-swatch-open { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bs-warning) 35%, var(--ui-surface)) 0 3px, var(--ui-surface) 3px 5px); }
/* place on the first line, driver on the second, both cut off with … when the bar is short (full text in the tooltip) */
.vcal td.booked a { line-height: 1.2; }
.vcal .vcal-line1, .vcal .vcal-line2 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcal .vcal-line1 { font-weight: 600; }
.vcal .vcal-line2 { font-size: .68rem; font-weight: 400; }
.vcal .vcal-line2.is-missing { display: inline-block; max-width: 100%; vertical-align: top; margin-top: .1rem; padding: 0 .3rem; border-radius: .25rem;
  background: #fff; color: var(--bs-danger); font-weight: 600; }
.vcal .vcal-line1 .bi, .vcal .vcal-line2 .bi { font-size: .65rem; }
.vcal-weeks th:not(.sticky-col), .vcal-weeks td { min-width: 4.5rem; max-width: 4.5rem; }
.vcal-weeks .sticky-col { min-width: 9.5rem; }
.vcal-weeks td.booked { text-align: left; }
.vcal.stage-days th.stage-day, .vcal.stage-days td { min-width: 2.7rem; max-width: 2.7rem; }
.vcal.stage-days td.booked { max-width: none; }
/* plate and vehicle columns live in the one sticky cell (several sticky cells side by side leave gaps in a collapsed table) */
.stage-grid th.vcal-fixed { padding: 0 !important; min-width: 0 !important; max-width: none !important; z-index: 2; }
.stage-grid thead th.vcal-fixed { z-index: 4; }
.vcal-cols { display: flex; align-items: stretch; height: 100%; }
.vcal-c { flex: none; width: 6rem; padding: .3rem .4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem;
  font-weight: 400; text-align: left; border-left: 1px solid var(--bs-border-color); }
thead .vcal-c { font-weight: 600; }
.vcal-c-plate { width: 8.5rem; border-left: 0; font-size: .75rem; }
.vcal-c[data-col="hp"] { width: 3rem; }
.vcal-c[data-col="engine"], .vcal-c[data-col="tuev"], .vcal-c[data-col="pool"] { width: 4.8rem; }
.vcal-c[data-col="km"] { width: 5rem; text-align: right; }
.vcal-c[data-col="vin"] { width: 9.5rem; font-family: var(--bs-font-monospace); }
.vcal-c[data-col="paint"], .vcal-c[data-col="branding"], .vcal-c[data-col="trim"] { width: 7rem; }
.stage-grid th.vcal-fixed { box-shadow: inset -2px 0 0 var(--ui-border-strong); }
/* stage plan columns */
.vcal-c[data-col="module"] { width: 7rem; }
.vcal-c[data-col="base"] { width: 6rem; }
.vcal-c[data-col="bookings"], .vcal-c[data-col="load"] { width: 4.8rem; text-align: right; }
.vcal-c[data-col="days"] { width: 7rem; text-align: right; }
.vcal-c[data-col="next"] { width: 7rem; }
.vcal-c[data-col="status"] { width: 5.5rem; }

/* own alert/confirm dialog (GatePortalUI.confirm / alert, data-confirm) */
.ui-dialog .modal-dialog { max-width: 28rem; }
.ui-dialog .modal-body { padding: 1.5rem 1.5rem 1rem; }
.ui-dialog .modal-footer { border-top: 0; padding: 0 1.5rem 1.25rem; gap: .5rem; }
.ui-dialog .modal-footer > * { margin: 0; }
.ui-dialog-icon { width: 2.75rem; height: 2.75rem; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.ui-dialog[data-variant="danger"] .ui-dialog-icon { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.ui-dialog[data-variant="warning"] .ui-dialog-icon { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.ui-dialog-message { white-space: pre-line; color: var(--bs-secondary-color); overflow-wrap: anywhere; }

/* client dashboard: stacked month bars (done / planned) and horizontal share bars */
.ui-bar-stack { width: min(26px, 70%); height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.ui-bar-stack > span { display: block; min-height: 0; }
.ui-bar-stack > span:first-child { border-radius: 4px 4px 0 0; }
.ui-bar-stack .seg-done { background: var(--portal-primary); }
.ui-bar-stack .seg-planned { background: color-mix(in srgb, var(--portal-primary) 30%, var(--ui-surface)); }
[data-bs-theme="dark"] .ui-bar-stack .seg-done { background: var(--portal-accent); }
[data-bs-theme="dark"] .ui-bar-stack .seg-planned { background: color-mix(in srgb, var(--portal-accent) 35%, var(--ui-surface)); }
.ui-bars:hover .ui-bar:not(:hover) .ui-bar-stack { opacity: .45; }
.ui-legend-swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; vertical-align: -.05rem; margin-right: .3rem; }
.ui-share { display: grid; grid-template-columns: minmax(6rem, 10rem) 1fr 2.5rem; align-items: center; gap: .5rem; font-size: .875rem; }
.ui-share + .ui-share { margin-top: .45rem; }
.ui-share-track { height: .55rem; border-radius: 99px; background: var(--ui-surface-2, var(--bs-tertiary-bg)); overflow: hidden; }
.ui-share-fill { display: block; height: 100%; border-radius: 99px; background: var(--portal-primary); }
.ui-kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* ── Charts of the client reporting (Pages/Shared/_VizChart.cshtml, viz.js) ─────────────────────────────────────
   One hue for the current series, a recessive grey (dashed) for the previous year; colours validated with the dataviz
   palette check (lightness band, CVD and normal-vision separation, 3:1 against the surface). Tenants override --viz-current. */
:root, [data-bs-theme="light"] {
  --viz-current: #2a78d6;
  --viz-previous: #8a93a3;
  --viz-up: #1a7f37;
  --viz-down: #c62828;
}
[data-bs-theme="dark"] {
  --viz-current: #3987e5;
  --viz-previous: #5d6778;
  --viz-up: #3fb950;
  --viz-down: #f47067;
}
.viz { margin: 0; position: relative; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: var(--ui-text-muted); margin-bottom: .5rem; }
.viz-key { display: inline-flex; align-items: center; gap: .4rem; }
.viz-swatch { width: 14px; height: 10px; border-radius: 3px; background: var(--viz-current); display: inline-block; }
.viz-lines .viz-key .viz-swatch { height: 3px; }
.viz-lines .viz-key.is-prev .viz-swatch { background: repeating-linear-gradient(90deg, var(--viz-previous) 0 4px, transparent 4px 6px); }
.viz-columns .viz-key.is-prev .viz-swatch { background: var(--viz-previous); opacity: .75; }
.viz-frame { display: flex; gap: .5rem; }
.viz-yaxis { position: relative; width: 2.6rem; flex: none; font-size: .72rem; color: var(--ui-text-muted); font-variant-numeric: tabular-nums; }
.viz-yaxis span { position: absolute; right: 0; transform: translateY(50%); white-space: nowrap; }
.viz-plot { position: relative; flex: 1; height: var(--viz-h, 220px); }
.viz-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--ui-border); }
.viz-grid.is-base { border-top: 1px solid var(--ui-border-strong); }
.viz-cols { position: absolute; inset: 0; display: flex; }
.viz-col { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; align-items: flex-end; gap: 2px; padding: 0 clamp(2px, .6vw, 10px); outline: none; cursor: default; border-radius: 6px 6px 0 0; }
.viz-col:hover, .viz-col.is-active, .viz-col:focus-visible { background: color-mix(in srgb, var(--ui-text) 5%, transparent); }
.viz-col:focus-visible { box-shadow: inset 0 0 0 2px var(--viz-current); }
.viz-bar { flex: 1 1 0; max-width: 28px; min-height: 0; border-radius: 4px 4px 0 0; background: var(--viz-current); transition: height .6s var(--ui-ease); }
.viz-bar.is-prev { background: var(--viz-previous); opacity: .75; }
.viz-col.is-hl .viz-bar.is-cur { background: color-mix(in srgb, var(--viz-current) 78%, var(--ui-text)); }
.viz-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.viz-line { fill: none; stroke: var(--viz-current); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.viz-line.is-prev { stroke: var(--viz-previous); stroke-width: 2; stroke-dasharray: 6 5; }
.viz-end { position: absolute; transform: translate(-50%, -140%); font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ui-text); background: var(--ui-surface); padding: 0 .25rem; border-radius: 4px; pointer-events: none; white-space: nowrap; }
.viz-end.is-prev { color: var(--ui-text-muted); transform: translate(-50%, 40%); font-weight: 500; }
.viz-hits { position: absolute; inset: 0; display: flex; }
.viz-hit { flex: 1 1 0; min-width: 0; outline: none; }
.viz-hit:focus-visible { box-shadow: inset 0 0 0 2px var(--viz-current); border-radius: 6px; }
.viz-cross { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--ui-border-strong); pointer-events: none; }
.viz-dot { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--viz-current); box-shadow: 0 0 0 2px var(--ui-surface); transform: translate(-50%, 50%); pointer-events: none; }
.viz-dot.is-prev { background: var(--viz-previous); }
.viz-tip { position: absolute; top: -.5rem; z-index: 5; transform: translateY(-100%); min-width: 9rem; padding: .45rem .65rem; border-radius: 8px; background: var(--ui-surface); border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow-lg); font-size: .78rem; color: var(--ui-text); pointer-events: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-tip-title { font-weight: 600; margin-bottom: .1rem; }
.viz-xaxis { display: grid; grid-template-columns: repeat(var(--n), 1fr); margin-left: 3.1rem; margin-top: .35rem; font-size: .72rem; color: var(--ui-text-muted); text-align: center; }
.viz-xaxis .is-hl { color: var(--ui-text); font-weight: 600; }
.viz-spark { width: 100%; height: 32px; display: block; }
.viz-spark polyline { fill: none; stroke: var(--viz-current); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
@media (prefers-reduced-motion: reduce) { .viz-bar { transition: none; } }

/* client reporting: navigation, hero, tiles, deltas, rankings, heatmap, records */
.rp-nav { display: flex; flex-wrap: wrap; gap: .25rem; padding: .25rem; border-radius: 999px; background: var(--ui-surface); border: 1px solid var(--ui-border); width: fit-content; max-width: 100%; }
.rp-nav a { padding: .4rem .95rem; border-radius: 999px; color: var(--ui-text-muted); text-decoration: none; font-size: .875rem; font-weight: 500; display: inline-flex; gap: .4rem; align-items: center; }
.rp-nav a:hover { color: var(--ui-text); background: var(--ui-surface-2); }
.rp-nav a.active { background: var(--ui-text); color: var(--ui-surface); }
.rp-hero { position: relative; overflow: hidden; border-radius: var(--ui-radius-lg); padding: 1.75rem; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--viz-current) 65%, transparent) 0%, transparent 60%), color-mix(in srgb, var(--portal-primary) 85%, #0b1220); }
.rp-hero-label { font-size: .8rem; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.rp-hero-value { font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.rp-hero-sub { opacity: .85; }
.rp-hero .rp-delta, .rp-hero .rp-delta.is-up, .rp-hero .rp-delta.is-down, .rp-hero .rp-delta.is-flat { background: rgba(255, 255, 255, .18); color: #fff; }
.rp-hero-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 1rem; }
.rp-hero-facts > div { border-left: 2px solid rgba(255, 255, 255, .25); padding-left: .75rem; }
.rp-hero-facts strong { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.rp-hero-facts span { font-size: .78rem; opacity: .8; }
.rp-tile { height: 100%; padding: 1rem 1.1rem .75rem; display: flex; flex-direction: column; gap: .2rem; }
.rp-tile-label { font-size: .8rem; color: var(--ui-text-muted); font-weight: 500; }
.rp-tile-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.rp-tile-foot { display: flex; justify-content: space-between; gap: .5rem; align-items: center; font-size: .75rem; color: var(--ui-text-muted); }
.rp-delta { position: relative; display: inline-flex; align-items: center; gap: .2rem; font-size: .75rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-delta.is-up { color: var(--viz-up); background: color-mix(in srgb, var(--viz-up) 12%, transparent); }
.rp-delta.is-down { color: var(--viz-down); background: color-mix(in srgb, var(--viz-down) 12%, transparent); }
.rp-delta.is-flat { color: var(--ui-text-muted); background: var(--ui-surface-2); }
.rp-switch { display: flex; flex-wrap: wrap; gap: .35rem; }
.rp-switch button { border: 1px solid var(--ui-border); background: var(--ui-surface); color: var(--ui-text-muted); border-radius: 999px; padding: .25rem .75rem; font-size: .8rem; }
.rp-switch button:hover { color: var(--ui-text); }
.rp-switch button.active { border-color: var(--viz-current); color: var(--ui-text); box-shadow: inset 0 0 0 1px var(--viz-current); font-weight: 600; }
.rp-rank { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) minmax(4rem, 34%) 4.5rem; gap: .6rem; align-items: center; padding: .4rem 0; font-size: .85rem; }
.rp-rank + .rp-rank { border-top: 1px solid var(--ui-border); }
.rp-rank-no { color: var(--ui-text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.rp-rank-track { display: grid; gap: 2px; }
.rp-rank-fill { height: 8px; border-radius: 4px; background: var(--viz-current); min-width: 2px; }
.rp-rank-fill.is-prev { background: var(--viz-previous); opacity: .75; height: 5px; }
.rp-rank-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-heat { display: grid; grid-template-columns: minmax(6rem, 9.5rem) repeat(12, minmax(2.1rem, 1fr)); gap: 3px; font-size: .75rem; }
.rp-heat-head { color: var(--ui-text-muted); text-align: center; }
.rp-heat-row { color: var(--ui-text-muted); align-self: center; font-variant-numeric: tabular-nums; }
.rp-heat-cell { border-radius: 5px; aspect-ratio: 1.6; display: grid; place-items: center; font-variant-numeric: tabular-nums; color: var(--ui-text); }
.rp-heat-cell.is-strong { color: #fff; }
.rp-record { height: 100%; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.rp-record .bi-trophy { color: var(--viz-current); }
.rp-duel-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.1; }
.rp-duel-prev { color: var(--ui-text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-duel-bars { display: grid; gap: 3px; margin-top: .5rem; }
.rp-duel-bars span { height: 6px; border-radius: 3px; background: var(--viz-current); min-width: 2px; }
.rp-duel-bars span.is-prev { background: var(--viz-previous); opacity: .75; }
@media (max-width: 575.98px) { .rp-heat { grid-template-columns: 3rem repeat(12, minmax(1.3rem, 1fr)); font-size: .65rem; } .rp-rank { grid-template-columns: 1.2rem minmax(0, 1fr) 4rem; } .rp-rank-track { display: none; } }
@media print {
  .rp-nav, .rp-switch, .ui-page-header .btn, .rp-preview, .rp-filter { display: none !important; }
  .viz-tip, .viz-cross, .viz-dot { display: none !important; }
  .rp-hero, .viz-bar, .viz-swatch, .rp-rank-fill, .rp-heat-cell, .rp-duel-bars span, .rp-delta { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card, .rp-hero, .rp-tile, .rp-record { break-inside: avoid; }
  .viz-bar { transition: none; }
  @page { size: A4 landscape; margin: 12mm; }
}

/* ---------- Public contest pages (Pages/Contest, /gewinnspiel/{key}) ---------- */
.contest-prizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: .5rem; }
.contest-prize { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .6rem .4rem; border: 1px solid var(--ui-border); border-radius: .75rem; text-align: center; font-size: .8rem; line-height: 1.2; }
.contest-prize img { width: 64px; height: 64px; object-fit: cover; border-radius: .5rem; }
.contest-prize .bi { font-size: 2rem; color: var(--portal-primary); }
.contest-prize.is-gone { opacity: .45; }
.contest-result { border-radius: var(--ui-radius, 1rem); padding: 2rem 1.25rem; text-align: center; }
.contest-result > i { font-size: 3.6rem; display: block; line-height: 1; margin-bottom: .75rem; }
.contest-result h1 { font-size: 1.7rem; font-weight: 800; margin: 0 0 .5rem; color: inherit; }
.contest-result p { margin: .25rem 0 0; white-space: pre-line; }
.contest-result.is-won { background: linear-gradient(135deg, var(--portal-primary), color-mix(in srgb, var(--portal-primary) 60%, #0b1220)); color: #fff; }
.contest-result.is-won > i { animation: contest-pop .6s var(--ui-ease, ease) both; }
.contest-result.is-lost { background: var(--ui-surface-2); color: var(--ui-text); border: 1px solid var(--ui-border); }
.contest-result.is-lost > i { color: var(--ui-text-muted); }
@keyframes contest-pop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .contest-result.is-won > i { animation: none; } }
.contest-choice { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; }
.contest-option { position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .9rem .6rem; border: 2px solid var(--ui-border); border-radius: .9rem; text-align: center; cursor: pointer; background: var(--ui-surface); }
.contest-option input { position: absolute; opacity: 0; pointer-events: none; }
.contest-option img { width: 88px; height: 88px; object-fit: cover; border-radius: .6rem; }
.contest-option .bi { font-size: 2.4rem; color: var(--portal-primary); }
.contest-option-name { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.contest-option:hover { border-color: color-mix(in srgb, var(--portal-primary) 50%, var(--ui-border)); }
.contest-option:has(input:checked) { border-color: var(--portal-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--portal-primary) 25%, transparent); }
.contest-option:has(input:focus-visible) { outline: 2px solid var(--portal-primary); outline-offset: 2px; }
.contest-option.is-gone { opacity: .45; cursor: not-allowed; }
.contest-terms { max-height: 18rem; overflow: auto; padding: .75rem 1rem; border: 1px solid var(--ui-border); border-radius: .6rem; background: var(--ui-surface-2); }
.contest-terms p:last-child { margin-bottom: 0; }

/* ---------- Race: timing at the stand and the ranking screen (Pages/Contest/Timing, RankingBoard) ---------- */
.contest-time-input { width: 7.5rem; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.ranking-board { min-height: 100vh; margin: 0; background: radial-gradient(120% 100% at 100% 0%, color-mix(in srgb, var(--portal-primary) 55%, transparent) 0%, transparent 60%), #0b1016; color: #fff; display: flex; flex-direction: column; font-size: clamp(1rem, 1.6vw, 1.6rem); }
.ranking-head { display: flex; align-items: center; gap: 1.5rem; padding: 1.5vw 3vw; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.ranking-head h1 { flex: 1; margin: 0; font-size: 1.8em; font-weight: 800; letter-spacing: -.02em; }
.ranking-logo { color: #fff; }
.ranking-logo img, .ranking-logo svg { height: 2.2em; width: auto; }
.ranking-clock { opacity: .7; font-variant-numeric: tabular-nums; }
.ranking-columns { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; padding: 2vw 3vw; }
@media (max-width: 767.98px) { .ranking-columns { grid-template-columns: 1fr; } }
.ranking-col h2 { font-size: 1em; text-transform: uppercase; letter-spacing: .12em; opacity: .7; margin: 0 0 .8em; }
.ranking-empty { opacity: .6; }
.ranking-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35em; }
.ranking-list li { display: grid; grid-template-columns: 2.2em 1fr auto; align-items: center; gap: .8em; padding: .45em .8em; border-radius: .5em; background: rgba(255, 255, 255, .06); }
.ranking-place { font-weight: 800; text-align: center; opacity: .8; font-variant-numeric: tabular-nums; }
.ranking-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking-list li.is-top { background: rgba(255, 255, 255, .12); font-size: 1.1em; }
.ranking-list li.is-1 .ranking-place { color: #f5c542; opacity: 1; }
.ranking-list li.is-2 .ranking-place { color: #d6dbe2; opacity: 1; }
.ranking-list li.is-3 .ranking-place { color: #e0a36b; opacity: 1; }

/* ---------- Calendar colours and blocked periods (stage plan, vehicle calendar; see CalendarPalette) ---------- */
.calendar-swatch { display: inline-block; width: 12px; height: 12px; margin-right: .35rem; vertical-align: -1px; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .25); }
.stage-grid td.booked.is-block { background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, .12) 0 3px, transparent 3px 8px); }

/* ---------- Event website: templates and block editor (Pages/Intern/Admin/Events/Site, SitePage) ---------- */
.site-template-card { display: flex; flex-direction: column; gap: .35rem; padding: 1rem; border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm); cursor: pointer; background: var(--ui-surface); }
.site-template-card:has(input:checked) { border-color: var(--portal-primary); box-shadow: 0 0 0 2px var(--portal-primary); }
.site-template-card .form-check-input { align-self: flex-end; margin: 0 0 -1.4rem; }
.site-template-swatch { display: flex; align-items: flex-end; height: 4.5rem; border-radius: var(--ui-radius-sm); color: #fff; padding: .5rem .75rem; font-size: 1.6rem; font-weight: 700; }
.site-blocks { position: sticky; top: 1rem; }
.site-block-list { max-height: calc(100vh - 14rem); overflow: auto; }
.site-block { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; cursor: default; }
.site-block.is-active { background: var(--ui-primary-soft); box-shadow: inset 3px 0 0 var(--portal-primary); }
.site-block.is-hidden .site-block-name { opacity: .5; text-decoration: line-through; }
.site-block.is-dragging { opacity: .45; }
.site-grip { cursor: grab; color: var(--ui-text-muted); }
.site-block-name { flex: 1; min-width: 0; color: inherit; text-decoration: none; font-weight: 500; }
.site-block-actions { display: flex; gap: .5rem; }
.site-block-actions form { display: inline; }
.site-palette { width: 22rem; max-height: 70vh; overflow: auto; }
.site-palette .dropdown-item { display: flex; gap: .75rem; align-items: flex-start; white-space: normal; padding: .5rem .9rem; }
.site-palette .dropdown-item > i { font-size: 1.2rem; margin-top: .1rem; }
.site-form-card .card-body { max-height: calc(100vh - 12rem); overflow: auto; }
.site-section + .site-section { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--ui-border); }
.site-section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ui-text-muted); margin-bottom: .5rem; }
.site-item { border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); padding: .5rem .75rem .75rem; margin-bottom: .5rem; background: var(--ui-surface-2, transparent); }
.site-item-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.site-image img { display: block; max-height: 7rem; max-width: 100%; border-radius: var(--ui-radius-sm); margin-bottom: .5rem; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.site-color .form-control-color { max-width: 3rem; }
.site-preview-card { position: sticky; top: 1rem; }
.site-preview-frame { position: relative; height: calc(100vh - 9rem); min-height: 480px; background: var(--ui-surface-2, #f4f4f4); overflow: hidden; }
.site-preview-frame iframe { position: absolute; top: 0; left: 0; border: 0; background: #fff; transform-origin: 0 0; }
.site-preview-frame.is-mobile iframe { box-shadow: 0 0 0 1px var(--ui-border); }
/* own fields of the event registration (Pages/Event/_AnswerFields) on the simple registration page */
.event-page legend.form-label { font-size: 1rem; float: none; margin-bottom: .5rem; }

/* Evaluation of event forms (Pages/Intern/Admin/Events/FormResponses) */
.form-stats li { display: grid; grid-template-columns: minmax(5rem, 9rem) 1fr auto; align-items: center; gap: .5rem; padding: .2rem 0; font-size: .875rem; }
.form-stats-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-stats-bar { height: .55rem; border-radius: 4px; background: var(--ui-surface-2, #eef1f4); overflow: hidden; }
.form-stats-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--portal-primary); }
.form-stats-count { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Media library of an event website (Pages/Intern/Admin/Events/Media, picker in SitePage) */
.media-pick { display: block; width: 100%; padding: .25rem; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); background: var(--ui-surface); text-align: left; }
.media-pick:hover, .media-pick:focus-visible { border-color: var(--portal-primary); box-shadow: 0 0 0 2px var(--portal-primary); }
.media-pick img, .media-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: calc(var(--ui-radius-sm) - 2px); display: block; margin-bottom: .25rem;
    background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; }

/* Check-in: live tiles and the camera scanner (Pages/Event/CheckIn) */
a.event-stat:hover { border-color: var(--portal-primary); }
a.event-stat.is-active { border-color: var(--portal-primary); box-shadow: 0 0 0 1px var(--portal-primary); }
.event-stat-value.is-changed { color: var(--portal-primary); transition: color .2s; }
.event-scanner { border: 0; padding: 0; width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; background: #000; color: #fff; }
.event-scanner::backdrop { background: #000; }
.event-scanner video { width: 100%; height: 100%; object-fit: cover; }
.event-scanner-frame { position: absolute; inset: 50% auto auto 50%; width: min(70vw, 70vh); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.event-scanner-text { position: absolute; left: 0; right: 0; bottom: 5.5rem; text-align: center; font-weight: 600; }
.event-scanner .btn { position: absolute; left: 50%; bottom: 1.5rem; transform: translateX(-50%); }
/* ticket as PDF template: library thumbnails and the placement editor (Intern/Admin/Events/TicketPdf) */
.tpl-thumb { display: flex; justify-content: center; align-items: center; min-height: 160px; padding: .75rem; background: var(--ui-surface-2); border-bottom: 1px solid var(--bs-border-color); border-radius: var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0; }
.tpl-thumb canvas { max-width: 100%; box-shadow: 0 4px 14px rgba(15, 23, 42, .18); }
.card.border-dashed { border-style: dashed; }
.tpl-stage-wrap { display: flex; justify-content: center; padding: 1rem; background: var(--ui-surface-2); border-radius: var(--ui-radius-sm); overflow: auto; max-height: 85vh; }
.tpl-stage { position: relative; flex: none; box-shadow: 0 6px 24px rgba(15, 23, 42, .18); }
.tpl-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; background: #fff; --hair: 1px; touch-action: none; user-select: none; }
.tpl-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tpl-grid { position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(37, 99, 235, .45) var(--hair), transparent var(--hair)),
        linear-gradient(to bottom, rgba(37, 99, 235, .45) var(--hair), transparent var(--hair)),
        linear-gradient(to right, rgba(37, 99, 235, .2) var(--hair), transparent var(--hair)),
        linear-gradient(to bottom, rgba(37, 99, 235, .2) var(--hair), transparent var(--hair));
    background-size: var(--G) var(--G), var(--G) var(--G), var(--g) var(--g), var(--g) var(--g); }
.tpl-grid::before, .tpl-grid::after { content: ""; position: absolute; border: 0 dashed rgba(219, 39, 119, .75); }
.tpl-grid::before { left: 50%; top: 0; bottom: 0; border-left-width: var(--hair); }
.tpl-grid::after { top: 50%; left: 0; right: 0; border-top-width: var(--hair); }
.tpl-layer { position: absolute; inset: 0; }
.tpl-el { position: absolute; cursor: move; outline: var(--hair) dashed rgba(37, 99, 235, .7); }
.tpl-el.is-selected { outline: calc(var(--hair) * 2) solid #2563eb; z-index: 2; }
.tpl-el .tpl-text { white-space: pre-wrap; overflow-wrap: break-word; }
.tpl-el.is-qr img { display: block; width: 100%; height: 100%; pointer-events: none; }
.tpl-handle { position: absolute; right: calc(var(--hair) * -6); bottom: calc(var(--hair) * -6); width: calc(var(--hair) * 12); height: calc(var(--hair) * 12); background: #2563eb; border: calc(var(--hair) * 2) solid #fff; border-radius: 50%; cursor: nwse-resize; display: none; }
.tpl-el.is-selected .tpl-handle { display: block; }
.tpl-is-clean .tpl-el { outline: none; }
.tpl-is-clean .tpl-handle { display: none !important; }
/* new event: choice of the ticket template */
.tpl-choice { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tpl-option { display: flex; flex-direction: column; gap: .5rem; padding: .6rem; border: 1px solid var(--bs-border-color); border-radius: var(--ui-radius-sm); cursor: pointer; position: relative; }
.tpl-option:has(input:checked) { border-color: var(--bs-primary); box-shadow: 0 0 0 1px var(--bs-primary); }
.tpl-option > input { position: absolute; top: .5rem; left: .5rem; margin: 0; }
.tpl-option-thumb { display: flex; align-items: center; justify-content: center; height: 140px; background: var(--ui-surface-2); border-radius: var(--ui-radius-sm); overflow: hidden; }
.tpl-option-thumb canvas { max-height: 130px; max-width: 100%; width: auto !important; }
.tpl-option-html i { font-size: 2rem; color: var(--bs-secondary-color); }
/* page editor of the event website: each block in a popup docked on the right, preview stays visible and clickable */
.site-block-modal { pointer-events: none; }
.site-block-modal .modal-dialog { pointer-events: auto; }
.site-block-dialog { max-width: min(560px, calc(100vw - 2rem)); width: 100%; margin: 1rem 1rem 1rem auto; height: calc(100vh - 2rem); }
.site-block-dialog .modal-content { height: 100%; box-shadow: 0 18px 50px rgba(15, 23, 42, .28); border: 1px solid var(--bs-border-color); }
.site-media-modal { z-index: 1075; }
body:has(.site-media-modal.show) .modal-backdrop { z-index: 1070; }
.site-preview-frame iframe.is-loading { visibility: hidden; }
@media (max-width: 575.98px) { .site-block-dialog { margin: .5rem; height: calc(100vh - 1rem); } }
.site-block.is-nested { padding-left: 2rem; background: var(--ui-surface-2); }
.site-block.is-nested.is-active { background: var(--ui-primary-soft); }
.site-block-tab { display: inline-block; margin-left: .35rem; padding: 0 .4rem; border-radius: 1rem; font-size: .7rem; font-weight: 600; background: var(--ui-primary-soft); color: var(--portal-primary); vertical-align: middle; }
.site-placement { padding-bottom: .75rem; margin-bottom: .75rem; border-bottom: 1px solid var(--bs-border-color); }
.site-tab-content { padding: .6rem .75rem; border: 1px solid var(--bs-border-color); border-radius: var(--ui-radius-sm); margin-bottom: .5rem; }
@media (min-width: 1800px) { .site-editor.has-dialog { margin-right: 580px; } }
/* new page of the event website: choice of the page template */
.site-page-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.site-page-template { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--bs-border-color); border-radius: var(--ui-radius-sm); cursor: pointer; }
.site-page-template:has(input:checked) { border-color: var(--bs-primary); box-shadow: 0 0 0 1px var(--bs-primary); }
.site-page-template > i { font-size: 1.25rem; color: var(--portal-primary); }
.site-page-template > input { margin-top: .3rem; }
/* form editor (Events → Anmeldeformular / Formulare): outline, dialog and preview */
.fb-section { border: 1px solid var(--bs-border-color); border-radius: var(--ui-radius-sm); padding: .6rem .75rem .75rem; margin-bottom: .75rem; }
.fb-section-head { display: flex; align-items: center; gap: .25rem; margin-bottom: .35rem; }
.fb-section-head .fb-label { font-weight: 600; }
.fb-fields .fb-fields { margin-left: 1.1rem; }
.fb-field { display: flex; align-items: center; gap: .5rem; padding: .2rem .25rem; border-radius: var(--ui-radius-sm); }
.fb-field:hover, .fb-section-head:hover { background: var(--bs-tertiary-bg); }
.fb-icon { color: var(--portal-primary); width: 1.1rem; text-align: center; }
.fb-open { all: unset; cursor: pointer; flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; }
.fb-open:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; border-radius: 2px; }
.fb-type { font-size: .8rem; color: var(--bs-secondary-color); max-width: 100%; }
.fb-tools { display: inline-flex; flex: none; }
.fb-option { margin: .1rem 0 .35rem 1.35rem; padding-left: .6rem; border-left: 2px solid color-mix(in srgb, var(--bs-primary) 45%, transparent); }
.fb-when { font-size: .8rem; color: var(--bs-secondary-color); }
.fb-add { padding: 0 .25rem; font-size: .85rem; }
.fb-choice { display: flex; align-items: center; gap: .35rem; margin-bottom: .35rem; }
.fb-choice [name=optionLabel] { flex: 1 1 auto; }
.fb-preview { position: sticky; top: 1rem; }
.fb-preview-frame { position: relative; height: calc(100vh - 10rem); min-height: 420px; background: var(--ui-surface-2, #f4f4f4); }
.fb-preview-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.fb-preview-frame iframe.is-loading { visibility: hidden; }
.fb-section-when { color: var(--bs-primary-text-emphasis); flex-basis: 100%; }
