:root {
  --bg: #241529;
  --panel: #2b1b33;
  --panel-2: #342040;
  --line: #43304d;
  --gold: #c9a54e;
  --gold-dim: #8f7435;
  --text: #f3eef6;
  --muted: #a596b0;
  --ok: #4cb782;
  --warn: #e0a33e;
  --err: #e0584e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

/* --- Kopf --- */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo .bar { width: 5px; height: 46px; background: var(--gold); }
.logo .wort { font-family: var(--serif); font-size: 27px; letter-spacing: 0.5px; line-height: 1; }
.logo .sub {
  color: var(--gold); font-size: 10px; letter-spacing: 4.5px; margin-top: 4px;
}
header .spacer { flex: 1; }

nav { display: flex; gap: 4px; margin-left: 20px; }
nav a {
  color: var(--muted); text-decoration: none; font-size: 13px; letter-spacing: 0.4px;
  padding: 7px 13px; border-radius: 6px; border: 1px solid transparent;
}
nav a:hover { color: var(--text); }
nav a.aktiv { color: var(--gold); border-color: var(--gold-dim); background: var(--panel-2); }

/* --- Layout --- */
main { padding: 26px 28px 80px; max-width: 1280px; margin: 0 auto; }
h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0 0 16px; }
h3 { font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--gold);
     margin: 0 0 14px; font-weight: 600; }

.karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }

.karte {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  /* Traegt den Loeschknopf in der Ecke. */
  position: relative;
}
.karte:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
/* Loeschen sitzt auf der Karte selbst, damit man die Akte dafuer nicht erst
   oeffnen muss. Immer sichtbar, nicht erst beim Darueberfahren – auf dem Handy
   gibt es kein "hover". Der Titel haelt rechts Platz frei, damit ein langer
   Name nicht unter dem Knopf verschwindet. */
.karte .titel { font-family: var(--serif); font-size: 19px; margin-bottom: 2px;
                padding-right: 36px; }
.karte .kartenweg {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; padding: 0; line-height: 1; font-size: 16px;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.karte .kartenweg:hover { color: var(--err); border-color: var(--err); filter: none; }
.karte .nr { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.karte .zeile { display: flex; justify-content: space-between; align-items: baseline;
                margin-top: 12px; }
.karte .preis { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 18px;
}
.zwei { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .zwei { grid-template-columns: 1fr; } }

/* --- Formular --- */
.feld { margin-bottom: 14px; }
.feld label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px;
              letter-spacing: 0.3px; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
input[type=checkbox] { width: auto; }

/* Der eingebaute Dateiknopf ist auf dunklem Grund kaum zu sehen und je nach
   Browser verschieden gross. Darum ein eigener Knopf – das Feld selbst liegt
   unsichtbar darunter und oeffnet beim Klick trotzdem die Dateiauswahl. */
.dateiwahl {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px;
}
.dateiwahl:hover { border-color: var(--gold-dim); }
.dateiwahl input[type=file] { position: absolute; width: 0; height: 0; opacity: 0; }
.dateiwahl .waehlen {
  flex: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 12px; font-size: 13px;
}
.dateiwahl .dateiname {
  color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis;
  /* Ohne min-width schrumpft ein Flex-Kind nicht und der Name laeuft aus dem Kasten. */
  white-space: nowrap; min-width: 0;
}
.raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.flags { display: flex; flex-wrap: wrap; gap: 16px; }
.flags label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); }

button {
  background: var(--gold);
  color: #2a1a30;
  border: 0;
  border-radius: 6px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
button:hover { filter: brightness(1.08); }
button.leise { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.leise:hover { color: var(--text); border-color: var(--gold-dim); filter: none; }
button.gefahr { background: transparent; color: var(--err); border: 1px solid var(--line); }
.knopfleiste { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* --- Kalkulation --- */
.kalk { font-variant-numeric: tabular-nums; }
.kalk .zeile { display: flex; justify-content: space-between; padding: 7px 0;
               border-bottom: 1px solid var(--line); }
.kalk .zeile:last-child { border-bottom: 0; }
.kalk .zeile span:first-child { color: var(--muted); }
.kalk .summe { font-size: 17px; font-weight: 600; padding-top: 12px; }
.kalk .summe span:first-child { color: var(--text); }
.gut { color: var(--ok); }
.schlecht { color: var(--err); }

/* --- Tabelle Kosten --- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
     color: var(--muted); font-weight: 500; padding: 0 8px 8px 0; }
td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
td.r, th.r { text-align: right; padding-right: 0; padding-left: 18px; white-space: nowrap; }

/* "display: flex" weiter unten wuerde das hidden-Attribut aushebeln – sonst
   steht auf der Anmeldeseite eine leere rote Fehlerbox. */
[hidden] { display: none !important; }

/* --- Hinweise --- */
.hinweis { display: flex; gap: 10px; padding: 10px 12px; border-radius: 6px; font-size: 13px;
           margin-bottom: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.hinweis.fehler { border-color: var(--err); }
.hinweis.warnung { border-color: var(--warn); }
.hinweis .punkt { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; }
.hinweis.fehler .punkt { background: var(--err); }
.hinweis.warnung .punkt { background: var(--warn); }
.hinweis.info .punkt { background: var(--gold); }

/* --- Kleinkram --- */
.marke {
  display: inline-block; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted);
}
.marke.verkauft { color: var(--ok); border-color: var(--ok); }
.marke.verfuegbar { color: var(--gold); border-color: var(--gold-dim); }
.marke.differenz { color: var(--warn); border-color: var(--warn); text-transform: none; }
.marke.entwurf { color: var(--muted); }
.marke.final { color: var(--ok); border-color: var(--ok); }
.marke.storniert { color: var(--err); border-color: var(--err); }
.leer { color: var(--muted); text-align: center; padding: 60px 20px; }
.zurueck { display: inline-block; background: none; border: 0; color: var(--muted); cursor: pointer;
           padding: 0; margin-bottom: 14px; font-size: 13px; text-decoration: none; }
.zurueck:hover { color: var(--gold); }
.hinweistext { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* --- Anmeldung / Einrichtung --- */
body.tor { display: flex; align-items: center; justify-content: center; min-height: 100vh;
           padding: 24px; }
.tor-karte { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
             padding: 32px 30px; width: 100%; max-width: 380px; }
.tor-karte .hinweis { margin-top: 14px; margin-bottom: 0; }
.tor-karte h3 { margin-bottom: 4px; }

/* --- Benutzermenü --- */
.ich { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.ich .kreis { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2);
              border: 1px solid var(--gold-dim); color: var(--gold); display: flex;
              align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
              flex: none; text-decoration: none; cursor: pointer; }
.ich .kreis:hover { border-color: var(--gold); }

/* --- Schmale Fenster und Telefon --- */
@media (max-width: 920px) {
  header { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  nav { order: 3; flex-basis: 100%; margin-left: 0; overflow-x: auto; }
  nav a { padding: 7px 10px; }
  /* Der Name verschwindet hier, darum ist der Kreis der Weg zu "Mein Zugang" –
     und muss gross genug sein, um ihn mit dem Daumen zu treffen. */
  .ich #ichName { display: none; }
  .ich .kreis { width: 40px; height: 40px; font-size: 14px; }
  main { padding: 20px 16px 70px; }
  .karten { grid-template-columns: 1fr; }
  /* Breite Tabellen scrollen innerhalb ihres Panels, statt die Seite zu sprengen. */
  .panel { overflow-x: auto; }
  table { font-size: 13px; }
}
