@import url('/static/fonts.css');

/* ------------------------------------------------------------------ Farben */
:root {
  --wein: #6A2238;
  --reben: #4C6A3A;
  --ocker: #A97A1F;

  --bg: #F5F1EB;
  --flaeche: #FFFDF9;
  --flaeche-2: #FAF6F0;
  --text: #2A2024;
  --leise: #6E6266;
  --rand: #E4DAD0;
  --akzent: var(--wein);
  --akzent-text: #FFFFFF;
  --akzent-weich: #F3E6EA;
  --link: var(--wein);
  --wohnt: var(--reben);
  --wohnt-weich: #E6EEDF;
  --kuenftig: var(--ocker);
  --kuenftig-weich: #F6EDD9;
  --ehemalig: #8A7F82;
  --ehemalig-weich: #EEEAE8;
  --gefahr: #A3272E;
  --schatten: 0 1px 2px rgba(42, 32, 36, .06), 0 2px 8px rgba(42, 32, 36, .05);
  --schild: linear-gradient(180deg, #FFFEFB, #F8F3EA);
  --schraube: radial-gradient(circle at 35% 35%, #EDE5DA, #B8AC9E 70%);

  --serif: 'Young Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  color-scheme: light;
}

/* Dunkler Modus: automatisch nach Systemeinstellung oder per Umschalter (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="hell"]) {
    --bg: #161113; --flaeche: #211A1D; --flaeche-2: #2A2125; --text: #F1E9E5; --leise: #B4A7A4;
    --rand: #3A2E32; --akzent: #8E3352; --akzent-weich: #3A1F28; --link: #E39AB0;
    --wohnt: #8DB176; --wohnt-weich: #24301E; --kuenftig: #D9AA4C; --kuenftig-weich: #352A15;
    --ehemalig: #9C9093; --ehemalig-weich: #2C2427; --gefahr: #E06A70;
    --schatten: 0 1px 2px rgba(0,0,0,.4); --schild: linear-gradient(180deg, #2A2226, #231C1F);
    --schraube: radial-gradient(circle at 35% 35%, #6A5E58, #3B322F 70%);
    color-scheme: dark;
  }
}
:root[data-theme="dunkel"] {
  --bg: #161113; --flaeche: #211A1D; --flaeche-2: #2A2125; --text: #F1E9E5; --leise: #B4A7A4;
  --rand: #3A2E32; --akzent: #8E3352; --akzent-weich: #3A1F28; --link: #E39AB0;
  --wohnt: #8DB176; --wohnt-weich: #24301E; --kuenftig: #D9AA4C; --kuenftig-weich: #352A15;
  --ehemalig: #9C9093; --ehemalig-weich: #2C2427; --gefahr: #E06A70;
  --schatten: 0 1px 2px rgba(0,0,0,.4); --schild: linear-gradient(180deg, #2A2226, #231C1F);
  --schraube: radial-gradient(circle at 35% 35%, #6A5E58, #3B322F 70%);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ Grundlagen */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--sans); min-height: 100vh;
}
a { color: var(--link); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: .005em; }
button, input, select, textarea { font: inherit; color: inherit; }
.versteckt { display: none !important; }
.leise { color: var(--leise); }
.klein { font-size: .875rem; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 42px; padding: .5em 1em; border-radius: 10px; border: 1px solid var(--rand);
  background: var(--flaeche); cursor: pointer; text-decoration: none; color: var(--text);
  font-weight: 500; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.knopf:hover { border-color: var(--leise); }
.knopf:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .schild:focus-visible, .reiter:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--akzent) 45%, transparent); outline-offset: 2px;
}
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf.primaer:hover { filter: brightness(1.08); }
.knopf.gefahr { color: var(--gefahr); }
.knopf.gefahr.voll { background: var(--gefahr); border-color: var(--gefahr); color: #fff; }
.knopf.flach { border-color: transparent; background: transparent; }
.knopf.klein { min-height: 34px; padding: .25em .7em; font-size: .9rem; }
.knopf[disabled] { opacity: .55; cursor: default; }

input[type=text], input[type=search], input[type=password], input[type=date], input[type=email], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: .55em .75em; border: 1px solid var(--rand);
  border-radius: 10px; background: var(--flaeche); font-size: 16px; /* verhindert Zoom auf iPhone */
}
textarea { min-height: 90px; resize: vertical; }
label.feld { display: block; }
label.feld > span { display: block; font-size: .85rem; color: var(--leise); margin-bottom: .25em; font-weight: 500; }

/* ------------------------------------------------------------------ Kopf */
.kopf {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rand);
}
.kopf-innen { max-width: 1180px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.marke { font-family: var(--serif); font-size: 1.2rem; white-space: nowrap; color: var(--akzent); text-decoration: none; display: flex; align-items: center; gap: .5rem; }
:root[data-theme="dunkel"] .marke { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="hell"]) .marke { color: var(--link); } }
.marke svg { width: 26px; height: 26px; }
.kopf .abstand { flex: 1; }
.menue { position: relative; }
.menue-liste {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--flaeche);
  border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.15); padding: .35rem; z-index: 30;
}
.menue-liste button, .menue-liste a { display: block; width: 100%; text-align: left; padding: .6rem .75rem; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.menue-liste button:hover, .menue-liste a:hover { background: var(--flaeche-2); }
.menue-liste .kopfzeile { padding: .5rem .75rem; font-size: .85rem; color: var(--leise); border-bottom: 1px solid var(--rand); margin-bottom: .25rem; }

.reiterleiste { max-width: 1180px; margin: 0 auto; padding: 0 1rem; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.reiterleiste::-webkit-scrollbar { display: none; }
.reiter {
  flex: none; padding: .55rem .9rem; border: 0; background: none; cursor: pointer; color: var(--leise);
  border-bottom: 3px solid transparent; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.reiter.aktiv { color: var(--text); border-bottom-color: var(--akzent); }
.reiter.neu { color: var(--link); }

main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ------------------------------------------------------------------ Übersicht */
.objektkopf { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.objektkopf h1 { font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.2; }
.objektkopf .unter { color: var(--leise); margin-top: .2rem; }
.objektkopf .abstand { flex: 1; }

.kennzahlen { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kennzahl { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--schatten); }
.kennzahl .wert { font-family: var(--serif); font-size: clamp(1.25rem, 3.2vw, 1.75rem); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kennzahl .bez { font-size: .82rem; color: var(--leise); }
@media (max-width: 720px) { .kennzahlen { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; } }

.werkzeuge { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.werkzeuge .suche { flex: 1; position: relative; }
.werkzeuge .suche input { padding-left: 2.3rem; }
.werkzeuge .suche svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--leise); }

.gruppe { margin-bottom: 1.75rem; }
.gruppe h2 { font-size: 1.15rem; margin-bottom: .6rem; display: flex; align-items: baseline; gap: .5rem; }
.gruppe h2 .anzahl { font-family: var(--sans); font-size: .85rem; color: var(--leise); }
.schilder { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
@media (max-width: 460px) { .schilder { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; } }

/* Türschild */
.schild {
  position: relative; display: flex; flex-direction: column; text-align: center; cursor: pointer;
  background: var(--schild); border: 1px solid var(--rand); border-radius: 10px; padding: 1.1rem .8rem .8rem;
  box-shadow: var(--schatten), inset 0 0 0 4px var(--flaeche), inset 0 0 0 5px var(--rand);
  color: inherit; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease; min-width: 0;
}
.schild:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(42,32,36,.10), inset 0 0 0 4px var(--flaeche), inset 0 0 0 5px var(--rand); }
.schild::before, .schild::after {
  content: ''; position: absolute; top: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--schraube);
}
.schild::before { left: 10px; } .schild::after { right: 10px; }
.schild .nr { font-family: var(--serif); font-size: 2.3rem; line-height: 1.05; color: var(--akzent); overflow-wrap: anywhere; }
:root[data-theme="dunkel"] .schild .nr { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="hell"]) .schild .nr { color: var(--link); } }
.schild .nr.lang { font-size: 1.5rem; padding-top: .4rem; }
.schild .nr.leer { font-size: 1.1rem; color: var(--leise) !important; padding: .55rem 0 .35rem; }
.schild .name { font-weight: 600; margin-top: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schild .mitmieter { font-size: .8rem; color: var(--leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schild .fuss { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: .6rem; padding-top: .55rem; border-top: 1px dashed var(--rand); font-size: .85rem; }
.schild .miete { font-variant-numeric: tabular-nums; font-weight: 500; }
.schild .doks { display: inline-flex; align-items: center; gap: .15rem; color: var(--leise); font-size: .8rem; }
.schild .doks svg { width: 14px; height: 14px; }
.schild.ehemalig { opacity: .78; }
.schild.ehemalig .nr { color: var(--ehemalig) !important; }

.status { display: inline-flex; align-items: center; gap: .3em; padding: .1em .55em; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.wohnt { color: var(--wohnt); background: var(--wohnt-weich); }
.status.kuenftig { color: var(--kuenftig); background: var(--kuenftig-weich); }
.status.ehemalig { color: var(--ehemalig); background: var(--ehemalig-weich); }
.status.bald { color: var(--ocker); background: var(--kuenftig-weich); }

.leer-hinweis { text-align: center; padding: 3rem 1rem; color: var(--leise); }

/* ------------------------------------------------------------------ Detail */
.zurueck { margin-bottom: .75rem; }
.detailkopf { display: flex; gap: 1rem; align-items: center; background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--schatten); margin-bottom: 1rem; flex-wrap: wrap; }
.detailkopf .nr { font-family: var(--serif); font-size: 3rem; line-height: 1; color: var(--akzent); min-width: 2ch; }
:root[data-theme="dunkel"] .detailkopf .nr { color: var(--link); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="hell"]) .detailkopf .nr { color: var(--link); } }
.detailkopf .nr.leer { font-size: 1.2rem; color: var(--leise) !important; }
@media (max-width: 420px) { .marke { font-size: 1.05rem; } #nutzerName { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; } }
.detailkopf h1 { font-size: 1.6rem; line-height: 1.2; }
.detailkopf .titel { flex: 1; min-width: 200px; }
.detailkopf .titel .unter { color: var(--leise); margin-top: .2rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.aktionen { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

.raster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 860px) { .raster { grid-template-columns: minmax(0, 1fr); } }
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--schatten); min-width: 0; }
.karte h2 { font-size: 1.1rem; margin-bottom: .75rem; display: flex; align-items: center; gap: .5rem; }
.karte h2 .abstand { flex: 1; }
.karte.breit { grid-column: 1 / -1; }
dl.felder { margin: 0; display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: .45rem 1rem; }
dl.felder dt { color: var(--leise); font-size: .9rem; }
dl.felder dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
@media (max-width: 460px) {
  dl.felder { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.felder dt { margin-top: .6rem; font-size: .8rem; }
}
.kontakt-links { display: flex; flex-direction: column; gap: .15rem; }
.hinweisbox { background: var(--flaeche-2); border-radius: 8px; padding: .55rem .75rem; font-size: .9rem; margin-top: .75rem; }

/* Dokumente */
.ablage {
  border: 2px dashed var(--rand); border-radius: var(--radius); padding: 1.1rem; text-align: center; color: var(--leise);
  cursor: pointer; transition: background .15s, border-color .15s; margin-bottom: .75rem;
}
.ablage.drueber { border-color: var(--akzent); background: var(--akzent-weich); color: var(--text); }
.ablage strong { color: var(--link); }
.dateiliste { list-style: none; margin: 0; padding: 0; }
.dateiliste li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--rand); }
.dateiliste li:first-child { border-top: 0; }
.dateiliste .icon { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: .7rem; font-weight: 700; background: var(--flaeche-2); color: var(--leise); }
.dateiliste .icon.pdf { background: var(--akzent-weich); color: var(--link); }
.dateiliste .icon.bild { background: var(--wohnt-weich); color: var(--wohnt); }
.dateiliste .icon.word { background: #E1E8F4; color: #2F5597; }
:root[data-theme="dunkel"] .dateiliste .icon.word { background: #1E2633; color: #8FB0E6; }
.dateiliste .info { flex: 1; min-width: 0; }
.dateiliste .info a, .dateiliste .info .dname { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dateiliste .info .meta { font-size: .8rem; color: var(--leise); }
.dateiliste .knoepfe { display: flex; gap: .25rem; flex: none; }
.uploads { margin-bottom: .5rem; font-size: .9rem; }
.uploads .zeile { display: flex; justify-content: space-between; gap: .5rem; padding: .2rem 0; }
.uploads .fehler { color: var(--gefahr); }
.untertitel { font-size: .9rem; font-weight: 600; color: var(--leise); margin: 1rem 0 .25rem; text-transform: uppercase; letter-spacing: .05em; }

/* Notizen */
.notizform { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.notizform .knopf { align-self: flex-end; }
.notizen { list-style: none; margin: 0; padding: 0; }
.notizen li { padding: .7rem 0; border-top: 1px solid var(--rand); }
.notizen li:first-child { border-top: 0; }
.notizen .meta { font-size: .8rem; color: var(--leise); display: flex; gap: .5rem; align-items: center; }
.notizen .meta .abstand { flex: 1; }
.notizen .text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .15rem; }
.notizen .loeschen { border: 0; background: none; color: var(--leise); cursor: pointer; padding: .2rem .4rem; border-radius: 6px; }
.notizen .loeschen:hover { color: var(--gefahr); background: var(--flaeche-2); }

/* ------------------------------------------------------------------ Dialoge */
dialog {
  border: 1px solid var(--rand); border-radius: 16px; padding: 0; background: var(--flaeche); color: var(--text);
  width: min(640px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 12, 16, .45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 1.5rem); }
dialog .dkopf { padding: 1rem 1.25rem; border-bottom: 1px solid var(--rand); display: flex; align-items: center; gap: .5rem; }
dialog .dkopf h2 { font-size: 1.25rem; flex: 1; }
dialog .dinhalt { padding: 1rem 1.25rem; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
dialog .dinhalt .ganz { grid-column: 1 / -1; }
dialog .dfuss { padding: .85rem 1.25rem; border-top: 1px solid var(--rand); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
dialog .dfehler { color: var(--gefahr); grid-column: 1 / -1; font-weight: 500; }
dialog .abschnitt { grid-column: 1 / -1; font-family: var(--serif); font-size: 1rem; color: var(--leise); margin-top: .4rem; border-bottom: 1px solid var(--rand); padding-bottom: .2rem; }
@media (max-width: 560px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; border: 0; }
  dialog form { max-height: 100dvh; height: 100%; }
  dialog .dinhalt { grid-template-columns: minmax(0, 1fr); flex: 1; }
}
.checkzeile { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.checkzeile input { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ Nutzer-Tabelle */
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th, .tabelle td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--rand); vertical-align: middle; }
.tabelle th { font-size: .82rem; color: var(--leise); font-weight: 600; }
@media (max-width: 640px) {
  .tabelle thead { display: none; }
  .tabelle tr { display: block; border-bottom: 1px solid var(--rand); padding: .5rem 0; }
  .tabelle td { display: block; border: 0; padding: .15rem 0; }
}

/* ------------------------------------------------------------------ Meldungen */
.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 10px; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: calc(100vw - 2rem); font-weight: 500;
}
.toast.fehler { background: var(--gefahr); color: #fff; }
.laden { padding: 3rem; text-align: center; color: var(--leise); }

/* ------------------------------------------------------------------ Login */
.login-seite { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-karte { width: min(400px, 100%); background: var(--flaeche); border: 1px solid var(--rand); border-radius: 16px; padding: 2rem 1.75rem; box-shadow: var(--schatten); }
.login-karte .marke { justify-content: center; font-size: 1.5rem; margin-bottom: .25rem; }
.login-karte p { text-align: center; margin: 0 0 1.5rem; }
.login-karte form { display: flex; flex-direction: column; gap: .9rem; }
.login-karte .knopf { width: 100%; margin-top: .3rem; }
.login-karte .fehler { color: var(--gefahr); text-align: center; font-weight: 500; min-height: 1.5em; margin: 0; }

@media print {
  .kopf, .aktionen, .zurueck, .ablage, .notizform, .knoepfe { display: none !important; }
  body { background: #fff; }
}
