/*
  RF-Software – Oberfläche

  Gestaltungsidee: Die Seitenleiste ist ein geschlossener Rollladen. Oben sitzt der
  weiße Kasten mit dem Firmenlogo, darunter die rote Leiste in der Farbe des Logos,
  und feine waagerechte Linien deuten die Lamellen an. Alles andere bleibt ruhig:
  Tabellen und Formulare, wie das Büro sie den ganzen Tag braucht.

  Rot ist dem Logo, der Markierung des aktiven Menüpunkts und Fehlern vorbehalten.
  Schaltflächen und Links sind stahlblau.

  Es werden keine externen Schriften oder Skripte geladen – die Seite kommt vollständig
  vom eigenen Server.
*/

:root {
  --steel-900: #1c2933;   /* Seitenleiste */
  --steel-800: #273947;
  --steel-600: #4d6272;   /* Rahmen von Eingabefeldern */
  --ink: #16202a;         /* Text */
  --muted: #55626e;       /* Nebentext */
  --paper: #f1f3f5;       /* Seitenhintergrund */
  --surface: #ffffff;     /* Tabellen und Formulare */
  --line: #d4dae0;
  --action: #0e5a87;      /* Links und Hauptschaltflächen */
  --action-dark: #0a4467;
  --brand: #e31e25;       /* Rot aus dem Logo: Leiste unter dem Logo, aktiver Menüpunkt */

  --ok: #1b6a41;
  --ok-bg: #e5f2ea;
  --warn: #7a4f00;
  --warn-bg: #fdf2d5;
  --error: #9f2228;
  --error-bg: #fbe8e9;
  --info-bg: #e4eff6;

  --radius: 6px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Ausgeblendet heißt ausgeblendet – auch für Elemente mit eigener display-Angabe wie .btn. */
[hidden] {
  display: none !important;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

a {
  color: var(--action);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--action-dark);
}

:focus-visible {
  outline: 3px solid var(--action-dark);
  outline-offset: 2px;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 650;
  line-height: 1.3;
}

p {
  margin: 0 0 1rem;
}

.skip-link {
  position: absolute;
  left: -999rem;
  top: 0;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Rahmen: Seitenleiste und Inhalt -------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100vh;
  padding: 0 0 1rem;
  overflow-y: auto;
  color: #e8edf1;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 14px),
    var(--steel-900);
}

/* Der weiße Kasten über den Lamellen: Logo, auf dem Smartphone daneben die Menü-Schaltfläche. */
.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 4px solid var(--brand);
  background: #ffffff;
}

.brand {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem 1rem 0.875rem;
}

.brand img {
  display: block;
  width: 100%;
  max-width: 17rem;
  height: auto;
}

.side-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 0;
}

/* Nur auf schmalen Bildschirmen und nur mit Skript sichtbar (siehe unten). */
.menu-toggle {
  display: none;
}

.side :focus-visible {
  outline-color: #ffffff;
}

.side .brand:focus-visible,
.side .menu-toggle:focus-visible {
  outline-color: var(--action-dark);
  outline-offset: -4px;
}

.side-search {
  margin: 0 1.25rem;
}

.side-search label {
  display: block;
  margin-bottom: 0.25rem;
  color: #c3ced7;
  font-size: 0.8125rem;
}

.side-search input {
  padding: 0.4375rem 0.625rem;
  font-size: 0.9375rem;
}

.side nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.side nav a {
  display: block;
  padding: 0.5rem 1.25rem;
  border-left: 4px solid transparent;
  color: #e8edf1;
  text-decoration: none;
}

.side nav a:hover {
  background: var(--steel-800);
}

.side nav a[aria-current="page"] {
  border-left-color: var(--brand);
  background: var(--steel-800);
  color: #ffffff;
  font-weight: 600;
}

.side-user {
  margin: auto 1.25rem 0;
  padding-top: 0.875rem;
  border-top: 1px solid #44586a;
  font-size: 0.9375rem;
}

.side-user-name {
  margin: 0 0 0.25rem;
  font-weight: 600;
}

.side-user a,
.side-user .link-button {
  color: #c9d6e0;
}

.side-user form {
  margin-top: 0.25rem;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

main {
  min-width: 0;
  max-width: 78rem;
  padding: 2rem 2.25rem 4rem;
}

main:focus {
  outline: none;
}

main > section {
  margin-top: 2.25rem;
}

/* --- Seitenkopf ------------------------------------------------------------------ */

.crumb {
  margin-bottom: 0.75rem;
  font-size: 0.9375rem;
}

.page-head,
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.page-head {
  margin-bottom: 1.25rem;
}

.section-head {
  align-items: center;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  margin: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

/* Steht der Untertitel direkt unter der Seitenüberschrift, braucht das Folgende Abstand. */
main > .subtitle {
  margin-bottom: 1.25rem;
}

.count,
.meta,
.help {
  color: var(--muted);
  font-size: 0.9375rem;
}

.count {
  margin-bottom: 0.5rem;
}

.meta {
  margin-top: 2.5rem;
}

.muted {
  color: var(--muted);
}

.prose {
  max-width: 68ch;
}

.nowrap {
  white-space: nowrap;
}

.empty {
  max-width: 68ch;
  padding: 1rem 1.125rem;
  border: 1px dashed #aab5bf;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

/* --- Schaltflächen ---------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 0.5rem 0.9375rem;
  border: 1px solid var(--action);
  border-radius: var(--radius);
  background: var(--action);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--action-dark);
  background: var(--action-dark);
  color: #ffffff;
}

.btn-quiet {
  border-color: var(--steel-600);
  background: var(--surface);
  color: var(--ink);
}

.btn-quiet:hover {
  border-color: var(--ink);
  background: #e9edf0;
  color: var(--ink);
}

/* --- Meldungen und Kennzeichen ---------------------------------------------------- */

.messages {
  margin-bottom: 1.25rem;
}

.msg {
  max-width: 68ch;
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--action);
  border-radius: var(--radius);
  background: var(--info-bg);
}

.msg p:last-child {
  margin-bottom: 0;
}

.msg-success {
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.msg-warning {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.msg-error {
  border-left-color: var(--error);
  background: var(--error-bg);
}

/* Zustände stehen immer als Wort da, die Farbe unterstützt nur (U01). */
.tag {
  display: inline-block;
  margin-left: 0.375rem;
  padding: 0.0625rem 0.5rem;
  border: 1px solid #8fb39f;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag-muted {
  border-color: #aab5bf;
  background: #e9edf0;
  color: var(--muted);
}

/* --- Tabellen ---------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table-narrow {
  max-width: 28rem;
}

.table-wrap:has(.table-narrow) {
  max-width: 28rem;
}

.table th,
.table td {
  padding: 0.5625rem 0.875rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table-top td {
  vertical-align: top;
}

.table thead th {
  border-bottom: 2px solid #b4bec7;
  background: #f7f8f9;
  font-weight: 600;
  white-space: nowrap;
}

.table tbody th {
  font-weight: 400;
}

.table tbody tr:last-child th,
.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #f5f8fa;
}

.table .num,
.table .num-id {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .num {
  text-align: right;
}

.change-label {
  color: var(--muted);
}

.change del {
  color: var(--muted);
}

.change ins {
  font-weight: 600;
  text-decoration: none;
}

/* --- Stammdaten als Liste ----------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem 2rem;
  margin: 0;
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.facts-wide {
  grid-column: 1 / -1;
}

.facts dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.facts dd {
  margin: 0;
}

/* --- Ordnerbaum ---------------------------------------------------------------------- */

.tree {
  margin: 0;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  list-style: none;
}

.tree li {
  padding: 0.1875rem 0;
}

.tree .tree-depth-0 {
  font-weight: 600;
}

.tree .tree-depth-1 {
  padding-left: 1.5rem;
}

.tree .tree-depth-2 {
  padding-left: 3rem;
}

.tree .tree-depth-3 {
  padding-left: 4.5rem;
}

.tree .tree-depth-4 {
  padding-left: 6rem;
}

/* --- Suche und Filter ------------------------------------------------------------------ */

.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-grow {
  flex: 1 1 18rem;
  max-width: 34rem;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.filter label,
.form label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.filter-check label,
.field-check label {
  font-weight: 400;
}

/* Spaltenfilter: klappt unter der Suche auf und nimmt die ganze Breite ein. */
.filter-more {
  flex: 1 1 100%;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.filter-more summary {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--action);
  cursor: pointer;
}

.filter-more[open] summary {
  margin-bottom: 0.75rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem 1rem;
}

.filter-grid input,
.filter-grid select {
  width: 100%;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.25rem;
}

/* Während die Liste beim Tippen nachlädt, tritt der alte Stand kurz zurück. */
[data-live-results][aria-busy="true"] {
  opacity: 0.55;
}

/* Anzahl links, Export rechts. */
.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.list-tools .count {
  margin: 0;
}

/* Sortierbare Spaltenköpfe: sehen aus wie Überschriften, verhalten sich wie Verweise. */
.table thead th a.sort {
  color: inherit;
  text-decoration: none;
}

.table thead th a.sort:hover,
.table thead th a.sort:focus-visible {
  color: var(--action);
  text-decoration: underline;
}

.table thead th[aria-sort="ascending"] a.sort,
.table thead th[aria-sort="descending"] a.sort {
  color: var(--action-dark);
}

/* --- Formulare ----------------------------------------------------------------------------- */

.form {
  max-width: 46rem;
}

.form fieldset {
  margin: 0 0 1.5rem;
  padding: 1.125rem 1.25rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.form legend {
  padding: 0 0.375rem;
  font-size: 1.0625rem;
  font-weight: 650;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.25rem;
}

.req {
  color: var(--error);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--steel-600);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--action);
}

.field-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.field-check label {
  margin: 0;
}

.field-check .help,
.field-check .error {
  flex-basis: 100%;
}

.field .help {
  margin: 0.25rem 0 0;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--error);
  border-width: 2px;
}

.error {
  margin: 0.25rem 0 0;
  color: var(--error);
  font-size: 0.9375rem;
  font-weight: 600;
}

.row {
  display: grid;
  gap: 0 1rem;
}

.row-2 {
  grid-template-columns: 1fr 1fr;
}

.row-3 {
  grid-template-columns: 8rem 1fr 1fr;
}

.row-plz {
  grid-template-columns: 7rem 1fr 5rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* --- Seitenwechsel ------------------------------------------------------------------------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.9375rem;
}

/* --- Anmeldung ----------------------------------------------------------------------------- */

.login {
  max-width: 24rem;
  margin: 12vh auto 0;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.login-logo {
  margin: -2rem -2rem 1.5rem;
  padding: 1.5rem 2rem 1.25rem;
  border-bottom: 4px solid var(--brand);
}

.login-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.login h1 {
  margin-bottom: 1rem;
  font-size: 1.375rem;
}

.login > .help {
  margin: 1.25rem 0 0;
}

/* --- Dokumente und Upload ------------------------------------------------------------------ */

/* Wohin die Dateien gehen, steht groß über dem Upload (F03). */
.target {
  display: grid;
  gap: 0.5rem;
  max-width: 46rem;
  margin: 0.75rem 0 0;
  padding: 0.875rem 1.125rem;
  border-left: 4px solid var(--action);
  border-radius: var(--radius);
  background: var(--surface);
}

.target dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.target dd {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
}

.target dd .muted {
  font-weight: 400;
}

.upload {
  max-width: 46rem;
}

.upload-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.upload-source label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

/* Mit Skript werden die beiden Auswahlfelder zu großen Schaltflächen. */
.upload-enhanced .upload-source {
  position: relative;
}

.upload-enhanced .upload-source label {
  margin: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--steel-600);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
}

.upload-enhanced .upload-source label:hover {
  border-color: var(--ink);
  background: #e9edf0;
}

.upload-enhanced .upload-source input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.upload-enhanced .upload-source input:focus-visible + label,
.upload-enhanced .upload-source:focus-within label {
  outline: 3px solid var(--action-dark);
  outline-offset: 2px;
}

.upload-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.upload-item {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
}

.upload-item + .upload-item {
  margin-top: 0.375rem;
}

.upload-item[data-state="fertig"] {
  border-left-color: var(--ok);
}

.upload-item[data-state="fehler"] {
  border-left-color: var(--error);
}

.upload-item[data-state="laeuft"] {
  border-left-color: var(--action);
}

.upload-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  overflow: hidden;
  border-radius: 4px;
  background: #e9edf0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-status {
  color: var(--muted);
  font-size: 0.9375rem;
}

.upload-item[data-state="fertig"] .upload-status {
  color: var(--ok);
  font-weight: 600;
}

.upload-item[data-state="fehler"] .upload-status {
  color: var(--error);
  font-weight: 600;
}

.upload-text progress {
  width: 100%;
  height: 0.5rem;
  accent-color: var(--action);
}

.upload-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.upload-actions .link-button {
  color: var(--action);
}

.target-confirm {
  margin: 1rem 0 0;
}

.upload-summary {
  margin: 0.75rem 0 0;
  font-weight: 600;
}

.upload-summary:empty {
  display: none;
}

.upload > .help {
  margin-top: 1rem;
}

.btn:disabled {
  border-color: #9aa7b2;
  background: #c9d1d8;
  color: #3d4954;
  cursor: not-allowed;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.doc-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background: #e3e8ec;
}

.doc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.doc-pdf {
  padding: 0.5rem 1rem;
  border: 2px solid var(--steel-600);
  border-radius: 4px;
  color: var(--steel-600);
  font-weight: 650;
}

.doc-meta {
  padding: 0.75rem 0.875rem 0.875rem;
  font-size: 0.9375rem;
}

.doc-meta p {
  margin: 0 0 0.375rem;
}

.doc-meta .muted {
  font-size: 0.875rem;
}

.doc-text {
  font-weight: 600;
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-top: 0.5rem;
}

/* Große Tippflächen für die Objektwahl auf dem Smartphone (U04). */
.tap-list {
  max-width: 46rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tap-list li + li {
  margin-top: 0.5rem;
}

.tap-list > li > a {
  display: block;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--action);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.tap-list > li > a:hover {
  border-color: var(--ink);
  border-left-color: var(--action-dark);
  background: #f5f8fa;
}

.tap-main {
  display: block;
  font-size: 1.0625rem;
  font-weight: 600;
}

.tap-sub {
  display: block;
  color: var(--muted);
}

.tree a {
  font-weight: 600;
}

.tree .tree-count {
  color: var(--muted);
  font-weight: 400;
}

input[type="date"] {
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--steel-600);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

/* --- Zustände, Arbeitslisten, Aufträge und Bestellungen ------------------------------------ */

/* Ein Zustand steht immer als Wort da; die Farbe unterstützt nur (U01, M06). */
.state {
  margin-left: 0;
  border-radius: 0.75rem;
  white-space: normal;
}

.tag-ok {
  border-color: #8fb39f;
  background: var(--ok-bg);
  color: var(--ok);
}

.tag-warn {
  border-color: #d9b45a;
  background: var(--warn-bg);
  color: var(--warn);
}

.tag-error {
  border-color: #dba0a3;
  background: var(--error-bg);
  color: var(--error);
}

.tag-info {
  border-color: #9bbdd3;
  background: var(--info-bg);
  color: var(--action-dark);
}

.tabs {
  margin-bottom: 1.25rem;
  border-bottom: 2px solid #b4bec7;
}

.tabs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tabs a {
  display: block;
  margin-bottom: -2px;
  padding: 0.5rem 0.875rem;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.tabs a:hover {
  background: #e9edf0;
}

.tabs a[aria-current="page"] {
  border-color: #b4bec7;
  border-bottom-color: var(--brand);
  background: var(--surface);
}

.tab-count {
  display: inline-block;
  min-width: 1.5rem;
  margin-left: 0.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: #e9edf0;
  color: var(--ink);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.table tfoot th,
.table tfoot td {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  background: #f7f8f9;
  font-weight: 400;
}

.table tfoot .total th,
.table tfoot .total td {
  border-top: 2px solid #b4bec7;
  font-weight: 650;
}

.table .row-muted td {
  color: var(--muted);
}

.cell-actions {
  white-space: nowrap;
}

.cell-actions a,
.cell-actions form {
  display: block;
}

.cell-actions form {
  margin: 0;
}

.inline-form {
  margin-top: 1rem;
}

.inline-form .help {
  max-width: 68ch;
  margin-bottom: 0.5rem;
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Wareneingang: Eingabefelder in der Tabelle bleiben schmal. */
.form-wide {
  max-width: none;
}

.form-wide > .row,
.form-wide > .field {
  max-width: 46rem;
}

.form-wide .table-wrap {
  margin-bottom: 1.25rem;
}

.table-entry input[type="text"] {
  width: 100%;
  min-width: 5.5rem;
}

.table-entry tbody th {
  min-width: 12rem;
  text-align: left;
}

.field-group {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.field-group legend {
  padding: 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.field-group .field {
  margin-bottom: 0.5rem;
}

.field-group .help {
  margin: 0.25rem 0 0.5rem;
}

.tap-list-compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.5rem;
  max-width: none;
}

.tap-list-compact li + li {
  margin-top: 0;
}

/* Offene Aufträge unter einem Objekt auf der Seite „Fotos hochladen“. */
.tap-orders {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
  list-style: none;
}

.tap-orders li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.375rem 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tap-orders li + li {
  margin-top: 0.25rem;
}

.tap-order-name {
  font-weight: 600;
}

.tap-order-links {
  display: flex;
  gap: 0.5rem;
}

.tap-order-links a {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--action);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
}

.tap-order-links a:hover {
  background: var(--info-bg);
}

.tree .tree-depth-5 {
  padding-left: 7.5rem;
}

.tree .tree-depth-6 {
  padding-left: 9rem;
}

/* Druckansicht der Bestellung. */
.sheet {
  max-width: 50rem;
  padding: 2rem 2.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem 2rem;
  margin-bottom: 2rem;
}

.sheet-sender {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 650;
}

.sheet-address {
  font-style: normal;
}

.sheet-facts {
  margin: 0;
}

.sheet-facts div {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}

.sheet-facts dt {
  color: var(--muted);
}

.sheet-facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.sheet-title {
  font-size: 1.375rem;
}

.sheet-table {
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
}

/* --- Schmale Bildschirme (Smartphone der Techniker) ---------------------------------------- */

@media (max-width: 56rem) {
  .shell {
    display: block;
  }

  .side {
    position: static;
    height: auto;
    gap: 0;
    padding: 0;
  }

  .brand {
    padding: 0.75rem 1rem 0.625rem;
  }

  .brand img {
    max-width: 14rem;
  }

  .side-body {
    gap: 0.5rem;
    padding: 0.5rem 0 0.75rem;
  }

  /* Auf dem Smartphone zählt jeder Zentimeter: Die Schnellsuche entfällt hier, Kunden und
     Fotos haben ihre eigene Suche auf der Seite. */
  .side-search {
    display: none;
  }

  /* Aufklappbares Menü. Ohne Skript (.js fehlt) bleibt es einfach offen. */
  .js .menu-toggle {
    display: inline-block;
    flex: 0 0 auto;
    min-width: 6.5rem;
    margin-right: 1rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--steel-600);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }

  .js .side-body {
    display: none;
  }

  .js .side.is-open .side-body {
    display: flex;
  }

  .side nav a {
    padding: 0.8125rem 1rem;
    font-size: 1.0625rem;
  }

  .side-user {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1.25rem;
    margin: 0.25rem 1rem 0;
    padding-top: 0.75rem;
  }

  .side-user-name {
    flex-basis: 100%;
    margin: 0;
  }

  .side-user form {
    margin: 0;
  }

  main {
    padding: 1.25rem 1rem 3rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .row-2,
  .row-3,
  .row-plz {
    grid-template-columns: 1fr;
  }

  .upload-pick {
    grid-template-columns: 1fr;
  }

  .upload-item {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }

  .upload-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    gap: 1rem;
  }

  .upload-name {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .filter-photo .btn {
    width: 100%;
  }

  .upload .actions .btn {
    width: 100%;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .login {
    margin: 1.5rem 1rem 0;
  }

  .tree .tree-depth-5 {
    padding-left: 6.5rem;
  }

  .tree .tree-depth-6 {
    padding-left: 7rem;
  }

  .tap-orders {
    margin-left: 0.5rem;
  }

  .tap-order-links a {
    padding: 0.5rem 0.875rem;
  }

  .sheet {
    padding: 1.25rem 1rem;
  }

  .sheet-head {
    grid-template-columns: 1fr;
  }
}

@media print {
  .side,
  .skip-link,
  .filter,
  .actions,
  .page-actions,
  .pagination,
  .crumb,
  .messages,
  .tabs,
  .print-hide {
    display: none;
  }

  main {
    padding: 0;
  }

  .sheet {
    max-width: none;
    padding: 0;
    border: 0;
  }

  .shell {
    display: block;
  }

  body {
    background: #ffffff;
  }
}

/* --- Einsatzplanung ----------------------------------------------------------------------- */

input[type="datetime-local"] {
  width: 100%;
  max-width: 18rem;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--steel-600);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.page-actions form {
  margin: 0;
}

.step-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

/* Der Tagesplan: links die Zeit, wie auf einem Stundenzettel, rechts wer und wo. */
.agenda {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.agenda-item {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr) minmax(0, 16rem);
  gap: 0.25rem 1.25rem;
  padding: 0.875rem 1.125rem;
}

.agenda-item + .agenda-item {
  border-top: 1px solid var(--line);
}

.agenda-item p {
  margin: 0;
}

.agenda-time {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.agenda-title {
  font-size: 1.0625rem;
  font-weight: 600;
}

.agenda-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.375rem;
}

.agenda-cancelled .agenda-time,
.agenda-cancelled .agenda-body {
  color: var(--muted);
  text-decoration: line-through;
}

.agenda-cancelled .agenda-body a {
  color: var(--muted);
}

.agenda-none {
  margin: 0;
  color: var(--muted);
}

.inline-form-flush {
  padding-left: 0;
}

.evidence + .evidence {
  margin-top: 1rem;
}

.evidence-agent {
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
}

.link-once input {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.9375rem;
}

/* Liste für die Monteure: ein Blatt, das auch gedruckt lesbar bleibt. */
.crew-head {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--ink);
}

.crew-head .sheet-title,
.crew-head p {
  margin: 0;
}

.crew-stop {
  padding: 1rem 0;
  break-inside: avoid;
}

.crew-stop + .crew-stop {
  border-top: 1px solid var(--line);
}

.crew-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 2rem;
  margin: 0 0 0.5rem;
}

.crew-wide {
  grid-column: 1 / -1;
}

.crew-facts dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.crew-facts dd {
  margin: 0;
}

/* Die Seite für den Kunden: ohne Menü, auf dem Telefon gut zu lesen und zu tippen. */
.public {
  max-width: 34rem;
  margin: 6vh auto 2rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.public-logo {
  margin: -2rem -2rem 1.5rem;
  padding: 1.5rem 2rem 1.25rem;
  border-bottom: 4px solid var(--brand);
}

.public-logo img {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
}

.public h1 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.public-appointment {
  margin: 0 0 1.5rem;
  padding: 0.875rem 1rem;
  border-left: 4px solid var(--action);
  background: var(--info-bg);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.public-declarations {
  padding-bottom: 0.5rem;
}

.public-check {
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0;
  padding: 0.625rem 0;
}

.public-check + .public-check {
  border-top: 1px solid var(--line);
}

.public-check input[type="checkbox"] {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.125rem;
}

.public-check label {
  flex: 1;
}

.public-check .help {
  flex-basis: auto;
}

.public .actions .btn {
  width: 100%;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  font-size: 1.0625rem;
}

.public-foot {
  margin: 2rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

@media (max-width: 56rem) {
  .agenda-item {
    grid-template-columns: 1fr;
  }

  .step-nav {
    margin-left: 0;
  }

  .crew-facts {
    grid-template-columns: 1fr;
  }

  .public {
    margin: 0;
    border: 0;
    border-radius: 0;
  }
}

@media print {
  .crew-stop a {
    color: inherit;
    text-decoration: none;
  }
}

.crew-day {
  margin: 1.5rem 0 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--ink);
  font-size: 1.125rem;
  break-after: avoid;
}

.crew-time {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 650;
}

/* --- Artikelbilder ---------------------------------------------------------------------- */

.table .thumb-col {
  width: 3.5rem;
  padding-right: 0;
}

.article-thumb {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
}

.article-image {
  margin: 0 0 1rem;
}

.article-image img {
  display: block;
  max-width: 10rem;
  max-height: 10rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.article-image figcaption {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

input[type="file"] {
  max-width: 100%;
  font: inherit;
}


/* --- Übersicht: Kacheln ------------------------------------------------------------------
   Sechs Spalten: Eine Kachel nimmt ein Drittel (2), die Hälfte (3), zwei Drittel (4) oder
   die ganze Breite (6). Reihenfolge und Breite legt jede Person selbst fest
   (static/js/dashboard.js). */

.tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1.25rem;
}

.tile {
  display: flex;
  flex-direction: column;
  grid-column: span 2;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tile-span-3 {
  grid-column: span 3;
}

.tile-span-4 {
  grid-column: span 4;
}

.tile-span-6 {
  grid-column: 1 / -1;
}

.tile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.tile-head h2 {
  margin: 0;
  font-size: 1.0625rem;
}

.tile-body {
  min-width: 0;
  padding: 0.25rem 1rem 0.75rem;
}

.tile-body > .table-wrap,
.tile-body > .empty {
  margin-top: 0.75rem;
}

.tile-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile-list li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.tile-list li:last-child {
  border-bottom: 0;
}

.tile-label {
  min-width: 0;
}

.tile-count {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tile-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tile-tools button {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--steel-600);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.tile-tools button:disabled {
  opacity: 0.4;
  cursor: default;
}

.tiles-status {
  min-height: 1.5rem;
  margin: 0 0 0.5rem;
  color: var(--ok);
  font-size: 0.9375rem;
}

.tiles-status.is-error {
  color: var(--error);
}

/* Leer nimmt die Zeile keinen Platz ein, bleibt aber im Dokument – sonst läse ein
   Vorleseprogramm die erste Meldung nicht vor. */
.tiles-status:empty {
  min-height: 0;
  margin: 0;
}

/* Beim Anordnen: Die Kachel ist der Griff, ihr Inhalt ruht. */
.tiles.is-arranging .tile {
  border-style: dashed;
  border-color: var(--steel-600);
  cursor: grab;
  user-select: none;
}

/* Titel und Knöpfe immer untereinander – sonst bräche die Zeile nur bei schmalen Kacheln um. */
.tiles.is-arranging .tile-head {
  flex-direction: column;
  align-items: flex-start;
}

.tiles.is-arranging .tile-body {
  opacity: 0.55;
  pointer-events: none;
}

.tile.is-dragged {
  opacity: 0.35;
}

/* Schmaleres Fenster: zwei Spalten. Drittel und Hälfte werden eine Spalte, alles Breitere füllt die Zeile. */
@media (max-width: 75rem) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile,
  .tile-span-3 {
    grid-column: span 1;
  }

  .tile-span-4,
  .tile-span-6 {
    grid-column: 1 / -1;
  }
}

/* Smartphone: alles untereinander, in der gewählten Reihenfolge. */
@media (max-width: 56rem) {
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }

  .tile,
  .tile-span-3,
  .tile-span-4,
  .tile-span-6 {
    grid-column: 1 / -1;
  }
}

@media print {
  [data-tiles-actions],
  .tile-tools,
  .tiles-help,
  .tiles-status {
    display: none;
  }
}


/* Verweis auf das PDF unter der Belegnummer */
.doc-link {
  font-size: 0.875rem;
  font-weight: 400;
  white-space: nowrap;
}


/* --- Anfragen ---------------------------------------------------------------------- */

/* Zahl der neuen Anfragen am Menüpunkt */
.nav-count {
  display: inline-block;
  min-width: 1.5rem;
  margin-left: 0.375rem;
  padding: 0 0.4375rem;
  border-radius: 999px;
  background: #ffffff;
  color: var(--steel-900);
  font-size: 0.8125rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* Kunde anlegen oder über die Nummer zuordnen; Zuständigkeit ändern */
.inquiry-customer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}

.inquiry-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.inquiry-customer .inquiry-inline {
  margin-top: 0;
}

.inquiry-inline label {
  flex-basis: 100%;
  font-weight: 600;
}

.inquiry-inline input,
.inquiry-inline select {
  width: auto;
  min-width: 12rem;
}

/* Wortlaut einer versendeten Antwort */
.inquiry-mail {
  max-width: 68ch;
  margin-top: 0.5rem;
  padding: 0.625rem 0.875rem;
  border-left: 3px solid var(--line);
  background: #f7f8f9;
}
