:root {
    --bg: #f4f7fb;
    --bg-accent: #eef4ff;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --surface-dark: #101828;
    --text: #172033;
    --muted: #667085;
    --line: rgba(15, 23, 42, 0.08);
    --line-strong: rgba(15, 23, 42, 0.14);
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.12);
    --success: #16a34a;
    --success-dark: #15803d;
    --danger: #dc2626;
    --warning: #f59e0b;
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 14px 40px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.18);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 26px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-weight: 400;
    background:
        radial-gradient(circle at 8% 10%, rgba(255, 160, 67, 0.22), transparent 28%),
        radial-gradient(circle at 92% 14%, rgba(20, 184, 166, 0.20), transparent 30%),
        radial-gradient(circle at 50% 95%, rgba(37, 99, 235, 0.18), transparent 34%),
        linear-gradient(135deg, #fff7ed 0%, #f0fdfa 40%, #eef2ff 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(120deg, rgba(255,255,255,0.38) 0 1px, transparent 1px 120px),
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.34) 0 2px, transparent 3px),
        radial-gradient(circle at 78% 70%, rgba(255,255,255,0.26) 0 2px, transparent 3px);
    background-size: 120px 120px, 34px 34px, 42px 42px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,0.42), rgba(0,0,0,0.10) 72%, transparent);
    z-index: 0;
}

body > * {
    position: relative;
    z-index: 1;
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input {
    font: inherit;
}

button {
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button.primary-button,
button.secondary-button,
.add-button,
.remove-button,
.viewer-nav,
#to-top-button {
    -webkit-tap-highlight-color: transparent;
}

button.primary-button {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 0.82rem 1.3rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.96rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

button.primary-button:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.32);
}

button.secondary-button {
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
    border: 1px solid rgba(15, 23, 42, 0.08);
    padding: 0.75rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 400;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    margin-right: 0;
}

button.secondary-button:hover {
    background: #fff;
    border-color: rgba(37, 99, 235, 0.18);
}

.hidden {
    display: none !important;
}

#login-container {
    width: min(92vw, 480px);
    margin: 7vh auto;
    padding: 2.25rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

#login-container h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(2rem, 4vw, 2.5rem);
    line-height: 1.05;
}

#login-container p {
    margin: 0 0 1.6rem;
    color: var(--muted);
    font-size: 0.98rem;
}

.form-field {
    margin-bottom: 1rem;
    text-align: left;
}

.form-field label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
    font-weight: 400;
    color: #344054;
}

.form-field input {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(15, 23, 42, 0.10);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.form-field input:focus {
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
    background: #fff;
}

#login-form .primary-button {
    width: 100%;
    margin-top: 0.5rem;
}

#app-container {
    width: min(1400px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

#app-container header {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100px;
    margin-bottom: 1rem;
    padding: 1.15rem 1.4rem;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

#welcome-message {
    margin: 0;
    font-size: clamp(1.3rem, 2.8vw, 2rem);
    font-weight: 400;
    letter-spacing: -0.02em;
}

#categories-page,
#products-page {
    position: relative;
}

.category-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 1rem 0;
}

.category-tile {
    position: relative;
    min-height: 270px;
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 26px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.category-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent 48%, rgba(14, 165, 233, 0.10));
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: -1;
}

.category-tile:hover {
    transform: translateY(-6px);
    border-color: rgba(37, 99, 235, 0.18);
    box-shadow: 0 22px 44px rgba(15, 23, 42, 0.16);
}

.category-tile:hover::before {
    opacity: 1;
}

.category-tile img {
    width: 160px;
    height: 160px;
    object-fit: contain;
    margin-bottom: 1rem;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.12));
}

.category-tile-name {
    font-size: 1.04rem;
    font-weight: 400;
    color: var(--text);
    letter-spacing: -0.01em;
}

.top-buttons {
    position: sticky;
    top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    z-index: 1000;
    margin-bottom: 1rem;
}

#products-category-heading {
    margin: 0 0 1.2rem;
    padding: 1.05rem 1.2rem;
    font-size: clamp(1.2rem, 2.2vw, 1.75rem);
    font-weight: 400;
    color: var(--text);
    letter-spacing: -0.02em;
    background: rgba(255,255,255,0.78);
    border: 1px solid rgba(255,255,255,0.72);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.category-section {
    margin-bottom: 2rem;
}

.category-heading {
    font-size: 1.35rem;
    margin-bottom: 0.9rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(59, 130, 246, 0.02));
    color: var(--primary-dark);
    font-weight: 400;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.2rem;
}

.product-card {
    position: relative;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(255,255,255,0.82);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.55rem;
    min-height: 100%;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: rgba(37, 99, 235, 0.14);
    box-shadow: 0 22px 44px rgba(15, 23, 42, 0.16);
}

.product-card img {
    width: 100%;
    height: 190px;
    object-fit: contain;
    margin-bottom: 0.25rem;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(248,250,252,0.92), rgba(241,245,249,0.82));
    border: 1px solid rgba(15, 23, 42, 0.05);
    padding: 0.85rem;
    cursor: zoom-in;
}

.product-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.product-description {
    font-size: 0.96rem;
    line-height: 1.45;
    color: #344054;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-button {
    margin-top: auto;
    background: linear-gradient(135deg, var(--success) 0%, #22c55e 100%);
    color: #fff;
    border: none;
    width: 100%;
    padding: 0.82rem 1rem;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 400;
    box-shadow: 0 12px 24px rgba(22, 163, 74, 0.22);
}

.add-button:hover {
    background: linear-gradient(135deg, var(--success-dark) 0%, var(--success) 100%);
}

.quantity-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #fbbf24, var(--warning));
    color: #111827;
    border-radius: 999px;
    padding: 0 0.55rem;
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 12px 24px rgba(245, 158, 11, 0.24);
}

#to-top-button {
    position: fixed;
    right: 18px;
    bottom: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 999px;
    min-width: 56px;
    height: 56px;
    padding: 0 16px;
    font-size: 0.94rem;
    font-weight: 400;
    cursor: pointer;
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.28);
    z-index: 1000;
}

#to-top-button:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(2, 6, 23, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 26px;
    padding: 1.2rem;
    width: min(100%, 360px);
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.85);
}

.modal-content h3 {
    margin-top: 0.1rem;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

#numpad-input {
    width: 100%;
    font-size: 1.65rem;
    font-weight: 400;
    text-align: center;
    padding: 0.85rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    margin-bottom: 1rem;
    background: #fff;
    color: var(--text);
}

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.numpad-grid button {
    padding: 1rem;
    font-size: 1.15rem;
    font-weight: 400;
    background: linear-gradient(180deg, #ffffff, #f5f7fb);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    cursor: pointer;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.numpad-grid button:hover {
    background: #fff;
}

.numpad-actions {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.numpad-actions button {
    flex: 1;
    margin: 0;
}

.cart-items {
    max-height: min(48vh, 420px);
    overflow-y: auto;
    margin-bottom: 1rem;
    text-align: left;
    padding-right: 0.2rem;
}

.cart-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.85rem 0.95rem;
    font-size: 0.92rem;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff, #f7f9fc);
}

.cart-item-label {
    flex: 1;
    color: #344054;
}

.remove-button {
    background: linear-gradient(135deg, #ef4444 0%, var(--danger) 100%);
    color: #fff;
    border: none;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 400;
    cursor: pointer;
    margin-left: 0;
}

.remove-button:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

#viewer-modal {
    background: rgba(2, 6, 23, 0.82);
    z-index: 2000;
}

#viewer-modal .viewer-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

#viewer-image {
    max-width: min(94vw, 1080px);
    max-height: 72vh;
    object-fit: contain;
    border-radius: 24px;
    background: rgba(255,255,255,0.04);
}

.viewer-details {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    color: #fff;
    text-align: center;
    font-size: 0.98rem;
    line-height: 1.45;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    max-width: min(90vw, 780px);
}

#viewer-add {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    min-width: 180px;
    z-index: 50;
}

.viewer-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    z-index: 100;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#numpad-modal {
    z-index: 3000;
}

#cart-modal {
    z-index: 2500;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 58px;
    height: 58px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.10);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.viewer-nav:hover {
    background-color: rgba(255, 255, 255, 0.16);
}

.viewer-nav:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.viewer-nav-left {
    left: 1rem;
}

.viewer-nav-right {
    right: 1rem;
}

#viewer-modal,
#viewer-content,
#viewer-image {
    touch-action: none;
}

#viewer-image {
    pointer-events: none;
}

@media (max-width: 900px) {
    #app-container {
        width: min(100vw - 20px, 1400px);
        padding-top: 16px;
    }

    .products-grid,
    .category-tiles {
        gap: 1rem;
    }

    .product-card img {
        height: 170px;
    }
}

@media (max-width: 768px) {
    #login-container {
        margin: 24px auto;
        padding: 1.4rem;
    }

    #app-container header {
        min-height: 84px;
        padding: 1rem;
        border-radius: 20px;
    }

    .top-buttons {
        top: 10px;
        flex-wrap: wrap;
    }

    .category-tiles {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .category-tile {
        min-height: 190px;
        border-radius: 20px;
    }

    .category-tile img {
        width: 92px;
        height: 92px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .product-card {
        border-radius: 20px;
        padding: 0.85rem;
    }

    .product-card img {
        height: 150px;
        border-radius: 16px;
    }

    .viewer-nav {
        width: 46px;
        height: 46px;
        font-size: 1.5rem;
    }

    .viewer-nav-left {
        left: 0.5rem;
    }

    .viewer-nav-right {
        right: 0.5rem;
    }

    #viewer-add {
        bottom: 1rem;
        width: calc(100% - 32px);
        max-width: 360px;
    }
}

@media (max-width: 520px) {
    #app-container {
        width: calc(100vw - 16px);
    }

    .top-buttons {
        justify-content: stretch;
    }

    .top-buttons .secondary-button {
        flex: 1;
    }

    .category-tiles,
    .products-grid {
        grid-template-columns: 1fr 1fr;
    }

    .product-description {
        min-height: 68px;
        font-size: 0.9rem;
    }

    .modal {
        padding: 12px;
    }

    .modal-content {
        border-radius: 20px;
        padding: 1rem;
    }
}
