* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #17212b;
    --muted: #667085;
    --line: #e5e7eb;
    --accent: #0f62fe;
    --accent-dark: #084ec2;
    --danger: #b42318;
    --danger-bg: #fdecec;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

body {
    height: 100vh;
}

.app-shell {
    max-width: 760px;
    height: 100vh;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    margin: 0 0 12px;
    flex: 0 0 auto;
    background: var(--bg);
    z-index: 20;
}

.page-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.eyebrow {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 4px;
}

h1 {
    font-size: 28px;
    line-height: 1.15;
    margin: 0;
}

.subhead {
    margin: 6px 0 0;
    font-size: 16px;
    color: var(--muted);
}

.logout-link {
    display: inline-block;
    text-decoration: none;
    color: var(--muted);
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #eef2f6;
    white-space: nowrap;
}

.header-user-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.current-user-label {
    font-size: 13px;
    color: var(--muted);
    background: #eef2f6;
    padding: 6px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.card {
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-head h2 {
    margin: 0;
    font-size: 20px;
}

.badge {
    font-size: 13px;
    color: var(--muted);
    background: #eef2f6;
    padding: 6px 10px;
    border-radius: 999px;
}

.empty-state {
    padding: 20px 0;
    color: var(--muted);
}

label {
    display: block;
    font-size: 15px;
    font-weight: bold;
    margin: 14px 0 8px;
}

.input {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    padding: 12px 14px;
    font-size: 16px;
    background: #fff;
    outline: none;
    appearance: none;
}

.input:focus {
    border-color: var(--accent);
}

.input-with-clear {
    padding-right: 44px;
}

.search-input-wrap {
    position: relative;
}

.clear-input-button {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #e5e7eb;
    color: #475467;
    font-size: 20px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.clear-input-button.is-visible {
    display: inline-flex;
}

.textarea {
    min-height: 100px;
    resize: vertical;
}

.button-primary,
.button-secondary {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: bold;
    margin-top: 16px;
    border: none;
    cursor: pointer;
}

.button-primary {
    background: var(--accent);
    color: #fff;
}

.button-primary:hover {
    background: var(--accent-dark);
}

.button-secondary {
    background: #eef2f6;
    color: var(--text);
}

.fab {
    position: fixed;
    left: 20px;
    bottom: 20px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 12px 28px rgba(15, 98, 254, 0.35);
}

.suggestions {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.suggestion-item {
    display: block;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    text-align: left;
    padding: 12px 14px;
    cursor: pointer;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item strong {
    display: block;
    font-size: 16px;
    color: var(--text);
}

.suggestion-item span {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.booking-groups {
    display: grid;
    gap: 18px;
}

.booking-group {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.booking-group:first-child {
    border-top: none;
    padding-top: 0;
}

.booking-group-date {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.booking-group-items {
    display: grid;
}

.booking-row {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 6px;
    border-radius: 10px;
    border-bottom: 1px solid var(--line);
}

.booking-row:last-child {
    border-bottom: none;
}

.booking-row-link {
    text-decoration: none;
    color: inherit;
}

.booking-row-link:hover,
.booking-row-link:active {
    background: #f8fafc;
}

.booking-time-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    padding-top: 2px;
}

.booking-time {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.4;
}

.booking-user {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.2;
}

.booking-text-wrap {
    min-width: 0;
}

.booking-text {
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.booking-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.35;
}

.booking-amount {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    text-align: right;
    padding-top: 2px;
}

.is-negative {
    color: var(--danger);
}

.toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.toggle-button {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: var(--text);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 12px 14px;
}

.toggle-button.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.toggle-button-danger {
    color: var(--danger);
}

.toggle-button-danger.is-active {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.menge-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menge-input-wrap {
    width: 180px;
    max-width: 100%;
}

.einheit-badge {
    min-width: 56px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    background: #eef2f6;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: bold;
    white-space: nowrap;
}

/* PIN Screen */
.pin-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(255,255,255,0.35), rgba(255,255,255,0) 35%),
        linear-gradient(180deg, #dfe7ef 0%, #cfd9e4 100%);
}

.pin-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.pin-card {
    width: 100%;
    max-width: 420px;
    padding: 20px 18px 28px;
    text-align: center;
}

.pin-title-wrap {
    margin-bottom: 22px;
}

.pin-lock {
    font-size: 34px;
    margin-bottom: 8px;
}

.pin-title {
    font-size: 30px;
    margin: 0;
    font-weight: 700;
}

.pin-subtitle {
    color: var(--muted);
    font-size: 15px;
    margin: 8px 0 0;
}

.pin-form {
    margin-top: 8px;
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 12px 0 18px;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(23, 33, 43, 0.6);
    background: transparent;
    transition: all 0.15s ease;
}

.pin-dot.is-filled {
    background: #17212b;
    border-color: #17212b;
    transform: scale(1.05);
}

.pin-error {
    min-height: 22px;
    color: var(--danger);
    font-size: 15px;
    margin-bottom: 16px;
}

.pin-error-placeholder {
    color: transparent;
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 82px);
    justify-content: center;
    gap: 14px 18px;
    margin-top: 10px;
}

.pin-key {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.75);
    color: #17212b;
    font-size: 30px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(4px);
    transition: transform 0.08s ease, background 0.12s ease;
}

.pin-key:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.92);
}

.pin-key-action {
    font-size: 24px;
}

.pin-key-empty {
    visibility: hidden;
    pointer-events: none;
}

@media (max-width: 420px) {
    .pin-keypad {
        grid-template-columns: repeat(3, 72px);
        gap: 12px 14px;
    }

    .pin-key {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }

    .menge-row {
        align-items: stretch;
    }

    .menge-input-wrap {
        width: 150px;
    }
}

@media (min-width: 768px) {
    .app-shell {
        padding-top: 28px;
    }

    .card {
        padding: 20px;
    }
}

.booking-groups {
    display: grid;
    gap: 18px;
}

.booking-group {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.booking-group:first-child {
    border-top: none;
    padding-top: 0;
}

.booking-group-toggle {
    width: 100%;
    border: none;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0 10px;
    cursor: pointer;
    text-align: left;
}

.booking-group-date {
    font-size: 18px;
    font-weight: bold;
}

.booking-group-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.booking-group-count {
    font-size: 13px;
    color: var(--muted);
    background: #eef2f6;
    padding: 4px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.booking-group-chevron {
    width: 24px;
    text-align: center;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
}

.booking-group-items {
    display: grid;
}

.booking-group-items[hidden] {
    display: none;
}

main {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 96px;
}