/* =====================================================
   Self-Checkout POS Demo · Marktplatz am Eck
   Modern, eye-appealing UI · 3 switchable color themes
   ===================================================== */

/* --- Theme 1: Warm Bakery (default) ---
   Cream background, dark espresso text, warm amber accent.
   Inspired by a German Marktplatz bakery. */
:root,
:root[data-theme="bakery"] {
    --bg:            #FBF7F0;        /* cream */
    --bg-soft:       #F3EADA;
    --surface:       #FFFFFF;
    --surface-2:     #FFFDF8;
    --primary:       #2A1A0F;        /* dark espresso */
    --primary-soft:  #4A3424;
    --text:          #2A1A0F;
    --text-muted:    #7A6A5A;
    --text-faint:    #A89888;
    --line:          #EBE0D0;
    --line-soft:     #F1E7D5;

    --accent:        #E07A2A;        /* warm amber */
    --accent-hover:  #C6671F;
    --accent-soft:   #FBEAD8;
    --success:       #2F8F4A;
    --success-soft:  #DEF2E2;
    --danger:        #C8362A;
    --danger-soft:   #FBE0DC;
    --info:          #2D6CB1;
    --info-soft:     #DCE9F6;

    --brand-logo-bg: linear-gradient(135deg, #E07A2A 0%, #C6671F 100%);
    --checkout-bg:   var(--checkout-bg);
--checkout:#000;--checkoutbg:     #cf0;
    /* Effects */
    --shadow-sm: 0 1px 2px rgba(42,26,15,.06), 0 1px 1px rgba(42,26,15,.04);
    --shadow:    0 4px 14px rgba(42,26,15,.10), 0 2px 6px rgba(42,26,15,.06);
    --shadow-lg: 0 14px 40px rgba(42,26,15,.18), 0 6px 18px rgba(42,26,15,.10);
    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 22px;
    --radius-xl: 30px;

    --font-ui:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-head:  'Sora', 'Inter', system-ui, sans-serif;
    --font-mono:  'JetBrains Mono', ui-monospace, 'Courier New', monospace;

    --transition: 180ms cubic-bezier(.4, .0, .2, 1);
}

/* --- Theme 2: Modern Dark ---
   Dark slate background, light text, vivid teal accent.
   Inspired by modern POS terminals (Square / Stripe). */
:root[data-theme="dark"] {
    --bg:            #0F1419;
    --bg-soft:       #161D24;
    --surface:       #1B232C;
    --surface-2:     #1F2832;
    --primary:       #F1F5F9;        /* light text on dark */
    --primary-soft:  #CBD5E1;
    --text:          #F1F5F9;
    --text-muted:    #94A3B8;
    --text-faint:    #64748B;
    --line:          #2D3744;
    --line-soft:     #243039;

    --accent:        #2DD4BF;        /* vivid teal */
    --accent-hover:  #14B8A6;
    --accent-soft:   #134E4A;
    --success:       #34D399;
    --success-soft:  #064E3B;
    --danger:        #F87171;
    --danger-soft:   #7F1D1D;
    --info:          #60A5FA;
    --info-soft:     #1E3A8A;

    --brand-logo-bg: linear-gradient(135deg, #2DD4BF 0%, #14B8A6 100%);
    --checkout-bg:   var(--checkout-bg);
--checkout:#fff;--checkoutbg:     #0c0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.30), 0 1px 1px rgba(0,0,0,.20);
    --shadow:    0 4px 14px rgba(0,0,0,.40), 0 2px 6px rgba(0,0,0,.25);
    --shadow-lg: 0 14px 40px rgba(0,0,0,.50), 0 6px 18px rgba(0,0,0,.30);
}

/* --- Theme 3: Fresh Mint ---
   Pale mint background, deep forest text, emerald accent.
   Inspired by a fresh greengrocer / organic market. */
:root[data-theme="mint"] {
    --bg:            #F0FAF3;        /* pale mint */
    --bg-soft:       #DDF2E2;
    --surface:       #FFFFFF;
    --surface-2:     #F7FEF9;
    --primary:       #0F2E1B;        /* deep forest */
    --primary-soft:  #1F4F36;
    --text:          #0F2E1B;
    --text-muted:    #4A7060;
    --text-faint:    #8AAA9A;
    --line:          #C8E5D2;
    --line-soft:     #DDEFE2;

    --accent:        #059669;        /* emerald */
    --accent-hover:  #047857;
    --accent-soft:   #D1FAE5;
    --success:       #16A34A;
    --success-soft:  #DCFCE7;
    --danger:        #DC2626;
    --danger-soft:   #FEE2E2;
    --info:          #0284C7;
    --info-soft:     #E0F2FE;

    --brand-logo-bg: linear-gradient(135deg, #059669 0%, #047857 100%);
    --checkout-bg:   var(--checkout-bg);
--checkout:#000;--checkoutbg:     #cf0;
    --shadow-sm: 0 1px 2px rgba(15,46,27,.06), 0 1px 1px rgba(15,46,27,.04);
    --shadow:    0 4px 14px rgba(15,46,27,.10), 0 2px 6px rgba(15,46,27,.06);
    --shadow-lg: 0 14px 40px rgba(15,46,27,.18), 0 6px 18px rgba(15,46,27,.10);
}

/* Backwards-compat: keep the old :root variable aliases working (they now
   point to the theme-aware variables above). All rules below use these
   variable names, so they automatically pick up the active theme. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
input:focus, button:focus { outline: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ===== App layout ===== */
.app {
    display: grid;
    grid-template-rows: 64px 1fr;
    height: 100vh;
}

/* ===== Top bar ===== */
.topbar {
    display: grid;
    grid-template-columns: 320px 1fr 360px;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    padding: 0 24px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand-logo-bg);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand-text h1 {
    font-family: var(--font-head);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--primary);
    letter-spacing: -0.01em;
}
.brand-text .tagline {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Scan/search bar */
.scanbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-soft);
    border: 1.5px solid transparent;
    border-radius: 12px;
    padding: 0 14px;
    height: 44px;
    max-width: 640px;
    margin: 0 auto;
    transition: var(--transition);
}
.scanbar:focus-within {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.scanbar .icon {
    color: var(--accent);
    font-size: 18px;
    display: flex;
    align-items: center;
}
.scanbar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text);
    padding: 0 4px;
}
.scanbar input::placeholder { color: var(--text-faint); }
.scanbar .hint {
    font-size: 11px;
    color: var(--text-faint);
    background: var(--surface);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--line);
    font-family: var(--font-mono);
}

.status-strip {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-end;
}
.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--success-soft);
    color: var(--success);
    font-size: 12px;
    font-weight: 600;
}
.status-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 50%, transparent);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 50%, transparent); }
    70%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--success) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 0%, transparent); }
}

/* ===== Theme switcher (palette swatches) ===== */
.theme-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: var(--bg-soft);
    border-radius: 20px;
    border: 1px solid var(--line);
}
.theme-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--line);
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.theme-swatch:hover {
    transform: scale(1.1);
    border-color: var(--text-faint);
}
.theme-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
.theme-swatch[data-t="bakery"] {
    background: linear-gradient(135deg, #FBF7F0 0%, #FBF7F0 50%, #E07A2A 50%, #E07A2A 100%);
}
.theme-swatch[data-t="dark"] {
    background: linear-gradient(135deg, #0F1419 0%, #0F1419 50%, #2DD4BF 50%, #2DD4BF 100%);
}
.theme-swatch[data-t="mint"] {
    background: linear-gradient(135deg, #F0FAF3 0%, #F0FAF3 50%, #059669 50%, #059669 100%);
}
.theme-swatch .check {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.theme-swatch.active .check { display: grid; }

.clock {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Main: catalog area ===== */
.main {
    display: grid;
    grid-template-columns: 1fr 480px;
    overflow: hidden;
    min-height: 0;
}

.catalog {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.cat-tabs {
    display: flex;
    gap: 8px;
    padding: 18px 24px 12px;
    overflow-x: auto;
    background: linear-gradient(180deg, var(--bg) 0%, rgba(251,247,240,0) 100%);
    border-bottom: 1px solid var(--line-soft);
}
.cat-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--line);
    white-space: nowrap;
    transition: var(--transition);
}
.cat-tab:hover {
    border-color: var(--text-faint);
    color: var(--text);
    transform: translateY(-1px);
}
.cat-tab.active {
    background: var(--primary);
    color: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 22%, transparent);
}
.cat-tab .emoji { font-size: 16px; }
.cat-tab .count {
    font-size: 11px;
    background: rgba(0,0,0,.08);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 2px;
}
.cat-tab.active .count {
    background: rgba(255,255,255,.18);
}

/* Search & result header */
.catalog-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 16px 24px 4px;
}
.catalog-head h2 {
    font-family: var(--font-head);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--primary);
}
.catalog-head .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}
.catalog-head .result-meta {
    font-size: 13px;
    color: var(--text-muted);
}

/* Product grid — using flexbox wrap instead of CSS grid.
   Flexbox gives each card its natural content height with no row-size
   negotiation, so cards in the same row never overlap cards in the
   next row regardless of how long product names are. */
.product-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px 24px 32px;
    overflow-y: auto;
    align-items: flex-start;   /* each card keeps its natural height */
    align-content: flex-start; /* pack rows from the top */
    flex: 1;
    min-height: 0;
}
/* Each card takes a flexible basis of (170px - gap-share) and grows to fill the row.
   calc(): 170px min, 1fr-equivalent grow. */
.product-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
    /* Flex item sizing: start at 170px and grow to fill available row width.
       This guarantees the card is never narrower than 170px and never
       narrower than its content needs. */
    flex: 1 1 170px;
    min-width: 0;
    max-width: 240px;
    /* Card content stays inside the card at every breakpoint:
       Long names are clamped to 2 lines so a single long word never breaks
       the layout. */
    /* NO min-height: 0 — that would collapse the flex-column card. */
    /* NO contain: layout — it can interact badly with grid sizing. */
}
.product-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, transparent) 0%, color-mix(in srgb, var(--accent) 0%, transparent) 60%);
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}
.product-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}
.product-card:hover::before { opacity: 1; }
.product-card:active { transform: translateY(-1px) scale(.99); }

/* Product card media (image with emoji fallback) */
.pc-media {
    line-height: 1;
    height: 130px;
    display: grid;
    place-items: center;
    background: var(--bg-soft);
    border-radius: 10px;
    margin-bottom: 2px;
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
}
.pc-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 280ms ease;
}
.product-card:hover .pc-img { transform: scale(1.06); }
.pc-emoji-fallback {
    /* shown when image fails to load or while loading */
    font-size: 38px;
    line-height: 1;
}
.pc-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    /* Clamp to exactly 2 lines so a long product name always fits.
       The card row will grow to accommodate the 2-line name; if it's
       shorter, the card simply has a smaller height. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 32px;     /* reserves space for 2 lines even when name is short */
    word-break: break-word;
    overflow-wrap: anywhere;
}
.pc-unit {
    font-size: 11px;
    color: var(--text-faint);
    /* clamp to a single line so the unit never wraps awkwardly */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 auto;
}
.pc-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 6px;
    flex: 0 0 auto;
    gap: 6px;
}
.pc-price {
    font-family: var(--font-head);
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.pc-price .cur { font-size: 11px; color: var(--text-muted); margin-left: 1px; }
.pc-vat {
    font-size: 10px;
    color: var(--text-faint);
    background: var(--bg-soft);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
    flex: 0 0 auto;
}
.pc-add {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 600;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--accent) 35%, transparent);
    transition: var(--transition);
    opacity: 0;
}
.product-card:hover .pc-add { opacity: 1; }
.pc-add:hover { background: var(--accent-hover); transform: scale(1.1); }

/* Badge for in-cart quantity */
.pc-cart-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--success);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--success) 40%, transparent);
    animation: pop 280ms cubic-bezier(.34, 1.56, .64, 1);
z-index:12;
}
@keyframes pop {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Empty state */
.empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}
.empty .big { font-size: 56px; margin-bottom: 12px; }
.empty h3 { font-size: 17px; color: var(--text-muted); margin-bottom: 4px; }
.empty p { font-size: 13px; }

/* ===== Cart panel ===== */
.cart {
    background: var(--surface);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    box-shadow: -4px 0 24px color-mix(in srgb, var(--primary) 4%, transparent);
}
.cart-head {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.cart-head h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-head);
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}
.cart-head .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cart-clear {
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.cart-clear:hover { color: var(--accent-hover); }

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px;
    min-height: 0;
}
/* On mobile, give the items list at least enough room to scroll a few items */
@media (max-width: 820px) {
    .cart-items { min-height: 120px; padding: 6px 10px; }
}

.cart-empty {
    text-align: center;
    padding: 60px 20px 30px;
    color: var(--text-faint);
}
.cart-empty .big {
    font-size: 64px;
    margin-bottom: 12px;
    filter: grayscale(.3);
    opacity: .5;
}
.cart-empty h3 {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.cart-empty p {
    font-size: 12px;
}

.cart-item {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 8px;
    border-bottom: 1px solid var(--line-soft);
    transition: var(--transition);
}
.cart-item:hover { background: var(--bg-soft); border-radius: 8px; }
.ci-media {
    width: 48px;
    height: 48px;
    background: var(--bg-soft);
    border-radius: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
}
.ci-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ci-emoji-fallback {
    font-size: 24px;
    line-height: 1;
}
.ci-info {
    min-width: 0;
}
.ci-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ci-meta {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
    display: flex;
    gap: 6px;
    align-items: center;
}
.ci-meta .vat { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; }

.ci-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.ci-line {
    font-family: var(--font-head);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}
.ci-line .cur { font-size: 11px; color: var(--text-muted); }

.qty-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-soft);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--line-soft);
}
.qty-stepper button {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
    display: grid;
    place-items: center;
    transition: var(--transition);
}
.qty-stepper button:hover {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.qty-stepper button.del {
    color: var(--danger);
    margin-right: 2px;
}
.qty-stepper .qty {
    min-width: 28px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
}

/* Highlight the most recently added cart item so the user can see it land.
   Uses a left accent stripe + soft amber wash that fades out. */
.cart-item--just-added {
    background: var(--accent-soft);
    border-radius: 10px;
    box-shadow: inset 4px 0 0 var(--accent);
    animation: justAdded 1.4s ease-out;
}
@keyframes justAdded {
    0%   { background: color-mix(in srgb, var(--accent) 28%, transparent); transform: translateX(-2px); }
    25%  { background: var(--accent-soft); transform: translateX(0); }
    100% { background: var(--accent-soft); }
}

/* Cart footer */
.cart-foot {
    border-top: 1px solid var(--line);
    padding: 16px 20px 20px;
    background: var(--surface-2);
}
.totals {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    color: var(--text-muted);
}
.total-row.muted { font-size: 12px; color: var(--text-faint); }
.total-row .label { font-weight: 500; }
.total-row .val { font-family: var(--font-mono); font-weight: 500; color: var(--text); }
.total-row.grand {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    font-size: 16px;
    color: var(--text);
}
.total-row.grand .label { font-weight: 700; font-family: var(--font-head); }
.total-row.grand .val {
    font-family: var(--font-head);
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}
.total-row.grand .val .cur { font-size: 14px; color: var(--text-muted); margin-right: 2px; }

.checkout-btn {
    width: 100%;
    margin-top: 16px;
    padding: 16px;
    background: var(--checkoutbg);
    color: var(--checkout);
    border-radius: 14px;
    font-family: var(--font-head);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 35%, transparent);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
height:100px;
}
.checkout-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 45%, transparent);
}
.checkout-btn:active:not(:disabled) { transform: translateY(0); }
.checkout-btn:disabled {
    background: var(--line);
    color: var(--text-faint);
    box-shadow: none;
    cursor: not-allowed;
}

/* ===== Modal: payment ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--primary) 55%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    animation: fadein 220ms ease;
}
.modal-overlay.show { display: flex; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slidein 280ms cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes slidein {
    from { transform: translateY(20px) scale(.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-head {
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-head h2 {
    font-family: var(--font-head);
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}
.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 22px;
    color: var(--text-muted);
    transition: var(--transition);
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }

.modal-body {
    padding: 22px 28px;
    overflow-y: auto;
}

.modal-foot {
    padding: 16px 28px 24px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
}

/* Receipt auto-close countdown bar.
   A thin progress bar at the top of the modal-foot that drains over 8s.
   When it reaches zero, the modal closes and a new order begins. */
.modal-foot.receipt-countdown::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    transform-origin: left center;
    animation: countdown-drain 8s linear forwards;
}
@keyframes countdown-drain {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}
.modal-foot.receipt-countdown.paused::before {
    animation-play-state: paused;
}
/* Subtle hint label that flashes next to the OK button */
.modal-foot.receipt-countdown .countdown-hint {
    color: var(--text-muted);
    font-size: 12px;
    align-self: center;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-foot.receipt-countdown .countdown-hint .num {
    color: var(--accent);
    font-weight: 700;
    font-family: var(--font-mono);
    min-width: 1.2em;
    text-align: right;
}
.btn {
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--line); color: var(--text-faint); box-shadow: none; cursor: not-allowed; transform: none; }
.btn-ghost {
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--line-soft); }
.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--success) 30%, transparent);
}
.btn-success:hover { background: #247a3c; transform: translateY(-1px); }

/* Payment amount summary */
.pay-summary {
    background: var(--bg-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
    text-align: center;
}
.pay-summary .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.pay-summary .amount {
    font-family: var(--font-head);
    font-size: 40px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
    margin-top: 4px;
}
.pay-summary .amount .cur { font-size: 18px; color: var(--text-muted); margin-right: 4px; }

/* Payment method tabs */
.pay-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.pay-method {
    padding: 16px 10px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    transition: var(--transition);
}
.pay-method:hover { border-color: var(--text-faint); transform: translateY(-1px); }
.pay-method.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.pay-method .icon { font-size: 26px; margin-bottom: 4px; }
.pay-method .name { font-size: 13px; font-weight: 600; color: var(--text); }

/* Cash quick amount buttons */
.quick-cash {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.quick-cash button {
    padding: 12px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    transition: var(--transition);
}
.quick-cash button:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.cash-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-soft);
    border-radius: 12px;
    padding: 0 16px;
    border: 1.5px solid transparent;
    transition: var(--transition);
}
.cash-input-wrap:focus-within {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.cash-input-wrap .sym {
    font-size: 18px;
    color: var(--text-muted);
    font-weight: 600;
}
.cash-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}
.cash-change {
    margin-top: 14px;
    padding: 12px 16px;
    background: var(--success-soft);
    border-radius: 10px;
    color: var(--success);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cash-change.insufficient {
    background: var(--danger-soft);
    color: var(--danger);
}
.cash-change .val {
    font-family: var(--font-head);
    font-size: 20px;
    font-weight: 800;
}

/* ===== Card terminal simulation ===== */
.card-terminal {
    background: linear-gradient(180deg, #1F2937 0%, #111827 100%);
    border-radius: var(--radius);
    padding: 22px 20px 18px;
    color: #E5E7EB;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.08),
        0 6px 18px rgba(0,0,0,.18);
}
.ct-screen {
    background: #0B1220;
    border: 1px solid #1F2937;
    border-radius: 10px;
    padding: 18px 16px;
    text-align: center;
    color: #D1FAE5;  /* classic terminal-green tint */
    font-family: var(--font-mono);
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.ct-icon { font-size: 38px; line-height: 1; margin-bottom: 4px; }
.ct-title {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    color: #F9FAFB;
    letter-spacing: -0.01em;
}
.ct-sub { font-size: 12px; color: #9CA3AF; }
.ct-amount {
    font-family: var(--font-head);
    font-size: 26px;
    font-weight: 800;
    color: #FDE68A;
    letter-spacing: -0.02em;
    margin-top: 6px;
}
.ct-amount-sm {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    color: #FDE68A;
}
.ct-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 12px;
    color: #9CA3AF;
    padding: 2px 4px;
}
.ct-row .ct-label { color: #9CA3AF; }
.ct-row .ct-pan { font-family: var(--font-mono); color: #D1D5DB; letter-spacing: .03em; }
.ct-hint {
    text-align: center;
    color: #6B7280;
    font-size: 11px;
    margin-top: 10px;
}

/* PIN dots */
.pin-dots {
    display: flex;
    gap: 10px;
    margin: 10px 0 4px;
}
.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #374151;
    border: 1px solid #4B5563;
    transition: var(--transition);
}
.pin-dot.filled {
    background: #FDE68A;
    border-color: #FDE68A;
    box-shadow: 0 0 8px rgba(253,230,138,.55);
    animation: pinPop 200ms cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes pinPop {
    0%   { transform: scale(.5); }
    60%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* PIN pad — 4 columns × 3 rows: 1-9, C, 0, ⌫ */
.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}
.pin-key {
    height: 46px;
    border-radius: 10px;
    background: #1F2937;
    color: #F9FAFB;
    font-family: var(--font-head);
    font-size: 18px;
    font-weight: 700;
    border: 1px solid #374151;
    transition: var(--transition);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.pin-key:hover {
    background: #374151;
    border-color: #4B5563;
    transform: translateY(-1px);
}
.pin-key:active { transform: translateY(0) scale(.96); }

/* Larger spinner used inside card terminal */
.spinner-lg {
    width: 36px;
    height: 36px;
    border: 3.5px solid rgba(253,230,138,.18);
    border-top-color: #FDE68A;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}

/* ===== Receipt ===== */
.receipt {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    margin: 0;
    border: 1px dashed var(--line);
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--primary);
}
.receipt-head {
    text-align: center;
    border-bottom: 1px dashed var(--line);
    padding-bottom: 16px;
    margin-bottom: 14px;
}
.receipt-head .store {
    font-family: var(--font-head);
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}
.receipt-head .tagline {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.receipt-head .addr {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}
.receipt-head .meta {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.receipt-items {
    border-bottom: 1px dashed var(--line);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.receipt-item {
    display: grid;
    grid-template-columns: 26px 1fr auto;
    gap: 6px;
    padding: 4px 0;
    align-items: baseline;
}
.receipt-item .qty { color: var(--text-muted); font-size: 12px; }
.receipt-item .name {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.receipt-item .total { font-weight: 600; color: var(--primary); }
.receipt-item .unit-price {
    grid-column: 2 / 3;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: -2px;
}

.receipt-totals { padding: 0 0 12px; border-bottom: 1px dashed var(--line); margin-bottom: 12px; }
.receipt-totals .row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 12px;
    color: var(--text-muted);
}
.receipt-totals .row.grand {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: 15px;
    color: var(--primary);
    font-weight: 700;
}

.receipt-vat { padding-bottom: 12px; border-bottom: 1px dashed var(--line); margin-bottom: 12px; }
.receipt-vat .row {
    display: grid;
    grid-template-columns: 50px 1fr 1fr 1fr;
    gap: 6px;
    padding: 2px 0;
    font-size: 11px;
    color: var(--text-muted);
}
.receipt-vat .head {
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 4px;
    padding-bottom: 4px;
}

.receipt-foot {
    text-align: center;
    padding-top: 6px;
}
.receipt-foot .thanks {
    font-family: var(--font-head);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}
.receipt-foot .sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.receipt-payment {
    margin: 12px 0;
    padding: 10px 12px;
    background: var(--bg-soft);
    border-radius: 8px;
}
.receipt-payment .row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text);
    padding: 2px 0;
}
.receipt-payment .row .val { font-weight: 700; color: var(--primary); }
.receipt-payment .row.change .val { color: var(--success); }

/* Scan animation flash */
.scan-flash {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--success) 18%, transparent), transparent);
    pointer-events: none;
    z-index: 90;
    opacity: 0;
    transition: opacity 120ms ease;
}
.scan-flash.show { opacity: 1; }

/* Toast */
.toast-wrap {
    position: fixed;
    top: 80px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 110;
    pointer-events: none;
}
.toast {
    background: var(--primary);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    animation: toastin 240ms cubic-bezier(.34, 1.56, .64, 1);
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast .emoji  { font-size: 18px; }
.toast.fade { animation: toastout 220ms ease forwards; }
@keyframes toastin  { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastout { to   { transform: translateX(40px); opacity: 0; } }

/* Loading spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 1100px) {
    .topbar { grid-template-columns: 260px 1fr 280px; }
    .main  { grid-template-columns: 1fr 340px; }
    /* Slightly smaller card basis on laptop */
    .product-card { flex-basis: 160px; }
    .pc-media { height: 110px; }
    .pc-emoji-fallback { font-size: 32px; }
    .pc-name  { font-size: 12px; }
    .pc-price { font-size: 16px; }
}
@media (max-width: 820px) {
    .topbar { grid-template-columns: 1fr; padding: 10px 14px; gap: 8px; height: auto; }
    .app { grid-template-rows: auto 1fr; }
    .main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .cart {
        border-left: none;
        border-top: 1px solid var(--line);
        max-height: 45vh;
        min-height: 240px;
    }
    /* On phones: smaller card basis so 2 cards fit per row comfortably */
    .product-grid { gap: 10px; padding: 12px 14px 24px; }
    .product-card { flex: 1 1 130px; padding: 10px; gap: 5px; max-width: 200px; }
    .pc-media { height: 100px; }
    .pc-emoji-fallback { font-size: 30px; }
    .pc-name  { font-size: 12px; min-height: 28px; }
    .pc-price { font-size: 15px; }
    .pc-add   { width: 28px; height: 28px; font-size: 16px; }
    /* On phones, keep the theme switcher visible but hide clock + status pill to save space */
    .status-strip { gap: 8px; }
    .status-strip .clock,
    .status-strip .status-pill { display: none; }
    /* Compact cart foot on mobile so items get more vertical room */
    .cart-foot { padding: 10px 14px 14px; }
    .totals { gap: 3px; }
    .total-row { font-size: 12px; }
    .total-row.grand { font-size: 14px; }
    .total-row.grand .val { font-size: 20px; }
    .checkout-btn { margin-top: 10px; padding: 13px; font-size: 14px; }
}
