/* ============================================================================
   NEXUS CAFM – Designsystem (Phase 0)
   Quelle der Wahrheit: docs/brand/DESIGN_SYSTEM.md
   CI: Corporate Red #E2003D, Corporate Black #000000 (CD-Manual S. 5).
   Grammatik: ALL-INKL Keynote 2021 – editoriale Ruhe, dunkle Orientierungs-
   flächen, präzises Rot, Mikrolabels, 10°-Motiv sparsam.
   ========================================================================== */

/* ---------- Fonts (self-hosted, SIL OFL – siehe ASSET_AND_FONT_LICENSES.md) */
@font-face {
  font-family: 'Aldrich';
  src: url('../fonts/Aldrich-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/IBMPlexSans-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/IBMPlexSans-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/IBMPlexSans-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../fonts/IBMPlexSans-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ---------- Design Tokens (Masterprompt 25.6) ---------------------------- */
:root {
  /* Verbindliche CI */
  --brand-red: #e2003d;
  --brand-black: #000000;
  --brand-white: #ffffff;

  /* Text und Flächen */
  --ink-primary: #231f20;
  --ink-secondary: #666164;
  --ink-muted: #767174;
  --surface-canvas: #f7f6f7;
  --surface-card: #ffffff;
  --surface-inverse: #050505;
  --surface-selected: #fff0f3;
  --border-subtle: #e5e2e3;
  --border-default: #d6d2d4;
  --border-strong: #bdbcbe;

  /* Interaktion */
  --action-primary: #e2003d;
  --action-primary-hover: #c60036;
  --action-primary-active: #a8002d;
  --action-primary-text: #ffffff;
  --focus-outer: #000000;
  --focus-inner: #ffffff;

  /* Semantik – UI-Erweiterung, nicht Teil der Corporate Colours */
  --status-info: #005fcc;
  --status-success: #007a4d;
  --status-warning: #a33a00;
  --status-danger: #a8002d;
  --status-info-surface: #eaf2fc;
  --status-success-surface: #e8f5ef;
  --status-warning-surface: #fbeee6;
  --status-danger-surface: #fbe9ee;

  /* Form */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-low: 0 1px 2px rgb(0 0 0 / 0.06);
  --shadow-overlay: 0 16px 40px rgb(0 0 0 / 0.16);

  /* 4-px-Raster */
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px;  --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px; --space-20: 80px;

  /* Typografie */
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Aldrich', 'IBM Plex Sans', system-ui, sans-serif;

  /* Motion */
  --motion-fast: 180ms cubic-bezier(.2,.6,.3,1);
  --motion-spatial: 320ms cubic-bezier(.3,.7,.2,1);

  /* Shell */
  --topbar-h: 64px;
  --sidenav-w: 256px;
  --bottomnav-h: calc(60px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Reset / Basis ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px; line-height: 1.5;
  color: var(--ink-primary);
  background: var(--surface-canvas);
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 0.875em; background: var(--surface-canvas); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-subtle); }

:focus-visible {
  outline: 2px solid var(--focus-outer);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-inner);
  border-radius: 2px;
}

.vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link {
  position: absolute; left: var(--space-4); top: -48px; z-index: 100;
  background: var(--brand-black); color: #fff; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); transition: top var(--motion-fast);
}
.skip-link:focus { top: var(--space-2); }

/* ---------- Typo-Skala --------------------------------------------------- */
.display {
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1.04; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 400;
}
.display--ondark { color: #fff; }
h1, .h1 { font-size: 32px; line-height: 40px; font-weight: 700; }
h2, .h2 { font-size: 24px; line-height: 32px; font-weight: 600; }
h3, .h3 { font-size: 20px; line-height: 28px; font-weight: 600; }
.text-small { font-size: 14px; line-height: 20px; }
.text-caption { font-size: 12px; line-height: 16px; color: var(--ink-secondary); }
.num { font-variant-numeric: tabular-nums; }

/* Overline / Kapitelmarker – Versalien nur für kurze Marker */
.overline {
  font-family: var(--font-display);
  font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-secondary);
  display: inline-flex; align-items: center; gap: var(--space-3);
}
.overline--ondark { color: rgb(255 255 255 / 0.72); }
.overline--red { color: var(--brand-red); }
.overline-tick { display: inline-block; width: 28px; height: 1px; background: var(--brand-red); }

/* Vertikales Mikrolabel (Keynote-Motiv) */
.microlabel {
  font-family: var(--font-display);
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  writing-mode: vertical-rl; color: var(--ink-muted);
  display: inline-flex; align-items: center; gap: var(--space-3);
}
.microlabel::after { content: ''; width: 1px; height: 40px; background: currentColor; opacity: 0.5; }

/* 10°-Motiv: schmaler roter Sliver als Abschnittsmarker */
.sliver { display: inline-block; width: 14px; height: 22px; background: var(--brand-red); transform: skewX(-10deg); }

/* ---------- Shell -------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--space-4) 0 var(--space-3);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
}
.topbar-burger { display: none; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius-sm); }
.topbar-burger:hover { background: var(--surface-canvas); }
.topbar-brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar-logo { height: 34px; width: auto; }
.topbar-divider { width: 1px; height: 28px; background: var(--border-default); }
.topbar-product { font-family: var(--font-display); font-size: 15px; letter-spacing: 0.14em; white-space: nowrap; }
.topbar-search {
  flex: 1; max-width: 520px; margin-left: var(--space-6);
  display: flex; align-items: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-3);
  background: var(--surface-canvas); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  color: var(--ink-muted);
}
.topbar-search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink-primary); }
.topbar-search input:focus { outline: none; }
.topbar-search:focus-within { border-color: var(--border-strong); }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.topbar-user { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--ink-secondary); white-space: nowrap; }
.topbar-logout { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius-sm); color: var(--ink-secondary); }
.topbar-logout:hover { background: var(--surface-canvas); color: var(--ink-primary); }

.sync-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--status-success);
  background: var(--status-success-surface);
  border: 1px solid currentColor; border-radius: 999px;
  padding: 3px 10px; white-space: nowrap;
}
.sync-chip.is-offline { color: var(--status-warning); background: var(--status-warning-surface); }
.sync-chip.has-outbox { color: var(--status-info); background: var(--status-info-surface); }

.shell-body { display: flex; min-height: calc(100dvh - var(--topbar-h)); }

.sidenav {
  width: var(--sidenav-w); flex: 0 0 auto;
  background: var(--surface-card);
  border-right: 1px solid var(--border-default);
  padding: var(--space-4) 0 var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.sidenav ul { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--space-2); }
.sidenav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3);
  border-left: 3px solid transparent; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--ink-secondary);
  transition: background var(--motion-fast), color var(--motion-fast);
}
.sidenav-item:hover { background: var(--surface-canvas); color: var(--ink-primary); }
.sidenav-item.is-active {
  background: var(--surface-selected);
  border-left-color: var(--brand-red);
  color: var(--brand-black);
}
.sidenav-item.is-planned { color: var(--ink-muted); cursor: default; }
.sidenav-item.is-planned:hover { background: none; color: var(--ink-muted); }
.sidenav-item.is-planned em {
  margin-left: auto; font-style: normal; font-size: 11px;
  color: var(--ink-muted); border: 1px solid var(--border-default);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.sidenav-foot { margin-top: auto; padding: 0 var(--space-2); }
.sidenav-version { font-size: 11px; color: var(--ink-muted); padding: var(--space-3) var(--space-3) 0; }
.sidenav-scrim { position: fixed; inset: 0; z-index: 45; background: rgb(0 0 0 / 0.4); }

.page { flex: 1; min-width: 0; padding: var(--space-6) var(--space-6) var(--space-16); }

.bottomnav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--bottomnav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface-card);
  border-top: 1px solid var(--border-default);
}
.bottomnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; font-size: 11px; font-weight: 500; color: var(--ink-secondary);
  border-top: 2px solid transparent;
}
.bottomnav-item.is-active { color: var(--brand-black); border-top-color: var(--brand-red); background: var(--surface-selected); }

/* Responsive Shell */
@media (max-width: 1023px) {
  :root { --topbar-h: 56px; }
  .topbar-burger { display: flex; }
  .topbar-search { display: none; }
  .topbar-user span { display: none; }
  .topbar-logout { display: none; }
  .topbar-logo { height: 28px; }
  .sidenav {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    transition: transform var(--motion-spatial);
    box-shadow: var(--shadow-overlay);
  }
  .shell.nav-open .sidenav { transform: translateX(0); }
  .bottomnav { display: flex; }
  .page { padding: var(--space-4) var(--space-4) calc(var(--bottomnav-h) + var(--space-8)); }
}
@media (min-width: 1024px) {
  .sidenav-scrim { display: none !important; }
}
@media (max-width: 519px) {
  .topbar-product, .topbar-divider { display: none; }
  .topbar { gap: var(--space-2); }
}

/* ---------- Seitenkopf --------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-head-titles { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.page-head-actions { margin-left: auto; display: flex; gap: var(--space-3); flex-wrap: wrap; }
.page-title { font-size: 32px; line-height: 40px; font-weight: 700; }
@media (max-width: 1023px) { .page-title { font-size: 24px; line-height: 32px; } }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--ink-secondary); }
.breadcrumb a:hover { color: var(--ink-primary); text-decoration: underline; }
.breadcrumb .ic { opacity: 0.5; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
  transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--action-primary); color: var(--action-primary-text); }
.btn--primary:hover { background: var(--action-primary-hover); }
.btn--primary:active { background: var(--action-primary-active); }
.btn--secondary { background: var(--surface-card); border-color: var(--brand-black); color: var(--brand-black); }
.btn--secondary:hover { background: var(--surface-canvas); }
.btn--tertiary { background: none; color: var(--ink-primary); font-weight: 500; }
.btn--tertiary:hover { background: var(--surface-canvas); }
.btn--danger { background: var(--surface-card); border-color: var(--status-danger); color: var(--status-danger); }
.btn--danger:hover { background: var(--status-danger-surface); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 var(--space-4); font-size: 14px; }
.btn[disabled], .btn.is-disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 18px; height: 18px;
  border: 2px solid rgb(255 255 255 / 0.4); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn--secondary.is-loading::after, .btn--tertiary.is-loading::after { border-color: rgb(0 0 0 / 0.2); border-top-color: var(--ink-primary); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1023px) { .btn { min-height: 48px; } .btn--sm { min-height: 40px; } }

/* ---------- Chips / Status ---------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; line-height: 16px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid; white-space: nowrap;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip--neutral { color: var(--ink-secondary); background: var(--surface-canvas); border-color: var(--border-default); }
.chip--info { color: var(--status-info); background: var(--status-info-surface); border-color: currentColor; }
.chip--success { color: var(--status-success); background: var(--status-success-surface); border-color: currentColor; }
.chip--warning { color: var(--status-warning); background: var(--status-warning-surface); border-color: currentColor; }
.chip--danger { color: var(--status-danger); background: var(--status-danger-surface); border-color: currentColor; }
.chip--brand { color: var(--action-primary-hover); background: var(--surface-selected); border-color: currentColor; }
.chip--ondark { color: #ff9ab5; background: rgb(255 255 255 / 0.06); border-color: currentColor; }

/* Filterchips */
.filterbar { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.filterchip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--space-4);
  border: 1px solid var(--border-default); border-radius: 999px;
  background: var(--surface-card); font-size: 14px; font-weight: 500; color: var(--ink-secondary);
  transition: all var(--motion-fast);
}
.filterchip:hover { border-color: var(--border-strong); color: var(--ink-primary); }
.filterchip.is-active { background: var(--brand-black); border-color: var(--brand-black); color: #fff; }
@media (max-width: 1023px) { .filterchip { min-height: 44px; } }

/* ---------- Cards -------------------------------------------------------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.card-title .ic { color: var(--ink-muted); }

.grid { display: grid; gap: var(--space-4); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* KPI-Karte (hell, operativ) */
.kpi { display: flex; flex-direction: column; gap: var(--space-1); }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--ink-secondary); }
.kpi-value { font-family: var(--font-display); font-size: 40px; line-height: 1.1; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; color: var(--ink-secondary); display: flex; align-items: center; gap: 6px; }
.kpi-drill { margin-top: var(--space-2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; color: var(--ink-primary); }
.kpi-drill:hover { color: var(--brand-red); }
.kpi--danger .kpi-value { color: var(--status-danger); }
.kpi--warning .kpi-value { color: var(--status-warning); }

/* Schwarze Management-/Hero-Zone (Keynote-Kapitelfläche) */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface-inverse); color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-8) var(--space-8);
  margin-bottom: var(--space-6);
}
.hero .overline { color: rgb(255 255 255 / 0.72); }
.hero-title { font-family: var(--font-display); font-size: clamp(28px, 3.4vw, 48px); line-height: 1.08; letter-spacing: 0.05em; text-transform: uppercase; margin: var(--space-3) 0 var(--space-2); }
.hero-sub { font-size: 15px; color: rgb(255 255 255 / 0.8); max-width: 60ch; }
.hero-meta { display: flex; flex-wrap: wrap; gap: var(--space-6); margin-top: var(--space-6); }
.hero-meta-item { display: flex; flex-direction: column; gap: 2px; }
.hero-meta-item b { font-family: var(--font-display); font-size: 26px; font-weight: 400; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.hero-meta-item span { font-size: 12px; color: rgb(255 255 255 / 0.66); }
.hero-meta-item.is-alert b { color: #ff5c85; }
.hero-dots {
  position: absolute; top: -20px; right: -10px; width: 280px; height: 200px; opacity: 0.5;
  background-image: radial-gradient(rgb(255 255 255 / 0.5) 1px, transparent 1.5px);
  background-size: 22px 22px;
  transform: rotate(-10deg);
  pointer-events: none;
}
@media (max-width: 1023px) { .hero { padding: var(--space-6) var(--space-5); } }

/* ---------- Listen / Tabellen -------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-secondary); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  position: sticky; top: 0; background: var(--surface-card);
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); height: 46px; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-canvas); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Aufgaben-/Objektkarte (mobil und Board) */
.taskcard {
  display: block; background: var(--surface-card);
  border: 1px solid var(--border-subtle); border-left: 4px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.taskcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-low); }
.taskcard--kritisch { border-left-color: var(--status-danger); }
.taskcard--hoch { border-left-color: var(--status-warning); }
.taskcard--mittel { border-left-color: var(--status-info); }
.taskcard--niedrig { border-left-color: var(--border-strong); }
.taskcard-head { display: flex; align-items: flex-start; gap: var(--space-3); }
.taskcard-id { font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.taskcard-title { font-size: 15px; font-weight: 600; line-height: 20px; }
.taskcard-loc { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-secondary); margin-top: var(--space-1); }
.taskcard-foot { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); align-items: center; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }

/* Listenzeile mobil */
.rowlink {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-3) var(--space-4);
  background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
}
.rowlink:hover { border-color: var(--border-strong); }
.rowlink .ic:last-child { margin-left: auto; color: var(--ink-muted); }

/* ---------- Formulare ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field label { font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 16px; color: var(--ink-primary);
  min-height: 48px; padding: 0 var(--space-4);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--surface-card);
  transition: border-color var(--motion-fast);
}
.field textarea { padding: var(--space-3) var(--space-4); min-height: 96px; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-black); outline: none; box-shadow: 0 0 0 1px var(--brand-black); }
.field-hint { font-size: 12px; color: var(--ink-secondary); }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--status-danger); }
.field-error { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--status-danger); }
.field input[disabled], .field select[disabled] { background: var(--surface-canvas); color: var(--ink-muted); }

.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); border: 1px solid;
  font-size: 14px; margin-bottom: var(--space-4);
}
.alert--danger { color: var(--status-danger); background: var(--status-danger-surface); border-color: currentColor; }
.alert--info { color: var(--status-info); background: var(--status-info-surface); border-color: currentColor; }
.alert--warning { color: var(--status-warning); background: var(--status-warning-surface); border-color: currentColor; }
.alert--success { color: var(--status-success); background: var(--status-success-surface); border-color: currentColor; }
.alert .ic { flex: 0 0 auto; margin-top: 1px; }

/* ---------- Drawer / Bottom Sheet / Toast -------------------------------- */
.drawer {
  position: fixed; z-index: 60; top: 0; right: 0; bottom: 0;
  width: min(440px, 100%);
  background: var(--surface-card);
  box-shadow: var(--shadow-overlay);
  transform: translateX(105%);
  transition: transform var(--motion-spatial);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.drawer-title { font-size: 18px; font-weight: 600; }
.drawer-close { margin-left: auto; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.drawer-close:hover { background: var(--surface-canvas); }
.drawer-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.drawer-scrim { position: fixed; inset: 0; z-index: 55; background: rgb(0 0 0 / 0.4); opacity: 0; pointer-events: none; transition: opacity var(--motion-fast); }
.drawer-scrim.is-open { opacity: 1; pointer-events: auto; }

@media (max-width: 767px) {
  .drawer {
    top: auto; left: 0; width: 100%; max-height: 82dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(105%);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .drawer.is-open { transform: translateY(0); }
  .drawer-head::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong);
  }
}

.toast-region { position: fixed; z-index: 80; bottom: calc(var(--bottomnav-h) + var(--space-3)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--space-2); width: min(420px, calc(100% - 32px)); }
@media (min-width: 1024px) { .toast-region { bottom: var(--space-6); } }
.toast {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--brand-black); color: #fff;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay); font-size: 14px;
  animation: toast-in var(--motion-spatial);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Zustände ------------------------------------------------------ */
.skeleton { position: relative; overflow: hidden; background: var(--border-subtle); border-radius: var(--radius-sm); color: transparent !important; min-height: 14px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.6), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  text-align: center; padding: var(--space-10) var(--space-6);
  color: var(--ink-secondary);
}
.empty .ic { width: 44px; height: 44px; color: var(--border-strong); }
.empty-title { font-size: 16px; font-weight: 600; color: var(--ink-primary); }
.empty p { font-size: 14px; max-width: 40ch; }

.banner-offline {
  display: none; align-items: center; gap: var(--space-3);
  background: var(--brand-black); color: #fff;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: 14px; margin-bottom: var(--space-4);
}
body.is-offline .banner-offline { display: flex; }

/* ---------- Karte (schematisches Canvas, Phase 0) ------------------------- */
.map-shell { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-4); align-items: start; }
@media (max-width: 1023px) { .map-shell { grid-template-columns: 1fr; } }
.map-canvas {
  position: relative; overflow: hidden;
  background: var(--surface-inverse);
  border-radius: var(--radius-lg);
  min-height: 420px;
}
.map-canvas svg { width: 100%; height: auto; display: block; }
.map-attribution {
  position: absolute; right: var(--space-2); bottom: var(--space-2);
  font-size: 11px; color: rgb(255 255 255 / 0.75);
  background: rgb(0 0 0 / 0.55); padding: 2px 8px; border-radius: 4px;
}
.map-toolbar {
  position: absolute; top: var(--space-3); right: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1);
}
.map-toolbar button {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: rgb(255 255 255 / 0.95); color: var(--ink-primary);
  border-radius: var(--radius-sm); border: 1px solid var(--border-default);
}
.map-toolbar button:hover { background: #fff; }

.map-marker { cursor: pointer; }
.map-marker circle.dot { fill: var(--brand-red); stroke: #fff; stroke-width: 2; transition: r var(--motion-fast); }
.map-marker.is-selected circle.dot { stroke: #fff; }
.map-marker.is-selected circle.halo { stroke: #fff; }
.map-marker text { fill: #fff; font-family: var(--font-body); /* Größe über SVG-Attribut (viewBox-skaliert) */ }

/* ---------- Plan-Canvas --------------------------------------------------- */
.plan-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; }
@media (max-width: 1279px) { .plan-shell { grid-template-columns: minmax(0, 1fr) 320px; } .plan-side--left { display: none; } }
@media (max-width: 1023px) { .plan-shell { grid-template-columns: 1fr; } }
.plan-canvas {
  position: relative; overflow: hidden;
  background: var(--surface-inverse);
  border-radius: var(--radius-lg);
  touch-action: none;
}
.plan-canvas svg { width: 100%; height: auto; display: block; cursor: grab; }
.plan-canvas svg:active { cursor: grabbing; }
.plan-room { fill: rgb(255 255 255 / 0.04); stroke: rgb(255 255 255 / 0.85); stroke-width: 1.2; cursor: pointer; transition: fill var(--motion-fast); }
.plan-room:hover { fill: rgb(255 255 255 / 0.12); }
.plan-room.is-selected { fill: rgb(226 0 61 / 0.22); stroke: var(--brand-red); stroke-width: 2; stroke-dasharray: 5 3; }
.plan-room-label { fill: rgb(255 255 255 / 0.9); font-family: var(--font-body); font-size: 11px; pointer-events: none; }
.plan-room-sub { fill: rgb(255 255 255 / 0.55); font-size: 9px; }
.plan-asset circle { fill: var(--surface-inverse); stroke: #fff; stroke-width: 1.4; }
.plan-asset.is-selected circle { stroke: var(--brand-red); fill: rgb(226 0 61 / 0.3); }
.plan-asset text { fill: #fff; font-size: 8px; }
.plan-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--space-1);
  background: var(--brand-black); border-radius: var(--radius-md);
  padding: var(--space-2); margin-bottom: var(--space-3);
}
.plan-toolbar button, .plan-toolbar .tool-planned {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 var(--space-3);
  color: #fff; font-size: 13px; font-weight: 500; border-radius: var(--radius-sm);
}
.plan-toolbar button:hover { background: rgb(255 255 255 / 0.12); }
.plan-toolbar button.is-active { background: var(--brand-red); }
.plan-toolbar .tool-planned { color: rgb(255 255 255 / 0.66); cursor: default; }
.plan-toolbar .tool-planned em { font-style: normal; font-size: 10px; border: 1px solid rgb(255 255 255 / 0.4); padding: 0 6px; border-radius: 999px; margin-left: 2px; }
.plan-sep { width: 1px; background: rgb(255 255 255 / 0.2); margin: 4px 4px; }

.layer-row { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-2); border-radius: var(--radius-sm); }
.layer-row:hover { background: var(--surface-canvas); }
.layer-row input { width: 18px; height: 18px; accent-color: var(--brand-red); }
.layer-row .layer-sw { width: 12px; height: 12px; border-radius: 3px; }

/* ---------- Kanban -------------------------------------------------------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: var(--space-4); align-items: start; }
@media (max-width: 1279px) { .kanban { grid-template-columns: repeat(2, minmax(240px, 1fr)); } }
@media (max-width: 767px) { .kanban { grid-template-columns: 1fr; } }
.kanban-col { background: var(--surface-canvas); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-3); }
.kanban-col-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-3); font-size: 13px; font-weight: 600; }
.kanban-col-head .count { margin-left: auto; font-size: 12px; color: var(--ink-secondary); background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 999px; padding: 1px 8px; }
.kanban-col .stack { gap: var(--space-2); }

/* ---------- Reinigungsroute ---------------------------------------------- */
.route-list { display: flex; flex-direction: column; }
.route-stop { display: flex; gap: var(--space-4); position: relative; padding: var(--space-2) 0; }
.route-stop-line { display: flex; flex-direction: column; align-items: center; width: 32px; flex: 0 0 auto; }
.route-stop-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  border: 2px solid var(--border-strong); background: var(--surface-card); color: var(--ink-secondary);
}
.route-stop.is-done .route-stop-dot { background: var(--status-success); border-color: var(--status-success); color: #fff; }
.route-stop.is-active .route-stop-dot { background: var(--brand-red); border-color: var(--brand-red); color: #fff; }
.route-stop-line::after { content: ''; flex: 1; width: 2px; background: var(--border-default); margin-top: 2px; }
.route-stop:last-child .route-stop-line::after { display: none; }
.route-stop .taskcard { flex: 1; margin-bottom: var(--space-2); }

/* ---------- Profil / Team ------------------------------------------------- */
.profile-head {
  display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: center;
  background: var(--surface-inverse); color: #fff;
  border-radius: var(--radius-lg); padding: var(--space-6);
  margin-bottom: var(--space-5); position: relative; overflow: hidden;
}
.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; color: var(--brand-black);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 22px; flex: 0 0 auto;
}
.avatar--sm { width: 44px; height: 44px; font-size: 16px; }
.profile-head h1 { font-size: 26px; }
.profile-head .text-caption { color: rgb(255 255 255 / 0.7); }

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-default); margin-bottom: var(--space-5); overflow-x: auto; }
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: 14px; font-weight: 500; color: var(--ink-secondary);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink-primary); }
.tab.is-active { color: var(--brand-black); border-bottom-color: var(--brand-red); font-weight: 600; }
.tab.is-planned { color: var(--ink-secondary); cursor: default; }
.tab.is-planned em { font-style: normal; font-size: 10px; border: 1px solid var(--border-default); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

.skillbar { display: flex; gap: 3px; }
.skillbar i { width: 22px; height: 8px; border-radius: 2px; background: var(--border-subtle); }
.skillbar i.f { background: var(--brand-black); }
.skillbar i.gap { background: var(--status-warning-surface); border: 1px dashed var(--status-warning); }

/* ---------- Login --------------------------------------------------------- */
.login-page { min-height: 100dvh; background: var(--surface-canvas); }
.login-split { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100dvh; }
.login-hero {
  position: relative; overflow: hidden;
  background: var(--surface-inverse); color: #fff;
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-5);
  padding: var(--space-16) var(--space-12);
}
.login-hero-dots {
  position: absolute; top: 40px; left: 40px; width: 300px; height: 220px; opacity: 0.5;
  background-image: radial-gradient(rgb(255 255 255 / 0.5) 1px, transparent 1.5px);
  background-size: 24px 24px; transform: rotate(-10deg);
}
.login-hero-sub { font-size: 15px; color: rgb(255 255 255 / 0.75); line-height: 1.6; }
.login-hero-meta { display: flex; gap: var(--space-6); font-family: var(--font-display); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: rgb(255 255 255 / 0.66); }
.login-panel { display: flex; align-items: center; justify-content: center; padding: var(--space-8) var(--space-6); }
.login-panel-inner { width: min(400px, 100%); }
.login-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-10); }
.login-brand img { height: 40px; width: auto; }
.login-brand-divider { width: 1px; height: 32px; background: var(--border-default); }
.login-brand-product { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.14em; }
.login-title { font-size: 32px; line-height: 40px; font-weight: 700; margin-bottom: var(--space-2); }
.login-sub { font-size: 14px; color: var(--ink-secondary); margin-bottom: var(--space-6); }
.login-note { margin-top: var(--space-6); font-size: 12px; color: var(--ink-secondary); line-height: 1.6; }
@media (max-width: 1023px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { min-height: 280px; padding: var(--space-10) var(--space-6); justify-content: flex-end; }
  .login-hero .display { font-size: clamp(34px, 10vw, 48px); }
}

/* ---------- Design Lab ---------------------------------------------------- */
.lab-section { margin-bottom: var(--space-10); }
.lab-section > h2 { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.lab-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-bottom: var(--space-3); }
.swatch { width: 120px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-subtle); background: var(--surface-card); }
.swatch-color { height: 64px; }
.swatch-meta { padding: var(--space-2) var(--space-3); font-size: 11px; line-height: 1.5; }
.swatch-meta b { display: block; font-size: 12px; }

/* ---------- Utility ------------------------------------------------------- */
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }
.muted { color: var(--ink-secondary); }
.flex { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.center-col { max-width: 640px; margin-inline: auto; }
.wide-col { max-width: 1400px; margin-inline: auto; }

.sticky-action {
  position: sticky; bottom: calc(var(--bottomnav-h) + var(--space-2)); z-index: 30;
  background: var(--surface-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay);
  padding: var(--space-3); display: flex; gap: var(--space-2); flex-wrap: wrap;
}
@media (min-width: 1024px) { .sticky-action { bottom: var(--space-4); } }

/* ---------- Echte Browserkarte (Phase 1, ADR-0005) ------------------------ */
/* Dieselbe Keynote-Grammatik wie das schematische Canvas: dunkle Orientierungs-
   fläche, rote Auswahl, weiße Mikrolabels. Die Kacheln sind bewusst leicht
   entsättigt, damit Marker und rote Auswahl die Bildhierarchie behalten. */
.geomap {
  position: relative; overflow: hidden;
  background: var(--surface-inverse);
  border-radius: var(--radius-lg);
  min-height: 420px;
  isolation: isolate;
}
.geomap--tall { min-height: 520px; }
@media (max-width: 767px) { .geomap, .geomap--tall { min-height: 320px; } }

.geomap-fallback {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); padding: var(--space-6); text-align: center;
  color: rgb(255 255 255 / 0.75); font-size: 14px;
}
.geomap-fallback b { color: #fff; font-size: 16px; }
/* Sobald das Kartenmodul läuft, tritt der Ersatztext zurück. Ohne JavaScript
   bleibt er stehen und verweist auf Liste und Koordinatenfelder. */
.geomap.is-live .geomap-fallback { display: none; }

.geomap-viewport {
  position: absolute; inset: 0; overflow: hidden;
  cursor: grab; touch-action: none;
}
.geomap-viewport.is-dragging { cursor: grabbing; }
.geomap-tiles, .geomap-markers { position: absolute; inset: 0; }
.geomap-markers { pointer-events: none; }
.geomap-tile {
  position: absolute; top: 0; left: 0;
  max-width: none; user-select: none;
  filter: saturate(0.72) contrast(1.02);
}

.geomap-marker {
  position: absolute; top: 0; left: 0;
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--space-2);
  /* Der Ankerpunkt sitzt exakt auf der Koordinate, das Label daneben. */
  margin: -11px 0 0 -11px;
  padding: 4px 8px 4px 4px;
  min-height: 48px;
  border-radius: 999px;
  background: rgb(5 5 5 / 0.72);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 0.25);
}
.geomap-marker-dot {
  flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
  background: var(--brand-red); border: 2px solid #fff;
}
.geomap-marker-label { font-size: 12px; line-height: 16px; white-space: nowrap; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }
.geomap-marker:hover, .geomap-marker.is-highlight { background: rgb(5 5 5 / 0.92); border-color: #fff; }
.geomap-marker.is-selected { background: var(--brand-red); border-color: #fff; }
.geomap-marker.is-selected .geomap-marker-dot { background: #fff; border-color: var(--brand-red); }

.geomap-controls {
  position: absolute; z-index: 2; top: var(--space-3); right: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1);
}
.geomap-pad {
  position: absolute; z-index: 2; bottom: var(--space-8); right: var(--space-3);
  display: grid; grid-template-columns: repeat(2, 48px); gap: var(--space-1);
}
.geomap-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgb(255 255 255 / 0.95); color: var(--ink-primary);
  border-radius: var(--radius-sm); border: 1px solid var(--border-default);
  font-size: 20px; line-height: 1;
}
.geomap-btn:hover { background: #fff; }

.geomap-notice {
  position: absolute; z-index: 3; left: var(--space-3); right: 96px; top: var(--space-3);
  background: rgb(5 5 5 / 0.88); color: #fff;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); font-size: 13px;
}
.geomap-attribution {
  position: absolute; z-index: 3; right: var(--space-2); bottom: var(--space-2);
  font-size: 11px; color: rgb(255 255 255 / 0.8);
  background: rgb(0 0 0 / 0.6); padding: 2px 8px; border-radius: 4px;
  max-width: calc(100% - 16px);
}
.geomap-attribution a { text-decoration: underline; }

.geomap-legal { font-size: 12px; color: var(--ink-secondary); margin-top: var(--space-2); }

/* Touch-Ziele: am Zeigegerät bleibt die abgestimmte 44/36-px-Skala, am Finger
   werden alle bedienbaren Elemente auf mindestens 48 px angehoben. Rein additive
   Regeln – Layout und Optik der Desktop-Referenzscreens bleiben unverändert. */
@media (max-width: 767px), (pointer: coarse) {
  .btn, .btn--sm { min-height: 48px; }
  .topbar-burger { width: 48px; height: 48px; }
  .topbar-brand, .topbar-logout, .topbar-user { min-height: 48px; }
  .sidenav-item { min-height: 48px; }
  .skip-link { min-height: 48px; display: inline-flex; align-items: center; }
  .filterchip { min-height: 48px; }
  .tab { min-height: 48px; }
}

/* ---------- Portfolio, Objektseiten, Adresssuche -------------------------- */
.geocode-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .field--wide { grid-column: 1 / -1; }
@media (max-width: 767px) { .form-grid, .form-grid--3 { grid-template-columns: 1fr; } }

.datalist { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr); gap: var(--space-2) var(--space-4); font-size: 14px; }
.datalist dt { color: var(--ink-secondary); }
.datalist dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.tenant-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: 12px; line-height: 16px;
  border: 1px solid var(--border-default); border-radius: 999px;
  padding: 4px 12px; background: var(--surface-card);
  max-width: 220px; overflow: hidden; white-space: nowrap;
}
.tenant-chip .ic { flex: 0 0 auto; }
.tenant-chip b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 1023px) { .tenant-chip { display: none; } }

.lead { font-size: 18px; line-height: 28px; color: var(--ink-secondary); max-width: 60ch; }

.errorpage { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: var(--space-6); }
.errorpage-inner { max-width: 560px; }
.errorpage-inner .btn { margin-right: var(--space-2); margin-top: var(--space-2); }

/* ---------- Motion-Reduktion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
