/* Handy-Darstellung (iPhone-Web-App): Leiste unten, größere Tippflächen, kein Zoom beim Tippen in Felder. */
.mobile-bar { display: none; }
/* Das Handy-Menü gehört nur in die Handy-Ansicht; auf dem großen Bildschirm darf es nie erscheinen (stand ungestaltet unter der Seite). */
.mobile-menu { display: none; }
.photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photo-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px; border: 2px dashed var(--gold, #D5A936); border-radius: 16px; text-align: center; cursor: pointer; }
.photo-pick.secondary { border-style: solid; border-color: #cdd3cc; }
.photo-icon { font-size: 2.2rem; line-height: 1; }
.photo-form { max-width: 560px; }
.photo-form .button:disabled { opacity: .45; cursor: not-allowed; }
/* Such-Auswahlfelder (Kunde, Artikel): die leere Ergebnisliste zeigte einen Rahmenstrich, die echte Auswahl bleibt unsichtbar. */
.searchable-results[hidden], .searchable-results:empty { display: none; }
select.searchable-native { opacity: 0; pointer-events: none; }

@media (max-width: 700px) {
  /* Die Seite darf auf dem Handy nie seitlich verschiebbar sein (ein zu breites Element zog sie sonst auseinander). */
  html, body { max-width: 100%; overflow-x: hidden; }
  html { touch-action: pan-y pinch-zoom; }
  .table-wrap { touch-action: pan-x pan-y pinch-zoom; }
  .container, main { max-width: 100%; min-width: 0; }
  .card, form, .stack, .form-grid > * { min-width: 0; max-width: 100%; }
  img, video, canvas, svg { max-width: 100%; height: auto; }
  input, select, textarea { max-width: 100%; }
  /* Lange Wörter (Dateinamen, Nummern, E-Mail-Adressen) umbrechen statt die Seite zu verbreitern. */
  .card, .plain-list li, dd, dt, p, small, h1, h2, h3, summary, label { overflow-wrap: anywhere; }
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .container { padding: 14px 12px; }
  /* Die obere Menüleiste passt nicht auf ein Handy; stattdessen gibt es unten die Leiste und das Menü. */
  .topbar { height: auto; flex-wrap: nowrap; padding: 8px 12px; gap: 10px; justify-content: space-between; }
  .topbar nav { display: none; }
  .topbar .brand-art img, .topbar .brand img { max-height: 38px; width: auto; }
  .topbar form { margin-left: auto; }
  .mobile-menu { display: none; position: fixed; inset: 0; z-index: 70; overflow-y: auto; background: #171719; padding: calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .mobile-menu.open { display: block; }
  .mobile-menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .mobile-menu-grid a { display: flex; align-items: center; min-height: 52px; padding: 10px 14px; border-radius: 14px; background: #26262a; color: #f3ecd8; font-weight: 700; text-decoration: none; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head .actions, .actions { flex-wrap: wrap; }
  .button { min-height: 44px; }
  input, select, textarea, button { font-size: 16px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .grid.two, .split, .detail-grid, .template-layout { grid-template-columns: 1fr; }
  /* Tabellen nicht Buchstabe für Buchstabe umbrechen, sondern seitlich wischbar lassen. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 560px; }
  th { white-space: nowrap; }
  th, td { padding: 10px 8px; }
  /* Kleine Belegtabelle auf der Übersicht: alle Spalten bleiben, aber enger und kleiner; Datum und Betrag brechen nie um. */
  .recent-documents { min-width: 0 !important; font-size: .8rem; }
  .recent-documents th, .recent-documents td { padding: 8px 3px; }
  .recent-documents th { font-size: .62rem; letter-spacing: 0; }
  .recent-documents td:nth-child(4), .recent-documents td:nth-child(5) { white-space: nowrap; }
  .mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; gap: 4px; background: #171719; border-top: 1px solid #3a3a3d; padding: 6px 6px max(6px, calc(env(safe-area-inset-bottom) - 16px)); }
  .mobile-bar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: #e9e2cf; font-size: .72rem; line-height: 1.1; text-decoration: none; }
  .mobile-bar a .icon { font-size: 1.3rem; line-height: 1; }
  .mobile-bar a.camera { background: var(--gold, #D5A936); color: #171719; font-weight: 800; }
  .help-fab { bottom: calc(86px + env(safe-area-inset-bottom)); right: 10px; width: 38px; height: 38px; opacity: .8; }

  /* Formulare (Rechnung, Angebot, Kunden ...): ein Feld je Zeile, Positionen untereinander statt sieben Spalten. */
  .form-grid { grid-template-columns: 1fr; }
  .form-card { padding: 16px 14px; }
  .line-row { display: flex !important; flex-wrap: wrap; gap: 10px; padding: 12px; }
  .line-row > * { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .line-row > .item-picker, .line-row > *:has(textarea), .line-row > .delete, .line-row > .hidden-fields { flex: 1 1 100%; }
  .line-row input, .line-row select, .line-row textarea { width: 100%; }
  .line-row textarea { min-height: 84px; }
  .line-row .item-results { max-width: 100%; }
  .totals { max-width: none; margin-left: 0; }
  /* Speichern-Knöpfe: am Ende des Formulars, voll breit untereinander (festgeklebt würden sie auf dem Handy zu viel verdecken). */
  .sticky-save { position: static; flex-direction: column; align-items: stretch; margin-top: 8px; }
  .sticky-save .button { width: 100%; }
  summary { padding: 6px 0; }
}

/* Als App vom Home-Bildschirm gestartet: Platz für Statusleiste und Home-Balken. */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(8px + env(safe-area-inset-top)); }
}

@media (max-width: 760px){ .line-row > .line-tools { flex: 1 1 100%; } }
@media (max-width: 1000px) { .feedback-fab { bottom: calc(86px + env(safe-area-inset-bottom)); right: 56px; height: 38px; padding: 0 12px; opacity: .9 } .feedback-fab span { display: none } }
.mobile-menu-grid h3{grid-column:1/-1;margin:10px 0 0;font-size:.78rem;text-transform:uppercase;letter-spacing:.07em;color:#b9b19a}.mobile-menu-grid h3:first-child{margin-top:0}

/* 07.11.2026: Handy für alle Seiten. Tabellen werden Karten (Beschriftung je Zeile kommt aus mobile_tables.js),
   Reiter und Suchzeilen brechen um, Listenzeilen zeigen den Namen über die volle Breite. */
@media (max-width: 700px) {
  .table-wrap:has(> table.m-cards) { overflow: visible; }
  table.m-cards, .table-wrap table.m-cards { min-width: 0 !important; width: 100%; border: 0; background: transparent; }
  table.m-cards thead { display: none; }
  table.m-cards, table.m-cards tbody, table.m-cards tfoot, table.m-cards tr, table.m-cards td, table.m-cards tbody th, table.m-cards tfoot th { display: block; }
  table.m-cards tr { border: 1px solid var(--line, #e5e1d6); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; background: var(--card, #fff); }
  table.m-cards td, table.m-cards tbody th, table.m-cards tfoot th { display: block; position: relative; padding: 5px 0 5px 42%; min-height: 1.6em; border: 0; text-align: right; white-space: normal !important; overflow-wrap: anywhere; min-width: 0; max-width: none; }
  table.m-cards td::before, table.m-cards tbody th::before, table.m-cards tfoot th::before { content: attr(data-label); position: absolute; left: 0; top: 6px; width: 40%; text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted, #6f6a5c); }
  table.m-cards td[data-label=""], table.m-cards td:not([data-label]) { padding-left: 0; text-align: left; }
  table.m-cards td[data-label=""]::before, table.m-cards td:not([data-label])::before { display: none; }
  table.m-cards td:empty { display: none; }
  table.m-cards tr > td:first-child { font-weight: 600; }
  table.m-cards td input, table.m-cards td select { max-width: 62%; }
  table.m-cards td .actions, table.m-cards td form { justify-content: flex-end; }
  .tabs { flex-wrap: wrap; overflow: visible; }
  .tabs a { padding: 7px 10px; }
  .search { flex-wrap: wrap; }
  .search input, .search select { flex: 1 1 100%; min-width: 0; }
  .search .button, .search button { flex: 1 1 auto; }
  .quick-filters { flex-wrap: wrap; }
  main .dms-row { grid-template-columns: minmax(0, 1fr) auto; }
  main .dms-row > div:nth-child(2) { grid-column: 1 / -1; order: -1; }
  main .dms-row .sum { white-space: normal; }
  .grid.three, .grid.four, .form-grid { grid-template-columns: 1fr !important; }
  .cards { grid-template-columns: 1fr 1fr; }
  .cards > * { min-width: 0; }
  .inbox-files { max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
  .topbar .topbar-logout { display: none; }
  .mobile-logout { margin: 0 0 10px; }
}
/* Zeiterfassung: Knopf „Stempeln“ vor der Suche; am Handy steht er in der unteren Leiste */
.topbar .zt-quick { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3); color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; }
.topbar .zt-quick:hover { border-color: var(--gold, #d5a936); }
@media (max-width: 700px) {
  .topbar .zt-quick { display: none !important; }
  .mobile-bar a { min-width: 0; }
  .mobile-bar:has(> a:nth-child(7)) a { font-size: .62rem; }
}
