:root {
    --app-primary: #4e73df;
    --app-primary-dark: #2e59d9;
    --app-success: #1cc88a;
    --app-info: #36b9cc;
    --app-warning: #f6c23e;
    --app-danger: #e74a3b;
    --app-bg: #f6f7fb;
    --app-text: #5a5c69;
    --app-heading: #2f3241;
    --app-border: #e8eaf2;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 88px;
    --topbar-height: 72px;
    --shadow-sm: 0 0.15rem 1.35rem rgba(58, 59, 69, 0.08);
    --shadow-md: 0 0.5rem 2rem rgba(58, 59, 69, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
}

button,
a,
input,
select,
textarea {
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

:focus-visible {
    outline: 3px solid rgba(78, 115, 223, 0.25);
    outline-offset: 2px;
}

.card {
    border: 1px solid rgba(232, 234, 242, 0.85);
    border-radius: 0.85rem;
    box-shadow: var(--shadow-sm);
}

.card-header-clean {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--app-border);
    background: #fff;
    border-radius: 0.85rem 0.85rem 0 0 !important;
}

.table > :not(caption) > * > * {
    padding: 0.9rem 1.1rem;
    border-bottom-color: var(--app-border);
    white-space: nowrap;
}

.table thead th {
    color: #858796;
    background: #fafbfe;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark);
    --bs-btn-hover-border-color: var(--app-primary-dark);
    --bs-btn-active-bg: var(--app-primary-dark);
    --bs-btn-active-border-color: var(--app-primary-dark);
}

.form-control,
.form-select,
.input-group-text {
    border-color: #dfe2ea;
}

.form-control:focus,
.form-select:focus {
    border-color: #8da2e8;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.13);
}

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

.sidebar {
    position: static;
    display: flex;
    width: var(--sidebar-width);
    min-height: 100vh;
    align-self: stretch;
    flex-direction: column;
    overflow: visible;
    background: linear-gradient(180deg, #4e73df 0%, #224abe 100%);
    box-shadow: 0.25rem 0 1.5rem rgba(34, 74, 190, 0.14);
    transition: width 0.22s ease, transform 0.22s ease;
    z-index: 1045;
}

.sidebar-brand {
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: #fff;
}

.sidebar-brand:hover {
    color: #fff;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 0.8rem;
    background: #fff;
    color: var(--app-primary);
    font-weight: 800;
    letter-spacing: -0.04em;
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.12);
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.1;
}

.brand-copy strong {
    font-size: 1rem;
    letter-spacing: 0.025em;
}

.brand-copy small {
    margin-top: 0.25rem;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.67rem;
    letter-spacing: 0.035em;
}

.sidebar-divider {
    height: 1px;
    margin: 0 1rem 0.75rem;
    background: rgba(255, 255, 255, 0.14);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.65rem;
}

.sidebar-heading {
    padding: 0.65rem 0.9rem 0.4rem;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 0.65rem;
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-link i {
    width: 22px;
    flex: 0 0 22px;
    font-size: 1.08rem;
    text-align: center;
}

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

.sidebar-link.active {
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.85);
}

.sidebar-footer {
    padding: 0.75rem;
}

.sidebar-collapse {
    width: 100%;
    min-height: 44px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border: 0;
    border-radius: 0.65rem;
    background: rgba(0, 0, 0, 0.1);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.83rem;
}

.sidebar-collapse:hover {
    background: rgba(0, 0, 0, 0.17);
    color: #fff;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-heading {
    display: none;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-collapse {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-link {
    padding-inline: 0.5rem;
}

body.sidebar-collapsed .sidebar-collapse i {
    transform: rotate(180deg);
}

.sidebar-backdrop {
    display: none;
}

.app-main {
    display: flex;
    min-width: 0;
    min-height: 100vh;
    flex-direction: column;
}

.topbar {
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    gap: 0.85rem;
    padding: 0 1rem 0 1.25rem;
    border-bottom: 1px solid rgba(232, 234, 242, 0.9);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 0.12rem 1rem rgba(58, 59, 69, 0.06);
    z-index: 1030;
}

.topbar-title {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-title strong {
    overflow: hidden;
    color: var(--app-heading);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-icon {
    display: inline-grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    border-radius: 50%;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.25rem 0.4rem 0.65rem;
    border: 0;
    border-radius: 0.7rem;
    background: transparent;
}

.user-menu:hover,
.user-menu[aria-expanded="true"] {
    background: #f2f4f8;
}

.user-copy {
    max-width: 190px;
    text-align: right;
    line-height: 1.15;
}

.user-copy strong,
.user-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-copy strong {
    color: var(--app-heading);
    font-size: 0.83rem;
}

.user-copy small {
    margin-top: 0.2rem;
    color: #858796;
    font-size: 0.7rem;
}

.user-avatar {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid #dfe5f6;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--app-primary);
    font-size: 0.8rem;
    font-weight: 800;
}

.page-content {
    flex: 1;
}

.app-footer {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--app-border);
    background: #fff;
    color: #858796;
    font-size: 0.78rem;
}

.page-heading .eyebrow,
.eyebrow {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--app-primary);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--metric-color);
    content: "";
}

.metric-card .card-body {
    padding: 1.2rem 1.25rem 1.15rem 1.35rem;
}

.metric-primary { --metric-color: var(--app-primary); }
.metric-success { --metric-color: var(--app-success); }
.metric-info { --metric-color: var(--app-info); }
.metric-warning { --metric-color: var(--app-warning); }

.metric-icon {
    position: absolute;
    top: 1.1rem;
    right: 1.1rem;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 0.75rem;
    background: color-mix(in srgb, var(--metric-color) 12%, white);
    color: var(--metric-color);
    font-size: 1.1rem;
}

.metric-label {
    margin-bottom: 0.35rem;
    color: var(--metric-color);
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.metric-value {
    padding-right: 3.2rem;
    color: var(--app-heading);
    font-size: clamp(1.25rem, 2vw, 1.55rem);
    font-weight: 800;
}

.metric-meta {
    margin-top: 0.55rem;
    font-size: 0.75rem;
}

.dashboard-chart {
    position: relative;
    height: 325px;
}

.payment-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid #e3e8f8;
    border-radius: 0.75rem;
    background: #f8faff;
}

.payment-total span {
    color: #858796;
    font-size: 0.8rem;
}

.payment-total strong {
    color: var(--app-heading);
    font-size: 1.2rem;
}

.progress-item {
    margin-bottom: 1.35rem;
    font-size: 0.82rem;
}

.progress {
    height: 0.55rem;
    border-radius: 999px;
    background: #edf0f6;
}

.progress-bar {
    border-radius: 999px;
}

.badge-soft-success,
.badge-soft-warning,
.badge-soft-info {
    border-radius: 999px;
    font-weight: 700;
}

.badge-soft-success {
    background: rgba(28, 200, 138, 0.12);
    color: #13855c;
}

.badge-soft-warning {
    background: rgba(246, 194, 62, 0.18);
    color: #9d7600;
}

.badge-soft-info {
    background: rgba(54, 185, 204, 0.13);
    color: #247d8a;
}

.empty-state-icon {
    display: grid;
    width: 84px;
    height: 84px;
    margin: 0 auto 1.25rem;
    place-items: center;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--app-primary);
    font-size: 2rem;
}

/* Cash module */
.cash-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
    gap: 1rem;
    align-items: start;
}

.cash-products,
.cash-cart {
    min-height: 680px;
}

.product-search .input-group-text,
.product-search .form-control {
    min-height: 48px;
}

.cash-categories {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: thin;
}

.cash-categories .btn {
    flex: 0 0 auto;
    border: 1px solid #e0e4ee;
    border-radius: 999px;
    background: #fff;
    color: #6b6f80;
    font-weight: 600;
}

.cash-categories .btn:hover,
.cash-categories .btn.active {
    border-color: var(--app-primary);
    background: var(--app-primary);
    color: #fff;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.85rem;
}

.product-card {
    display: flex;
    min-height: 172px;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    border: 1px solid #e1e5ef;
    border-radius: 0.85rem;
    background: #fff;
    text-align: left;
    box-shadow: 0 0.15rem 0.65rem rgba(58, 59, 69, 0.04);
}

.product-card:hover {
    border-color: #a8b8ee;
    box-shadow: 0 0.55rem 1.35rem rgba(78, 115, 223, 0.12);
    transform: translateY(-2px);
}

.product-card:active {
    transform: translateY(0);
}

.product-icon {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 0.8rem;
    place-items: center;
    border-radius: 0.75rem;
    background: #eef2ff;
    color: var(--app-primary);
    font-size: 1.1rem;
}

.product-name {
    color: var(--app-heading);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.25;
}

.product-category {
    margin-top: 0.2rem;
    color: #9a9cab;
    font-size: 0.68rem;
}

.product-price {
    margin-top: auto;
    padding-top: 0.75rem;
    color: var(--app-primary);
    font-size: 1rem;
    font-weight: 800;
}

.cash-no-results {
    display: flex;
    min-height: 300px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.65rem;
    color: #9a9cab;
}

.cash-no-results i {
    font-size: 2rem;
}

.cash-cart {
    position: sticky;
    top: calc(var(--topbar-height) + 1rem);
    display: flex;
    max-height: calc(100vh - var(--topbar-height) - 2rem);
    flex-direction: column;
}

.cash-cart-body {
    min-height: 180px;
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
}

.cart-empty {
    display: flex;
    min-height: 250px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 2rem 1rem;
    color: #979aa9;
    text-align: center;
}

.cart-empty-icon {
    display: grid;
    width: 68px;
    height: 68px;
    margin-bottom: 1rem;
    place-items: center;
    border-radius: 50%;
    background: #f0f2f7;
    font-size: 1.65rem;
}

.cart-empty strong {
    color: #6f7282;
}

.cart-empty small {
    max-width: 240px;
    margin-top: 0.35rem;
    line-height: 1.45;
}

.cart-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--app-border);
}

.cart-item:last-child {
    border-bottom: 0;
}

.cart-item-name {
    overflow: hidden;
    color: var(--app-heading);
    font-size: 0.85rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    margin-top: 0.18rem;
    color: #8b8e9d;
    font-size: 0.72rem;
}

.cart-item-total {
    color: var(--app-heading);
    font-size: 0.87rem;
    font-weight: 800;
    text-align: right;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.55rem;
}

.cart-quantity {
    min-width: 28px;
    color: var(--app-heading);
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
}

.cart-action {
    display: grid;
    width: 28px;
    height: 28px;
    padding: 0;
    place-items: center;
    border: 1px solid #dfe3ec;
    border-radius: 0.45rem;
    background: #fff;
    color: #656979;
}

.cart-action:hover {
    border-color: #b9c5ee;
    background: #f3f6ff;
    color: var(--app-primary);
}

.cart-remove {
    margin-left: 0.25rem;
    border-color: transparent;
    color: #b9bbc5;
}

.cart-remove:hover {
    border-color: rgba(231, 74, 59, 0.2);
    background: rgba(231, 74, 59, 0.08);
    color: var(--app-danger);
}

.cash-cart-summary {
    padding: 1rem 1.15rem 1.15rem;
    border-top: 1px solid var(--app-border);
    background: #fbfcfe;
    border-radius: 0 0 0.85rem 0.85rem;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.55rem;
    font-size: 0.82rem;
}

.summary-row span {
    color: #858796;
}

.summary-row strong {
    color: var(--app-heading);
}

.summary-divider {
    height: 1px;
    margin: 0.85rem 0;
    background: var(--app-border);
}

.summary-total {
    margin-bottom: 1rem;
}

.summary-total span {
    color: var(--app-heading);
    font-size: 1rem;
    font-weight: 700;
}

.summary-total strong {
    color: var(--app-primary);
    font-size: 1.35rem;
}

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

.payment-method {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.65rem 0.35rem;
    border: 1px solid #dfe3ec;
    border-radius: 0.65rem;
    background: #fff;
    color: #747786;
    font-size: 0.69rem;
    font-weight: 700;
}

.payment-method i {
    font-size: 1.05rem;
}

.payment-method:hover,
.payment-method.active {
    border-color: var(--app-primary);
    background: #eef2ff;
    color: var(--app-primary);
}

.checkout-total-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-radius: 0.75rem;
    background: #eefaf5;
}

.checkout-total-box span {
    color: #5b7368;
    font-size: 0.82rem;
}

.checkout-total-box strong {
    color: #13855c;
    font-size: 1.35rem;
}

/* Login */
.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 15%, rgba(78, 115, 223, 0.14), transparent 30rem),
        radial-gradient(circle at 85% 85%, rgba(54, 185, 204, 0.1), transparent 28rem),
        #f6f7fb;
}

.login-page {
    min-height: calc(100vh - 52px);
    padding: 2rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 2.25rem;
    border: 1px solid rgba(232, 234, 242, 0.92);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-md);
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.3rem;
}

.login-brand-mark {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border-radius: 1rem;
    background: linear-gradient(145deg, var(--app-primary), var(--app-primary-dark));
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    box-shadow: 0 0.75rem 1.5rem rgba(78, 115, 223, 0.24);
}

.login-card .input-group-text {
    color: #8e91a1;
}

.login-card .form-control,
.login-card .input-group-text {
    min-height: 50px;
}

.login-footer {
    min-height: 52px;
    color: #858796;
    font-size: 0.76rem;
    text-align: center;
}

@media (max-width: 1199.98px) {
    .cash-layout {
        grid-template-columns: minmax(0, 1fr) 360px;
    }
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-width) !important;
        height: 100vh;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        transform: translateX(-100%);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar-label,
    body.sidebar-collapsed .sidebar-heading {
        display: initial;
    }

    body.sidebar-collapsed .sidebar-brand,
    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        display: block;
        visibility: hidden;
        border: 0;
        background: rgba(20, 24, 38, 0.42);
        opacity: 0;
        transition: opacity 0.2s ease, visibility 0.2s ease;
        z-index: 1040;
    }

    body.sidebar-open .sidebar-backdrop {
        visibility: visible;
        opacity: 1;
    }

    .cash-layout {
        grid-template-columns: 1fr;
    }

    .cash-products,
    .cash-cart {
        min-height: auto;
    }

    .cash-cart {
        position: static;
        max-height: none;
    }

    .cash-cart-body {
        max-height: 420px;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding-inline: 0.75rem;
    }

    .page-heading .btn {
        width: 100%;
    }

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

    .product-card {
        min-height: 158px;
        padding: 0.85rem;
    }

    .login-card {
        padding: 1.6rem 1.25rem;
    }

    .app-footer {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
