/* Billmation - Oberflaeche
   Ausgelegt auf Bildschirmarbeit UND Tablet/Smartphone (PWA).
   Alle Bedienelemente mindestens 44px hoch, damit sie am Touchscreen treffbar sind. */

:root {
  --navy: #0B1F3A;
  --navy-hell: #16304F;
  --korn: #5B93CC;
  --korn-hell: #E8F0F9;
  --flaeche: #FFFFFF;
  --hintergrund: #F4F6F9;
  --linie: #DDE3EB;
  --text: #14202E;
  --grau: #5A6675;
  --gruen: #1E7A4C;
  --gruen-hell: #E6F4EC;
  --rot: #B3261E;
  --rot-hell: #FBEAE9;
  --gelb: #8A6100;
  --gelb-hell: #FDF3DC;
  --radius: 8px;
  --schatten: 0 1px 2px rgba(11, 31, 58, .06), 0 4px 12px rgba(11, 31, 58, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--hintergrund);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- Gerüst */
.rahmen { display: flex; min-height: 100vh; min-height: 100dvh; }

.seitenleiste {
  width: 216px; flex-shrink: 0; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; height: 100dvh;
}
.marke { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.marke b { font-size: 18px; font-weight: 600; letter-spacing: .015em; }
.marke span { display: block; font-size: 11px; color: rgba(255,255,255,.55); margin-top: 2px; }

nav { padding: 10px 0; flex: 1; overflow-y: auto; }
nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 18px; background: none; border: 0; color: rgba(255,255,255,.72);
  font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
  border-left: 3px solid transparent;
}
nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
nav button.aktiv { background: rgba(91,147,204,.18); color: #fff;
                   border-left-color: var(--korn); font-weight: 500; }
nav button svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
nav .abschnitt { padding: 14px 18px 5px; font-size: 10.5px; text-transform: uppercase;
                 letter-spacing: .07em; color: rgba(255,255,255,.38); }

.statusleiste { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.1);
                font-size: 11.5px; color: rgba(255,255,255,.5); }
.statusleiste .punkt { display: inline-block; width: 7px; height: 7px;
                       border-radius: 50%; margin-right: 6px; background: var(--korn); }
.statusleiste .punkt.ok { background: #4ADE80; }
.statusleiste .punkt.warnung { background: #FBBF24; }
.statusleiste .punkt.fehler { background: #F87171; }

.inhalt { flex: 1; min-width: 0; padding: 24px 28px 60px; }

/* ---------------------------------------------------------------- Kopf */
.seitenkopf { display: flex; justify-content: space-between; align-items: flex-start;
              gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.seitenkopf h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.seitenkopf p { margin: 3px 0 0; color: var(--grau); font-size: 13.5px; }
.werkzeuge { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Karten */
.karte { background: var(--flaeche); border: 1px solid var(--linie);
         border-radius: var(--radius); box-shadow: var(--schatten); margin-bottom: 16px; }
.karte > h2 { font-size: 14px; font-weight: 600; margin: 0;
              padding: 14px 18px; border-bottom: 1px solid var(--linie); }
.karte .rumpf { padding: 18px; }

.kachelreihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
               gap: 14px; margin-bottom: 20px; }
.kachel { background: var(--flaeche); border: 1px solid var(--linie);
          border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--schatten); }
.kachel .bez { font-size: 12.5px; color: var(--grau); }
.kachel .wert { font-size: 25px; font-weight: 600; margin-top: 4px;
                font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kachel .zusatz { font-size: 12px; color: var(--grau); margin-top: 2px; }
.kachel.warnung .wert { color: var(--gelb); }
.kachel.fehler .wert { color: var(--rot); }

/* ---------------------------------------------------------------- Formular */
.feldgitter { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
              gap: 14px; }
.feld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.feld.breit { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 500; color: var(--grau); }
label .pflicht { color: var(--rot); }

input, select, textarea {
  font: inherit; font-size: 14.5px; padding: 10px 11px; min-height: 44px;
  border: 1px solid var(--linie); border-radius: 6px; background: #fff;
  color: var(--text); width: 100%;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--korn); outline-offset: -1px; border-color: var(--korn); }
input[readonly], input:disabled, select:disabled {
  background: var(--hintergrund); color: var(--grau); }
input.zahl { text-align: right; font-variant-numeric: tabular-nums; }

fieldset { border: 0; padding: 0; margin: 0 0 22px; }
fieldset > legend { font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--navy); padding: 0 0 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--linie); width: 100%; }

.schalter { display: flex; align-items: center; gap: 9px; min-height: 44px; }
.schalter input { width: 18px; height: 18px; min-height: 0; flex-shrink: 0; }
.schalter label { font-size: 14px; color: var(--text); font-weight: 400; }

/* ---------------------------------------------------------------- Knöpfe */
button.knopf {
  font: inherit; font-size: 14.5px; font-weight: 500; padding: 0 16px;
  min-height: 44px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--linie); background: #fff; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap;
}
button.knopf:hover { background: var(--hintergrund); }
button.knopf.haupt { background: var(--navy); border-color: var(--navy); color: #fff; }
button.knopf.haupt:hover { background: var(--navy-hell); }
button.knopf.gefahr { color: var(--rot); border-color: #E9C3C0; }
button.knopf.gefahr:hover { background: var(--rot-hell); }
button.knopf.klein { min-height: 34px; padding: 0 11px; font-size: 13px; }
button.knopf:disabled { opacity: .45; cursor: not-allowed; }
button.knopf svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- Tabellen */
.tabellenrahmen { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.liste { width: 100%; border-collapse: collapse; font-size: 14px; }
table.liste th {
  text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--grau); padding: 10px 12px;
  border-bottom: 1px solid var(--linie); white-space: nowrap; background: var(--flaeche);
}
table.liste td { padding: 11px 12px; border-bottom: 1px solid var(--linie);
                 vertical-align: middle; }
table.liste tbody tr:hover { background: var(--korn-hell); }
table.liste tbody tr.klickbar { cursor: pointer; }
table.liste tfoot td { padding: 11px 12px; font-weight: 600;
                       border-top: 2px solid var(--navy); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums;
                   white-space: nowrap; }
td.nummer { font-variant-numeric: tabular-nums; font-weight: 500; }
.leer { padding: 44px 20px; text-align: center; color: var(--grau); }
.leer p { margin: 0 0 14px; }

/* ---------------------------------------------------------------- Marken */
.marke-status { display: inline-block; padding: 3px 9px; border-radius: 20px;
                font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.st-entwurf { background: var(--gelb-hell); color: var(--gelb); }
.st-festgeschrieben { background: var(--gruen-hell); color: var(--gruen); }
.st-storniert { background: var(--rot-hell); color: var(--rot); }
.st-bezahlt { background: var(--korn-hell); color: #2A5D96; }

.meldung { padding: 12px 15px; border-radius: 6px; font-size: 14px; margin-bottom: 14px; }
.meldung.hinweis { background: var(--korn-hell); color: #24507F; }
.meldung.warnung { background: var(--gelb-hell); color: var(--gelb); }
.meldung.fehler { background: var(--rot-hell); color: var(--rot); }
.meldung.erfolg { background: var(--gruen-hell); color: var(--gruen); }
.meldung ul { margin: 7px 0 0; padding-left: 19px; }
.meldung li { margin-bottom: 3px; }

.hash { font-family: "Cascadia Mono", Consolas, "SF Mono", monospace;
        font-size: 11.5px; color: var(--grau); word-break: break-all; }

/* ---------------------------------------------------------------- Positionen */
.positionszeile { display: grid; gap: 9px; padding: 13px 0;
                  border-bottom: 1px solid var(--linie);
                  grid-template-columns: 28px 1fr 92px 86px 108px 66px 108px 44px;
                  align-items: start; }
.positionszeile .pos-nr { padding-top: 12px; color: var(--grau); font-size: 13px; }
.positionszeile .summe { padding-top: 12px; text-align: right;
                         font-variant-numeric: tabular-nums; font-weight: 500; }
.positionskopf { display: grid; gap: 9px; padding-bottom: 7px;
                 grid-template-columns: 28px 1fr 92px 86px 108px 66px 108px 44px;
                 font-size: 11.5px; font-weight: 600; text-transform: uppercase;
                 letter-spacing: .05em; color: var(--grau);
                 border-bottom: 1px solid var(--linie); }
.positionskopf .r { text-align: right; }
.knopf-loeschen { background: none; border: 0; color: var(--grau); cursor: pointer;
                  font-size: 19px; line-height: 1; padding: 11px 0; min-height: 44px; }
.knopf-loeschen:hover { color: var(--rot); }

.summenkasten { display: flex; justify-content: flex-end; padding: 16px 0 4px; }
.summenkasten table { border-collapse: collapse; min-width: 290px; }
.summenkasten td { padding: 5px 0; font-size: 14px; }
.summenkasten td.wert { text-align: right; font-variant-numeric: tabular-nums;
                        padding-left: 30px; }
.summenkasten tr.gesamt td { border-top: 2px solid var(--navy); padding-top: 9px;
                             font-size: 17px; font-weight: 600; }

/* ---------------------------------------------------------------- Dialog */
.abdeckung { position: fixed; inset: 0; background: rgba(11,31,58,.42);
             display: flex; align-items: center; justify-content: center;
             padding: 18px; z-index: 200; }
.dialog { background: #fff; border-radius: 10px; width: 100%; max-width: 620px;
          max-height: 88vh; display: flex; flex-direction: column;
          box-shadow: 0 18px 50px rgba(11,31,58,.28); }
.dialog h2 { font-size: 17px; margin: 0; padding: 18px 20px;
             border-bottom: 1px solid var(--linie); }
.dialog .rumpf { padding: 20px; overflow-y: auto; flex: 1; }
.dialog .fuss { padding: 14px 20px; border-top: 1px solid var(--linie);
                display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Hinweis */
.wolke { position: fixed; bottom: 22px; right: 22px; z-index: 300;
         background: var(--navy); color: #fff; padding: 13px 18px;
         border-radius: 8px; font-size: 14px; max-width: 400px;
         box-shadow: 0 8px 26px rgba(11,31,58,.3); }
.wolke.fehler { background: var(--rot); }
.wolke.erfolg { background: var(--gruen); }

.suchleiste { display: flex; gap: 9px; margin-bottom: 15px; flex-wrap: wrap; }
.suchleiste input, .suchleiste select { max-width: 260px; }

.laden { padding: 44px; text-align: center; color: var(--grau); }

/* ---------------------------------------------------------------- Mobil */
.mobilkopf { display: none; }

@media (max-width: 860px) {
  .rahmen { flex-direction: column; }

  .mobilkopf {
    display: flex; align-items: center; gap: 12px; padding: 11px 15px;
    background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 100;
  }
  .mobilkopf b { font-size: 16.5px; font-weight: 600; flex: 1; }
  .mobilkopf button { background: none; border: 0; color: #fff; padding: 9px;
                      cursor: pointer; min-height: 44px; min-width: 44px; }
  .mobilkopf svg { width: 22px; height: 22px; }

  .seitenleiste {
    position: fixed; inset: 0 auto 0 0; width: 258px; height: 100dvh; z-index: 150;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .seitenleiste.offen { transform: translateX(0); }
  .seitenleiste.offen + .schleier { display: block; }
  .schleier { display: none; position: fixed; inset: 0;
              background: rgba(11,31,58,.45); z-index: 140; }

  .inhalt { padding: 16px 14px 80px; }
  .seitenkopf h1 { font-size: 19px; }
  .werkzeuge { width: 100%; }
  .werkzeuge button { flex: 1; }

  /* Positionen werden am Telefon zu gestapelten Karten */
  .positionskopf { display: none; }
  .positionszeile {
    grid-template-columns: 1fr 1fr; gap: 10px; padding: 15px 0;
    background: var(--hintergrund); border-radius: 8px; padding: 14px;
    margin-bottom: 11px; border: 1px solid var(--linie);
  }
  .positionszeile .pos-nr { display: none; }
  .positionszeile > .feld-bezeichnung { grid-column: 1 / -1; }
  .positionszeile .summe { grid-column: 1 / -1; text-align: right; padding-top: 0;
                           border-top: 1px solid var(--linie); padding-top: 9px; }
  .knopf-loeschen { grid-column: 1 / -1; text-align: right; }

  /* Am Telefon zeigen Tabellen nur die wesentlichen Spalten */
  table.liste th.optional, table.liste td.optional { display: none; }

  .kachelreihe { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kachel { padding: 13px; }
  .kachel .wert { font-size: 21px; }

  .wolke { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .dialog { max-height: 92dvh; }
}

@media (max-width: 480px) {
  .kachelreihe { grid-template-columns: 1fr; }
  .feldgitter { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .seitenleiste, .mobilkopf, .werkzeuge, .suchleiste { display: none !important; }
  .inhalt { padding: 0; }
  .karte { box-shadow: none; border: 0; }
}

/* ================================================================ Anmeldung */
.anmeldung {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center;
  justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #0B1F3A 0%, #16304F 55%, #24507F 100%);
}
.anmeldekarte {
  background: #fff; border-radius: 12px; padding: 34px 30px; width: 100%;
  max-width: 400px; box-shadow: 0 20px 60px rgba(11,31,58,.35);
}
.anmeldekarte .marke { padding: 0 0 22px; border: 0; text-align: center; }
.anmeldekarte .marke b { font-size: 26px; color: var(--navy); letter-spacing: -.01em; }
.anmeldekarte .marke span { color: var(--grau); font-size: 13px; margin-top: 3px; }
.anmeldekarte .feld { margin-bottom: 14px; }
.anmeldekarte button { width: 100%; margin-top: 6px; }
.anmeldefuss { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--linie);
               font-size: 12px; color: var(--grau); text-align: center; }

/* ================================================================ Mandantenwahl */
.mandantwahl { padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.mandantwahl label { color: rgba(255,255,255,.5); font-size: 10.5px;
                     text-transform: uppercase; letter-spacing: .07em; }
.mandantwahl select {
  margin-top: 5px; background: rgba(255,255,255,.08); color: #fff;
  border-color: rgba(255,255,255,.16); min-height: 38px; font-size: 13.5px;
}
.mandantwahl select option { background: #16304F; color: #fff; }

.benutzerleiste { padding: 11px 18px; border-top: 1px solid rgba(255,255,255,.1);
                  display: flex; align-items: center; gap: 10px; }
.benutzerleiste .kuerzel {
  width: 30px; height: 30px; border-radius: 50%; background: var(--korn);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; flex-shrink: 0;
}
.benutzerleiste .wer { flex: 1; min-width: 0; }
.benutzerleiste .wer b { display: block; font-size: 13px; color: #fff;
                         font-weight: 500; overflow: hidden;
                         text-overflow: ellipsis; white-space: nowrap; }
.benutzerleiste .wer span { font-size: 11px; color: rgba(255,255,255,.5); }
.benutzerleiste button { background: none; border: 0; color: rgba(255,255,255,.6);
                         cursor: pointer; padding: 8px; min-height: 40px; }
.benutzerleiste button:hover { color: #fff; }
.benutzerleiste svg { width: 17px; height: 17px; }

/* ================================================================ Rechtematrix */
.rechteliste { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr));
               gap: 3px; }
.rechteliste .schalter { padding: 5px 8px; border-radius: 5px; min-height: 38px; }
.rechteliste .schalter:hover { background: var(--hintergrund); }

.modulgitter { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr));
               gap: 3px; }

.zugangskasten {
  background: var(--gruen-hell); border: 1px solid #B6DFC7; border-radius: 8px;
  padding: 15px; margin-top: 14px;
}
.zugangskasten dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px;
                    margin: 9px 0 0; }
.zugangskasten dt { color: var(--grau); font-size: 13px; }
.zugangskasten dd { margin: 0; font-family: "Cascadia Mono", Consolas, monospace;
                    font-size: 14px; font-weight: 600; }

.kennsatz { display: inline-block; padding: 2px 7px; border-radius: 4px;
            font-size: 11px; font-weight: 600; background: var(--hintergrund);
            color: var(--grau); margin-left: 6px; }
.kennsatz.an { background: var(--gruen-hell); color: var(--gruen); }
.kennsatz.aus { background: var(--rot-hell); color: var(--rot); }
