/* Klarbuch im Browser: iPhone & iPad */
html.kb-web, html.kb-web body { height: 100%; -webkit-text-size-adjust: 100%; }
html.kb-web body { overscroll-behavior: none; }
html.kb-web .shell { height: 100dvh; }
html.kb-web input, html.kb-web select, html.kb-web textarea { font-size: 16px; } /* iOS zoomt sonst beim Antippen */
html.kb-web .kb-kopf { padding-top: max(10px, env(safe-area-inset-top)); }
html.kb-web .picker { min-height: 100dvh; padding: max(40px, env(safe-area-inset-top)) 16px 40px; }
html.kb-web .picker > .kb-kopf { top: max(10px, env(safe-area-inset-top)); right: 12px; }
html.kb-web .sidebar { padding-top: env(safe-area-inset-top); }

/* Anzeige von Belegen / PDFs */
.kbw-viewer { position: fixed; inset: 0; z-index: 200; background: #0f172aee; display: flex; flex-direction: column; }
.kbw-vkopf { display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; background: var(--card, #fff); flex-wrap: wrap; }
.kbw-vname { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.kbw-vbody { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.kbw-vbody canvas, .kbw-vbody img { background: #fff; box-shadow: 0 6px 24px #0006; max-width: 100%; height: auto; }

/* iPad hochkant & kleiner: Seitenleiste als ausklappbares Menü */
@media (max-width: 1023px) {
  html.kb-web .shell { grid-template-columns: 1fr; }
  html.kb-web .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: 270px; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 0 40px #0005; }
  html.kb-web .shell.nav-offen .sidebar { transform: none; }
  html.kb-web .shell.nav-offen .nav-schleier { display: block; position: fixed; inset: 0; z-index: 55; background: #0f172a55; }
  html.kb-web .main .kb-menu { display: inline-flex; }
  html.kb-web .kb-kopf { padding-left: 14px; padding-right: 14px; }
  html.kb-web .page { padding: 12px 16px 60px; }
}
/* iPhone */
@media (max-width: 700px) {
  html.kb-web .page { padding: 8px 10px calc(60px + env(safe-area-inset-bottom)); }
  html.kb-web .page-head { gap: 8px; }
  html.kb-web .page-head h1 { font-size: 21px; width: 100%; }
  html.kb-web .grid.g2, html.kb-web .grid.g3, html.kb-web .grid.g4 { grid-template-columns: 1fr !important; }
  html.kb-web .form { grid-template-columns: repeat(6, 1fr); }
  html.kb-web .form > * { grid-column: span 6 !important; }
  html.kb-web .form .c2, html.kb-web .form .c3 { grid-column: span 3 !important; }
  html.kb-web .modal-backdrop { padding: 0; place-items: stretch; }
  html.kb-web .modal, html.kb-web .modal.wide { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  html.kb-web .modal-head { padding-top: max(14px, env(safe-area-inset-top)); }
  html.kb-web .modal-body { padding: 14px; -webkit-overflow-scrolling: touch; }
  html.kb-web .modal-foot { flex-wrap: wrap; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  html.kb-web .modal-foot .left { width: 100%; margin: 0 0 4px; flex-wrap: wrap; }
  html.kb-web .picker-grid { grid-template-columns: 1fr; }
  html.kb-web .kb-nutzer { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html.kb-web .grid-tools .search { width: 100%; }
  html.kb-web .preview-wrap { display: none; }
}
/* Tabellen seitlich scrollbar statt abgeschnitten */
@media (max-width: 1023px) {
  html.kb-web .card, html.kb-web .modal-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  html.kb-web table.list th, html.kb-web table.list td { white-space: nowrap; }
}
@media (max-width: 1023px) {
  html.kb-web .editor { grid-template-columns: 1fr; }
  html.kb-web .editor .preview-wrap { display: none; }
  html.kb-web .scan-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  html.kb-web .picker { padding-top: calc(70px + env(safe-area-inset-top)); }
  html.kb-web .picker > .kb-kopf { left: 12px; justify-content: flex-end; }
  html.kb-web table.pos thead { display: none; }
  html.kb-web table.pos, html.kb-web table.pos tbody { display: block; }
  html.kb-web table.pos tr { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  html.kb-web table.pos td { padding: 0; }
  html.kb-web table.pos td:first-child { grid-column: 1 / -1; }
  html.kb-web .scan-grid img, html.kb-web .scan-grid canvas { max-height: 45vh; object-fit: contain; }
}
html.kb-web #inbox-set { display: none; }
@media (max-width: 1023px) { html.kb-web .scan-grid img, html.kb-web .scan-grid canvas { max-height: 50vh; width: auto; max-width: 100%; object-fit: contain; display: block; margin: 0 auto; } }
