:root {
    --app-shell-bg: #eef2f6;
    --app-surface: #ffffff;
    --app-border: rgba(15, 23, 42, 0.1);
    --app-sidebar: #111827;
    --app-sidebar-2: #0f172a;
    --app-sidebar-text: #dbeafe;
    --app-muted: #64748b;
    --app-accent: #0ea5e9;
    --app-accent-2: #14b8a6;
    --app-warning: #f59e0b;
    --app-danger: #dc3545;
    --app-success: #198754;
    --app-sidebar-width: 260px;
    --app-topbar-height: 68px;
    --app-sidebar-brand-height: 68px;
    --app-mobilebar-height: 64px;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

body.app-shell-auth {
    background: var(--app-shell-bg);
}

.app-shell {
    min-height: 100vh;
    display: block;
    min-width: 0;
}

.app-shell-container {
    width: 100%;
    max-width: min(100%, 1480px);
    margin: 0 auto;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--app-sidebar-width);
    background: linear-gradient(180deg, var(--app-sidebar) 0%, var(--app-sidebar-2) 100%);
    color: var(--app-sidebar-text);
    display: none;
    flex-direction: column;
    z-index: 1040;
    box-shadow: 8px 0 22px rgba(15, 23, 42, 0.16);
}

html[data-app-nav-layout="sidebar"] .app-sidebar {
    display: flex;
}

.app-sidebar-brand {
    min-height: var(--app-sidebar-brand-height);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(14, 165, 233, 0.14);
    color: #7dd3fc;
    border: 1px solid rgba(125, 211, 252, 0.22);
    overflow: hidden;
}

.app-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}

.app-brand-title {
    color: #ffffff;
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.1;
    letter-spacing: 0;
}

.app-brand-subtitle {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
}

.app-sidebar-nav {
    padding: 1rem 0.85rem;
    overflow-y: auto;
    flex: 1;
}

.app-nav-section {
    padding: 0.8rem 0.6rem 0.35rem;
    color: #94a3b8;
    font-size: 0.68rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.app-nav-link {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.66rem 0.75rem;
    font-weight: 650;
    font-size: 0.9rem;
    border: 1px solid transparent;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.app-nav-link i {
    width: 1.25rem;
    text-align: center;
    color: #7dd3fc;
}

.app-nav-link:hover,
.app-nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(125, 211, 252, 0.18);
}

.app-sidebar-footer {
    padding: 1rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.app-sidebar-tools .app-kbd-status {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    padding: 0 0.55rem;
}

.app-sidebar-tools .pwa-network-status::before {
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.18);
}

.app-user-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.app-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(20, 184, 166, 0.15);
    color: #5eead4;
    border: 1px solid rgba(94, 234, 212, 0.18);
}

.app-workspace {
    min-height: 100vh;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.22s ease;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 68px;
    background: linear-gradient(90deg, var(--app-sidebar) 0%, var(--app-sidebar-2) 100%);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
    padding: 0;
}

.app-topbar > .container-fluid {
    min-height: 68px;
}

.app-sidebar-mobilebar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: var(--app-mobilebar-height);
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: linear-gradient(90deg, var(--app-sidebar) 0%, var(--app-sidebar-2) 100%);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
}

.app-sidebar-mobilebrand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1 1 auto;
    color: #ffffff;
}

.app-sidebar-mobilebrand:hover {
    color: #ffffff;
}

.app-sidebar-mobilebrand .app-brand-title,
.app-sidebar-mobilebrand .app-brand-subtitle {
    display: block;
    max-width: min(52vw, 220px);
}

.app-topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    max-width: min(42vw, 260px);
    color: #ffffff;
}

.app-topbar-brand:hover {
    color: #ffffff;
}

.app-topbar-brand .app-brand-mark {
    flex: 0 0 auto;
}

.app-topbar-brand .app-brand-title,
.app-topbar-brand .app-brand-subtitle {
    display: block;
    max-width: 180px;
}

.app-topbar-collapse {
    min-width: 0;
}

.app-topbar-nav {
    min-width: 0;
    gap: 0.3rem;
}

.app-topbar-nav::-webkit-scrollbar {
    display: none;
}

.app-topbar-link {
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.52rem 0.7rem;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.app-topbar-link i {
    color: #7dd3fc;
}

.app-topbar .app-topbar-link:hover,
.app-topbar .app-topbar-link:focus,
.app-topbar .app-topbar-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(125, 211, 252, 0.18);
}

.app-topbar-toggler:focus {
    box-shadow: none;
}

.app-sidebar-toggle,
.app-topbar-toggler,
.app-layout-toggle,
.app-user-menu-button,
.pwa-install-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.app-sidebar-toggle:hover,
.app-topbar-toggler:hover,
.app-layout-toggle:hover,
.app-user-menu-button:hover,
.pwa-install-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(125, 211, 252, 0.32);
    color: #ffffff;
}

.app-user-menu-button {
    width: auto;
    max-width: 190px;
    gap: 0.5rem;
    padding: 0 0.7rem;
}

.app-user-menu-name {
    max-width: 116px;
    font-size: 0.8rem;
    font-weight: 700;
}

.app-user-menu-chevron {
    font-size: 0.72rem;
    color: #94a3b8;
}

.app-topbar-actions {
    flex: 0 0 auto;
    min-width: 0;
}

@media (min-width: 1200px) {
    .app-topbar-collapse {
        flex: 1 1 auto;
    }

    .app-topbar-nav {
        overflow-x: auto;
        scrollbar-width: none;
    }
}

@media (max-width: 1199.98px) {
    .app-topbar-collapse {
        flex-basis: 100%;
        margin-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .app-topbar-link {
        width: 100%;
    }
}

.app-sidebar-toggle {
    display: none;
}

.app-topbar .app-kbd-status {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
}

html[data-app-nav-layout="sidebar"] .app-workspace {
    margin-left: var(--app-sidebar-width);
}

html[data-app-nav-layout="sidebar"] .app-topbar {
    display: none;
}

html[data-app-nav-layout="sidebar"] {
    --app-topbar-height: 0px;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
}

.app-content > *,
.app-content .row,
.app-content .card,
.app-content .card-custom,
.app-content .table-responsive {
    min-width: 0;
}

.app-content .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-content .table-responsive > .table {
    margin-bottom: 0;
}

.app-footer {
    margin-left: 0;
}

.app-shell-auth .card-custom {
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 24px rgba(15, 23, 42, 0.06);
}

.app-shell-auth .btn-custom {
    border-radius: 8px;
}

.app-kbd-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 34px;
    border-radius: 8px;
    border: 1px solid var(--app-border);
    padding: 0 0.75rem;
    color: #334155;
    background: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.pwa-network-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--app-success);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.12);
}

.pwa-network-status.is-offline::before {
    background: var(--app-danger);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.12);
}

.pwa-floating-panel {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1060;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pwa-floating-panel .pwa-network-status {
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.pwa-install-btn[hidden],
.pwa-floating-panel[hidden] {
    display: none !important;
}

.pwa-standalone .pwa-install-btn {
    display: none !important;
}

.offline-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: radial-gradient(circle at top left, rgba(14, 165, 233, 0.16), transparent 32rem), #eef2f6;
}

.offline-panel {
    width: min(100%, 520px);
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--app-border);
    box-shadow: 0 22px 70px rgba(15, 23, 42, 0.14);
    padding: 2rem;
}

.offline-icon {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(245, 158, 11, 0.14);
    color: var(--app-warning);
    font-size: 1.6rem;
}

.pos-sticky-panel {
    position: sticky;
    top: calc(var(--app-topbar-height) + 1rem);
}

.pos-cart-container {
    min-height: 320px;
}

.pos-scan-panel {
    position: sticky;
    top: calc(var(--app-topbar-height) + 1rem);
    z-index: 5;
}

/* Sidebar Backdrop Overlay on Mobile */
.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

body.sidebar-open {
    overflow: hidden !important;
}

@media (max-width: 991.98px) {
    html[data-app-nav-layout="topbar"] {
        --app-topbar-height: 68px;
    }

    html[data-app-nav-layout="sidebar"] {
        --app-topbar-height: var(--app-mobilebar-height);
    }

    .app-sidebar-backdrop {
        display: block;
    }

    body.sidebar-open .app-sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .app-sidebar {
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 0.22s ease, visibility 0.22s ease;
    }

    .app-sidebar.show {
        transform: translateX(0);
        visibility: visible;
    }

    .app-workspace,
    html[data-app-nav-layout="sidebar"] .app-workspace {
        margin-left: 0;
        width: 100%;
    }

    .app-topbar-brand {
        min-width: 0;
    }

    .app-topbar-brand .app-brand-title,
    .app-topbar-brand .app-brand-subtitle {
        max-width: 160px;
    }

    .app-content {
        padding: 1rem;
    }

    .app-topbar-actions {
        gap: 0.5rem !important;
    }

    html[data-app-nav-layout="sidebar"] .app-sidebar-toggle {
        display: inline-flex;
    }

    html[data-app-nav-layout="sidebar"] .app-sidebar-mobilebar {
        display: flex;
    }

    .pwa-floating-panel {
        right: 12px;
        bottom: 12px;
    }
}

@media (min-width: 992px) {
    .app-sidebar-toggle {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .app-kbd-status {
        display: none;
    }

    .app-topbar-brand .app-brand-subtitle,
    .app-user-menu-name,
    .app-user-menu-chevron {
        display: none;
    }

    .app-user-menu-button {
        width: 40px;
        padding: 0;
    }

    .app-content {
        padding: 0.85rem;
    }

    .offline-panel {
        padding: 1.25rem;
    }
}
