
:root {
    --navy: #172C40;
    --green: #198653;
    --background: #F1F4F7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--background);
    color: #222;
}

header {
    background: var(--navy);
    color: white;
    padding: 22px;
}

header h1 {
    margin: 0;
    font-size: 26px;
}

header p {
    color: lightgray;
    margin-bottom: 0;
}

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

.headerLogo {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

main {
    padding: 16px;
    max-width: 800px;
    margin: auto;
}

.counterRow {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.counter {
    flex: 2;
    min-width: 0;
    background: white;
    border-radius: 16px;
    padding: 20px;
}

.loadButton {
    flex: 1;
    min-width: 0;
    background: var(--green);
    color: white;
    font-weight: bold;
    font-size: 14px;
    line-height: 1.25;
    border-radius: 16px;
    padding: 10px;
}

.counter span {
    display: block;
    color: gray;
}

.counter strong {
    display: block;
    color: var(--navy);
    font-size: 34px;
    margin-top: 5px;
}

h2 {
    font-size: 20px;
}

.wagon {
    background: white;
    padding: 16px;
    margin-bottom: 10px;
    border-radius: 12px;
    cursor: pointer;
}

.wagonTop {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-weight: bold;
}

.wagonNumber {
    font-size: 18px;
    color: var(--navy);
    margin: 10px 0;
}

.details {
    color: #555;
    font-size: 15px;
    line-height: 1.4;
}

.loaded {
    color: var(--green);
}

button {
    border: 0;
    border-radius: 9px;
    padding: 14px;
    font-size: 15px;
    cursor: pointer;
}

.add, .addLoco, .deleteAll, .export {
    width: 100%;
    color: white;
    margin-top: 12px;
}

.add {
    background: var(--green);
}

.export {
    background: var(--navy);
}

.backupRow {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.backup {
    flex: 1;
    background: #e5e9ed;
    color: var(--navy);
    text-align: center;
    border-radius: 9px;
    padding: 14px;
    font-size: 15px;
    cursor: pointer;
}

label.importLabel {
    display: block;
    margin: 0;
    font-weight: normal;
}

.status {
    text-align: center;
    color: gray;
    font-size: 12px;
}

.overlay {
    position: fixed;
    inset: 0;
    background: var(--background);
    overflow-y: auto;
    z-index: 10;
}

.hidden {
    display: none !important;
}

.form {
    max-width: 700px;
    margin: auto;
    padding: 16px;
}

.formHeader {
    background: var(--navy);
    color: white;
    padding: 16px;
    margin: -16px -16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.formHeader h2 {
    margin: 0;
}

.close {
    color: white;
    background: transparent;
    font-size: 30px;
    line-height: 1;
    padding: 4px 10px;
    font-weight: bold;
}

label {
    display: block;
    font-weight: bold;
    margin: 16px 0 7px;
}

input {
    width: 100%;
    padding: 13px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    background: white;
}

.choices {
    display: flex;
    gap: 12px;
}

.choices button {
    background: #e5e9ed;
    flex: 1;
}

.choices button.selected {
    background: var(--green);
    color: white;
}

.save, .delete {
    width: 100%;
    margin-top: 20px;
    color: white;
}

.save {
    background: var(--green);
}

.delete {
    background: #b52d2d;
}

.deleteAll {
    background: #b52d2d;
}

@media (max-width: 400px) {
    main {
        padding: 12px;
    }
}

/* ===== Zugübersicht ===== */

.empty {
    text-align: center;
    padding: 40px 0;
}

.train {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: white;
    color: #222;
    text-align: left;
    padding: 18px 16px;
    margin-bottom: 10px;
    border-radius: 12px;
    font-family: inherit;
}

.trainInfo strong {
    display: block;
    font-size: 18px;
    color: var(--navy);
}

.trainDay {
    display: block;
    margin-top: 4px;
    color: #555;
    font-size: 15px;
}

.train {
    cursor: pointer;
}

.trainCount {
    background: var(--navy);
    color: white;
}

/* ===== Kopfzeile der Wagenübersicht ===== */

.wagonHeader {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.wagonHeaderText {
    flex: 1;
    min-width: 0;
}

.wagonHeader h1 {
    font-size: 22px;
}

.wagonHeader p {
    margin-top: 4px;
}

.back, .editTrain {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: bold;
    font-size: 17px;
    padding: 12px 14px;
}

.editTrain {
    font-size: 22px;
    padding: 8px 14px;
}

/* ===== Eingabeprüfung ===== */

input.invalid {
    border: 2px solid #b52d2d;
    background: #fdf2f2;
}

input.invalid:focus {
    outline: 2px solid rgba(181, 45, 45, 0.35);
}

.fieldError {
    color: #b52d2d;
    font-size: 14px;
    font-weight: bold;
    margin: 6px 0 0;
}

.fieldError:empty {
    display: none;
}

/* Festes "max." im Bremsgewicht-Feld */

.prefixInput {
    position: relative;
}

.prefix {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    font-weight: bold;
    color: var(--navy);
    pointer-events: none;
}

.prefix:not(.hidden) + input {
    padding-left: 56px;
}

/* ===== Triebfahrzeug-Markierung ===== */

.addLoco {
    background: #e5e9ed;
    color: var(--navy) !important;
    font-weight: bold;
}

.loco {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: var(--navy);
    color: white;
    padding: 10px 12px 10px 16px;
    margin-bottom: 10px;
    border-radius: 12px;
    border-left: 6px solid #f2b705;
}

.locoLabel {
    font-weight: bold;
    font-size: 17px;
}

.locoActions {
    display: flex;
    gap: 6px;
}

.locoActions button {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 16px;
    padding: 10px 13px;
    line-height: 1;
}

.locoActions button:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ===== Korrekte Wagennummer ===== */

/* Korrekte Prüfziffer: Feld bleibt normal, nur der grüne Hinweis erscheint */

.fieldError.ok {
    color: var(--green);
}

.locoActions button {
    white-space: nowrap;
}

/* ===== Bremse wirksam: "Aus" in Rot ===== */

.choices button#brakeNo.selected {
    background: #b52d2d;
    color: white;
}

/* ===== Verkehrstag: Datumsfeld auf dem Handy nicht breiter als der Bildschirm ===== */

input[type="date"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
}

input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}

.form {
    overflow-x: hidden;
}

input:disabled {
    background: #f5f7f9;
    color: #333;
    -webkit-text-fill-color: #333;
    opacity: 1;
}

.choices button:disabled {
    cursor: default;
}

/* ===== Gemeinsame Live-Züge ===== */

.join {
    width: 100%;
    margin-top: 12px;
    background: #e5e9ed;
    color: var(--navy);
    font-weight: bold;
}

.trainInfo {
    flex: 1;
    min-width: 0;
}

.trainTitleRow {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

/* Rechte Spalte: Code-Blase oben, Wagen-Blase darunter – beide gleich breit */
.trainBadges {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 110px;
}

.trainBadge {
    display: block;
    text-align: center;
    white-space: nowrap;
    font-weight: bold;
    font-size: 16px;
    padding: 10px 14px;
    border-radius: 999px;
    line-height: 1.2;
}

.trainCode {
    background: #e5e9ed;
    color: var(--navy);
    font-family: "Courier New", monospace;
    letter-spacing: 1px;
}

.trainEnable {
    font-family: inherit;
    letter-spacing: 0;
}

.trainShare {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e5e9ed;
    color: #555;
}

.trainShare.shared, .trainShare.edit {
    background: #eaf6ef;
    color: var(--green);
}

.trainShare.read {
    background: #e8eef5;
    color: var(--navy);
}

.shareBox {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.shareTop {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: gray;
}

.shareMain {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.shareCode {
    font-family: "Courier New", monospace;
    font-size: 30px;
    color: var(--navy);
    letter-spacing: 2px;
}

.shareCode.pending {
    color: #999;
    font-size: 22px;
    letter-spacing: 0;
    font-family: inherit;
}

.shareState {
    font-size: 13px;
    font-weight: bold;
}

.shareState.live {
    color: var(--green);
}

.shareState.busy {
    color: #b07a00;
}

.shareState.offline {
    color: #b52d2d;
}

.roleBadge {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 999px;
    background: #e5e9ed;
    color: var(--navy);
}

.roleBadge.edit {
    background: #eaf6ef;
    color: var(--green);
}

.shareButton {
    width: 100%;
    margin-top: 12px;
    background: #e5e9ed;
    color: var(--navy);
    font-weight: bold;
}

.shareButton:disabled {
    opacity: 0.5;
    cursor: default;
}

.formHint, .readOnlyHint {
    color: #555;
    line-height: 1.4;
}

.readOnlyHint {
    background: #e8eef5;
    color: var(--navy);
    font-weight: bold;
    padding: 12px;
    border-radius: 8px;
}

.member {
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}

.member strong {
    display: block;
    color: var(--navy);
    margin-bottom: 8px;
}

.memberRemove {
    width: 100%;
    margin-top: 8px;
    background: transparent;
    color: #b52d2d;
    font-weight: bold;
    padding: 8px;
}

.memberEmpty {
    color: gray;
    margin: 0;
}

/* ===== Ladungsgewicht ===== */

input.computed {
    background: #eef1f4;
    color: var(--navy);
    font-weight: bold;
    cursor: default;
}

.loadProgress {
    color: gray;
    margin: 0 0 8px;
}

.loadWagon {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
}

.loadWagon strong {
    display: block;
    color: var(--navy);
    font-size: 18px;
}

.loadNav {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.loadNav button {
    flex: 1;
    margin-top: 0;
}

.loadPrev {
    background: #e5e9ed;
    color: var(--navy);
    font-weight: bold;
}

.loadWagon .wagonNumber {
    display: block;
    margin: 6px 0 0;
}

.shareHint {
    color: #555;
    font-size: 14px;
    line-height: 1.4;
    margin: 0 0 16px;
}

/* ===== Achsen-Zustand unbekannt ("?") ===== */

.choices button.unknownChoice,
.choices button.unknownChoice.selected {
    flex: 0 0 auto;
    width: 48px;
    aspect-ratio: 1;
    padding: 0;
    background: var(--navy);
    color: white;
    font-weight: bold;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}

.choices button.unknownChoice.selected {
    box-shadow: 0 0 0 3px white, 0 0 0 6px var(--green);
}

.loadUnknown {
    color: #b52d2d;
    font-weight: bold;
}
