* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 0;
    padding: 0;
}

.pairing-panel {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    margin-top: 8px;
}

.pairing-panel input {
    width: 170px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.pairing-panel input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

.pairing-panel input:disabled {
    background-color: #f0f0f0;
    color: #999;
    cursor: not-allowed;
    border-color: #ccc;
}

.pairing-panel button {
    padding: 8px 12px;
    border: 0;
    border-radius: 4px;
    background: #e0e0e0;
    color: #333;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.pairing-panel button:hover {
    background: #d0d0d0;
}

#connectBtn {
    background: #0066cc;
    color: #fff;
}

#connectBtn:hover {
    background: #0052a3;
}

.display-header {
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
    padding: 12px;
    min-height: 0;
    overflow-y: auto;
}

.customer-info-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px;
    gap: 8px;
}

.field-name {
    grid-column: 1;
    grid-row: 1;
}

.field-account {
    grid-column: 2;
    grid-row: 1;
}

.field-money {
    grid-column: 1;
    grid-row: 2;
}

.field-free {
    grid-column: 2;
    grid-row: 2;
}

.connection-tile {
    grid-column: 3;
    grid-row: 1 / span 2;
    border-radius: 4px;
    padding: 0;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
    min-width: 30px;
    min-height: 38px;
}

.connection-tile.connected {
    background: #c8e6c9;
    border-color: #2e7d32;
}

.connection-tile.disconnected {
    background: #ffcccc;
    border-color: #c62828;
}

.connection-tile .customer-label,
.connection-tile .customer-value {
    color: #1e3a5f;
}

.connection-tile .customer-value {
    font-size: clamp(13px, 2.1vh, 22px);
}

.customer-field {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    display: block;
    min-width: 0;
}

.customer-label {
    display: block;
    font-size: 11px;
    color: #777;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
}

.customer-value {
    display: block;
    font-size: clamp(16px, 2.5vh, 24px);
    font-weight: 700;
    color: #1e3a5f;
    text-align: left;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-panel {
    background: #ffffff;
    border-radius: 0;
    border-top: 1px solid #e0e0e0;
    padding: 12px 12px 0 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-items {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cart-item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 0;
    background: #f9fbff;
    border: 1px solid #e1e9f4;
}

.cart-item-media {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef2f7;
    border: 1px solid #d7e2ef;
}

.cart-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cart-item-image-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #1e3a5f;
}

.cart-item-name {
    font-size: 16px;
    font-weight: 600;
    color: #1e3a5f;
}

.cart-item-total {
    font-size: 16px;
    font-weight: 700;
    color: #1e3a5f;
    text-align: right;
}

.cart-total {
    flex-shrink: 0;
    margin-top: 8px;
    padding: 10px 0 12px 0;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    font-weight: 700;
    color: #1e3a5f;
    background: #ffffff;
}

.payment-qr-overlay {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 28;
}

.payment-qr-card {
    width: 250px;
    background: #ffffff;
    border: 1px solid #d6dee8;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    padding: 12px;
}

.payment-qr-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a5f;
}

.payment-qr-meta,
.payment-qr-expiry {
    margin-top: 6px;
    font-size: 12px;
    color: #4f647d;
}

.payment-qr-image {
    width: 220px;
    height: 220px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    margin-top: 10px;
}

/* Transactions Panel Styles */
.transactions-panel {
    background: #ffffff;
    border-radius: 0;
    border-top: 1px solid #e0e0e0;
    padding: 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.transactions-header {
    margin-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

.transactions-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e3a5f;
}

.transactions-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-transactions {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 14px;
}

.transaction-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 0;
    background: #f9fbff;
    border: 1px solid #e1e9f4;
}

.transaction-item-has-storno {
    opacity: 0.55;
    background: #f3f3f3;
    border-color: #d7d7d7;
}

.transaction-item-storno {
    background: #f6f0fa;
    border-color: #ddd0ea;
}

.tx-type {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.tx-type-credit {
    background: #2e7d32;
}

.tx-type-debit {
    background: #c62828;
}

.tx-type-freigetraenk {
    background: #1565c0;
}

.tx-type-spende {
    background: #ef6c00;
}

.tx-type-storno {
    background: #6a1b9a;
}

.tx-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tx-time {
    font-size: 12px;
    color: #666;
}

.tx-type-label {
    font-size: 13px;
    font-weight: 600;
    color: #1e3a5f;
}

.tx-amount {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a5f;
    text-align: right;
}

.booking-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.booking-overlay.success {
    background: #1e8e3e;
    color: #ffffff;
}

.booking-overlay.error {
    background: #c62828;
    color: #ffffff;
}

.booking-overlay.positive {
    background: #1e8e3e;
    color: #ffffff;
}

.booking-overlay.negative {
    background: #c62828;
    color: #ffffff;
}

.booking-overlay.donate {
    background: #ef6c00;
    color: #ffffff;
}

.overlay-message {
    width: min(92vw, 760px);
}

.overlay-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 32px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.overlay-title {
    font-size: clamp(28px, 5.5vh, 56px);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.overlay-details {
    display: grid;
    gap: 10px;
}

.overlay-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
}

.overlay-label {
    font-size: clamp(14px, 2vh, 20px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.9;
}

.overlay-value {
    font-size: clamp(24px, 4vh, 40px);
    font-weight: 800;
}

.overlay-note {
    font-size: clamp(20px, 3vh, 32px);
    font-weight: 700;
    opacity: 0.98;
}

.hidden {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.scanner-panel {
    margin-top: 8px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
}

#scannerVideo {
    width: 100%;
    max-height: 240px;
    border-radius: 4px;
    background: #111827;
}

.scanner-actions {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

#scanQrBtn {
    background: #e0e0e0;
    color: #333;
}

#scanQrBtn:hover {
    background: #d0d0d0;
}

.terms-overlay {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.terms-overlay.hidden {
    display: none;
}

.terms-overlay-card {
    width: min(96vw, 1100px);
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #d6dbe5;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

@supports (height: 100dvh) {
    .terms-overlay-card {
        height: calc(100dvh - 40px);
        max-height: calc(100dvh - 40px);
    }
}

.terms-overlay-title {
    margin: 0;
    padding: 16px 20px;
    border-bottom: 1px solid #e4e8ef;
    font-size: clamp(24px, 3.2vh, 40px);
    color: #10213a;
}

.terms-overlay-pdf-pages {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: auto;
    padding: 14px;
    background: #f4f6fa;
}

.terms-overlay-pdf-pages canvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto 12px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
}

.terms-overlay-text {
    flex: 1;
    min-height: 0;
    padding: 18px 20px;
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.45;
    color: #1c2a40;
    font-size: clamp(14px, 2vh, 24px);
}

.terms-overlay-actions {
    display: flex;
    justify-content: flex-end;
    padding: 14px 20px 18px;
    border-top: 1px solid #e4e8ef;
    background: #f7f9fc;
}

.terms-overlay-actions.hidden {
    display: none;
}

.terms-overlay-accept-btn {
    border: 1px solid #3f4752;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    background: #4b5563;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    box-shadow: none;
}

.terms-overlay-accept-btn:hover {
    background: #3f4752;
}

#stopScanBtn {
    background: #f44336;
    color: #ffffff;
    border: 0;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

#stopScanBtn:hover {
    background: #d32f2f;
}

@media (max-width: 1000px) {
    .customer-info-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .field-name,
    .field-account,
    .field-money,
    .field-free,
    .connection-tile {
        grid-column: 1;
        grid-row: auto;
    }

    .pairing-panel input {
        width: 100%;
    }

    .pairing-panel {
        justify-content: flex-start;
    }

    .display-header {
        padding: 6px;
    }

    .customer-field {
        padding: 5px 7px;
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 6px;
    }

    .customer-label {
        display: inline-block;
        font-size: 11px;
        margin-bottom: 0;
    }

    .customer-value {
        display: inline-block;
        font-size: clamp(15px, 2.4vh, 22px);
        text-align: right;
    }

    .connection-tile .customer-value {
        font-size: clamp(14px, 2.2vh, 22px);
    }

    .connection-tile {
        min-height: 28px;
    }
}

@media (min-width: 721px) and (max-width: 1000px) {
    .customer-info-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px;
        gap: 6px;
    }

    .field-name {
        grid-column: 1;
        grid-row: 1;
    }

    .field-account {
        grid-column: 2;
        grid-row: 1;
    }

    .field-money {
        grid-column: 1;
        grid-row: 2;
    }

    .field-free {
        grid-column: 2;
        grid-row: 2;
    }

    .connection-tile {
        grid-column: 3;
        grid-row: 1 / span 2;
        min-height: 38px;
    }
}
