:root {
    /* --- Color Palette --- */
    --bg: #f4f7fb;
    --primary: #1e1b4b;
    /* Deep Indigo */
    --accent: #4f46e5;
    /* Vibrant Indigo */
    --success: #10b981;
    /* Emerald Green */
    --danger: #ef4444;
    /* Rose Red */
    --warning: #f59e0b;
    /* Amber Gold */
    --text: #0f172a;
    /* Slate Black */
    --text-light: #64748b;
    /* Slate Gray */
    --card-bg: #ffffff;

    /* --- Design Tokens --- */
    --radius: 24px;
    --radius-sm: 12px;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(30, 27, 75, 0.1);
}

/* --- Global Reset & Base Styles --- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    line-height: 1.5;
}

/* --- Header: Mobile Sticky Header --- */
header {
    background: var(--card-bg);
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 100;
    flex-shrink: 0;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-text h1 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1;
}

.brand-text p {
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 4px;
}

/* --- Navigation: Fixed Bottom Bar --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
    z-index: 1000;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--text-light);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    padding: 10px 5px;
    border-radius: 16px;
}

.nav-tab i {
    font-size: 1.6rem;
    transition: 0.2s;
}

.nav-tab.active {
    color: var(--accent);
    background: rgba(79, 70, 229, 0.05);
}

.nav-tab.active i {
    transform: translateY(-2px);
}

/* --- Main Content Layout --- */
main {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    padding-bottom: 120px;
    /* Space for Nav + FAB */
    -webkit-overflow-scrolling: touch;
}

.view {
    display: none;
    animation: viewEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.view.active {
    display: block;
}

@keyframes viewEnter {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- UI Building Blocks --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.glass-stat {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 2.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(30, 27, 75, 0.25);
}

.glass-stat i {
    position: absolute;
    right: -20px;
    bottom: -20px;
    font-size: 8rem;
    opacity: 0.12;
    transform: rotate(-15deg);
}

/* GLASS CSS SNIPPET */

.staff-glass-card {
    padding: 20px;
    border-radius: 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
    z-index: 1;

    /* THE SIGNATURE 7-LAYER SHADOW STACK */
    box-shadow:
        0 0 .3rem #0000003a,
        5px 5px .5rem #ffffffe6,
        5px 5px .6rem #0000003a,
        inset 1px 1px #fff,
        inset -1px -1px #fff,
        inset 4px 4px .2rem #00000010,
        inset 0 0 .0rem #a6adb3;
}

.h-main-label {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: normal;
}

.h-main-val {
    font-size: 2.8rem;
    font-weight: 900;
    line-height: normal;
}

.h-label {
    font-size: 0.75rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    text-align: center;
}

.h-val {
    font-size: 1.6rem;
    text-align: center;
    font-weight: 900;
    margin-top: 8px;
    letter-spacing: -1.5px;
}

.target-tag {
    font-size: .7em;
    text-align: center;
}

/* Updated List Item Styles for User Request */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.list-item:active {
    background: #f8fafc;
}

.list-item:last-child {
    border: none;
}

.item-info {
    flex: 1;
}

.item-info p {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.2;
}

.item-info .sub-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
}

.item-info .stock-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.bg-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.bg-ok {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.item-meta {
    text-align: right;
    margin-left: 15px;
}

.item-meta .price {
    font-weight: 900;
    color: var(--primary);
    font-size: 1.15rem;
    display: block;
}

.item-meta .time {
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 600;
    margin-top: 4px;
}

/* --- POS Grid System --- */
.category-scroll {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding: 5px 0 15px 0;
    margin-bottom: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.chip {
    background: var(--card-bg);
    padding: 10px 18px;
    border-radius: 25px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
    cursor: pointer;
    transition: 0.2s;
}

.chip.active {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.2);
}

.grid-pos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 14px;
}

.product-tile {
    background: var(--card-bg);
    padding: 1.6rem 1rem;
    border-radius: 22px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 2px solid transparent;
}

.product-tile:active {
    transform: scale(0.94);
}

.product-tile i {
    font-size: 2.2rem;
    color: var(--accent);
    display: block;
    margin-bottom: 12px;
}

.product-tile h4 {
    font-size: 0.85rem;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.3;
    min-height: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-tile .p-price {
    color: var(--success);
    font-weight: 900;
    font-size: 1.2rem;
}

.product-tile .p-stock {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 8px;
    font-weight: 700;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.tile-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: 900;
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
    z-index: 10;
}

/* Base Shared Styles for all FABs */
.fab-cart,
.fab-add {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 68px;
    height: 68px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(30, 27, 75, 0.3);
    z-index: 1000;
    /* Increased to ensure it stays above everything */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    &:hover {
        transform: scale(1.1);
        background: #2d2a6e;
    }

    &:active {
        transform: scale(0.85) rotate(-10deg);
    }

    /* Target the icon inside specifically */
    i {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Specific styling for the Cart FAB to handle the counter badge */
.fab-cart {
    .cart-count {
        position: absolute;
        top: 0;
        right: 0;
        background: var(--danger);
        width: 24px;
        height: 24px;
        border-radius: 50%;
        /* Changed to 50% for consistency */
        font-size: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 900;
        border: 3px solid var(--card-bg);
        /* Ensure the count doesn't move when the button rotates */
        transform: rotate(0deg);
    }
}

/* Specific styling for the Add FAB (if you want a different color, change it here) */
.fab-add {
    display: none;
    /* Controlled by your switchView JS */

    /* Ensure the plus icon is perfectly centered */
    i {
        font-size: 2.2rem;
    }
}

/* --- Modals & Interaction Layers --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: flex-end;
    padding: 10px;
}

.sheet {
    background: white;
    width: 100%;
    max-width: 550px;
    border-radius: 32px 32px 20px 20px;
    padding: 2.2rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* --- Form Elements --- */
label.h-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-light);
    font-size: 0.7rem;
}

input,
select {
    width: 100%;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    padding: 18px;
    border-radius: 18px;
    margin-bottom: 22px;
    font-size: 16px;
    font-weight: 600;
    outline: none;
    transition: 0.2s;
    appearance: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.btn {
    width: 100%;
    padding: 20px;
    border-radius: 22px;
    border: none;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
}

.btn-primary:active {
    transform: scale(0.97);
    filter: brightness(1.1);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.25);
}

.btn-success:active {
    transform: scale(0.97);
}

.btn-outline {
    background: #f1f5f9;
    color: var(--text-light);
    margin-top: 12px;
}

.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-box i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.3rem;
}

.search-box input {
    margin: 0;
    padding-left: 52px;
    border-radius: 22px;
    background: white;
    box-shadow: var(--shadow);
    border: none;
    height: 60px;
}

/* --- Utilities --- */
.text-red {
    color: var(--danger);
}

.text-green {
    color: var(--success);
}

.text-amber {
    color: var(--warning);
}

/* --- Desktop Viewport Handling --- */
@media (min-width: 1024px) {
    body {
        flex-direction: row;
    }

    header {
        display: none;
    }

    .bottom-nav {
        width: 110px;
        height: 100vh;
        flex-direction: column;
        justify-content: center;
        gap: 30px;
        position: static;
        border-top: none;
        border-right: 1px solid rgba(0, 0, 0, 0.05);
        padding: 0;
    }

    .nav-tab {
        flex: 0;
        width: 80px;
        height: 80px;
        justify-content: center;
        align-self: center;
    }

    .nav-tab span {
        font-size: 0.6rem;
    }

    .fab-cart {
        right: 50px;
        bottom: 50px;
        width: 85px;
        height: 85px;
        font-size: 2.4rem;
    }

    main {
        padding: 4rem;
        max-width: 1300px;
        margin: 0 auto;
    }

    .sheet {
        border-radius: 35px;
        margin-bottom: 0;
        max-height: 85vh;
        width: 500px;
    }

    .overlay {
        align-items: center;
    }

    .grid-pos {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 20px;
    }
}