/* ============================================================
   IN TIME Overnight – Sendungsverfolgung
   Optik angelehnt an https://www.intime-overnight.de/
   ============================================================ */

:root {
    --color-blue: #002d51;
    --color-blue-dark: #001f39;
    /* Aufgehellter Marken-Blauton für Flächen wie die Seitenleiste */
    --color-blue-pastel: #dde8f2;
    --color-blue-pastel-border: #bfd3e5;
    --color-orange: #f97800;
    --color-orange-dark: #d96700;
    --color-orange-soft: rgba(249, 120, 0, 0.15);
    --color-white: #ffffff;

    --color-text: #4a4a4a;
    --color-text-muted: #8a8a8a;
    --color-border: #d4d9de;
    --color-bg: #f3f5f7;
    --color-surface: #ffffff;
    --color-danger: #c0392b;
    --color-warning: #b58100;
    --color-info: #2b7cb8;

    --font-base: 'Verdana', Helvetica, Arial, Lucida, sans-serif;

    --radius: 4px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 45, 81, 0.08);
    --shadow-md: 0 4px 14px rgba(0, 45, 81, 0.10);

    --space-xs: 6px;
    --space-sm: 10px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;

    --content-width: 1080px;
}

/* ---------- Reset / Base ------------------------------------ */

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

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-base);
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- Layout ------------------------------------------ */

header {
    background-color: var(--color-blue);
    color: var(--color-white);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-lg);
    padding: var(--space-md) var(--space-xl);
    box-shadow: var(--shadow-md);
}

header .header-logo {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border-bottom: none;
}

header .header-logo img {
    height: 28px;
    width: auto;
    display: block;
}

header a {
    color: var(--color-white);
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 13px;
    padding: var(--space-xs) 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

header a:hover,
header a:focus-visible {
    color: var(--color-orange);
    border-bottom-color: var(--color-orange);
    outline: none;
}

/* Logout rechtsbündig, Button im Stil der Header-Links */
header form.logout-form {
    margin: 0 0 0 auto;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
}

header .logout-form button {
    color: var(--color-white);
    background-color: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-family: var(--font-base);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 13px;
    line-height: inherit;
    min-height: 0;
    padding: var(--space-xs) 0;
    margin: 0;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

header .logout-form button:hover,
header .logout-form button:focus-visible {
    color: var(--color-orange);
    background-color: transparent;
    border-color: transparent;
    border-bottom-color: var(--color-orange);
    box-shadow: none;
    outline: none;
}

header .logout-form button:active {
    transform: none;
}

main {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

/* Sendungserstellung und Lieferungsliste nutzen die volle Seitenbreite: beide
   tragen breite Tabellen, die sonst über den Container hinauslaufen — die
   Filterleiste bliebe dann schmaler als die Tabelle darunter. */
main:has(#shipment-form),
main:has(.list-filter),
main:has(.entity-form--wide),
main:has(.address-scroll) {
    max-width: none;
}

footer {
    background-color: var(--color-blue);
    color: var(--color-white);
    text-align: center;
    padding: var(--space-lg) var(--space-xl);
    margin-top: var(--space-xl);
    font-size: 12px;
}

/* ---------- Typography -------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-base);
    color: var(--color-orange);
    line-height: 1.25;
    margin: 0 0 var(--space-md);
}

h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

p { margin: 0 0 var(--space-md); }

a {
    color: var(--color-orange-dark);
}

a:hover {
    color: var(--color-orange);
}

/* Inhalts-Links (außerhalb von Header/Footer) als Block-Navigation */
main > a {
    display: inline-block;
    margin: 0 var(--space-sm) var(--space-sm) 0;
    color: var(--color-blue);
    text-decoration: none;
    font-weight: 700;
}

main > a:hover {
    color: var(--color-orange);
}

/* ---------- Listen ------------------------------------------ */

main ul {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

main ul li {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-orange);
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
}

main ul li a {
    text-decoration: none;
    font-weight: 700;
}

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

form {
    margin: 0;
}

label {
    display: block;
    font-weight: 700;
    font-size: 12px;
    color: var(--color-blue);
    margin-bottom: var(--space-xs);
}

input,
select,
textarea {
    font-family: var(--font-base);
    font-size: 14px;
    color: var(--color-text);
    width: 100%;
    padding: 11px 12px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
}

input:hover,
select:hover,
textarea:hover {
    border-color: #b6bcc3;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-orange);
    box-shadow: 0 0 0 3px var(--color-orange-soft);
}

/* Fehlerzustand erst nach Interaktion zeigen */
input:user-invalid,
select:user-invalid,
textarea:user-invalid {
    border-color: var(--color-danger);
}

input:user-invalid:focus,
select:user-invalid:focus,
textarea:user-invalid:focus {
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15);
}

/* Feld widerspricht einer Regel, ohne dass der Nutzer es geändert hat — etwa
   das Land einer gespeicherten Adresse nach dem Wechsel der Sendungsart */
.field-conflict {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly] {
    background-color: #eef0f2;
    color: var(--color-text-muted);
    cursor: not-allowed;
}

/* Login-Formular: zentriert als Karte */
form[method="post"] {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    max-width: 420px;
}

form[method="post"] > div {
    margin-bottom: var(--space-md);
}

/* ---------- Buttons ----------------------------------------- */

button {
    font-family: var(--font-base);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    color: var(--color-white);
    background-color: var(--color-orange);
    border: 1px solid var(--color-orange);
    border-radius: var(--radius);
    padding: 0 22px;
    min-height: 44px;
    margin: var(--space-xs) var(--space-xs) var(--space-xs) 0;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease,
        transform 0.05s ease, box-shadow 0.15s ease;
}

button:hover {
    background-color: var(--color-orange-dark);
    border-color: var(--color-orange-dark);
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-orange-soft);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:active {
    transform: none;
}

/* Aktions-Button in der Lieferungsliste – kompakt, Breite richtet sich nach der
   Beschriftung. Nimmt die großzügigen Maße der globalen button-Regel zurück. */
.list-action {
    width: auto;
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
    margin: 0;
    white-space: nowrap;
}

/* Buttons in Links (<a><button>) ohne Link-Unterstreichung */
a:has(> button) {
    text-decoration: none;
}

/* Buttons einer Zelle nebeneinander; wird es zu eng, rutscht ein ganzer
   Button in die nächste Zeile statt seine Beschriftung umzubrechen. */
.list-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-sm);
}

/* Aktions-Buttons nebeneinander, volle Breite */
.form-actions {
    display: flex;
    gap: var(--space-sm);
}

.form-actions button {
    flex: 1;
    margin: 0;
}

/* Blauer Button (z. B. "Weitere Sendung hinzufügen") */
.btn-blue {
    background-color: var(--color-blue);
    border-color: var(--color-blue);
}

.btn-blue:hover {
    background-color: var(--color-blue-dark);
    border-color: var(--color-blue-dark);
}

/* Ausgegraut, wenn deaktiviert (z. B. im Fertigstellen-Modus) */
.btn-blue:disabled,
.btn-blue:disabled:hover {
    background-color: #c7ccd1;
    border-color: #c7ccd1;
    color: var(--color-white);
    opacity: 1;
}

/* Buttons in Links (<a><button>) nehmen in der Leiste denselben Platz ein */
.form-actions > a {
    flex: 1;
    display: flex;
}

.form-actions > a > button {
    flex: 1;
    margin: 0;
}

/* Einzelner Button mittig unter einer Liste (z. B. "Zurück zur Liste") */
.centered-actions {
    display: flex;
    justify-content: center;
    margin-top: var(--space-md);
}

.centered-actions button {
    min-width: 240px;
}

/* Untertitel unter dem Seitentitel, z. B. "Lieferung 123 – Auftrag von …" */
h1.page-title-with-subtitle {
    margin-bottom: var(--space-xs);
}

.page-subtitle {
    color: var(--color-blue);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: var(--space-lg);
}

/* Löschen-Button ("X") an jedem Sendungsformular, liegt auf der blauen Kopfzeile */
form[id^="parcel_form_"] > button {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-md);
    min-height: 32px;
    width: 32px;
    padding: 0;
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    background-color: transparent;
    border-color: rgba(255, 255, 255, 0.35);
    border-radius: 50%;
}

form[id^="parcel_form_"] > button:hover {
    color: var(--color-white);
    background-color: var(--color-danger);
    border-color: var(--color-danger);
}

/* ---------- Sendungs-Erstellung ----------------------------- */

#forms-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
}

form[id^="parcel_form_"] {
    position: relative;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 3px solid var(--color-orange);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    padding-right: calc(var(--space-lg) + 32px + var(--space-sm));
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-width: none;
    width: 100%;
}

/* Kompaktere Felder — der größte Hebel für die Bauhöhe, weil pro Spalte bis zu
   sieben davon übereinander stehen. Bewusst nur vertikal: die horizontalen Werte
   kommen weiter aus der globalen input-Regel bzw. den Sonderregeln für
   Zeitfenster und Packstücke. */
form[id^="parcel_form_"] input,
form[id^="parcel_form_"] select {
    padding-top: 8px;
    padding-bottom: 8px;
}

/* Blocküberschriften ("Sendungsart festlegen", "Sendungsinformationen") */
form[id^="parcel_form_"] .block-title {
    font-weight: 700;
    color: var(--color-blue);
}

/* Spaltenzeile: Abholadresse | Zieladresse | Sendungsinformationen */
form[id^="parcel_form_"] > div.parcel-columns {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: var(--space-md);
}

form[id^="parcel_form_"] div.parcel-columns > * {
    flex: 1 1 0;
    min-width: 0;
}

/* Adresse und zugehöriges Datum teilen sich einen Rahmen */
form[id^="parcel_form_"] div.parcel-column,
form[id^="parcel_form_"] div.shipment-info-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-md);
}

/* location-form gibt seinen eigenen Kasten auf, wenn es in einer Spalte steckt */
form[id^="parcel_form_"] div.parcel-column > location-form {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
}

/* Datum sitzt unten im Block — auch wenn die Adressen unterschiedlich hoch sind */
form[id^="parcel_form_"] div.column-date {
    margin-top: auto;
    display: grid;
    gap: var(--space-xs);
}

form[id^="parcel_form_"] div.info-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xs);
}

/* Packstücke: eine Zeile je Stück, Kopfzeile gibt die Spaltenbreiten vor */
form[id^="parcel_form_"] div.packages-block,
form[id^="parcel_form_"] div.package-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* display:flex oben würde das hidden-Attribut sonst aushebeln */
form[id^="parcel_form_"] div.packages-block[hidden] {
    display: none;
}

/* "Packstücke" im selben Stil wie das Label "Stückzahl/Menge" darüber —
   Werte gespiegelt aus der globalen label-Regel */
form[id^="parcel_form_"] div.packages-block > .packages-title {
    display: block;
    font-weight: 700;
    font-size: 12px;
    color: var(--color-blue);
    margin-bottom: var(--space-xs);
}

form[id^="parcel_form_"] div.package-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
}

form[id^="parcel_form_"] div.package-row > input,
form[id^="parcel_form_"] div.package-row > span {
    flex: 1 1 0;
    min-width: 0;
}

/* Laufende Nummer des Packstücks */
form[id^="parcel_form_"] .package-id {
    flex: 0 0 18px;
    font-size: 12px;
    color: var(--color-text-muted);
    text-align: right;
}

form[id^="parcel_form_"] div.package-row > input {
    padding-left: var(--space-xs);
    padding-right: var(--space-xs);
    text-align: right;
}

form[id^="parcel_form_"] div.package-head > span {
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: center;
}

/* Summen unten im Block, auf Höhe von Abhol- und Lieferdatum */
form[id^="parcel_form_"] div.info-totals {
    margin-top: auto;
    display: grid;
    gap: var(--space-xs);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border);
}

form[id^="parcel_form_"] div.info-totals > div {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-sm);
    font-size: 13px;
}

/* Abholdatum und Zeitfenster stehen immer zusammen in einer Zeile */
form[id^="parcel_form_"] .pickup-date-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-sm);
}

/* Das Datumsfeld wächst nicht mit — der freie Platz der Zeile gehört den beiden
   Uhrzeiten. Der schmalere Innenabstand schafft zusätzlich Raum für "TT.MM.JJJJ",
   sodass das Feld trotz geringerer Breite nicht abschneidet. */
form[id^="parcel_form_"] .pickup-date-row > input {
    flex: 0 1 128px;
    min-width: 0;
    padding-left: var(--space-xs);
    padding-right: var(--space-xs);
}

form[id^="parcel_form_"] .time-range {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
}

/* min-width: 0 statt einer Untergrenze: die Felder dürfen mitschrumpfen, damit
   die Zeile bei schmalen Spalten nicht überläuft. */
form[id^="parcel_form_"] .time-range > input {
    flex: 1 1 0;
    min-width: 0;
    padding-left: var(--space-xs);
    padding-right: var(--space-xs);
}

form[id^="parcel_form_"] .time-range > span {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Lieferdatum + Infokasten nebeneinander, in schmalen Spalten untereinander */
form[id^="parcel_form_"] .delivery-date-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

form[id^="parcel_form_"] .delivery-date-row > input {
    flex: 0 1 140px;
    min-width: 0;
}

/* Datum und Lieferzeitraum teilen sich die Zeile; der Terminhinweis rutscht
   darunter, sobald der Platz nicht mehr reicht. */
form[id^="parcel_form_"] .delivery-date-row > select {
    flex: 1 1 150px;
    min-width: 0;
}

/* Hinweis zum Liefertermin — im Formular neben dem Feld, in der Lieferübersicht
   unter dem Termin. Neutraler Grundzustand (regulärer Wochentag). */
.delivery-info {
    padding: var(--space-xs) var(--space-sm);
    color: var(--color-text);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-left-width: 3px;
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.4;
    overflow-wrap: break-word;
}

/* Im Formular teilt er sich die Zeile mit dem Datumsfeld ... */
form[id^="parcel_form_"] .delivery-info {
    flex: 1 1 190px;
    min-width: 0;
}

/* ... in der Übersicht steht er unter dem Datum. */
#overview-container .delivery-info {
    margin-top: var(--space-xs);
}

/* Auffällige Liefertermine */
.delivery-info.delivery-sameday {
    color: var(--color-info);
    background-color: rgba(43, 124, 184, 0.12);
    border-color: var(--color-info);
}

.delivery-info.delivery-weekend {
    color: var(--color-warning);
    background-color: rgba(181, 129, 0, 0.12);
    border-color: var(--color-warning);
}

.delivery-info.delivery-holiday {
    color: var(--color-danger);
    background-color: rgba(192, 57, 43, 0.12);
    border-color: var(--color-danger);
}

/* Nur im Formular wird zusätzlich das Eingabefeld eingefärbt. Höhere Spezifität
   als input:focus / input[readonly], die sonst Rahmen- und Textfarbe überschreiben. */
form[id^="parcel_form_"] input.delivery-sameday,
form[id^="parcel_form_"] input.delivery-weekend,
form[id^="parcel_form_"] input.delivery-holiday {
    font-weight: 700;
}

form[id^="parcel_form_"] input.delivery-sameday {
    color: var(--color-info);
    background-color: rgba(43, 124, 184, 0.12);
    border-color: var(--color-info);
}

form[id^="parcel_form_"] input.delivery-weekend {
    color: var(--color-warning);
    background-color: rgba(181, 129, 0, 0.12);
    border-color: var(--color-warning);
}

form[id^="parcel_form_"] input.delivery-holiday {
    color: var(--color-danger);
    background-color: rgba(192, 57, 43, 0.12);
    border-color: var(--color-danger);
}

/* Kopfzeile: dunkelblaue Leiste über die volle Kartenbreite, Titel und alle
   Sendungsarten nebeneinander in einer Zeile. Die negativen Ränder heben den
   Innenabstand der Karte auf, die Höhe fasst den Löschen-Button ein. */
form[id^="parcel_form_"] > div.parcel-type-block {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    min-height: 48px;
    margin: calc(var(--space-lg) * -1);
    margin-right: calc((var(--space-lg) + 32px + var(--space-sm)) * -1);
    margin-bottom: 0;
    padding: var(--space-sm) var(--space-lg);
    padding-right: calc(var(--space-lg) + 32px + var(--space-sm));
    background-color: var(--color-blue);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

form[id^="parcel_form_"] > div.parcel-type-block > div.parcel-type-options {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
}

form[id^="parcel_form_"] div.parcel-type-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
}

/* globalen input-Reset (width/padding/border) für Radios zurücknehmen */
form[id^="parcel_form_"] div.parcel-type-option input[type="radio"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    accent-color: var(--color-orange);
    cursor: pointer;
}

form[id^="parcel_form_"] div.parcel-type-option label {
    margin: 0;
    cursor: pointer;
    white-space: nowrap;
}

/* Auf der blauen Leiste steht alles in Weiß. Muss nach den Regeln oben stehen —
   bei gleicher Spezifität gewinnt sonst die zuletzt notierte Farbe. */
form[id^="parcel_form_"] > div.parcel-type-block .block-title,
form[id^="parcel_form_"] > div.parcel-type-block label {
    color: var(--color-white);
}

/* Zeitfenster unter dem Abhol- bzw. Liefertermin in der Lieferübersicht */
#overview-container .overview-time {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ---------- Custom Element: location-form ------------------- */

location-form {
    display: block;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-md);
}

/* Titel ("Abholadresse" / "Zieladresse") */
location-form > div:first-child {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-orange);
    margin-bottom: var(--space-sm);
}

/* Eingabefelder-Raster. Etwas enger als --space-sm: bei sechs Feldern
   übereinander zählt jeder Abstand doppelt in die Bauhöhe. */
location-form .location-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    position: relative;
}

/* Vorschlagsliste */
location-form .location-suggestions {
    position: absolute;
    right: 0;
    width: 75%;
    margin-top: var(--space-xs);
    list-style: none;
    padding: 0;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 260px;
    overflow-y: auto;
    z-index: 10;
}

location-form .location-suggestions li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
}

location-form .location-suggestions li:last-child {
    border-bottom: none;
}

location-form .location-suggestions li:hover {
    background-color: var(--color-orange-soft);
}

location-form .location-suggestions strong {
    color: var(--color-blue);
    font-size: 13px;
}

location-form .location-suggestions span {
    color: var(--color-text-muted);
    font-size: 12px;
}

/* überflüssige Zeilenumbrüche in Formularen ausblenden */
location-form br,
form[id^="parcel_form_"] br {
    display: none;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-md);
}

th,
td {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

th {
    background-color: var(--color-blue);
    color: var(--color-white);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:nth-child(even) td,
tr:nth-of-type(even) td {
    background-color: #f7f9fa;
}

/* Anklickbare Zeilen (static/js/ui.js): hellorange beim Überfahren */
tbody tr[data-href] {
    cursor: pointer;
}

tbody tr[data-href]:hover td,
tbody tr[data-href]:focus-visible td {
    background-color: #fde4cc;
}

tbody tr[data-href]:focus-visible {
    outline: 2px solid var(--color-orange);
    outline-offset: -2px;
}

/* Hinweis in einer Zeile, z. B. "Konto vervollständigen – es fehlt: …" */
.row-note {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-warning);
}

/* ---------- Status-Punkt (Lieferungsliste) ------------------ */

.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--color-border);
    vertical-align: middle;
}

/* Erstellt: Farbe der Sendungsart (der ersten Sendung der Lieferung) */
.status-dot--type-on {
    background-color: #f4c020;
    box-shadow: 0 0 0 3px rgba(244, 192, 32, 0.2);
}

.status-dot--type-in {
    background-color: #4aa3df;
    box-shadow: 0 0 0 3px rgba(74, 163, 223, 0.22);
}

.status-dot--type-df {
    background-color: #9b59b6;
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.22);
}

.status-dot--type-sd {
    background-color: var(--color-orange);
    box-shadow: 0 0 0 3px var(--color-orange-soft);
}

/* Geliefert (Rechnung erstellt): grün – abgeschlossen */
.status-dot--delivered {
    background-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2);
}

/* Noch offen und mit auffälligem Liefertermin: rot. Steht nach den
   Status-Regeln, damit es die Farbe der Sendungsart überschreibt. */
.status-dot--alert {
    background-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.22);
}

/* ---------- Kacheln der Startseite --------------------------- */

/* Hinweiszeile, für welchen Kunden ein Mitarbeiter gerade anlegt */
.target-customer {
    padding: var(--space-sm) var(--space-md);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-blue);
    border-radius: var(--radius);
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

/* Ganze Kachel ist der Link – überschreibt die Regel für main > a */
.tiles a.tile {
    display: flex;
    flex-direction: column;
    margin: 0;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 400;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.tiles a.tile:hover {
    border-color: var(--color-orange);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.tiles a.tile:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-orange-soft);
}

.tiles .tile img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.tiles .tile-body {
    padding: var(--space-md);
}

.tiles .tile-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-blue);
    margin-bottom: var(--space-xs);
}

.tiles .tile-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text);
}

.tiles a.tile:hover .tile-title {
    color: var(--color-orange-dark);
}

/* ---------- Navigation -------------------------------------- */

/* Hauptnavigation unter dem Kopf: die Menüpunkte der Startseite */
.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0 var(--space-lg);
    padding: 0 var(--space-xl);
    background-color: var(--color-blue-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 20;
}

.main-nav a {
    display: block;
    padding: 12px 0;
    color: var(--color-orange);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 3px solid transparent;
}

.main-nav a:hover,
.main-nav a:focus-visible,
.main-nav a.active {
    color: var(--color-white);
    border-bottom-color: var(--color-orange);
    outline: none;
}

/* Kundenmanagement mit Unterpunkten: klappt beim Überfahren oder Fokus auf */
.main-nav-group {
    position: relative;
}

.main-nav-sub {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    padding: var(--space-xs) 0;
    background-color: var(--color-blue-dark);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md);
}

.main-nav-group:hover .main-nav-sub,
.main-nav-group:focus-within .main-nav-sub {
    display: block;
}

.main-nav .main-nav-sub a {
    padding: 8px var(--space-md);
    border-bottom: none;
    border-left: 3px solid transparent;
    text-transform: none;
    letter-spacing: 0;
}

.main-nav .main-nav-sub a:hover,
.main-nav .main-nav-sub a:focus-visible,
.main-nav .main-nav-sub a.active {
    border-left-color: var(--color-orange);
    background-color: rgba(255, 255, 255, 0.06);
}

/* Weiße Leiste mit den Punkten des geöffneten Kunden */
.sub-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-lg);
    padding: 0 var(--space-xl);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.sub-nav-title {
    padding: 10px 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.sub-nav a {
    display: block;
    padding: 10px 0;
    color: var(--color-blue);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    border-bottom: 3px solid transparent;
}

.sub-nav a:hover,
.sub-nav a:focus-visible,
.sub-nav a.active {
    color: var(--color-orange-dark);
    border-bottom-color: var(--color-orange);
    outline: none;
}

/* ---------- Startseite -------------------------------------- */

/* Inhalt vertikal mittig im sichtbaren Bereich */
body.page-landing main {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.page-landing .landing-title {
    text-align: center;
    font-size: 32px;
}

/* ---------- Login ------------------------------------------- */

/* Formular samt Überschrift mittig im sichtbaren Bereich */
body.page-login main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

body.page-login h1 {
    text-align: center;
}

body.page-login main form {
    width: 100%;
    max-width: 420px;
}

body.page-login main form button[type="submit"] {
    display: block;
    width: 100%;
    margin: var(--space-md) 0 0;
}

/* ---------- Kundenmanagement -------------------------------- */

/* Erfassungsformulare. Höhere Spezifität als form[method="post"], das sonst
   die schmale Login-Karte durchsetzt. */
main form.entity-form {
    max-width: 760px;
    margin-bottom: var(--space-lg);
}

/* Über die ganze Seite: der Rahmen sitzt am inneren .form-card, die Buttons
   stehen außerhalb darunter */
main form.entity-form--wide {
    max-width: none;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.form-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    overflow-x: auto;
}

/* Zwei Spalten, jedes zweite Feld rechts; .form-row--left bleibt links */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-xl);
}

.form-grid .form-row--left {
    grid-column: 1;
}

@media (max-width: 800px) {
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Die Rechnungstabelle füllt den Rahmen ohne eigenen Kasten */
.form-card > table {
    margin-bottom: 0;
    box-shadow: none;
}

.entity-form .form-row {
    margin-bottom: var(--space-md);
}

.entity-form .form-row ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.entity-form .form-row label {
    display: block;
}

/* Ankreuzlisten (Sendungsarten) nebeneinander statt untereinander */
.entity-form .form-row ul li label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
    font-weight: 400;
    color: var(--color-text);
    margin-bottom: 0;
}

.entity-form .form-row input[type="checkbox"] {
    width: auto;
    margin: 0;
    padding: 0;
    accent-color: var(--color-orange);
}

/* Telefonnummer: Ländervorwahl links, Rufnummer rechts */
.phone-field {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

/* Nur die Vorwahl steht drin (max. '+359'), deshalb so schmal wie möglich.
   Der schmalere Innenabstand schafft Platz für den Aufklapp-Pfeil. */
.phone-field select {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding-left: var(--space-xs);
    padding-right: var(--space-xs);
}

.phone-field input {
    flex: 1 1 auto;
    min-width: 0;
}

/* Passwortfeld mit Anzeigen/Verbergen-Umschalter */
.password-field {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.password-field input {
    flex: 1 1 auto;
    min-width: 0;
}

.password-field .password-toggle {
    flex: 0 0 auto;
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    font-size: 12px;
    padding: 0 var(--space-md);
    margin: 0;
    white-space: nowrap;
}

.password-field .password-toggle:hover {
    border-color: var(--color-orange);
    color: var(--color-orange);
}

.entity-form .form-hint {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.entity-form .form-error,
.form-error {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-danger);
}

.form-error[hidden] {
    display: none;
}


/* Passwortregeln unter dem Eingabefeld der Erstanmeldung */
.password-rules {
    margin: var(--space-xs) 0 0;
    padding-left: var(--space-lg);
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Schlichte Aufzählung statt Karten-Liste (`main ul` hat sonst Vorrang) */
main ul.password-rules {
    display: block;
    list-style: disc;
    padding-left: var(--space-lg);
}

main ul.password-rules li {
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
}

/* Adressliste: begrenzte Höhe mit eigenem Scrollbereich */
.address-scroll {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}

.address-scroll table {
    margin-bottom: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Kopfzeile bleibt beim Scrollen stehen */
.address-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.address-filter {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.address-filter label {
    margin: 0;
    white-space: nowrap;
}

.address-filter input {
    width: auto;
    flex: 1 1 320px;
    max-width: 420px;
    padding: 6px 8px;
    font-size: 13px;
}

.address-filter .address-count {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Filterleiste über der Lieferungsliste */
.list-filter {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    max-width: none;
}

.list-filter .filter-field {
    display: flex;
    flex-direction: column;
}

.list-filter label {
    margin-bottom: 2px;
}

.list-filter select,
.list-filter input {
    width: auto;
    min-width: 150px;
    padding: 6px 8px;
    font-size: 13px;
}

.list-filter .filter-actions {
    display: flex;
    flex-direction: row;
    gap: var(--space-sm);
    margin-left: auto;
}

/* Nur so breit wie Suchfeld und Button nebeneinander */
.list-filter--compact {
    width: fit-content;
    max-width: 100%;
}

.list-filter--compact input {
    width: 360px;
    max-width: 100%;
}

.list-filter--compact .filter-actions {
    margin-left: 0;
}

/* Hinweis in der Lieferungsliste: Same Day / Wochenende / Feiertag */
.delivery-badge {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--color-border);
    border-left-width: 3px;
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
}

.delivery-badge.delivery-sameday {
    color: var(--color-info);
    background-color: rgba(43, 124, 184, 0.12);
    border-color: var(--color-info);
}

.delivery-badge.delivery-weekend {
    color: var(--color-warning);
    background-color: rgba(181, 129, 0, 0.12);
    border-color: var(--color-warning);
}

.delivery-badge.delivery-holiday {
    color: var(--color-danger);
    background-color: rgba(192, 57, 43, 0.12);
    border-color: var(--color-danger);
}

/* ---------- Hilfsklassen ------------------------------------ */

[hidden] {
    display: none !important;
}

/* ---------- Responsive -------------------------------------- */

@media (max-width: 640px) {
    header {
        padding: var(--space-md) var(--space-lg);
        gap: var(--space-md);
    }

    main {
        padding: var(--space-lg) var(--space-md);
    }

    button {
        width: 100%;
        margin-right: 0;
    }

    form[id^="parcel_form_"] {
        flex-direction: column;
        padding-right: var(--space-lg);
    }

    form[id^="parcel_form_"] > button {
        width: 32px;
    }
}

/* Meldungen der serverseitigen Payload-Prüfung über den Knöpfen der
   Lieferübersicht. Farbgebung wie die übrigen Hinweise (vgl. .delivery-info),
   nur in der Fehlerfarbe. */
.form-errors {
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-danger);
    background-color: rgba(192, 57, 43, 0.12);
    border: 1px solid var(--color-danger);
    border-left-width: 3px;
    border-radius: var(--radius);
    line-height: 1.45;
}

.form-errors ul {
    margin: var(--space-xs) 0 0;
    padding-left: var(--space-lg);
}


/* Seitennavigation unter Listen */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin: calc(-1 * var(--space-xs)) 0 var(--space-md);
    font-size: 13px;
}

.pagination-info {
    color: var(--color-text-muted);
}

.pagination-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.pagination-links a,
.pagination-links span {
    min-width: 30px;
    padding: 4px 8px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background-color: var(--color-surface);
    color: var(--color-blue);
    text-decoration: none;
}

.pagination-links a:hover {
    border-color: var(--color-blue);
}

.pagination-links .pagination-current {
    background-color: var(--color-blue);
    border-color: var(--color-blue);
    color: var(--color-white);
    font-weight: 700;
}

.pagination-links .pagination-disabled,
.pagination-links .pagination-ellipsis {
    color: var(--color-text-muted);
}

.pagination-links .pagination-ellipsis {
    border-color: transparent;
    background: none;
}


/* Rechnung erstellen */
.invoice-table .num {
    text-align: right;
    white-space: nowrap;
}

.invoice-table .invoice-price input {
    width: 110px;
    padding: 6px 8px;
    text-align: right;
}

.invoice-table .invoice-price .form-error {
    display: block;
    white-space: normal;
}

.invoice-table tfoot td:first-child {
    text-align: right;
}

.invoice-table tfoot .invoice-total td {
    border-top: 2px solid var(--color-blue);
    font-size: 15px;
}


/* Zustellangaben unter jeder Sendung im Rechnungsformular */
.invoice-table tr.invoice-delivery td {
    border-top: none;
    background-color: var(--color-bg);
    padding-top: 4px;
    padding-bottom: 10px;
}

.invoice-table .delivery-inputs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.invoice-table .delivery-inputs .delivery-caption {
    font-weight: 700;
    color: var(--color-blue);
    margin-right: 6px;
}

.invoice-table .delivery-inputs label {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-muted);
}

.invoice-table .delivery-inputs input {
    width: auto;
    padding: 5px 8px;
    font-size: 13px;
}

.invoice-table .delivery-inputs input[type="text"] {
    width: 180px;
}

/* Rechnung: leere Pflichtfelder markieren */
.invoice-table input[aria-invalid="true"] {
    border-color: var(--color-danger);
}
