.cs-screen {
    --cs-navy: linear-gradient(170deg, #1c2b4f 0%, #24365f 60%, #2c416f 100%);
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    font-family: "DM Sans", "Segoe UI", sans-serif;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: #f4f6fb;
    color: #0f172a;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.cs-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.cs-bar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.cs-bar-logo {
    width: clamp(40px, 5vw, 56px);
    height: clamp(40px, 5vw, 56px);
    object-fit: contain;
    border-radius: 10px;
}

.cs-bar-brand strong {
    overflow: hidden;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-bar-end {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cs-bar-greeting {
    color: #475569;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    font-weight: 600;
}

.cs-full {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.75;
}

.cs-full:hover,
.cs-full:focus-visible,
.cs-full:active {
    opacity: 1;
}

:root:fullscreen .cs-full,
:root:-webkit-full-screen .cs-full {
    display: none;
}

.cs-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.cs-splash {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    background: linear-gradient(165deg, #0b1a5c 0%, #00008b 55%, #1e2fa8 100%);
    color: #fff;
}

.cs-splash h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.cs-splash p {
    max-width: 36rem;
    margin: 0;
    font-size: clamp(1.1rem, 2.2vw, 1.6rem);
    opacity: 0.85;
}

.cs-notice {
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
}

.cs-thanks {
    background: var(--cs-navy);
}

.cs-thanks-mark {
    display: grid;
    place-items: center;
    width: clamp(72px, 10vw, 112px);
    height: clamp(72px, 10vw, 112px);
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    animation: cs-pop 0.35s ease-out;
}

.cs-paid {
    display: grid;
    gap: 0.6rem;
    min-width: min(90vw, 420px);
    margin: 0.5rem 0;
}

.cs-paid div {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    padding: 0.7rem 1.1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    font-size: clamp(1.1rem, 2.2vw, 1.6rem);
}

.cs-paid dt {
    font-weight: 600;
    opacity: 0.85;
}

.cs-paid dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cs-paid .cs-change {
    background: #facc15;
    color: #0f172a;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.cs-basket {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 400px);
    min-height: 0;
}

.cs-lines {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}

.cs-lines-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 1.75rem 1rem;
}

.cs-lines-head h2 {
    margin: 0;
    font-size: clamp(1.4rem, 2.6vw, 2.1rem);
    font-weight: 700;
}

.cs-lines-head span {
    color: #64748b;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    font-weight: 600;
}

.cs-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #64748b;
    text-align: center;
}

.cs-empty-mark {
    display: grid;
    place-items: center;
    width: clamp(72px, 9vw, 104px);
    height: clamp(72px, 9vw, 104px);
    border-radius: 50%;
    background: #edf1f7;
    color: #24365f;
}

.cs-empty-mark svg {
    width: 45%;
    height: 45%;
}

.cs-empty h3 {
    margin: 0.5rem 0 0;
    color: #0f172a;
    font-size: clamp(1.3rem, 2.4vw, 1.9rem);
}

.cs-empty p {
    max-width: 28rem;
    margin: 0;
    font-size: clamp(1rem, 1.7vw, 1.3rem);
}

.cs-cols,
.cs-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(5rem, auto) minmax(6rem, auto) minmax(7rem, auto);
    align-items: center;
    gap: 1.25rem;
    padding: 0 1.75rem;
}

.cs-cols {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cs-cols span:not(:first-child),
.cs-line > :not(:first-child) {
    text-align: right;
}

.cs-list {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    list-style: none;
}

.cs-line {
    padding-top: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
    border-left: 6px solid transparent;
    padding-left: calc(1.75rem - 6px);
    font-size: clamp(1.05rem, 1.8vw, 1.4rem);
}

.cs-line.active {
    border-left-color: #24365f;
    background: #edf1f7;
    animation: cs-flash 0.6s ease-out;
}

.cs-line-name {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.cs-line-name strong {
    overflow-wrap: anywhere;
}

.cs-line-name .cs-saving {
    color: #15803d;
    font-size: 0.8em;
    font-weight: 600;
}

.cs-line-qty,
.cs-line-price {
    color: #334155;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cs-line-qty small {
    color: #64748b;
    font-size: 0.75em;
}

.cs-line-amount {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cs-summary {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--cs-navy);
    color: #fff;
}

.cs-due {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.cs-due span {
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.8;
}

.cs-due strong {
    font-size: clamp(1.9rem, 3.6vw, 3rem);
    font-weight: 700;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.cs-totals {
    display: grid;
    gap: 0.55rem;
    margin: 0;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
}

.cs-totals div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.cs-totals dt {
    font-weight: 600;
    opacity: 0.85;
}

.cs-totals dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cs-totals .cs-discount dd {
    color: #86efac;
}

.cs-totals .cs-total-row {
    margin-top: 0.3rem;
    padding: 0.9rem 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.35);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.15em;
}

.cs-totals .cs-total-row dt {
    opacity: 1;
}

.cs-saved {
    align-self: flex-start;
    margin: 0;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: #22c55e;
    color: #052e16;
    font-size: clamp(0.8rem, 1.1vw, 0.95rem);
    font-weight: 700;
}

.cs-points {
    margin: 0;
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    font-weight: 600;
    opacity: 0.85;
}

.cs-paying {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    font-size: clamp(0.85rem, 1.2vw, 1rem);
}

.cs-paying span {
    font-weight: 600;
}

.cs-paying.waiting {
    background: #facc15;
    color: #0f172a;
    animation: cs-pulse 1.6s ease-in-out infinite;
}

.cs-customer {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-top: auto;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
}

.cs-customer-mark {
    display: grid;
    flex: none;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 1.15rem;
    font-weight: 700;
}

.cs-customer div {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.cs-customer small {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.75;
}

.cs-customer strong {
    overflow: hidden;
    font-size: clamp(0.9rem, 1.2vw, 1.05rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-customer-points {
    font-size: 0.8rem;
    opacity: 0.85;
}

@keyframes cs-flash {
    from { background: #d3dbe9; }
    to { background: #edf1f7; }
}

@keyframes cs-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes cs-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* Large customer displays and TVs */
@media (min-width: 1800px) {
    .cs-basket {
        grid-template-columns: minmax(0, 1fr) clamp(360px, 26vw, 520px);
    }
}

/* 10–12" tablets and POS customer displays in landscape (1024–1366 wide) */
@media (max-width: 1366px) and (orientation: landscape) {
    .cs-basket {
        grid-template-columns: minmax(0, 1fr) clamp(260px, 31vw, 360px);
    }

    .cs-lines-head {
        padding: 1.1rem 1.25rem 0.75rem;
    }

    .cs-cols,
    .cs-line {
        gap: 1rem;
        padding-right: 1.25rem;
    }

    .cs-cols {
        padding-left: 1.25rem;
    }

    .cs-line {
        padding-left: calc(1.25rem - 6px);
    }

    .cs-summary {
        padding: 1.25rem;
    }
}

/* Short POS terminal displays: 1024×600, 800×480, 1280×400 */
@media (max-height: 640px) and (orientation: landscape) {
    .cs-bar {
        padding: 0.4rem 1rem;
    }

    .cs-bar-logo {
        width: 36px;
        height: 36px;
    }

    .cs-bar-brand strong,
    .cs-bar-greeting {
        font-size: 1rem;
    }

    .cs-full {
        min-height: 36px;
        padding: 0.3rem 0.75rem;
        font-size: 0.8rem;
    }

    .cs-lines-head {
        padding: 0.6rem 1rem 0.4rem;
    }

    .cs-lines-head h2 {
        font-size: 1.2rem;
    }

    .cs-lines-head span {
        font-size: 0.9rem;
    }

    .cs-cols {
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
        font-size: 0.7rem;
    }

    .cs-line {
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
        font-size: 1rem;
    }

    .cs-empty {
        gap: 0.4rem;
        padding: 1rem;
    }

    .cs-empty-mark {
        width: 56px;
        height: 56px;
    }

    .cs-empty h3 {
        font-size: 1.15rem;
    }

    .cs-empty p {
        font-size: 0.95rem;
    }

    .cs-summary {
        gap: 0.6rem;
        padding: 0.9rem 1rem;
    }

    .cs-due {
        gap: 0.15rem;
        padding-bottom: 0.6rem;
    }

    .cs-due strong {
        font-size: clamp(1.6rem, 7vh, 2.4rem);
    }

    .cs-totals {
        gap: 0.35rem;
        font-size: 0.85rem;
    }

    .cs-totals .cs-total-row {
        padding: 0.45rem 0;
    }

    .cs-customer {
        gap: 0.6rem;
        padding: 0.5rem 0.75rem;
    }

    .cs-customer-mark {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }

    .cs-splash {
        gap: 0.6rem;
        padding: 1.25rem;
    }

    .cs-splash h1 {
        font-size: clamp(1.6rem, 6vh, 2.4rem);
    }

    .cs-splash p,
    .cs-paid div {
        font-size: 1rem;
    }

    .cs-thanks-mark {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
}

/* Very short strip displays */
@media (max-height: 420px) and (orientation: landscape) {
    .cs-customer-points,
    .cs-saved,
    .cs-empty-mark {
        display: none;
    }
}

/* Portrait tablets, small tablets and pole displays */
@media (max-width: 900px), (orientation: portrait) {
    .cs-basket {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .cs-bar-greeting {
        display: none;
    }

    .cs-cols,
    .cs-line {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .cs-cols span:nth-child(3),
    .cs-line-price {
        display: none;
    }

    .cs-summary {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
        align-items: start;
        gap: 0.75rem 1.5rem;
        padding: 1rem 1.25rem;
        overflow: visible;
    }

    .cs-due {
        grid-column: 1;
        grid-row: 1;
        padding-bottom: 0;
        border-bottom: 0;
    }

    .cs-totals {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .cs-customer {
        grid-column: 1;
        grid-row: 2;
        margin-top: 0;
    }

    .cs-saved,
    .cs-paying {
        grid-column: 1 / -1;
    }
}

/* Phones */
@media (max-width: 560px) {
    .cs-bar {
        padding: 0.5rem 0.75rem;
    }

    .cs-bar-logo {
        width: 36px;
        height: 36px;
    }

    .cs-bar-brand strong {
        font-size: 1rem;
    }

    .cs-lines-head {
        padding: 0.85rem 1rem 0.5rem;
    }

    .cs-cols,
    .cs-line {
        gap: 0.75rem;
        padding-right: 1rem;
    }

    .cs-cols {
        padding-left: 1rem;
    }

    .cs-line {
        padding-top: 0.7rem;
        padding-bottom: 0.7rem;
        padding-left: calc(1rem - 6px);
        font-size: 1rem;
    }

    .cs-line-qty small {
        display: none;
    }

    .cs-summary {
        grid-template-columns: 1fr;
        gap: 0.6rem;
        padding: 0.9rem 1rem;
    }

    .cs-due,
    .cs-totals,
    .cs-customer {
        grid-column: 1;
        grid-row: auto;
    }

    .cs-due {
        flex-direction: row;
        align-items: baseline;
        justify-content: space-between;
    }

    .cs-due strong {
        font-size: 2rem;
    }

    .cs-paid {
        min-width: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cs-line.active,
    .cs-thanks-mark,
    .cs-paying.waiting {
        animation: none;
    }
}
