:root {
    --sidebar-bg: #111827;
    --sidebar-text: #e5e7eb;
    --brand: #f59e0b;
    --content-bg: #f5f7fb;
    --sidebar-expanded-width: 250px;
    --sidebar-collapsed-width: 70px;
    --sidebar-transition: 0.25s;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--content-bg);
}

/* Layout shell keeps sidebar + main aligned and animates width changes cleanly. */
.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.sidebar {
    width: var(--sidebar-expanded-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 12px;
    flex-shrink: 0;
    overflow-x: hidden;
    transition: width var(--sidebar-transition) ease, transform var(--sidebar-transition) ease;
    will-change: width, transform;
    z-index: 1035;
}

.sidebar .brand {
    margin: 0 8px 20px;
    transition: margin var(--sidebar-transition) ease;
}

.brand-title {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--brand);
    white-space: nowrap;
}

.brand-sub {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
}

.sidebar .nav {
    gap: 4px;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 10px 12px;
    font-weight: 500;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    transition: color var(--sidebar-transition) ease, background-color var(--sidebar-transition) ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-icon {
    width: 24px;
    min-width: 24px;
    text-align: center;
    font-size: 18px;
    line-height: 1;
}

.nav-label {
    opacity: 1;
    transition: opacity var(--sidebar-transition) ease;
}

/* Desktop collapsed state: keep only icons visible and shrink sidebar width. */
.app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    padding-left: 10px;
    padding-right: 10px;
}

.app-shell.sidebar-collapsed .sidebar .brand {
    margin-left: 0;
    margin-right: 0;
}

.app-shell.sidebar-collapsed .sidebar .brand-title,
.app-shell.sidebar-collapsed .sidebar .brand-sub,
.app-shell.sidebar-collapsed .sidebar .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

.app-shell.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #1f2937;
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-toggle {
    line-height: 1;
    padding: 4px 10px;
}

.page-title {
    margin: 0;
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar .user {
    font-weight: 600;
}

.content {
    padding: 20px;
}

.table td,
.table th {
    vertical-align: middle;
}

.pos-table input,
.pos-table select {
    min-width: 120px;
}

/* Mobile: sidebar starts hidden and slides in/out without reloading. */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--sidebar-transition) ease, visibility var(--sidebar-transition) ease;
    z-index: 1030;
}

@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-expanded-width);
        transform: translateX(-100%);
        box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
    }

    .app-shell.sidebar-collapsed .sidebar {
        width: var(--sidebar-expanded-width);
    }

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

    .app-shell.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .topbar {
        padding: 12px 16px;
    }

    .content {
        padding: 16px;
    }
}
