/* Handy und Tablet hochkant. Wird nach allen anderen Stylesheets geladen. */
@media (max-width: 760px) {
  body { display: block; min-height: 100dvh; }
  body.menu-open { overflow: hidden; }

  /* Kopfleiste mit Menü-Knopf; Seitenleiste wird zur Schublade */
  .mobile-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; background: var(--nav); color: #fff; box-shadow: 0 1px 0 var(--nav-line); padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .mobile-bar .brand { padding: 0; font-size: 20px; }
  .mobile-bar .brand-logo { width: 28px; height: 28px; border-radius: 7px; }
  .menu-btn { width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; display: grid; place-content: center; gap: 5px; cursor: pointer; }
  .menu-btn span { display: block; width: 20px; height: 2px; border-radius: 2px; background: #fff; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; width: min(290px, 84vw); z-index: 50; padding: max(20px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); transform: translateX(-100%); transition: transform .2s ease; }
  body.menu-open .sidebar { transform: none; box-shadow: 8px 0 30px #0006; }
  .sidebar .brand { padding-bottom: 20px; }
  .nav { padding: 12px 12px; font-size: 15.5px; }
  .subnav { margin: 0 -16px 18px; padding: 0 10px; }
  .page-head { align-items: flex-start; }
  .menu-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: var(--backdrop); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-open .menu-backdrop { opacity: 1; pointer-events: auto; }

  main { width: 100%; max-width: none; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
  header { flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
  h1 { font-size: 24px; }
  .eyebrow { font-size: 11px; margin-bottom: 2px; }

  /* Kacheln */
  .stats, .two-cols, .nl-stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .card { padding: 14px; }
  .stat-value { font-size: 20px; letter-spacing: -.4px; overflow-wrap: anywhere; }
  .stat-label { margin-bottom: 6px; }

  /* Leisten und Eingaben */
  .toolbar, .top-row { flex-wrap: wrap; gap: 10px; }
  .top-row { align-items: flex-start; }
  .search { min-width: 0; width: 100%; }
  .acc-export { margin-left: 0; width: 100%; }
  .acc-export a { flex: 1; justify-content: center; }
  .month-pick { flex: 1; min-width: 130px; }
  .month-pick select, .month-pick input { flex: 1; min-width: 0; }
  .acc-note { margin: -6px 0 18px; }
  .acc-toolbar .month-pick { flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; color: var(--muted); }
  .table.compact.acc-months td, .table.compact.acc-months th { padding: 9px 10px; }
  .tabs { overflow-x: auto; max-width: 100%; }
  .tab { white-space: nowrap; }
  input, select, textarea { font-size: 16px !important; } /* iOS zoomt sonst beim Antippen */

  /* Tabellen werden zu Karten: Beschriftung links (data-label aus der Kopfzeile) */
  .table-card { background: transparent; border: 0; padding: 0; overflow: visible; }
  .table-card > .table-head { padding: 4px 2px 10px; }
  .table:not(.compact), .table:not(.compact) tbody { display: block; }
  .table:not(.compact) thead { display: none; }
  .table:not(.compact) tr { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
  .table:not(.compact) td { display: grid; grid-template-columns: 118px minmax(0, 1fr); column-gap: 12px; align-items: baseline; padding: 5px 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .table:not(.compact) td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 30; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
  .table:not(.compact) td > * { grid-column: 2; }
  .table:not(.compact) td > .badge, .table:not(.compact) td > button, .table:not(.compact) td > select { justify-self: start; }
  .table:not(.compact) td:first-child { display: block; padding: 0 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
  .table:not(.compact) td:first-child::before, .table:not(.compact) td:not([data-label])::before { display: none; }
  .table:not(.compact) td:not([data-label]):not(:first-child) { display: block; padding-top: 8px; }
  .table:not(.compact) td.empty { display: block; padding: 24px 8px; text-align: center; }
  .table:not(.compact) .num-head { text-align: left; }
  .actions-cell { white-space: normal; }
  .srv-store-bar { width: auto; min-width: 0; }
  /* kleine Detailtabellen (z. B. Abrechnung) waagrecht scrollen */
  .table.compact { display: block; overflow-x: auto; white-space: nowrap; }

  .billing-sum { flex-wrap: wrap; gap: 14px; }
  .billing-head .secondary, .billing-head .primary { align-self: flex-start; }
  .srv-bar { grid-template-columns: minmax(0, 1fr) 72px; }
  .srv-bar-name { grid-column: 1 / -1; }
  .list-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .nl-preview { height: 60vh; }

  /* Dialoge fast bildschirmfüllend */
  dialog, dialog:has(.mail-preview) { width: calc(100vw - 16px); max-width: none; max-height: calc(100dvh - 16px); margin: auto; }
  .modal-box { min-width: 0; padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-actions { flex-wrap: wrap; margin-top: 20px; }
  .modal-actions > button { flex: 1 1 auto; }
  .modal-actions > button[style*="margin-right"] { flex-basis: 100%; margin-right: 0 !important; order: 9; }
}
@media (max-width: 380px) {
  .stats, .nl-stats { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .vat-stats { grid-template-columns: 1fr 1fr; }
  .vat-stats .card:last-child { grid-column: 1 / -1; }
  .vat-mode select { max-width: none; }
  .acc-page-tabs { display: flex; }
  .acc-page-tabs .tab { flex: 1; }
}
@media (max-width: 760px) {
  .vat-mode .month-pick { flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; color: var(--muted); }
  /* Kennzahlen kompakt: KZ links, Bezeichnung, darunter Bemessungsgrundlage | Steuer */
  .table.vat-table:not(.compact) tr { display: grid; grid-template-columns: 42px 1fr auto; column-gap: 10px; row-gap: 4px; padding: 10px 12px; margin-bottom: 6px; }
  .table.vat-table:not(.compact) td { display: block; padding: 0; margin: 0; border: 0; font-size: 14px; }
  .table.vat-table:not(.compact) td:empty { display: none; }
  .table.vat-table:not(.compact) td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; font-size: 15px; }
  .table.vat-table:not(.compact) td:nth-child(2) { grid-column: 2 / -1; }
  .table.vat-table:not(.compact) td:nth-child(2)::before { display: none; }
  .table.vat-table:not(.compact) td:nth-child(3) { grid-column: 2; }
  .table.vat-table:not(.compact) td:nth-child(4) { grid-column: 3; text-align: right; }
  .table.vat-table:not(.compact) td:nth-child(3)::before, .table.vat-table:not(.compact) td:nth-child(4)::before { display: block; font-size: 10px; margin-bottom: 1px; }
  .table.vat-table:not(.compact) tr.vat-total { background: var(--tint); }
}
