/*
 * Handy-Ansicht. Dieses Stylesheet gilt ohne eigene Media-Queries: base.html bindet es mit
 * media="(max-width: 760px)" (Automatisch), media="all" (Handy) oder media="not all" (Computer) ein.
 */

/* ---------- Rahmen und Kopfleiste mit Burger-Menü ---------- */
body { background: var(--raised); }
body.view-handy .app { max-width: 640px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.app { grid-template-columns: minmax(0, 1fr); background: var(--bg, #fafaf9); }
.sidebar {
  position: sticky; top: 0; z-index: 40; height: auto; min-height: 56px;
  flex-direction: row; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  border-right: 0; border-bottom: 1px solid var(--line);
}
.brand { padding: 0; }
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); color: var(--text); cursor: pointer;
}
.nav-toggle .icon { width: 22px; height: 22px; }
.sidebar-body { display: none; }
.sidebar.is-open .sidebar-body {
  display: flex; flex-direction: column; gap: 20px;
  position: fixed; top: 56px; bottom: 0; left: 0; right: 0; z-index: 39;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain; background: var(--raised);
  border-top: 1px solid var(--line);
}
body.view-handy .sidebar.is-open .sidebar-body { left: max(0px, calc(50% - 320px)); right: max(0px, calc(50% - 320px)); }
body.nav-open { overflow: hidden; }
.sidebar.is-open .nav a { height: 48px; padding: 0 12px; font-size: 16px; }
.sidebar.is-open .nav a .icon { width: 20px; height: 20px; }
.sidebar-foot { margin-top: 0; padding: 16px 0 0; }
.view-switch .segmented button { height: 40px; }
.view-switch summary { min-height: 40px; font-size: 14px; }
.segmented-sm button { height: 36px; padding: 0 12px; font-size: 14px; }
.keycap { display: none; }

/* ---------- Seite ---------- */
.page { padding: 16px 16px calc(48px + env(safe-area-inset-bottom)); }
.demo-banner { padding: 8px 16px; }
.page-head { flex-direction: column; align-items: stretch; gap: 12px; min-height: 0; margin-bottom: 16px; }
.page-head h1 { font-size: 24px; line-height: 30px; }
.page-head .actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.page-head .actions > form, .page-head .actions > .btn, .page-head .actions .btn { width: 100%; }
.page-head .actions .btn { justify-content: center; height: auto; padding: 10px 12px; white-space: normal; line-height: 18px; text-align: center; }
.btn { white-space: normal; }
.only-sm { display: block; }
.hide-sm { display: none !important; }

/* Bedienung mit dem Finger: größere Flächen, 16 px Schrift (iOS vergrößert sonst beim Antippen) */
.btn { min-height: 44px; }
.btn-sm { min-height: 36px; }
input, select, textarea, .input, .cell, .search input, .quick-search input,
.field input, .field select, .field textarea { font-size: 16px !important; }
.field input[type="text"], .field input[type="email"], .field input[type="number"], .field input[type="date"],
.field input[type="password"], .field input[type="search"], .field select, select.input, .input { min-height: 44px; }

/* ---------- Formulare und Raster ---------- */
.form-grid { gap: 14px; }
.form-grid > .field, .form-grid > [class*="span-"] { grid-column: span 12 !important; }
.form-actions { flex-wrap: wrap; }
.form-actions .btn { flex: 1 1 auto; justify-content: center; }
.toolbar { gap: 8px; }
.toolbar .input { min-width: 0; flex: 1 1 100%; }
.toolbar .segmented + .segmented { margin-left: 0; }
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button { flex: 0 0 auto; white-space: nowrap; height: 36px; }
.grid-2, .grid-equal, .grid-wide-left, .editor-grid, .head-grid { grid-template-columns: minmax(0, 1fr); }
.stats, .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; }
.stat .figure { font-size: 20px; line-height: 26px; }
.card-pad { padding: 16px; }
.card-head { padding: 12px 16px; flex-wrap: wrap; }
.facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
.facts dt { margin-top: 8px; font-size: 13px; }
.messages li { align-items: flex-start; }
.file-list li { flex-wrap: wrap; }

/* ---------- Tabellen werden zu Karten (Beschriftung aus dem Tabellenkopf, gesetzt von app.js) ---------- */
.table:not(.lines-table) thead { display: none; }
.table:not(.lines-table), .table:not(.lines-table) tbody { display: block; width: 100%; }
.table:not(.lines-table) tr { position: relative; display: flex; flex-direction: column; width: 100%; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table:not(.lines-table) tr:last-child { border-bottom: 0; }
.table:not(.lines-table) td {
  display: block; height: auto; min-height: 0; padding: 3px 0 !important; border: 0;
  text-align: right; overflow-wrap: anywhere;
}
.table:not(.lines-table) td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: 13px; text-align: left; }
.table:not(.lines-table) td:first-child { text-align: left; font-weight: 500; padding-bottom: 6px !important; }
.table:not(.lines-table) td:first-child::before { content: none; }
.table:not(.lines-table) td:empty { display: none; }
.table:not(.lines-table) td.title-sm { order: -1; text-align: left; font-weight: 500; padding-bottom: 6px !important; }
.table:not(.lines-table) td.title-sm::before, .table:not(.lines-table) td[colspan]::before { content: none; }
.table:not(.lines-table) td[colspan] { text-align: left; }
.table:not(.lines-table) tr.group-row td { font-weight: 600; }
.table:not(.lines-table) td .sub { display: block; }
.table:not(.lines-table) td .row-actions, .table:not(.lines-table) td form { display: inline-flex; }
.table-scroll { overflow-x: visible; }
.cell-wrap { max-width: none; }

/* ---------- Rechnungseditor: jede Zeile als Karte ---------- */
.table-scroll .lines-table { min-width: 0; }
.lines-table, .lines-table tbody { display: block; width: 100%; }
.lines-table thead { display: none; }
.lines-table tr.line {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; gap: 8px;
  grid-template-areas: "name name name del" "no qty unit unit" "price disc net net";
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.lines-table tr.line--heading, .lines-table tr.line--text { grid-template-areas: "text text text del"; }
.lines-table td { display: block; height: auto; padding: 0 !important; border: 0; width: auto !important; min-width: 0 !important; }
.lines-table td::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 12px; color: var(--muted); }
.lines-table .col-drag, .lines-table .col-pos { display: none; }
.lines-table .col-name { grid-area: name; }
.lines-table .col-name::before, .lines-table .col-text::before, .lines-table .col-del::before { content: none; }
.lines-table .col-no { grid-area: no; }
.lines-table .col-qty { grid-area: qty; }
.lines-table .col-unit { grid-area: unit; }
.lines-table .col-price { grid-area: price; }
.lines-table .col-disc { grid-area: disc; }
.lines-table .col-net { grid-area: net; text-align: right; align-self: end; padding-bottom: 10px !important; font-size: 16px; }
.lines-table .col-text { grid-area: text; }
.lines-table .col-del { grid-area: del; justify-self: end; }
.lines-table .cell { height: 40px; border-color: var(--line-strong); background: var(--surface); }
.lines-table .cell-sub { height: 36px; margin-top: 6px; }
.lines-table .cell-level { height: 32px; margin-top: 6px; }
.lines-table .btn-icon { width: 40px; height: 40px; }
.add-bar { padding: 12px 16px 4px; }
.quick-add { flex: 1 1 100%; }
.quick-search input { height: 44px; }
.quick-results { top: 48px; }
.quick-item { grid-template-columns: 80px minmax(0, 1fr) auto; }
.add-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.add-buttons .btn { justify-content: center; }

/* ---------- Fahrzeugannahme ---------- */
.photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.upload-row .upload-button, .upload-row select { flex: 1 1 100%; justify-content: center; }
.pick-list a { padding: 12px 16px; }

/* ---------- Anmeldung und öffentliche Seiten ---------- */
.login { padding: 16px; align-items: start; padding-top: 48px; }
.login .card { padding: 24px; }
body.public { padding: 24px 16px; }
