:root {
  --primaer: #5b7ea3;
  --primaer-dunkel: #4a6a8c;
  --primaer-hell: #eef3f8;
  --kopf-start: #52738f;
  --kopf-ende: #46617c;
  --tinte: #364152;
  --grau: #7c8ba1;
  --flaeche: #f3f5f9;
  --weiss: #fff;
  --linie: #e7ebf1;
  --gruen: #4d9e79;
  --gruen-hell: #eaf6f0;
  --rot: #d4776a;
  --rot-hell: #fbedeb;
  --gelb: #d0973f;
  --gelb-hell: #fbf2e3;
  --radius: 16px;
  --radius-klein: 10px;
  --schatten: 0 4px 16px rgba(54, 65, 82, .06), 0 1px 3px rgba(54, 65, 82, .05);
  --schatten-weich: 0 2px 8px rgba(54, 65, 82, .05);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--flaeche); color: var(--tinte); line-height: 1.5; }

/* ------------------------------------------------------------- Kopf */
header {
  background: linear-gradient(135deg, var(--kopf-start), var(--kopf-ende));
  color: #fff; display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 1.5rem; position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 10px rgba(30, 45, 60, .12);
}
.logo { font-weight: 700; font-size: 1.1rem; white-space: nowrap; letter-spacing: .2px; }
nav { display: flex; gap: 0.25rem; flex-wrap: wrap; align-items: center; flex: 1; }
nav a { color: rgba(255,255,255,.85); text-decoration: none; padding: 0.45rem 0.85rem; border-radius: 999px; transition: background .15s, color .15s; font-size: 0.95rem; }
nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
nav a.aktiv { background: rgba(255,255,255,.22); color: #fff; font-weight: 600; }
nav select { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; }
nav select option { color: var(--tinte); }
nav .mandant-name { color: rgba(255,255,255,.85); font-size: 0.9rem; padding: 0.35rem 0.75rem; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; white-space: nowrap; }

/* ------------------------------------------------------------- Inhalt */
main { max-width: 1200px; margin: 1.8rem auto; padding: 0 1.2rem; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0.4rem 0 1.2rem; color: var(--tinte); }
h2 { font-size: 1.08rem; font-weight: 700; margin: 0 0 0.9rem; color: var(--tinte); }

.meldung { background: var(--gruen-hell); border: 1px solid #cfe8dc; color: #2f6b4f; padding: 0.7rem 1.1rem; border-radius: var(--radius-klein); margin-bottom: 1rem; }
.meldung.fehler { background: var(--rot-hell); border-color: #f2d4cf; color: #9c4a3d; }

.karten { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.karte { background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius); padding: 1.1rem 1.3rem; box-shadow: var(--schatten-weich); }
.karte .zahl { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.karte.warn .zahl { color: var(--rot); }
.karte.ok .zahl { color: var(--gruen); }

/* ------------------------------------------------------------- Tabellen */
table { width: 100%; border-collapse: collapse; background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; box-shadow: var(--schatten-weich); font-size: 0.88rem; }
th, td { padding: 0.6rem 0.7rem; text-align: left; border-bottom: 1px solid var(--linie); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { background: var(--primaer-hell); font-weight: 600; white-space: nowrap; color: var(--tinte); }
tr:hover td { background: #fafbfd; }
.betrag { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.betrag.minus { color: var(--rot); } .betrag.plus { color: var(--gruen); }
.status-offen { color: var(--gelb); font-weight: 600; background: var(--gelb-hell); padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; }
.status-geprueft { color: var(--gruen); font-weight: 600; background: var(--gruen-hell); padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; }

/* ------------------------------------------- Zeitraum, Frist, Ablauf */
.zeitraum-leiste { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.zeitraum-leiste label { font-weight: 600; font-size: 0.9rem; }
.frist { background: var(--primaer-hell); color: var(--tinte); border-radius: 999px; padding: 0.3rem 0.9rem; font-size: 0.88rem; white-space: nowrap; }
.frist.knapp { background: var(--gelb-hell); color: #6b5227; }
.frist.ueberfaellig { background: var(--rot-hell); color: #9c4a3d; }

.schritte { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.schritt { flex: 1; min-width: 190px; display: flex; align-items: center; gap: 0.6rem;
  background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius-klein);
  padding: 0.7rem 1rem; font-size: 0.92rem; color: var(--grau); }
.schritt .nummer { display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--linie);
  color: var(--grau); font-weight: 700; font-size: 0.85rem; flex: 0 0 auto; }
.schritt.aktiv { border-color: var(--primaer); color: var(--tinte); font-weight: 600;
  box-shadow: 0 0 0 3px var(--primaer-hell); }
.schritt.aktiv .nummer { background: var(--primaer); color: #fff; }
.schritt.erledigt { color: var(--gruen); border-color: #cfe8dc; }
.schritt.erledigt .nummer { background: var(--gruen); color: #fff; }

.naechster-schritt { background: var(--weiss); border: 1px solid var(--primaer);
  border-left: 4px solid var(--primaer); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; margin-bottom: 1.5rem; box-shadow: var(--schatten-weich); }
.naechster-schritt p { margin: 0 0 0.9rem; }

table.cockpit td, table.cockpit th { vertical-align: middle; }
table.cockpit .klein-text { display: block; font-weight: 400; }

/* Feld-Ausrichtung in .zeile-Formularen (frueher inline-styles) */
.feld-unten { display: flex; align-items: flex-end; }
details.abweichend { margin-top: 0.8rem; }
details.abweichend summary { cursor: pointer; color: var(--primaer); font-size: 0.88rem; }
.bearbeiten-zeile > td { padding-top: 0; padding-bottom: 0.6rem; }
.bearbeiten-zeile summary { cursor: pointer; color: var(--primaer); }
.bearbeiten-form { margin-top: 0.6rem; }
.auswahl-kasten { cursor: pointer; }
.saldo { font-weight: 700; }

/* -------------------------------- Freigabe-Status und Nachrichten */
.status-leiste { border-radius: var(--radius-klein); padding: 0.8rem 1.1rem;
  margin: 1rem 0; font-size: 0.92rem; border: 1px solid var(--linie); }
.status-leiste.status-offen { background: var(--primaer-hell); }
.status-leiste.status-freigegeben { background: var(--gelb-hell); border-color: #f2e0bb; color: #6b5227; }
.status-leiste.status-gesendet { background: var(--gruen-hell); border-color: #cfe8dc; color: #2f6b4f; }

.nachrichten { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.2rem; }
.nachricht { border: 1px solid var(--linie); border-radius: var(--radius-klein);
  padding: 0.6rem 0.9rem; background: #fbfcfe; max-width: 46rem; }
.nachricht.eigen { background: var(--primaer-hell); border-color: #d6e2ee; align-self: flex-end; }
.nachricht .kopf { display: flex; gap: 0.6rem; align-items: baseline; margin-bottom: 0.25rem; }
.nachricht .text { white-space: pre-wrap; }
textarea { width: 100%; font: inherit; resize: vertical; }

/* -------------------------------------- USt-Voranmeldung-Kennziffern */
.kennziffer-zeile { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--linie); }
.kennziffer-zeile:last-child { border-bottom: 0; }
.kennziffer-zeile > span:first-child { flex: 1; }
.kennziffer-box { flex: 0 0 auto; border: 1px solid var(--tinte); border-radius: 4px; padding: 0.1rem 0.5rem; font-weight: 700; font-size: 0.85rem; }
.kennziffer-zeile .betrag { flex: 0 0 auto; min-width: 9rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.betrag-gross { font-size: 1.1rem; }
.ustva-kopf { display: flex; flex-wrap: wrap; gap: 0.4rem 2rem; margin-bottom: 1rem; font-size: 0.92rem; color: var(--grau); }
.ustva-kopf strong { color: var(--tinte); }

/* ------------------------------------------------------------- Formulare */
select, textarea,
input[type=text], input[type=number], input[type=date],
input[type=file], input[type=password], input[type=email] {
  padding: 0.5rem 0.65rem; border: 1px solid var(--linie); border-radius: var(--radius-klein);
  font: inherit; max-width: 100%; background: #fbfcfe; color: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
select:focus, textarea:focus, input:focus {
  outline: none; border-color: var(--primaer); background: var(--weiss);
  box-shadow: 0 0 0 4px var(--primaer-hell);
}
button, .knopf {
  background: var(--primaer); color: #fff; border: 0; padding: 0.55rem 1.2rem;
  border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600;
  text-decoration: none; display: inline-block; transition: background .15s, transform .1s;
}
button:hover, .knopf:hover { background: var(--primaer-dunkel); }
button:active, .knopf:active { transform: scale(.98); }
button:focus-visible, .knopf:focus-visible, a:focus-visible { outline: 2px solid var(--primaer); outline-offset: 2px; }
button.klein { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
button.rot { background: var(--rot); } button.rot:hover { background: #c15f51; }
button.gruen { background: var(--gruen); } button.gruen:hover { background: #3e8a67; }
button.beenden { background: transparent; border: 1px solid rgba(255,255,255,.35); color: rgba(255,255,255,.85); padding: 0.35rem 0.85rem; font-size: 0.8rem; font-weight: 500; }
button.beenden:hover { background: rgba(212, 119, 106, .85); border-color: transparent; color: #fff; }
form.inline { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; }

.formular, .abschnitt {
  background: var(--weiss); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 1.4rem 1.6rem; box-shadow: var(--schatten-weich); max-width: 640px;
}
.abschnitt { margin-bottom: 1.5rem; }
.abschnitt h2 { margin-bottom: 0.3rem; }
.abschnitt .beschreibung { color: var(--grau); font-size: 0.9rem; margin: 0 0 1.1rem; max-width: 60ch; }
.formular label, .abschnitt label { display: block; margin: 0.9rem 0 0.3rem; font-weight: 600; font-size: 0.9rem; color: var(--tinte); }
.formular label:first-child, .abschnitt form label:first-of-type { margin-top: 0; }
.formular input[type=text], .formular input[type=number],
.formular input[type=date], .formular input[type=password],
.formular select, .abschnitt input[type=text], .abschnitt input[type=password],
.abschnitt select { width: 100%; }
.formular .hinweis, .abschnitt .hinweis { color: var(--grau); font-size: 0.82rem; margin-top: 0.3rem; }
.zeile { display: flex; gap: 1rem; flex-wrap: wrap; }
.zeile > div { flex: 1; min-width: 140px; }

.hilfe { background: var(--gelb-hell); border: 1px solid #f2e0bb; border-radius: var(--radius-klein); padding: 0.85rem 1.1rem; font-size: 0.88rem; margin: 1rem 0; color: #6b5227; }
.klein-text { color: var(--grau); font-size: 0.8rem; }

/* ------------------------------------------------------------- Schmale Bildschirme */
@media (max-width: 900px) {
  header { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.8rem; position: static; }
  nav { gap: 0.15rem; }
  nav a { padding: 0.35rem 0.6rem; font-size: 0.9rem; }
  main { margin-top: 1.2rem; }
  .formular, .abschnitt { padding: 1.1rem 1.2rem; }
  th, td { padding: 0.45rem 0.5rem; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ------------------------------------- Kanzleien / Lizenzen (Betreiber) */
.status-aktiv { color: var(--gruen); font-weight: 600; background: var(--gruen-hell); padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; }
.status-gesperrt { color: var(--rot); font-weight: 600; background: var(--rot-hell); padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; }
.protokoll td { font-size: 0.86rem; }
.protokoll .zeitpunkt { white-space: nowrap; color: var(--grau); }
.protokoll .details { color: var(--grau); word-break: break-word; }

/* --------------------------------------- Mandanten-Startseite und Fehler */
.grossaktion { text-align: center; margin: 1.6rem 0 2rem; }
.knopf.gross {
  display: inline-block; font-size: 1.15rem; font-weight: 600;
  padding: 1rem 2.4rem; border-radius: var(--radius);
}
.grossaktion .klein-text { display: block; margin-top: 0.7rem; }

.fehlerseite { text-align: center; padding: 3rem 1rem; }
.fehlerseite .fehlercode {
  font-size: 3.4rem; font-weight: 700; color: var(--linie); line-height: 1;
}
.fehlerseite h1 { margin: 0.6rem 0 0.4rem; }
.fehlerseite p { color: var(--grau); max-width: 30rem; margin: 0 auto 1.2rem; }

/* ------------------------------------------------- Kleine Bildschirme
   Mandanten laden ihre Belege meist vom Handy hoch. Breite Tabellen
   duerfen die Seite dabei nicht seitlich verschieben -- sie bekommen
   stattdessen einen eigenen Bildlauf. */
@media (max-width: 620px) {
  body { -webkit-text-size-adjust: 100%; }
  main { padding: 0 0.7rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }

  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .karten { flex-direction: column; }
  .karte { width: 100%; }
  .zeile { flex-direction: column; gap: 0.6rem; }
  .zeile > div { width: 100%; }

  /* Fingerfreundliche Ziele statt Mausgroessen */
  button, .knopf, select, input[type="text"], input[type="date"],
  input[type="password"], input[type="file"] {
    min-height: 2.75rem; font-size: 1rem;
  }
  button.klein, .knopf.klein { min-height: 2.25rem; }
  .knopf.gross { width: 100%; padding: 1.1rem 1rem; }

  nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  nav a { white-space: nowrap; }
}
