:root {
    --bg: #f6f6f6;
    --panel: #ffffff;
    --ink: #111111;
    --muted: rgba(17, 17, 17, 0.62);
    --line: #e4e4e4;
    --accent: #e10613;
    --accent-ink: #ffffff;
    --accent-pressed: #b1050e;
    --danger: #e10613;
    --radius: 12px;
    font-family: "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
h1, h2 { margin: 0 0 0.5rem; }
.muted { color: var(--muted); }
.settings-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 1rem 0;
    border-bottom: 1px solid var(--line);
}
.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    padding: 0.7rem 0.9rem;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.settings-tab.is-current { color: var(--ink); border-bottom-color: var(--accent); }

.guest-body {
    min-height: 100vh;
    display: grid;
    place-items: safe center;
    padding: 1rem;
}
.guest-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 1.15rem 1rem;
    width: min(26rem, 100%);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}
.guest-card-photo-frame {
    margin: 0 -1.15rem 0;
}
.guest-card-photo {
    display: block;
    width: 100%;
    height: auto;
}
.guest-card-logo {
    display: block;
    width: 85%;
    height: auto;
    margin: 0.55rem auto 0;
}
.guest-card .stack { gap: 0.5rem; margin-top: 0.7rem; }
.guest-card label { gap: 0.2rem; }
.guest-card input[type="email"],
.guest-card input[type="password"] { padding: 0.5rem 0.7rem; }
.guest-card .btn { padding: 0.6rem 0.9rem; }
@media (max-width: 540px), (max-height: 520px) {
    .guest-body {
        display: flex;
        justify-content: center;
        min-height: 100svh;
        padding: 0;
    }
    .guest-card {
        width: 100%;
        max-width: 26rem;
        height: 100svh;
        display: flex;
        flex-direction: column;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: auto;
        padding: env(safe-area-inset-top) 1rem calc(1rem + env(safe-area-inset-bottom));
    }
    .guest-card-photo-frame {
        position: relative;
        flex: 1 1 auto;
        min-height: 9.5rem;
        margin: 0 -1rem 0;
        overflow: hidden;
    }
    .guest-card-photo {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center 40%;
    }
    .guest-card-logo,
    .guest-card-form { flex: 0 0 auto; }
    .guest-card-logo { margin-top: 0.45rem; }
    .guest-card .stack { gap: 0.45rem; margin-top: 0.45rem; }
    .guest-card label { font-size: 0.92rem; }
    .guest-card input[type="email"],
    .guest-card input[type="password"] {
        font-size: 16px;
        min-height: 44px;
        padding: 0.55rem 0.75rem;
    }
    .guest-card .btn { min-height: 48px; }
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: min(28rem, 100%);
    box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}
.panel { width: auto; margin-top: 1rem; }

.stack { display: grid; gap: 0.9rem; margin-top: 1.25rem; }
label { display: grid; gap: 0.35rem; font-weight: 600; }
label.inline { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"], input[type="date"], input[type="datetime-local"], input[type="month"], input[type="file"], select, textarea {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    background: #fff;
    font-family: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.toolbar {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar input[type="search"] { max-width: 28rem; }
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table th { font-size: 0.85rem; color: var(--muted); }
.actions { display: flex; align-items: center; gap: 0.75rem; }
.actions a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 0;
    padding: 0;
    color: var(--danger);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1.1rem;
    width: min(56rem, 100%);
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.badge {
    display: inline-block;
    background: #efefef;
    color: var(--ink);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.totals {
    display: flex;
    gap: 1.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    font-size: 1.05rem;
}
.items-table input, .items-table select { min-width: 4.5rem; }
.form-grid { width: min(72rem, 100%); }
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .page-head { flex-direction: column; }
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 0;
    border-radius: 8px;
    padding: 0.8rem 1.1rem;
    font-size: 1rem;
    cursor: pointer;
}
a.btn { text-decoration: none; text-align: center; }
.action-icon {
    width: 1.05em;
    height: 1.05em;
    flex: none;
    vertical-align: -0.15em;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-pressed); }
.btn-secondary { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px #111111; }
label.file-btn {
    display: inline-flex;
    align-items: center;
    width: auto;
    font-weight: 600;
}
label.file-btn input { display: none; }
.vehicle-photo {
    width: 12rem;
    max-width: 100%;
    border-radius: 0.5rem;
    border: 1px solid var(--line);
}
.vehicle-thumb {
    display: block;
    width: 4.5rem;
    height: 3.2rem;
    object-fit: cover;
    border-radius: 0.35rem;
    border: 1px solid var(--line);
}
.vehicle-table td {
    vertical-align: middle;
}
.vehicle-table td.actions {
    display: table-cell;
    vertical-align: middle;
}
.vehicle-table td.actions a,
.vehicle-table td.actions .link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 0.75rem;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    vertical-align: middle;
}
.vehicle-table td.actions a:last-child,
.vehicle-table td.actions .link-btn:last-child {
    margin-right: 0;
}
.vehicle-table td.actions a:hover,
.vehicle-table td.actions .link-btn:hover {
    color: var(--accent);
}
.app-main a:not(.btn) { color: var(--ink); text-decoration: none; }
.app-main a:not(.btn):hover { color: var(--accent); }
.error { color: var(--danger); margin: 0; font-weight: 600; }

.app-body { min-height: 100vh; background: var(--bg); }
.app-shell {
    --nav-width: 252px;
    --nav-width-narrow: 76px;
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}
.app-nav {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: var(--nav-width);
    flex: 0 0 var(--nav-width);
    height: 100vh;
    background: #111111;
    color: rgba(255, 255, 255, 0.92);
    z-index: 40;
    overflow: hidden;
    transition: width 0.2s ease, flex-basis 0.2s ease;
}
html.app-nav-collapsed .app-nav {
    width: var(--nav-width-narrow);
    flex-basis: var(--nav-width-narrow);
}
.app-nav-head, .app-nav-foot, .app-nav-scroll { padding-inline: 10px; }
.app-nav-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 68px;
    padding-top: 12px;
}
.app-nav-brand {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}
.app-nav-brand:hover, .app-nav-link:hover, .app-nav-collapse:hover { background: rgba(255, 255, 255, 0.06); }
.app-nav-logo {
    display: block;
    width: 100%;
    max-height: 52px;
    object-fit: contain;
    object-position: left center;
}
.app-nav-mark { display: none; }
html.app-nav-collapsed .app-nav-logo { display: none; }
html.app-nav-collapsed .app-nav-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}
html.app-nav-collapsed .app-nav-head { flex-direction: column; padding-inline: 8px; }
.app-nav-collapse, .app-topbar-menu, .app-nav-logout {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
}
.app-nav-scroll {
    display: grid;
    align-content: start;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-bottom: 16px;
}
.app-nav-section { display: grid; gap: 4px; }
.app-nav-heading {
    margin: 8px 12px 2px;
    color: rgba(255, 255, 255, 0.46);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.app-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    width: 100%;
    padding: 8px 12px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}
.app-nav-link.is-current {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.app-nav-icon { flex: 0 0 auto; }
.app-nav-label, .app-nav-user-name { overflow: hidden; text-overflow: ellipsis; }
html.app-nav-collapsed .app-nav-label,
html.app-nav-collapsed .app-nav-heading,
html.app-nav-collapsed .app-nav-user-meta { display: none; }
html.app-nav-collapsed .app-nav-link,
html.app-nav-collapsed .app-nav-user { justify-content: center; gap: 0; padding-inline: 8px; }
.app-nav-foot {
    display: grid;
    gap: 4px;
    padding-top: 12px;
    padding-bottom: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #0a0a0a;
}
.app-nav-user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px; }
.app-nav-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}
.app-nav-user-name { font-size: 0.9rem; font-weight: 600; }
.app-nav-logout { color: rgba(255, 255, 255, 0.68); }
.app-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 30;
}
.app-frame { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.app-topbar { display: none; }
.app-topbar-brand { display: inline-flex; align-items: center; text-decoration: none; }
.app-topbar-brand img { display: block; height: 34px; width: auto; }
.app-main { padding: 1.5rem; max-width: 90rem; }
@media (max-width: 880px) {
    .app-topbar {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.7rem 1rem;
        background: #111111;
        color: #fff;
    }
    .app-nav {
        position: fixed;
        left: 0;
        transform: translateX(-105%);
        width: min(18rem, 86vw);
        flex-basis: auto;
        transition: transform 0.2s ease;
    }
    html.app-nav-collapsed .app-nav { width: min(18rem, 86vw); }
    body.app-nav-open .app-nav { transform: none; }
    html.app-nav-collapsed .app-nav-label,
    html.app-nav-collapsed .app-nav-heading,
    html.app-nav-collapsed .app-nav-user-meta,
    html.app-nav-collapsed .app-nav-logo { display: block; }
    html.app-nav-collapsed .app-nav-mark { display: none; }
    html.app-nav-collapsed .app-nav-head { flex-direction: row; }
    html.app-nav-collapsed .app-nav-link,
    html.app-nav-collapsed .app-nav-user { justify-content: flex-start; gap: 12px; padding-inline: 12px; }
}
.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.beleg-frame {
    width: 100%;
    min-height: 28rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.review-uncertain {
    outline: 2px solid var(--accent);
    background: #fff;
}
@media (max-width: 900px) {
    .review-grid { grid-template-columns: 1fr; }
}
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1rem;
    align-items: start;
}
.upload-grid .stack { margin-top: 0; }
.scanner {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: #111111;
    color: #fff;
}
.scanner-view {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
}
.scanner-video, .scanner-photo {
    max-width: 100%;
    max-height: calc(100dvh - 9rem);
    background: #000;
}
.scanner-frame {
    position: relative;
    max-width: 100%;
    max-height: 100%;
}
.scanner-frame .scanner-photo { display: block; }
.scanner-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}
.scanner-status { margin: 0; min-height: 1.4rem; }
.scanner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding-bottom: env(safe-area-inset-bottom);
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(0 0 0 / 45%);
    z-index: 30;
}
.modal-card {
    width: min(32rem, calc(100% - 2rem));
    padding: 1.25rem;
    background: #fff;
    border-radius: 0.75rem;
}
.customer-picker { position: relative; }
.customer-picker > label { display: block; margin-bottom: 0.35rem; }
.customer-suggestions {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    margin: 0.25rem 0 0;
    padding: 0.25rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    box-shadow: 0 8px 24px rgb(0 0 0 / 8%);
    max-height: 16rem;
    overflow: auto;
}
.customer-suggestions button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 0.55rem 0.75rem;
    font: inherit;
    cursor: pointer;
}
.customer-suggestions button:hover { background: #f6f6f6; }
.customer-suggestions button.is-action {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    font-weight: 600;
}
