/* =====================================================================
   Immonilo – Designsystem
   Konzept: „Planmappe“ – mineralische Flächen, Patina-Grün als Marke,
   Messing für Hervorhebungen, Fraunces für Überschriften, Geist für UI,
   Geist Mono für Zahlen/Kennwerte. Hell und dunkel gleichwertig.
   ===================================================================== */
@import url("/assets/fonts/fonts.css");

:root {
  /* Flächen */
  --bg: #f1f3f0;
  --bg-2: #e8ebe7;
  --flaeche: #ffffff;
  --flaeche-2: #f7f8f6;
  --tinte: #12181b;
  --tinte-2: #4b575e;
  --tinte-3: #7a858b;
  --linie: #d9ded8;
  --linie-stark: #b9c1ba;
  /* Marke */
  --marke: #1e5b4f;
  --marke-hell: #2f7a6a;
  --marke-weich: #dcebe6;
  --marke-text: #ffffff;
  --messing: #b8893a;
  --messing-weich: #f4ead7;
  /* Status */
  --frei: #2b7d4f;
  --frei-weich: #dff1e6;
  --reserviert: #a8680f;
  --reserviert-weich: #fbeed6;
  --verkauft: #5f6670;
  --verkauft-weich: #e6e8ea;
  --gefahr: #b4372e;
  --gefahr-weich: #fbe3e0;
  --info: #2a5f9e;
  --info-weich: #e0ebf7;
  /* Form */
  --r-s: 6px;
  --r: 10px;
  --r-l: 16px;
  --schatten: 0 1px 2px rgb(18 24 27 / 6%), 0 4px 16px rgb(18 24 27 / 6%);
  --schatten-hoch: 0 8px 40px rgb(18 24 27 / 18%);
  --fokus: 0 0 0 3px color-mix(in srgb, var(--marke) 35%, transparent);
  /* Schrift */
  --f-titel: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --f-ui: "Geist", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-zahl: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --t-xs: 12px;
  --t-s: 13.5px;
  --t-m: 15px;
  --t-l: 18px;
  --t-xl: clamp(22px, 2.4vw, 28px);
  --t-xxl: clamp(30px, 4vw, 44px);
  --t-hero: clamp(40px, 7vw, 84px);
  /* Bewegung */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dauer: 180ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1214; --bg-2: #141a1d; --flaeche: #171e21; --flaeche-2: #1c2427;
    --tinte: #e9eeec; --tinte-2: #a9b4b3; --tinte-3: #7d8988; --linie: #273236; --linie-stark: #3a474b;
    --marke: #5fb39f; --marke-hell: #7ccab6; --marke-weich: #183a33; --marke-text: #0b1513;
    --messing: #d8ad5c; --messing-weich: #3a2f1a;
    --frei: #5cc28a; --frei-weich: #173426; --reserviert: #e0a54a; --reserviert-weich: #3a2b13;
    --verkauft: #9aa3ab; --verkauft-weich: #262d31; --gefahr: #ef7f74; --gefahr-weich: #3d1d1a;
    --info: #79a9e3; --info-weich: #172a40;
    --schatten: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 30%);
    --schatten-hoch: 0 12px 48px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1214; --bg-2: #141a1d; --flaeche: #171e21; --flaeche-2: #1c2427;
  --tinte: #e9eeec; --tinte-2: #a9b4b3; --tinte-3: #7d8988; --linie: #273236; --linie-stark: #3a474b;
  --marke: #5fb39f; --marke-hell: #7ccab6; --marke-weich: #183a33; --marke-text: #0b1513;
  --messing: #d8ad5c; --messing-weich: #3a2f1a;
  --frei: #5cc28a; --frei-weich: #173426; --reserviert: #e0a54a; --reserviert-weich: #3a2b13;
  --verkauft: #9aa3ab; --verkauft-weich: #262d31; --gefahr: #ef7f74; --gefahr-weich: #3d1d1a;
  --info: #79a9e3; --info-weich: #172a40;
  --schatten: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 30%);
  --schatten-hoch: 0 12px 48px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ Basis */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--tinte);
  font: 400 var(--t-m)/1.55 var(--f-ui); font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1, h2, .titel { font-family: var(--f-titel); font-weight: 560; letter-spacing: -0.015em; font-variation-settings: "opsz" 96, "SOFT" 30; }
h3, h4 { font-weight: 620; letter-spacing: -0.005em; }
p { margin: 0; max-width: 72ch; }
a { color: var(--marke); text-underline-offset: 3px; }
img, svg, video, canvas { max-width: 100%; display: block; }
.zahl, .tab-zahl, table td.zahl { font-family: var(--f-zahl); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.leise { color: var(--tinte-2); }
.sehr-leise { color: var(--tinte-3); }
.klein { font-size: var(--t-s); }
.mini { font-size: var(--t-xs); }
.augenbraue {
  font: 600 11.5px/1.2 var(--f-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--tinte-3);
}
::selection { background: color-mix(in srgb, var(--marke) 25%, transparent); }
:focus-visible { outline: none; box-shadow: var(--fokus); border-radius: var(--r-s); }
.nur-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ Knöpfe */
.btn {
  --b-bg: var(--flaeche); --b-fg: var(--tinte); --b-rand: var(--linie-stark);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: var(--r-s);
  border: 1px solid var(--b-rand); background: var(--b-bg); color: var(--b-fg);
  font: 550 var(--t-s)/1 var(--f-ui); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dauer) var(--ease), border-color var(--dauer), transform 80ms, box-shadow var(--dauer);
}
.btn:hover { --b-bg: var(--flaeche-2); --b-rand: var(--tinte-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primaer { --b-bg: var(--marke); --b-fg: var(--marke-text); --b-rand: var(--marke); }
.btn.primaer:hover { --b-bg: var(--marke-hell); --b-rand: var(--marke-hell); }
.btn.messing { --b-bg: var(--messing); --b-fg: #1a1408; --b-rand: var(--messing); }
.btn.gefahr { --b-fg: var(--gefahr); --b-rand: color-mix(in srgb, var(--gefahr) 45%, var(--linie)); }
.btn.gefahr:hover { --b-bg: var(--gefahr-weich); }
.btn.ghost { --b-bg: transparent; --b-rand: transparent; }
.btn.ghost:hover { --b-bg: var(--bg-2); }
.btn.klein { min-height: 30px; padding: 0 10px; font-size: var(--t-xs); }
.btn.gross { min-height: 48px; padding: 0 22px; font-size: var(--t-m); border-radius: var(--r); }
.btn.icon { width: 38px; padding: 0; }
.btn.klein.icon { width: 30px; }
.btn[aria-busy="true"] { color: transparent !important; position: relative; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--b-fg) 40%, transparent); border-top-color: var(--b-fg); animation: dreh .7s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Formulare */
.feld { display: grid; gap: 6px; min-width: 0; }
.feld > label, .feld > .label { font-size: var(--t-s); font-weight: 560; color: var(--tinte-2); }
.feld .hilfe { font-size: var(--t-xs); color: var(--tinte-3); }
.feld .fehler { font-size: var(--t-xs); color: var(--gefahr); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="search"], input[type="tel"], input[type="url"], input[type="month"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: var(--r-s);
  border: 1px solid var(--linie-stark); background: var(--flaeche); color: var(--tinte);
  font: 400 var(--t-m)/1.4 var(--f-ui); transition: border-color var(--dauer), box-shadow var(--dauer);
}
input:hover, select:hover, textarea:hover { border-color: var(--tinte-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--marke); box-shadow: var(--fokus); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--gefahr); }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--marke); width: 16px; height: 16px; }
.reihe { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.raster { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.raster-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.raster-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .raster-2, .raster-3 { grid-template-columns: 1fr; } }
.segment { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-2); border-radius: var(--r-s); border: 1px solid var(--linie); }
.segment button { border: 0; background: transparent; padding: 6px 12px; border-radius: 5px; font: 550 var(--t-s) var(--f-ui); color: var(--tinte-2); cursor: pointer; }
.segment button[aria-pressed="true"] { background: var(--flaeche); color: var(--tinte); box-shadow: var(--schatten); }

/* ------------------------------------------------------------------ Flächen */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r-l); padding: 20px; min-width: 0; }
.karte.eng { padding: 14px; }
.karte.hoch { box-shadow: var(--schatten); }
.karte > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.karte > header h3 { font-size: var(--t-l); }
.trenner { height: 1px; background: var(--linie); border: 0; margin: 16px 0; }
.stapel { display: grid; gap: 16px; }
.stapel-s { display: grid; gap: 8px; }

/* Kennzahl */
.kpi { display: grid; gap: 4px; }
.kpi .wert { font: 520 clamp(24px, 2.6vw, 32px)/1.1 var(--f-zahl); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .wert small { font-size: .5em; color: var(--tinte-3); margin-left: 4px; letter-spacing: 0; }
.kpi .delta { font-size: var(--t-xs); font-weight: 600; }
.kpi .delta.plus { color: var(--frei); } .kpi .delta.minus { color: var(--gefahr); }

/* Abzeichen / Chips */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font: 600 12px/1 var(--f-ui); background: var(--bg-2); color: var(--tinte-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ohne-punkt::before { display: none; }
.badge.frei { background: var(--frei-weich); color: var(--frei); }
.badge.reserviert { background: var(--reserviert-weich); color: var(--reserviert); }
.badge.verkauft { background: var(--verkauft-weich); color: var(--verkauft); }
.badge.gefahr { background: var(--gefahr-weich); color: var(--gefahr); }
.badge.info { background: var(--info-weich); color: var(--info); }
.badge.marke { background: var(--marke-weich); color: var(--marke); }
.badge.messing { background: var(--messing-weich); color: var(--messing); }
kbd { font: 500 11px/1 var(--f-zahl); padding: 3px 6px; border-radius: 4px; border: 1px solid var(--linie-stark); border-bottom-width: 2px; background: var(--flaeche); color: var(--tinte-2); }

/* ------------------------------------------------------------------ Tabellen */
.tabelle-huelle { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--r); background: var(--flaeche); }
table.tabelle { width: 100%; border-collapse: collapse; font-size: var(--t-s); }
.tabelle th { text-align: left; font: 600 11.5px/1.2 var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--tinte-3); padding: 11px 14px; border-bottom: 1px solid var(--linie); background: var(--flaeche-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tabelle td { padding: 11px 14px; border-bottom: 1px solid var(--linie); vertical-align: middle; }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle tbody tr { transition: background var(--dauer); }
.tabelle tbody tr:hover { background: var(--flaeche-2); }
.tabelle tbody tr.klickbar { cursor: pointer; }
.tabelle td.zahl, .tabelle th.zahl { text-align: right; }

/* ------------------------------------------------------------------ Zustände */
.leer {
  display: grid; justify-items: center; gap: 10px; text-align: center; padding: 48px 20px; color: var(--tinte-2);
  border: 1px dashed var(--linie-stark); border-radius: var(--r-l); background: var(--flaeche-2);
}
.leer .symbol { width: 44px; height: 44px; color: var(--marke); }
.leer h3 { color: var(--tinte); font-size: var(--t-l); }
.skelett { background: linear-gradient(90deg, var(--bg-2) 0%, var(--flaeche-2) 50%, var(--bg-2) 100%); background-size: 200% 100%; animation: schimmer 1.3s ease-in-out infinite; border-radius: var(--r-s); min-height: 14px; }
@keyframes schimmer { to { background-position: -200% 0; } }
.hinweis { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--info-weich); color: var(--tinte); font-size: var(--t-s); }
.hinweis.warn { background: var(--reserviert-weich); }
.hinweis.gefahr { background: var(--gefahr-weich); }
.hinweis.ok { background: var(--frei-weich); }
.fortschritt { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.fortschritt > i { display: block; height: 100%; background: linear-gradient(90deg, var(--marke), var(--marke-hell)); border-radius: inherit; transition: width .6s var(--ease); }

/* ------------------------------------------------------------------ Dialog & Toast */
dialog.dialog {
  border: 1px solid var(--linie); border-radius: var(--r-l); padding: 0; background: var(--flaeche); color: var(--tinte);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--schatten-hoch);
}
dialog.dialog.breit { width: min(960px, calc(100vw - 24px)); }
dialog.dialog.voll { width: calc(100vw - 24px); height: calc(100dvh - 24px); max-width: none; max-height: none; }
dialog.dialog::backdrop { background: rgb(10 14 16 / 45%); backdrop-filter: blur(3px); }
dialog.dialog[open] { animation: auf .22s var(--ease); }
@keyframes auf { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.dialog > header h2 { font-size: var(--t-xl); }
.dialog > .inhalt { padding: 16px 20px; overflow: auto; max-height: calc(100dvh - 180px); }
.dialog > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--linie); background: var(--flaeche-2); border-radius: 0 0 var(--r-l) var(--r-l); }
.toasts { position: fixed; z-index: 1000; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--tinte); color: var(--bg); box-shadow: var(--schatten-hoch); font-size: var(--t-s); animation: auf .22s var(--ease); }
.toast.fehler { background: var(--gefahr); color: #fff; }
.toast.ok::before { content: "✓"; font-weight: 700; color: var(--marke-hell); }

/* ------------------------------------------------------------------ Reiter */
.reiter { display: flex; gap: 2px; border-bottom: 1px solid var(--linie); overflow-x: auto; scrollbar-width: none; }
.reiter button, .reiter a {
  border: 0; background: none; padding: 10px 14px; font: 550 var(--t-s) var(--f-ui); color: var(--tinte-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.reiter [aria-selected="true"], .reiter .aktiv { color: var(--tinte); border-bottom-color: var(--marke); }

/* ------------------------------------------------------------------ Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.spalte { background: var(--bg-2); border-radius: var(--r-l); padding: 10px; display: grid; gap: 8px; min-height: 120px; }
.spalte > header { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 6px; font: 600 var(--t-s) var(--f-ui); }
.spalte.ziel { outline: 2px dashed var(--marke); outline-offset: -4px; }
.kachel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r); padding: 12px; display: grid; gap: 6px; cursor: grab; box-shadow: 0 1px 0 rgb(0 0 0 / 3%); transition: box-shadow var(--dauer), transform var(--dauer); }
.kachel:hover { box-shadow: var(--schatten); }
.kachel.zieht { opacity: .55; transform: rotate(1.5deg); }

/* ------------------------------------------------------------------ App-Hülle */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.seitenleiste {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; border-right: 1px solid var(--linie); background: var(--flaeche); overflow-y: auto;
}
.marke:not(.badge) { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font: 600 17px/1 var(--f-titel); color: var(--tinte); text-decoration: none; letter-spacing: -0.01em; }
.marke:not(.badge) .logo { width: 30px; height: 30px; flex: none; }
.marke:not(.badge) em { font-style: italic; color: var(--marke); font-weight: 500; }
/* Wortmarke „immonilo“ – letzter Buchstabe als Sprechblase (Assistent Jo) */
.wortmarke { display: inline-flex; align-items: baseline; font: 600 1.16em/1 var(--f-titel); letter-spacing: -0.025em; color: var(--tinte); font-variation-settings: "opsz" 72, "SOFT" 60; white-space: nowrap; }
.wortmarke .wm-blase { flex: none; margin-left: .02em; transform: translateY(.13em); color: var(--messing); overflow: visible; }
.nav-gruppe { margin: 12px 8px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); color: var(--tinte-2);
  text-decoration: none; font: 520 var(--t-s)/1.2 var(--f-ui); transition: background var(--dauer), color var(--dauer);
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--bg-2); color: var(--tinte); }
.nav a[aria-current="page"] { background: var(--marke-weich); color: var(--marke); font-weight: 600; }
.nav a .zaehler { margin-left: auto; font: 600 11px/1 var(--f-zahl); padding: 3px 6px; border-radius: 999px; background: var(--messing-weich); color: var(--messing); }
.haupt { min-width: 0; display: flex; flex-direction: column; }
.kopfleiste {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--linie);
}
.suche-knopf {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px;
  border: 1px solid var(--linie-stark); border-radius: var(--r); background: var(--flaeche); color: var(--tinte-3);
  font: 400 var(--t-s) var(--f-ui); cursor: pointer; text-align: left;
}
.suche-knopf:hover { border-color: var(--tinte-3); }
.suche-knopf kbd { margin-left: auto; }
.suche-knopf span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .suche-knopf kbd { display: none; } .suche-knopf { min-width: 0; } }
.inhalt-bereich { padding: 28px 24px 64px; width: 100%; max-width: 1440px; margin: 0 auto; }
.seitenkopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.seitenkopf h1 { font-size: var(--t-xxl); }
.seitenkopf p { margin-top: 6px; color: var(--tinte-2); }
.menue-knopf { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .seitenleiste { position: fixed; z-index: 50; left: 0; width: 280px; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--schatten-hoch); }
  .app.menue-offen .seitenleiste { transform: none; }
  .menue-knopf { display: inline-flex; }
  .inhalt-bereich { padding: 20px 16px 64px; }
  .kopfleiste { padding: 10px 16px; }
}

/* Befehlspalette */
.palette { width: min(640px, calc(100vw - 24px)); margin-top: 12vh; }
.palette input { border: 0; border-bottom: 1px solid var(--linie); border-radius: 0; min-height: 56px; font-size: var(--t-l); padding: 0 20px; box-shadow: none !important; }
.palette ul { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-s); cursor: pointer; font-size: var(--t-s); }
.palette li[aria-selected="true"] { background: var(--marke-weich); color: var(--marke); }
.palette li .sehr-leise { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .seitenleiste, .kopfleiste, .toasts, .nicht-drucken { display: none !important; }
  .app { display: block; } body { background: #fff; }
}
