/* Schmale Bildschirme (Handy): gemeinsame Korrekturen für alle Seiten. Wird nach den Seitenstilen geladen. */

/* Grid-/Flex-Kinder dürfen schmaler werden als ihr Inhalt – sonst schieben lange Zeilen die Seite seitlich auf */
.page > *, .grid-2 > *, .cm-layout > *, .fifo-layout > * { min-width: 0; }
.section-head > * { min-width: 0; overflow-wrap: anywhere; }
textarea { max-width: 100%; }
img, svg, canvas { max-width: 100%; }

/* Breite Tabellen als Karten (Klasse setzt fe-mobile.js, wenn die Tabelle nicht in die Breite passt) */
table.m-cards { min-width: 0 !important; width: 100% !important; table-layout: auto !important; }
table.m-cards thead, table.m-cards colgroup { 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 { display: block; }
table.m-cards tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
table.m-cards tfoot tr { border-bottom: 0; }
/* Beschriftung als mitwachsende linke Spalte (Float in einem flow-root-Block): lange, umbrechende Beschriftungen
   schieben die nächste Zeile nach unten statt sie zu überlappen */
table.m-cards td, table.m-cards tbody th {
  display: flow-root; min-height: 1.5em; padding: 3px 0 3px 40% !important; border: 0 !important;
  text-align: left !important; white-space: normal !important; overflow-wrap: anywhere;
}
table.m-cards td::before, table.m-cards tbody th::before {
  content: attr(data-label); float: left; width: calc(66.667% - 12px); margin-left: -66.667%; padding-right: 12px; box-sizing: content-box; /* % bezieht sich auf die Inhaltsbreite (60 % der Zelle) */
  font-size: .78rem; font-weight: 600; line-height: 1.35; color: var(--muted); text-align: left; white-space: normal; overflow-wrap: normal; -webkit-hyphens: auto; hyphens: auto;
}
/* Zellen ohne Spaltenüberschrift (Reihenfolge, Aktionen, Hinweiszeilen) über die volle Breite */
table.m-cards td.m-nolabel, table.m-cards tbody th.m-nolabel { padding-left: 0 !important; }
table.m-cards td.m-nolabel:not(:empty) { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
table.m-cards td.m-nolabel::before, table.m-cards tbody th.m-nolabel::before { content: none; }
table.m-cards td.m-first { padding-left: 0 !important; font-size: 1rem; }
table.m-cards td.m-first::before { content: none; }
table.m-cards td.m-first.m-first-num::before { content: attr(data-label) "\00a0"; float: none; display: inline; width: auto; margin: 0; padding: 0; font-size: inherit; font-weight: inherit; color: inherit; }
table.m-cards td input:not([type="checkbox"]):not([type="radio"]), table.m-cards td select { width: 100%; max-width: 16rem; }

@media (max-width: 600px) {
  /* Balkendiagramm (Dashboard): Name | Betrag | Anteil, Balken darunter */
  .bars li { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "label num share" "track track track"; row-gap: 5px; }
  .bars li > :nth-child(1) { grid-area: label; }
  .bars li > :nth-child(2) { grid-area: track; }
  .bars li > :nth-child(3) { grid-area: num; }
  .bars li > :nth-child(4) { grid-area: share; }
  .page-head .actions { margin-left: 0; }
}
table.m-cards td:empty, table.m-cards tbody th:empty { display: none; }

/* Touch: senkrechtes Wischen über Schieberegler und Diagrammen scrollt die Seite, statt hängen zu bleiben */
input[type="range"], canvas { touch-action: pan-y; }

/* iOS Safari: Datumsfelder haben eine feste Mindestbreite und ignorieren width – ohne native Optik passen sie ins Raster */
@supports (-webkit-touch-callout: none) {
  input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] {
    -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; max-width: 100%;
  }
  input[type="date"]::-webkit-date-and-time-value, input[type="month"]::-webkit-date-and-time-value { text-align: left; }
}
/* Alle Eingabefelder im Raster dürfen schmaler werden als ihre Standardbreite */
.field > input, .field > select { min-width: 0; max-width: 100%; box-sizing: border-box; }

/* Karten mit viel Platz (Desktop neben den Sidebars): Werte nebeneinander, Beschriftung darüber */
.table-wrap { container-type: inline-size; }
@container (min-width: 520px) {
  table.m-cards tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 18px; align-items: start; padding: 12px 0; }
  table.m-cards td, table.m-cards tbody th { padding: 0 !important; min-height: 0; }
  table.m-cards td::before, table.m-cards tbody th::before { float: none; display: block; width: auto; margin: 0 0 2px; padding: 0; }
  table.m-cards td.m-first { grid-column: 1 / -1; order: -1; }
  table.m-cards tr > * { min-width: 0; }
  table.m-cards td.m-nolabel:not(:empty) { align-self: center; grid-column: auto / span 2; }
}

/* Reiterleisten: nicht seitlich scrollbar (ließ sich auf Touch-Geräten verschieben und „tanzen“, weil die
   Unterstreichung 1 px übersteht) – passen die Reiter nicht in eine Zeile, brechen sie um */
.tabs { overflow: visible !important; flex-wrap: wrap; touch-action: manipulation; }
/* Handy: Reiter teilen sich die Breite gleichmäßig, lange Namen brechen innerhalb des Reiters um */
@media (max-width: 600px) {
  .tabs { flex-wrap: nowrap; gap: 0; }
  .tab { flex: 1 1 0; min-width: 0; padding: 9px 4px; font-size: .8125rem; line-height: 1.25; white-space: normal; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; text-align: center; } /* trennt mit Bindestrich statt mitten im Wort */
}

/* Auswahlfelder überall gleich (Safari/iOS zeigt sonst graue Systemfelder), mit eigenem Pfeil */
select:not([multiple]) {
  -webkit-appearance: none; appearance: none; padding-right: 28px !important;
  background-color: var(--raise); color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238496A6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 8px;
}

/* Zahlenfelder (von auth.js zu Textfeldern mit Komma-Unterstützung umgestellt) */
input[data-num] { font-variant-numeric: tabular-nums; }

/* Prioritäts-Marken (fe-priority.js) und Schalter „Priorität: automatisch | eigene“ */
.prio-badge { display: inline-block; margin: 0 6px 2px 0; padding: 0 7px; border: 1px solid currentColor; border-radius: 999px; font-size: .7rem; font-weight: 700; line-height: 1.5; vertical-align: middle; white-space: nowrap; }
.prio-badge.prio-1 { color: var(--loss); background: rgb(224 106 95 / .12); }
.prio-badge.prio-2 { color: var(--accent); background: rgb(201 163 90 / .12); }
.prio-badge.prio-3 { color: var(--info, #6E9BD8); background: rgb(110 155 216 / .10); }
.prio-badge.prio-none { color: var(--muted); font-weight: 500; }
.prio-switch { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: .8125rem; color: var(--muted); }
.prio-switch select { min-height: 30px; padding: 3px 28px 3px 8px; font-size: .8125rem; }

/* Kennzahlen-Profil als kleine Balken (fe-profile.js): je Bereich ein Balken, Höhe = Wert von 0–10 */
.profile-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 22px; padding: 0 2px; vertical-align: middle; border-bottom: 1px solid var(--line-2); }
.profile-bars i { display: block; width: 6px; height: var(--h, 6%); border-radius: 1px 1px 0 0; background: #C9A35A; opacity: .9; }
.profile-bars i.empty { height: 2px; background: var(--line-2); }

/* Touch-Geräte: Tippflächen mindestens 24 px hoch (WCAG 2.2, Zielgröße) – Textlinks außerhalb von Fließtext,
   „Zur Startseite“ und Schieberegler */
@media (pointer: coarse), (max-width: 600px) {
  .hub-link { padding: 4px 0; min-height: 24px; }
  input[type="range"] { min-height: 28px; }
}

