body {
    font-family: Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 0px;
}
.container {
    max-width: 900px;
    margin: 0 auto;
}
.card {
    background: #fff;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.form-group { margin-bottom: 15px; }
label { font-weight: bold; display: block; margin-bottom: 5px; font-size: 0.9em; }
input[type="text"], input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #a0a0a0;
    box-sizing: border-box;
}

/* DB-Style Befehlsblöcke */
.befehl-header, .befehl-footer {
    background: #f0f0f0;
    padding: 15px;
    border: 2px solid #333;
    margin-bottom: 15px;
}
.befehl-block {
    border: 2px solid #000;
    margin: 15px 0;
    background: #fff;
}
.block-title {
    background: #333;
    color: #fff;
    padding: 8px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}
.block-content { padding: 15px; }
.btn {
    padding: 10px 15px;
    cursor: pointer;
    font-weight: bold;
}
.btn-primary { background: #0052a3; color: white; border: none; }
.btn-success { background: #28a745; color: white; border: none; }
.btn-large { width: 100%; padding: 15px; font-size: 1.1em; margin-top: 20px;}
.btn-delete { background: #dc3545; color: white; border: none; padding: 3px 8px; cursor: pointer; }

/* Ansicht für abgerufene Befehle */
.db-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
.db-table td {
    border: 1px solid #000;
    padding: 10px;
    width: 50%;
}
.output-block {
    border: 1px solid #000;
    padding: 10px;
    margin-bottom: 10px;
    background: #fafafa;
}

/* Styling für die Passwortbarriere */
.auth-card {
    max-width: 450px;
    margin: 60px auto;
    border: 1px solid #dcdcdc;
    border-top: 4px solid #0052a3; /* DB-Blau Akzent */
}
.auth-header {
    text-align: center;
    margin-bottom: 20px;
}
.auth-header h2 {
    margin-bottom: 5px;
}
.auth-header p {
    color: #666;
    font-size: 0.9em;
    margin: 0;
}

/* Hinweistexte / Alerts */
.alert {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: bold;
}
.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.block-selector {
    background: #e9ecef;
    padding: 15px;
    border: 1px dashed #333;
    margin: 15px 0;
}
/* --- DB-Vordruck Design-System --- */
.print-body {
    background: #e4e4e4;
    padding: 20px;
    margin: 0;
}

.action-bar {
    max-width: 210mm;
    margin: 0 auto 15px auto;
    display: flex;
    gap: 10px;
}

/* Container skaliert exakt auf DIN-A4 Breite */
.vordruck-container {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    margin: 0 auto;
    padding: 15mm 12mm;
    box-sizing: border-box;
    border: 1px solid #999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    color: #000;
    font-family: "Courier New", Courier, monospace; /* Klassischer Schreibmaschinen-Vibe für Daten */
}

.vordruck-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #000;
    padding-bottom: 5px;
    margin-bottom: 15px;
    font-family: Arial, sans-serif;
}

.vordruck-main-title {
    font-size: 1.5rem;
    font-weight: bold;
}

/* Kopf- und Fußzeilen-Gitter wie im echten Formular */
.vordruck-grid {
    display: grid;
    border-left: 1px solid #000;
    border-top: 1px solid #000;
    font-family: Arial, sans-serif;
}

.kopf-grid {
    grid-template-columns: 1fr 1fr;
}

.fuss-grid {
    grid-template-columns: 2fr 1fr 1fr;
    margin-top: 20px;
}

.cell {
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 6px;
    position: relative;
    min-height: 45px;
}

.wide-cell {
    grid-column: span 2;
}

.sub-cell {
    grid-column: span 1;
}

.cell .label {
    font-weight: bold;
    font-size: 1.1rem;
    float: left;
    margin-right: 8px;
}

.cell .val-title {
    font-size: 0.75rem;
    color: #333;
    display: inline-block;
}

.cell .val {
    font-family: "Courier New", monospace;
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 5px;
    padding-left: 20px;
    color: #0003b3; /* DB-Dateneintrag Blau */
}

/* Styling der Befehlsblöcke */
.vordruck-blocks {
    margin-top: 2px;
}

.vordruck-block {
    border: 2px solid #000;
    margin-top: -2px; /* Verhindert doppelte Rahmen */
    font-family: Arial, sans-serif;
}

.vordruck-block-header {
    display: flex;
    background: #f0f0f0;
    border-bottom: 1px solid #000;
    align-items: center;
}

.checkbox-box {
    width: 35px;
    text-align: center;
    font-weight: bold;
    border-right: 1px solid #000;
    padding: 6px 0;
}

.block-number {
    width: 35px;
    text-align: center;
    font-weight: bold;
    border-right: 1px solid #000;
    font-size: 1.2rem;
    padding: 6px 0;
}

.block-name {
    padding-left: 10px;
    font-weight: bold;
}

.vordruck-block-body {
    padding: 10px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.vordruck-block-body .num {
    font-weight: bold;
    margin-right: 10px;
}

.inline-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 5px;
}

.underline-data {
    font-family: "Courier New", monospace;
    font-weight: bold;
    color: #0003b3;
    border-bottom: 1px dashed #000;
    padding: 0 10px;
}

.freitext-output {
    font-family: "Courier New", monospace;
    font-weight: bold;
    color: #0003b3;
    margin-top: 5px;
    padding: 5px;
    background: #fdfdfd;
    border: 1px dotted #ccc;
    white-space: pre-line;
}

.code-font {
    font-family: monospace !important;
}

/* --- PRINT RULES (Magie fürs Drucken) --- */
@media print {
    body.print-body {
        background: #fff;
        padding: 0;
        margin: 0;
    }
    .no-print {
        display: none !important;
    }
    .vordruck-container {
        border: none;
        box-shadow: none;
        padding: 0;
        width: 100%;
    }
    .cell .val, .underline-data, .freitext-output {
        color: #000 !important; /* Beim echten Drucken alles schwarz */
    }
}

/* --- Modus: Nur Anzeigen / Drucken --- */
.view-mode {
    background: #fff;
    color: #000;
}

/* Alle Löschen- oder Aktionsbuttons ausblenden */
.view-mode .btn-delete,
.view-mode .btn-add,
.view-mode button {
    display: none !important;
}

/* Textfelder: Rahmen entfernen, Text fetten, Unterlinie wie im Vordruck */
.view-mode input[type="text"],
.view-mode textarea {
    border: none !important;
    border-bottom: 1px solid #000 !important;
    background: transparent !important;
    font-weight: bold !important;
    color: #000 !important;
    padding: 0 5px !important;
    pointer-events: none; /* Macht das Feld komplett ungültig für Klicks */
    box-shadow: none !important;
}

/* Textareas für Freitexte (z.B. 95.96) Linien-Look verpassen */
.view-mode textarea {
    border-bottom: none !important;
    line-height: 24px !important;
    background: linear-gradient(to bottom, transparent 23px, #000 23px) !important;
    background-size: 100% 24px !important;
    resize: none;
}

/* Checkboxes manipulieren: Standard-Design entfernen und echtes [X] bauen */
.view-mode input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid #000 !important;
    background: #fff !important;
    vertical-align: middle;
    position: relative;
    cursor: default;
    pointer-events: none;
    margin-right: 5px;
}

/* Wenn das Kästchen ausgewählt ist, ein echtes 'X' reinrendern */
.view-mode input[type="checkbox"]:checked::before {
    content: "X";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: Arial, sans-serif;
    font-weight: bold;
    font-size: 13px;
    color: #000;
}
.view-mode input[type="checkbox"],
.view-mode input[type="radio"] {
    pointer-events: none; /* Macht das Element unklickbar */
    opacity: 0.8;         /* Optischer Hinweis, dass es inaktiv ist */
}

.view-mode input[type="text"],
.view-mode textarea {
    pointer-events: none; /* Verhindert das Ändern des Textes */
    background-color: #f9f9f9 !important;
    border: none !important;
    border-bottom: 1px solid #ccc !important;
}

.view-mode .btn-delete {
    display: none !important; /* Lösch-Button komplett ausblenden */
}

.view-mode .placeholder-label {
    font-size: 0.65rem;
    color: #666;
    font-style: italic;
    line-height: 1.2;
    margin-top: 2px;
    /* Verhindert, dass das Label zu breit wird */
    max-width: 100%;
}

.view-mode .befehl-content {
    margin-bottom: 10px;
}
