/* basis.css — Tokens, Grundlayout, Seitenmenü, Fußleiste, Tabellen- und Formular-Basis,
   Anmeldeseite. Erste von drei Dateien (basis → komponenten → ansichten, SPEC 14). */
:root {
  --fg: #1a1a1a;
  --muted: #666;
  --bg: #fafafa;
  --karte: #fff;
  --rand: #d8d8d8;
  --akzent: #1f4a8a;
  --offen: #e5e5e5;
  --ueberfaellig-bg: #ffdede;
  --ueberfaellig-fg: #a10000;
  --erledigt-bg: #d8f0d8;
  --erledigt-fg: #1a5a1a;
  --fehler-bg: #ffe0b3;
  --fehler-fg: #7a3800;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding-bottom: 3.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 1rem;
  background: var(--akzent);
  color: #fff;
}
body.nicht-produktiv header.topbar,
body.nicht-produktiv footer.seitenfuss { background: #a10000; }
body.nicht-produktiv .instanz-tag {
  background: #ffd400; color: #a10000; font-weight: 700;
  padding: 0.1rem 0.5rem; border-radius: 3px; margin-left: 0.5rem;
  font-size: 0.85em; letter-spacing: 0.5pt;
}
.topbar .brand { font-weight: 600; color: #fff; text-decoration: none; }
.topbar .instanz-tag.topbar-instanz { margin-left: auto; margin-right: 0; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { color: #fff; text-decoration: none; }
.topbar nav a:hover { text-decoration: underline; }
.topbar .benutzer { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: #eee; }
.topbar .benutzer strong { color: #fff; }
.topbar .benutzer .link {
  background: none; color: #eee; border: none;
  text-decoration: underline; cursor: pointer; padding: 0;
}

main { padding: 1rem; max-width: 1200px; margin: 0 auto; }
main.voll { max-width: none; }

/* ---- Seitenmenü (Burger) ---- */
:root { --sm-breite-schmal: 3.25rem; --sm-breite-offen: 13rem; }
.seitenmenue {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 3rem;   /* Platz für den fixierten Copyright-Footer */
  width: var(--sm-breite-schmal);
  background: var(--karte);
  border-right: 1px solid var(--rand);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding-top: 3.2rem;
  /* visible statt hidden, damit die Flyouts (.sm-sub) rechts herausragen
     dürfen; die Beschriftungen clippen stattdessen die Einträge selbst. */
  overflow: visible;
  transition: width 0.18s ease;
}
body.sm-offen .seitenmenue { width: var(--sm-breite-offen); }
body.mit-seitenmenue main { margin-left: var(--sm-breite-schmal); max-width: none; }
body.mit-seitenmenue.sm-offen main { margin-left: var(--sm-breite-offen); }
.sm-burger {
  position: absolute;
  top: 0.55rem;
  left: 0.6rem;
  background: none;
  border: none;
  padding: 0.3rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
}
.sm-burger:hover { color: var(--fg); background: var(--bg); }
.sm-logo { display: none; padding: 0.4rem 0.9rem 0.7rem 0.9rem; text-align: center; }
.sm-logo img { display: inline-block; width: 50%; height: auto; }
body.sm-offen .sm-logo { display: block; }
.sm-nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.4rem 0; }
.sm-nav a {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 0.85rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.92em;
  white-space: nowrap;
  border-left: 3px solid transparent;
  overflow: hidden;
}
.sm-nav a:hover { background: var(--bg); border-left-color: var(--akzent); }
.sm-nav a svg {
  width: 22px;
  height: 22px;
  flex: none;
  color: var(--akzent);
}
.sm-nav a span {
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
body.sm-offen .sm-nav a span { opacity: 1; pointer-events: auto; }
body.nicht-produktiv .sm-nav a svg { color: #a10000; }
body.nicht-produktiv .sm-nav a:hover { border-left-color: #a10000; }

/* Untermenü als Flyout (Anfragen, Bestellungen): öffnet bei Hover oder
   Tastaturfokus rechts neben dem Menü — im schmalen wie im offenen Zustand.
   Direkt anliegend (left: 100%), damit die Maus beim Rüberfahren keine
   Lücke überquert und das Flyout dabei zuklappt. */
.sm-gruppe { position: relative; }
.sm-sub {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 11rem;
  padding: 0.3rem 0;
  background: var(--karte);
  border: 1px solid var(--rand);
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 41;
}
/* Kind-Kombinator (>), nicht Nachfahre: eine Gruppe öffnet nur ihr eigenes
   Flyout. Bei verschachtelten Gruppen (Stammdaten → Lieferanten → …) würde
   der Nachfahren-Selektor sonst alle Unter-Flyouts auf einmal aufklappen. */
.sm-gruppe:hover > .sm-sub,
.sm-gruppe:focus-within > .sm-sub { display: block; }
/* Zweite Ebene: Flyout hängt rechts am Eintrag der ersten Ebene, oberkantenbündig
   mit dessen Zeile (die eigene Titelzeile gleicht das Padding des Elternpanels aus). */
.sm-sub .sm-gruppe > .sm-sub { top: -0.3rem; }
/* Titelzeile nennt den Hauptpunkt — im schmalen Menü ist er sonst nicht
   ablesbar, das Flyout stünde ohne Bezug neben einem Icon. */
.sm-sub-titel {
  padding: 0.35rem 0.9rem 0.45rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--rand);
  color: var(--akzent);
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5pt;
  white-space: nowrap;
}
body.nicht-produktiv .sm-sub-titel { color: #a10000; }
/* Hauptpunkt bleibt markiert, solange das Flyout offen ist */
.sm-gruppe:hover > a { background: var(--bg); border-left-color: var(--akzent); }
body.nicht-produktiv .sm-gruppe:hover > a { border-left-color: #a10000; }
.sm-nav .sm-sub a {
  padding: 0.5rem 0.9rem;
  gap: 0.6rem;
  font-size: 0.9em;
  border-left: 0;
}
.sm-nav .sm-sub a:hover { background: var(--bg); }
.sm-nav .sm-sub a svg { width: 16px; height: 16px; color: var(--muted); }
.sm-nav .sm-sub a:hover svg { color: var(--akzent); }
body.nicht-produktiv .sm-nav .sm-sub a:hover svg { color: #a10000; }
/* Beschriftungen im Flyout sind immer sichtbar, unabhängig vom Menüzustand */
.sm-nav .sm-sub a span { opacity: 1; pointer-events: auto; }
/* Pfeil rechts am Hauptpunkt — erscheint mit der Beschriftung im offenen Menü */
.sm-pfeil { margin-left: auto; color: var(--muted); font-size: 1.15em; line-height: 1; }
/* Fußbereich clippt seine Beschriftung ebenfalls selbst (overflow des Menüs ist jetzt visible) */
.sm-benutzer, .sm-abmelden button { overflow: hidden; }

/* Fußbereich mit Benutzer + Abmelden */
.sm-fuss {
  margin-top: auto;
  border-top: 1px solid var(--rand);
  padding: 0.6rem 0 0.9rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sm-benutzer,
.sm-abmelden button {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.55rem 0.85rem;
  color: var(--fg);
  font-size: 0.92em;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.sm-benutzer svg,
.sm-abmelden button svg {
  width: 22px;
  height: 22px;
  flex: none;
  color: var(--muted);
}
/* Avatar aus dem ERP-Ausweisbild statt Platzhalter-Icon; gleiche Spurbreite wie die Icons */
.sm-benutzer .sm-avatar {
  width: 26px;
  height: 26px;
  margin: -2px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 18%;
  box-shadow: 0 0 0 1.5px var(--rand);
}
.sm-benutzer span,
.sm-abmelden button span {
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.sm-offen .sm-benutzer span,
body.sm-offen .sm-abmelden button span { opacity: 1; pointer-events: auto; }
.sm-abmelden { margin: 0; }
.sm-abmelden button {
  width: 100%;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
}
.sm-abmelden button:hover {
  background: var(--bg);
  border-left-color: var(--akzent);
  color: var(--ueberfaellig-fg);
}
.sm-abmelden button:hover svg { color: var(--ueberfaellig-fg); }
body.nicht-produktiv .sm-abmelden button:hover { border-left-color: #a10000; }

footer.seitenfuss .build { opacity: 0; transition: opacity 0.2s; }
footer.seitenfuss:hover .build, footer.seitenfuss:focus-within .build { opacity: 1; }
footer.seitenfuss {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 1rem;
  background: var(--akzent);
  color: #fff;
  font-size: 0.75em;
  text-align: center;
  z-index: 50;
  line-height: 1.5;
}
h1 { margin-top: 0.5rem; }
h2 { margin-top: 1.5rem; }

.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  padding: 1rem 1.5rem;
  max-width: 400px;
  margin: 3rem auto;
}
.hinweis { color: var(--muted); font-size: 0.9em; }

table { border-collapse: collapse; width: 100%; background: var(--karte); }
table th, table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rand); text-align: left; }
table th { background: #f0f0f0; font-weight: 600; }
.rechts { text-align: right; }

table.uebersicht td { padding-top: 0.66rem; padding-bottom: 0.66rem; }
.uebersicht a { color: var(--akzent); }
table.uebersicht th a.sortlink {
  color: inherit; text-decoration: none; display: inline-block;
}
table.uebersicht th a.sortlink:hover { text-decoration: underline; }
table.uebersicht th a.sortlink-aktiv { color: var(--akzent); }
table.we-liste th a.sortlink {
  color: inherit; text-decoration: none; display: inline-block;
}
table.we-liste th a.sortlink:hover { text-decoration: underline; }
table.we-liste th a.sortlink-aktiv { color: var(--akzent); }
fieldset { border: 1px solid var(--rand); padding: 0.75rem 1rem; margin: 1rem 0; background: var(--karte); }
legend { padding: 0 0.5rem; font-weight: 600; }
form.bestellform fieldset { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
form.bestellform fieldset > legend { grid-column: 1 / -1; }
form.bestellform fieldset > table { grid-column: 1 / -1; }
form.bestellform fieldset > button { grid-column: 1 / -1; justify-self: start; margin-top: 0.5rem; }
form.bestellform label { display: flex; flex-direction: column; font-size: 0.85em; color: var(--muted); }
form.bestellform label.voll { grid-column: 1 / -1; }
form.bestellform input, form.bestellform select, form.bestellform textarea { padding: 0.3rem; font-size: 1em; }

table.positionen input, table.positionen select { width: 100%; padding: 0.2rem; }

td.zeile-loeschen { width: 32px; text-align: center; padding: 0; }
button.loeschen-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 0.3rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 3px;
}
button.loeschen-btn:hover { color: var(--ueberfaellig-fg); background: var(--ueberfaellig-bg); }
button.loeschen-btn svg { display: block; }

.aktionen { margin-top: 1rem; }
button.primaer {
  background: var(--akzent); color: #fff; border: none;
  padding: 0.5rem 1.5rem; font-size: 1em; cursor: pointer;
}
button.primaer:hover { background: #163765; }

/* ---- Login-Seite ---- */
body.anmeldung-body {
  min-height: 100vh;
  padding-bottom: 4rem;
  background:
    radial-gradient(ellipse at top left, #eef3fb 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, #f4f6fa 0%, transparent 60%),
    var(--bg);
}
body.anmeldung-body.nicht-produktiv {
  background:
    radial-gradient(ellipse at top left, #fdecec 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, #f4f6fa 0%, transparent 60%),
    var(--bg);
}
main.anmeldung-buehne {
  min-height: calc(100vh - 4rem);
  max-width: none;
  padding: 2rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.anmeldung-karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-top: 4px solid var(--akzent);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(31, 74, 138, 0.12),
              0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 2rem 2.5rem 2.25rem 2.5rem;
  width: 100%;
  max-width: 26rem;
  text-align: center;
}
body.nicht-produktiv .anmeldung-karte {
  border-top-color: #a10000;
  box-shadow: 0 12px 40px rgba(161, 0, 0, 0.15),
              0 2px 8px rgba(0, 0, 0, 0.06);
}
.anmeldung-logo {
  margin: 0 auto 0.5rem auto;
  max-width: 18rem;
}
.anmeldung-logo img {
  display: block;
  width: 100%;
  height: auto;
}
.anmeldung-subtitel {
  font-size: 1.05em;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0 0 1.25rem 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rand);
}
.anmeldung-karte form.anmelden {
  text-align: left;
  margin-top: 0.25rem;
}
.anmeldung-karte form.anmelden button {
  align-self: stretch;
  margin-top: 0.75rem;
  padding: 0.55rem;
  font-size: 1em;
}
.anmeldung-fehler {
  background: var(--ueberfaellig-bg);
  color: var(--ueberfaellig-fg);
  border: 1px solid var(--ueberfaellig-fg);
  padding: 0.5rem 0.75rem;
  border-radius: 3px;
  margin-top: 0.75rem;
  font-size: 0.9em;
  text-align: left;
}
.anmeldung-hinweis {
  margin: 0.75rem 0 0 0;
  font-size: 0.85em;
  color: var(--muted);
  text-align: center;
}

/* Touch-freundlich */
@media (pointer: coarse) {
  button.we-btn { padding: 1rem 1.2rem; font-size: 1.05em; min-width: 130px; }
  button.we-submit { padding: 0.9rem 2rem; font-size: 1.15em; }
}

/* hidden-Attribut muss gegen display:flex der Formular-Labels gewinnen (Sprachfeld bei mehreren Lieferanten) */
form.bestellform label[hidden] { display: none; }

/* ---- Schmale Bildschirme, z. B. Telefon quer (SPEC 14.8) ----
   Nur unterhalb 930 px bzw. 500 px Höhe; der Desktop bleibt unberührt. */
@media (max-width: 930px) {
  main { padding: 0.6rem 0.7rem; }
  h1 { font-size: 1.35rem; margin: 0.3rem 0 0.6rem; }
  h1.mit-blaettern { gap: 0.4rem; }
  .topbar { padding: 0.35rem 0.7rem; }
}
@media (max-height: 500px) {
  /* Höhe ist knapp: fester Fußbereich weg, Platz für Inhalt */
  footer.seitenfuss { position: static; }
  .seitenmenue { bottom: 0; }
  body { padding-bottom: 0.5rem; }
}
