* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 20px;
    background: #1f2937;
    color: #fff;
}

.topbar-brand-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-brand {
    font-weight: 600;
    font-size: 1.05rem;
}

.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topbar-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
    text-decoration: none;
    font-size: 0.9rem;
    text-align: center;
}

.topbar-nav a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.topbar-nav a.active {
    background: #2563eb;
    color: #fff;
    font-weight: 600;
}

.topbar-nav-secondary a {
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
    min-height: 36px;
    padding: 6px 12px;
}

/* Auffällig gestaltete Sync-Buttons - oben rechts in der Kopfzeile (Brand-Row), nicht in der
   normalen Nav-Zeile, damit sie als eigenständige Aktion erkennbar bleiben statt als
   Navigationspunkt zwischen den anderen Menülinks. Laufen beide im Hintergrund (fetch), keine
   Navigation zu einer eigenen Sync-Seite mehr - siehe <script> weiter unten in nav.php. */
.nav-sync-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.nav-cta {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    background: #dc2626;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.nav-cta:hover {
    background: #b91c1c;
    color: #fff;
}

.nav-cta:disabled {
    opacity: 0.6;
    cursor: default;
}

.nav-cta-hint {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
}

.nav-cta-schnell {
    background: #15803d;
}

.nav-cta-schnell:hover {
    background: #166534;
}

.nav-sync-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
}

.nav-sync-status-ok {
    color: #86efac;
    font-weight: 600;
}

.nav-sync-status-error {
    color: #fca5a5;
    font-weight: 600;
}

/* Fuß-Leiste für selten gebrauchte Funktionen (inkl. Bestellwesen/Listing-Unterseiten) - steht im
   normalen Textfluss ganz am Ende jeder Seite (nicht dauerhaft eingeblendet, damit sie auf
   Laptop-Bildschirmen keinen permanenten Platz wegnimmt). Wird per "order" im Flex-Layout von
   body (siehe oben) unabhängig von ihrer Position im HTML - direkt nach dem <header> aus
   nav.php - ans Ende sortiert, auch wenn danach noch weitere Elemente (z.B. mehrere <main>-
   Abschnitte) folgen. Bewusst als schlichte Text-Links gehalten, im Gegensatz zu den
   button-artigen Haupt-Menüpunkten oben. */
.app-footer-links {
    order: 999;
    margin-top: auto;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    padding: 8px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 24px;
}

.app-footer-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
}

.app-footer-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
}

.app-footer-links a {
    font-size: 0.8rem;
    color: #555;
    text-decoration: underline;
    white-space: nowrap;
}

.app-footer-links a:hover {
    color: #1a1a1a;
}

.page {
    max-width: 640px;
    margin: 40px auto;
    padding: 0 20px;
}

.page-wide {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card label {
    font-weight: 600;
    margin-top: 8px;
}

.card input[type="text"],
.card input[type="password"],
.card input[type="file"],
.card select,
.card textarea {
    padding: 10px 12px;
    font-size: 1.1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
}

.card button {
    margin-top: 16px;
    padding: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.card button:hover {
    background: #1d4ed8;
}

.pp-hidden-input {
    display: none;
}

.pp-dropzone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    color: #555;
    transition: border-color 0.15s, background 0.15s;
}

.pp-dropzone:hover {
    border-color: #2563eb;
}

.pp-dropzone-over {
    border-color: #2563eb;
    background: #eff6ff;
}

.pp-dropzone p {
    margin: 0;
    pointer-events: none;
}

.pp-dropzone-files {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    text-align: left;
    font-size: 0.9rem;
    color: #333;
    pointer-events: none;
}

.pp-dropzone-files li {
    padding: 2px 0;
}

.radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 4px 0 4px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    width: auto;
    cursor: pointer;
}

.hint {
    color: #555;
    font-size: 0.95rem;
}

.error {
    color: #b91c1c;
    font-weight: 600;
}

.success {
    color: #15803d;
    font-weight: 600;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}

.notfound-banner {
    max-width: 900px;
    margin: 20px auto;
    color: #b91c1c;
    font-weight: 700;
    font-size: 1.3rem;
    text-align: center;
}

@media print {
    .no-print {
        display: none !important;
    }
    body {
        margin: 0;
    }
}

/* Laufzettel (auch für Einlagern genutzt) */
.laufzettel-table {
    width: 100%;
    max-width: 900px;
    margin: 24px auto;
    border-collapse: collapse;
}

.laufzettel-table th,
.laufzettel-table td {
    border: 1px solid #999;
    padding: 8px 12px;
    text-align: left;
    font-size: 14px;
}

.laufzettel-table th {
    background: #f0f2f5;
}

.id-summary {
    max-width: 900px;
    margin: 24px auto;
}

.id-summary p {
    font-size: 14px;
    margin: 4px 0;
}

.id-summary-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Login-Seite */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    width: 320px;
    text-align: center;
}

.login-box h1 {
    margin: 0 0 4px;
    font-size: 1.4rem;
}

.login-box .subtitle {
    margin: 0 0 20px;
    color: #666;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-box input {
    padding: 12px;
    font-size: 1.1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.login-box button {
    padding: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 8px;
}

/* Scan-Seite */
.scan-page h1 {
    text-align: center;
}

.scan-form h2 {
    margin: 0;
    font-size: 1.1rem;
}

.scan-form form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scan-form input[type="text"] {
    display: block;
    width: 100%;
    font-size: 1.6rem;
    text-align: center;
    padding: 16px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.button-row button {
    flex: 1 1 auto;
    margin-top: 0;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.button-row button:hover {
    background: #1d4ed8;
}

.button-row-stacked {
    flex-direction: column;
}

.button-link {
    display: block;
    flex: 1 1 auto;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.button-link:hover,
.button-link:active {
    background: #1d4ed8;
    color: #fff;
}

.button-link-secondary {
    background: #e5e7eb;
    color: #111;
}

.button-link-secondary:hover,
.button-link-secondary:active {
    background: #d1d5db;
    color: #111;
}

.button-link-sub {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
}

.button-link-secondary .button-link-sub {
    color: rgba(17, 17, 17, 0.65);
}

.button-link-small {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.scan-form button {
    font-size: 1.2rem;
    padding: 16px;
}

.ean-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ean-grid input[type="text"] {
    font-size: 1rem;
    padding: 8px;
    text-align: center;
}

/* Einlagern-Seite - kompakter als der Rest der App (viele Zeilen sollen auf kleinen/Laptop-
   Bildschirmen gleichzeitig sichtbar sein), deshalb eigene, engere Werte statt der globalen
   .page/.card/.button-row/.button-link-Maße. */
.einlagern-page {
    max-width: 780px;
    margin: 20px auto;
}

.einlagern-page h1 {
    font-size: 1.3rem;
    margin: 0 0 10px;
}

.einlagern-page .hint {
    font-size: 0.82rem;
    margin: 4px 0;
}

.einlagern-page .card {
    padding: 14px 16px;
    gap: 6px;
}

.einlagern-page .button-row {
    margin-top: 10px;
    gap: 8px;
}

.einlagern-page .button-row button,
.einlagern-page .button-link {
    padding: 10px;
    font-size: 0.95rem;
}

.einlagern-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.einlagern-table th,
.einlagern-table td {
    padding: 3px 6px;
    text-align: left;
    font-size: 13px;
}

.einlagern-table th {
    color: #555;
}

.einlagern-table input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

.einlagern-table .einlagern-menge {
    max-width: 70px;
}

.einlagern-table input:disabled {
    background: #eee;
    color: #888;
    border-color: #ddd;
}

.einlagern-row-saved td {
    background: #f7f7f5;
}

.einlagern-status-row td {
    padding-top: 0;
    padding-bottom: 6px;
}

.einlagern-status {
    font-size: 13px;
}

.einlagern-status-meta {
    font-weight: 400;
    color: #555;
}

.einlagern-status-ok {
    color: #15803d;
    font-weight: 600;
}

.einlagern-status-error {
    color: #b91c1c;
    font-weight: 600;
}

.einlagern-status-pending {
    color: #888;
    font-style: italic;
}

.einlagern-aendern {
    font-size: 12px;
    color: #2563eb;
    margin-left: 4px;
}

.einlagern-hidden {
    display: none;
}

/* Dynamische Zeilen (neues, zusammengelegtes Einlagern - eine Zeile nach der anderen) - bewusst
   knapp bemessen, damit auf Laptop-Bildschirmen möglichst viele Zeilen gleichzeitig sichtbar sind. */
.einlagern-zeile {
    background: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 0 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.einlagern-zeile.einlagern-row-saved {
    background: #f7f7f5;
    box-shadow: none;
}

.einlagern-zeile-felder {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
}

.einlagern-feld {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.einlagern-feld label {
    font-size: 0.78rem;
    color: #555;
}

.einlagern-feld input[type="text"] {
    padding: 6px 8px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

.einlagern-feld input:disabled {
    background: #eee;
    color: #888;
    border-color: #ddd;
}

/* Primärfeld (Lagerfach/Reservefach) mit bereits bekanntem, automatisch vorbelegtem Wert - deutlich
   lesbarer als das normale ausgegraute :disabled, damit auf einen Blick klar ist "hier ist schon
   ein Fach hinterlegt, einfach weiterscannen". Gilt nur solange das Feld gesperrt ist: sobald über
   "ändern" wieder aktiviert wird, greift automatisch wieder die normale Eingabefeld-Optik. */
.einlagern-feld input.einlagern-primaerfach-bekannt:disabled {
    background: #eafaf0;
    color: #15803d;
    font-weight: 700;
    border-color: #86d9a8;
}

.einlagern-links {
    font-size: 0.78rem;
    margin-top: 1px;
}

.einlagern-links a {
    color: #2563eb;
    text-decoration: underline;
}

.einlagern-soll-info {
    margin-top: 8px;
}

.einlagern-abweichung-block {
    margin-top: 4px;
    font-size: 0.82rem;
}

.einlagern-abweichung-block a {
    color: #2563eb;
    text-decoration: underline;
}

.einlagern-abweichung-formular:not(.einlagern-hidden) {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.einlagern-abweichung-formular label {
    font-size: 0.85rem;
    color: #555;
}

.einlagern-abweichung-feld {
    width: 90px;
    padding: 4px 6px;
    font-size: 0.9rem;
}

.einlagern-zeile-status {
    margin-top: 6px;
    font-size: 12px;
}

/* Auffüllen-Seite */
.auffuellen-page {
    max-width: 1100px;
}

.auffuellen-flash {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin: 16px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.15s ease;
}

.einlagern-primaer-ehemalig {
    font-size: 0.75rem;
    font-style: italic;
    color: #64748b;
    margin-top: 2px;
}

.auffuellen-bestellt-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e40af;
    color: #fff;
    border-radius: 999px;
    padding: 5px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    margin-bottom: 4px;
}

.auffuellen-warnung {
    margin-top: 8px;
    color: #b91c1c;
    font-weight: 600;
    font-size: 1rem;
}

.auffuellen-log-table {
    max-width: 1300px;
}

.auffuellen-bemerkung-input {
    width: 100%;
    min-width: 220px;
    padding: 8px 10px;
    font-size: 1.05rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

.auffuellen-flash-gruen {
    background: #bbf7d0;
}

.auffuellen-flash-rot {
    background: #fecaca;
}

.auffuellen-scan-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.auffuellen-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 140px;
}

.auffuellen-field label {
    font-weight: 600;
    font-size: 0.9rem;
}

.auffuellen-field input[type="text"] {
    padding: 12px;
    font-size: 1.2rem;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.auffuellen-lagerwechsel-button {
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 600;
    background: #e5e7eb;
    color: #111;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.auffuellen-lagerwechsel-button.active {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.auffuellen-feedback-text {
    margin: 14px 0 0;
    font-size: 1.15rem;
    font-weight: 700;
    min-height: 1.4em;
}

.auffuellen-counts {
    font-size: 0.95rem;
    color: #333;
}

.auffuellen-status-lagerwechsel {
    color: #92400e;
    font-weight: 600;
}

/* Historie-Kategorien */
.historie-kategorien {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 20px;
}

.historie-kategorien a {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 8px;
    background: #e5e7eb;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.historie-kategorien a:hover {
    background: #d1d5db;
}

.historie-kategorien a.active {
    background: #2563eb;
    color: #fff;
    font-weight: 600;
}
