:root {
    --app-bg: #f3f5f9;
    --card-bg: #ffffff;
    --brand: #0d6efd;
    --brand-dark: #0a58ca;
    --text: #1f2937;
    --muted: #6b7280;
    --sidebar-bg: #111827;
    --sidebar-text: #d1d5db;
    --sidebar-active: #2563eb;
    --danger: #dc3545;
    --success: #198754;
    --radius: 14px;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--app-bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.touch-btn {
    min-height: 50px;
    font-weight: 600;
    border-radius: 12px;
}

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(145deg, #edf2ff 0%, #f8fbff 55%, #e5f0ff 100%);
}

.auth-wrapper {
    width: 100%;
    max-width: 460px;
}

.auth-card {
    background: #fff;
    border-radius: 22px;
    padding: 26px;
    box-shadow: 0 22px 45px rgba(2, 6, 23, 0.08);
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    margin-bottom: 20px;
    padding: 0 10px;
}

.brand-dot {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: #3b82f6;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    text-decoration: none;
    color: var(--sidebar-text);
    padding: 12px 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px;
}

.app-main {
    flex: 1;
    padding: 22px;
    overflow-x: auto;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.app-topbar h1 {
    font-size: 1.35rem;
    margin: 0;
    font-weight: 700;
}

.panel {
    background: var(--card-bg);
    border: 1px solid #edf0f4;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
}

.panel-body {
    padding: 18px;
}

.stat-card {
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 16px;
    height: 100%;
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.88rem;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.table > :not(caption) > * > * {
    padding: 0.85rem 0.7rem;
}

/* POS Screen */
.pos-body {
    --pos-bg-top: #fff1f8;
    --pos-bg-bottom: #ffe4f1;
    --pos-card: rgba(255, 255, 255, 0.88);
    --pos-card-strong: #fff8fc;
    --pos-border: rgba(225, 94, 153, 0.18);
    --pos-shadow: 0 20px 60px rgba(152, 44, 105, 0.14);
    --pos-primary: #e64696;
    --pos-primary-dark: #bf2f76;
    --pos-secondary: #fff0f7;
    --pos-text: #4f1834;
    --pos-muted: #95647d;
    height: 100vh;
    overflow: hidden;
    background:
            radial-gradient(circle at top left, rgba(255, 255, 255, 0.8) 0, rgba(255, 255, 255, 0) 34%),
            radial-gradient(circle at top right, rgba(255, 192, 227, 0.42) 0, rgba(255, 192, 227, 0) 28%),
            linear-gradient(180deg, var(--pos-bg-top) 0%, var(--pos-bg-bottom) 100%);
    color: var(--pos-text);
}

.pos-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    isolation: isolate;
}

.pos-shell::before,
.pos-shell::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(6px);
    z-index: -1;
}

.pos-shell::before {
    width: 300px;
    height: 300px;
    top: 32px;
    right: -100px;
    background: rgba(255, 181, 216, 0.28);
}

.pos-shell::after {
    width: 220px;
    height: 220px;
    left: -70px;
    bottom: 60px;
    background: rgba(255, 210, 231, 0.4);
}

.pos-topbar {
    margin: 12px 12px 0;
    padding: 16px 18px 14px;
    border: 1px solid var(--pos-border);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--pos-shadow);
    backdrop-filter: blur(16px);
}

.pos-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.pos-heading-card {
    max-width: 680px;
}

.pos-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 14px;
    margin-bottom: 10px;
    border-radius: 999px;
    background: rgba(230, 70, 150, 0.1);
    color: var(--pos-primary-dark);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pos-title h1 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--pos-text);
}

.pos-subtitle {
    margin-top: 6px;
    color: var(--pos-muted);
    font-size: 0.96rem;
}

.pos-action-group {
    flex-wrap: wrap;
    justify-content: flex-end;
}

#syncNowBtn {
    min-height: 38px;
    border-radius: 10px;
    font-weight: 600;
    border-color: rgba(230, 70, 150, 0.22);
    color: var(--pos-primary-dark);
    background: rgba(255, 240, 247, 0.92);
}

#syncStatusText {
    font-size: 0.78rem;
    color: var(--pos-muted) !important;
}

.pos-body .badge.text-bg-success {
    background: linear-gradient(135deg, #f06bb0 0%, #d63585 100%) !important;
    color: #fff !important;
}

.pos-body .badge.text-bg-warning {
    background: linear-gradient(135deg, #ffcb75 0%, #f59e0b 100%) !important;
    color: #663405 !important;
}

.pos-body .badge.text-bg-primary {
    background: rgba(230, 70, 150, 0.16) !important;
    color: var(--pos-primary-dark) !important;
}

#mobileCartBtn,
#mobileCartFab {
    border-color: rgba(230, 70, 150, 0.22);
    background: rgba(255, 248, 252, 0.95);
    color: var(--pos-primary-dark);
}

#mobileCartBtn .badge,
#mobileCartFab .badge {
    background: var(--pos-primary);
    color: #fff;
}

.mobile-cart-total {
    display: block;
    font-size: 0.78rem;
    color: var(--pos-muted);
    margin-top: 2px;
}

.pos-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 14px;
    padding: 12px;
}

.product-panel,
.cart-panel {
    background: var(--pos-card);
    border-radius: 24px;
    border: 1px solid var(--pos-border);
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--pos-shadow);
    backdrop-filter: blur(18px);
}

.product-list {
    padding: 12px;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    overflow-y: auto;
}

.product-card {
    border: 1px solid rgba(230, 70, 150, 0.14);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 243, 249, 0.96) 100%);
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 165px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.product-card:active {
    transform: scale(0.98);
}

.product-card:hover {
    border-color: rgba(230, 70, 150, 0.3);
    box-shadow: 0 18px 30px rgba(196, 53, 126, 0.14);
}

.product-card img {
    width: 100%;
    height: 92px;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 10px;
}

.product-name {
    font-weight: 700;
    font-size: 0.94rem;
    line-height: 1.2;
    color: var(--pos-text);
}

.product-price {
    margin-top: auto;
    color: var(--pos-primary-dark);
    font-weight: 800;
}

.cart-items {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

.cart-item {
    border: 1px solid rgba(230, 70, 150, 0.12);
    border-radius: 18px;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 18px rgba(195, 64, 130, 0.08);
}

.qty-controls {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(230, 70, 150, 0.18);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.qty-btn {
    border: 0;
    background: rgba(255, 240, 247, 0.9);
    color: var(--pos-primary-dark);
    min-width: 38px;
    min-height: 38px;
    font-weight: 700;
}

.cart-summary {
    border-top: 1px solid rgba(230, 70, 150, 0.12);
    padding: 14px;
    background: linear-gradient(180deg, rgba(255, 248, 252, 0.95) 0%, rgba(255, 240, 247, 0.96) 100%);
    border-radius: 0 0 24px 24px;
}

.payment-methods .btn {
    min-height: 46px;
    font-weight: 600;
    border-radius: 14px !important;
    border-color: rgba(230, 70, 150, 0.2);
    color: var(--pos-primary-dark);
    background: rgba(255, 255, 255, 0.84);
}

.payment-methods .btn.active,
.payment-methods .btn:active,
.payment-methods .btn:hover {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--pos-primary) 0%, var(--pos-primary-dark) 100%);
}

.pos-body .form-control,
.pos-body .form-select {
    border-color: rgba(230, 70, 150, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--pos-text);
    box-shadow: none;
}

.pos-body .form-control:focus,
.pos-body .form-select:focus {
    border-color: rgba(230, 70, 150, 0.42);
    box-shadow: 0 0 0 0.2rem rgba(230, 70, 150, 0.12);
}

.pos-body .btn-outline-secondary,
.pos-body .btn-outline-danger,
.pos-body .btn-outline-primary {
    border-radius: 14px;
}

.pos-body .btn-outline-secondary {
    border-color: rgba(230, 70, 150, 0.18);
    color: var(--pos-primary-dark);
    background: rgba(255, 250, 252, 0.9);
}

.pos-body .btn-outline-danger {
    border-color: rgba(228, 92, 139, 0.18);
    color: #b92762;
    background: rgba(255, 245, 249, 0.92);
}

.pos-body .btn-success,
.pos-body #checkoutBtn {
    border: 0;
    background: linear-gradient(135deg, #f05ca8 0%, #d52f7f 100%);
    box-shadow: 0 16px 30px rgba(213, 47, 127, 0.26);
}

.cart-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(83, 17, 48, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
    z-index: 1040;
}

.mobile-bottom-bar {
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(230, 70, 150, 0.14);
    background: rgba(255, 248, 252, 0.94);
    backdrop-filter: blur(16px);
    display: flex;
    gap: 10px;
}

.receipt-paper {
    max-width: 700px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    padding: 22px;
}

@media (max-width: 1200px) {
    .app-sidebar {
        width: 220px;
    }
}

@media (max-width: 991.98px) {
    .pos-body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .pos-shell {
        min-height: 100vh;
    }

    .app-layout {
        display: block;
    }

    .app-sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-radius: 0 0 16px 16px;
    }

    .pos-grid {
        grid-template-columns: 1fr;
        overflow: visible;
        padding-bottom: 98px;
    }

    .product-panel {
        min-height: 400px;
    }

    .cart-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        top: 92px;
        bottom: calc(84px + env(safe-area-inset-bottom));
        min-height: 0;
        transform: translateY(calc(100% + 24px));
        opacity: 0;
        pointer-events: none;
        transition: transform 0.28s ease, opacity 0.28s ease;
        z-index: 1045;
    }

    .pos-title {
        flex-wrap: wrap;
    }

    .mobile-bottom-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        padding-left: 12px;
        padding-right: 12px;
    }

    .mobile-cart-open .cart-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-cart-open .cart-panel {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    #mobileCartBtn {
        display: inline-flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        min-width: 148px;
        padding: 10px 14px;
    }

    #mobileCartFab {
        flex: 0 0 auto;
        min-width: 128px;
    }

    #checkoutBtn {
        flex: 1 1 auto;
    }
}

@media (max-width: 640px) {
    .pos-topbar {
        margin: 10px 10px 0;
        padding: 14px;
        border-radius: 20px;
    }

    .pos-title h1 {
        font-size: 1.28rem;
    }

    .pos-subtitle {
        font-size: 0.88rem;
    }

    .product-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .product-card {
        min-height: 156px;
        padding: 10px;
    }

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

    .cart-items {
        padding-bottom: 18px;
    }
}

@media print {
    body {
        background: #fff !important;
    }

    .no-print {
        display: none !important;
    }

    .receipt-paper {
        box-shadow: none !important;
        border: none !important;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
}
