html {
    font-size: 14px;
}

body {
    margin: 0;
    background-color: #f4f6f9;
    color: #263238;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    overflow-x: hidden;
    transition: all .3s ease;
}

h1, .h1 { font-size: 22px; }
h2, .h2 { font-size: 20px; }
h3, .h3 { font-size: 18px; }
h4, .h4 { font-size: 16px; }
h5, .h5 { font-size: 15px; }
h6, .h6 { font-size: 14px; }

.container,
.container-fluid {
    padding-left: 12px;
    padding-right: 12px;
}

.sidebar {
    width: 220px;
    height: 100vh;
    max-height: 100vh;
    background: #1f2937;
    position: fixed;
    top: 0;
    left: 0;
    padding-top: 14px;
    box-shadow: 2px 0 10px rgba(0,0,0,.08);
    z-index: 1030;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    transition: all .3s ease;
}

.sidebar-brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    padding: 0 12px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i {
    color: #fbbf24;
}

.sidebar .nav-link,
.offcanvas .nav-link {
    color: #d1d5db;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 3px 10px;
    transition: all .3s ease;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    display: block;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active,
.offcanvas .nav-link:hover,
.offcanvas .nav-link.active {
    background: #2563eb;
    color: #fff;
}

.sidebar .submenu .nav-link,
.offcanvas .submenu .nav-link {
    padding-left: 32px;
    font-size: 12px;
    margin-top: 2px;
    margin-bottom: 2px;
    color: #cbd5e1;
}

.sidebar .submenu .nav-link:hover,
.sidebar .submenu .nav-link.active,
.offcanvas .submenu .nav-link:hover,
.offcanvas .submenu .nav-link.active {
    background: rgba(37, 99, 235, 0.16);
    color: #fff;
}

.submenu-toggle-icon {
    transition: transform .25s ease;
    float: right;
}

.nav-link[aria-expanded="true"] .submenu-toggle-icon {
    transform: rotate(180deg);
}

.content-wrapper {
    margin-left: 220px;
    min-height: 100vh;
    max-width: calc(100vw - 220px);
    transition: all .3s ease;
}

.topbar {
    background: #ffffff;
    padding: 8px 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1020;
    gap: 12px;
}

.topbar h5,
.page-heading {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    color: #111827;
}

.page-content {
    padding: 12px 15px;
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.stats-card,
.table-card,
.form-card,
.card {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,.05);
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 700;
    color: #0f172a;
}

.form-group,
.mb-3 {
    margin-bottom: 10px !important;
}

label,
.form-label {
    font-size: 13px;
    margin-bottom: 4px;
    font-weight: 600;
    color: #374151;
}

.form-control,
.form-select,
select,
textarea {
    font-size: 14px;
    padding: 6px 10px;
    min-height: 36px;
    border-radius: 8px;
    border-color: #cfd8e3;
}

textarea.form-control,
textarea {
    min-height: 70px;
}

.form-control:focus,
.form-select:focus,
select:focus,
textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 .15rem rgba(37, 99, 235, .18);
}

.btn {
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 8px;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.btn-primary {
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-outline-danger,
.btn-outline-secondary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    font-size: 13px;
    margin-bottom: 0;
    background: #ffffff;
}

.table th,
.table td {
    font-size: 13px;
    vertical-align: middle;
    padding: .55rem .6rem;
}

.table-card .table,
.card .table {
    white-space: nowrap;
}

.table thead th {
    background: #eff6ff;
    color: #1e3a8a;
    border-bottom: 1px solid #dbeafe;
}

.alert {
    border-radius: 10px;
}

.app-alert .btn-close::before,
.app-alert .btn-close::after {
    content: none !important;
}

.app-alert .btn-close span {
    display: none !important;
}

.badge {
    padding: 6px 10px;
    border-radius: 20px;
}

.badge-soft-success {
    background: #dcfce7;
    color: #166534;
}

.badge-soft-danger {
    background: #fee2e2;
    color: #991b1b;
}

.gold-mobile-sidebar {
    background: #1f2937;
}

body.sidebar-collapsed .sidebar {
    width: 72px;
}

body.sidebar-collapsed .content-wrapper {
    margin-left: 72px;
    max-width: calc(100vw - 72px);
}

body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .sidebar .nav-link .menu-text,
body.sidebar-collapsed .sidebar .submenu,
body.sidebar-collapsed .sidebar .submenu-toggle-icon {
    display: none !important;
}

body.sidebar-collapsed .sidebar .nav-link {
    text-align: center;
    padding-left: 10px;
    padding-right: 10px;
}

body.sidebar-collapsed .sidebar .nav-link i,
body.sidebar-collapsed .sidebar .sidebar-brand i {
    margin-right: 0 !important;
}

.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1f2937, #2563eb);
}

.login-card {
    border: 0;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(2,6,23,.25);
}

.login-brand {
    background: linear-gradient(160deg, #111827, #2563eb);
    color: white;
    padding: 46px;
}

.login-form {
    background: white;
    padding: 42px;
}

@media (max-width: 1199px) {
    .page-content {
        padding: 12px;
    }
}

@media (max-width: 991px) {
    body {
        font-size: 13px;
    }

    .sidebar {
        display: none !important;
    }

    .content-wrapper {
        margin-left: 0;
        max-width: 100vw;
    }

    .page-content {
        padding: 10px;
    }

    .topbar {
        padding: 8px 12px;
    }

    .topbar h5,
    .page-heading {
        max-width: 55vw;
        font-size: 15px;
    }

    .table,
    .table th,
    .table td {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .container,
    .container-fluid,
    .page-content {
        padding-left: 8px;
        padding-right: 8px;
    }

    .card-body,
    .table-card .card-body,
    .form-card .card-body {
        padding: .85rem;
    }
}

/* Bootstrap-lite compatibility helpers used by the Inventory-style layout */
.collapse:not(.show) {
    display: none;
}

.collapsing {
    height: 0;
    overflow: hidden;
    transition: height .35s ease;
}

.d-inline-flex {
    display: inline-flex !important;
}

.float-end {
    float: right !important;
}

.mt-1 {
    margin-top: .25rem !important;
}

.min-vh-100 {
    min-height: 100vh !important;
}

.bg-dark {
    background-color: #1f2937 !important;
}

.btn-close-white {
    color: #ffffff;
    filter: invert(1) grayscale(100%) brightness(200%);
}

.offcanvas-title {
    margin-bottom: 0;
    line-height: 1.4;
}

/* Sidebar duplicate rendering fix
   Keep only one sidebar in the layout and make it responsive for desktop/mobile. */
.sidebar-backdrop {
    display: none;
}

@media (min-width: 992px) {
    .sidebar {
        display: block !important;
        transform: none !important;
    }
}

@media (max-width: 991px) {
    .sidebar {
        display: block !important;
        width: 220px;
        max-width: 82vw;
        transform: translateX(-100%);
        z-index: 1050;
    }

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

    body.mobile-sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1040;
    }

    body.sidebar-collapsed .sidebar {
        width: 220px;
    }

    body.sidebar-collapsed .sidebar-brand span,
    body.sidebar-collapsed .sidebar .nav-link .menu-text,
    body.sidebar-collapsed .sidebar .submenu-toggle-icon {
        display: inline !important;
    }

    body.sidebar-collapsed .sidebar .submenu {
        display: block !important;
    }

    body.sidebar-collapsed .sidebar .nav-link {
        text-align: left;
        padding-left: 12px;
        padding-right: 12px;
    }
}


/* Sidebar toggle + submenu scrolling fix */
.desktop-menu-toggle {
    display: inline-flex !important;
}

.mobile-menu-toggle {
    display: none !important;
}

.sidebar > .nav {
    padding-bottom: 18px;
}

.sidebar .submenu.show {
    max-height: 58vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar,
.sidebar .submenu::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb,
.sidebar .submenu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.25);
    border-radius: 20px;
}

@media (max-width: 991px) {
    .desktop-menu-toggle {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: inline-flex !important;
    }

    .sidebar {
        height: 100vh;
        max-height: 100vh;
        padding-bottom: 22px;
        overflow-y: auto;
    }

    body.mobile-sidebar-open {
        overflow: hidden;
    }

    .sidebar .submenu.show {
        max-height: 52vh;
    }
}

@media (min-width: 992px) {
    .desktop-menu-toggle {
        display: inline-flex !important;
    }

    .mobile-menu-toggle {
        display: none !important;
    }
}

/* Bootstrap-style autocomplete dropdown for Sales Entry item picker */
.sales-autocomplete-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    z-index: 1050;
    max-height: 280px;
    overflow-y: auto;
    padding: .35rem 0;
    margin-top: .15rem;
    font-size: .95rem;
    color: #212529;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: .375rem;
}
.sales-autocomplete-menu.show {
    display: block !important;
}
.sales-autocomplete-menu .dropdown-item {
    display: block;
    width: 100%;
    padding: .55rem .85rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    text-decoration: none;
    white-space: normal;
    background-color: transparent;
    border: 0;
    cursor: pointer;
}
.sales-autocomplete-menu .dropdown-item:hover,
.sales-autocomplete-menu .dropdown-item:focus,
.sales-autocomplete-menu .dropdown-item.active {
    color: #1e2125;
    background-color: #e9ecef;
    outline: 0;
}
.sales-autocomplete-menu .dropdown-item.disabled,
.sales-autocomplete-menu .dropdown-item:disabled {
    color: #6c757d;
    pointer-events: auto;
    background-color: transparent;
    cursor: not-allowed;
}
.sales-autocomplete-menu .badge {
    white-space: nowrap;
}
