:root {
    --sidebar-w: 250px;
    --brand: #6f4e37;
    --brand-dark: #3d291b;
    --accent: #c4a484;
    --bg: #f4f1ec;
    --bottom-nav-h: 68px;
}

.theme-spice {
    --brand: #c2410c;
    --brand-dark: #7c2d12;
    --accent: #fdba74;
    --bg: #fff7ed;
}

.theme-coffee {
    --brand: #6f4e37;
    --brand-dark: #3d291b;
    --accent: #d4a574;
    --bg: #f7f3ee;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Cairo", sans-serif;
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
}

.app-navbar {
    background: var(--brand-dark);
    padding-top: max(.4rem, env(safe-area-inset-top));
}

.app-navbar .navbar-brand {
    max-width: min(52vw, 280px);
}

.app-shell {
    display: flex;
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
}

.app-sidebar {
    width: var(--sidebar-w);
    background: var(--brand-dark);
    color: #fff;
    flex-direction: column;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.1rem 1rem;
    display: flex;
    gap: .6rem;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-nav {
    padding: .75rem .5rem 1.5rem;
}

.sidebar-nav .nav-link {
    color: rgba(255,255,255,.78);
    border-radius: .7rem;
    padding: .7rem .9rem;
    display: flex;
    gap: .6rem;
    align-items: center;
    margin-bottom: .15rem;
    min-height: 44px;
}

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

.app-main {
    flex: 1;
    padding: 1.25rem;
    min-width: 0;
}

.stat-card {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.05);
}

.hq-shop-card-active {
    outline: 2px solid var(--brand);
}

.stat-card .icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.18);
}

.page-card {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.05);
}

.btn-brand {
    background: var(--brand);
    color: #fff;
    border: 0;
}

.btn-brand:hover {
    background: var(--brand-dark);
    color: #fff;
}

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

.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at top right, var(--accent), transparent 40%),
        linear-gradient(160deg, var(--brand-dark), var(--brand));
}

.login-card {
    width: min(440px, 94vw);
    border: 0;
    border-radius: 1.2rem;
}

.badge-stock-low {
    background: #dc3545;
}

.offcanvas {
    background: var(--brand-dark);
    color: #fff;
}

.offcanvas .nav-link {
    color: #fff;
}

.offcanvas .btn-close {
    filter: invert(1);
}

.shop-switch .form-select {
    font-size: 1rem;
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    background: #fff;
    border-top: 1px solid #eadfd0;
    padding: .35rem .2rem max(.35rem, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(0,0,0,.06);
}

.mobile-bottom-nav a,
.mobile-bottom-nav button {
    flex: 1;
    border: 0;
    background: none;
    color: #6b5b4b;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    font-size: .72rem;
    padding: .35rem .2rem;
    min-height: 52px;
}

.mobile-bottom-nav i {
    font-size: 1.25rem;
}

.mobile-bottom-nav .active,
.mobile-bottom-nav .nav-pos {
    color: var(--brand);
    font-weight: 700;
}

.mobile-bottom-nav .nav-pos i {
    font-size: 1.45rem;
}

.has-mobile-nav .app-main {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}

.form-control,
.form-select,
.btn {
    min-height: 42px;
}

.form-control,
.form-select {
    font-size: 16px;
}

.btn-sm {
    min-height: 36px;
}

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

@media (max-width: 991.98px) {
    .app-main {
        padding: .85rem .75rem calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    }
    .app-main .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: .6rem;
    }
    .page-card,
    .stat-card {
        overflow: hidden;
    }
    .table {
        font-size: .9rem;
    }
    .btn-group {
        flex-wrap: wrap;
    }
}

.stock-stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    background: #fff;
    border-radius: 1rem;
    padding: .85rem .7rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 8px 24px rgba(0,0,0,.05);
    border: 2px solid transparent;
    min-height: 76px;
}

.stock-stat.is-active {
    border-color: var(--brand);
}

.stock-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}

.stock-stat-label {
    color: #7a6a5c;
    font-size: .8rem;
}

.stock-stat-ok .stock-stat-value { color: #15803d; }
.stock-stat-low .stock-stat-value { color: #dc2626; }

.stock-search {
    position: relative;
}

.stock-search-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #9a8b7c;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.stock-search .form-control {
    padding-right: 2.6rem;
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.05);
}

.stock-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
    padding-bottom: .5rem;
}

.stock-card {
    background: #fff;
    border-radius: 1.1rem;
    padding: .85rem .9rem .95rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.05);
    border: 1px solid rgba(0,0,0,.03);
}

.stock-card.is-low {
    background: linear-gradient(180deg, #fff7f7, #fff);
    border-color: #fecaca;
}

.stock-card-head {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    margin-bottom: .55rem;
}

.stock-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(111, 78, 55, .08);
    color: var(--brand);
    flex-shrink: 0;
}

.stock-card.is-low .stock-card-icon {
    background: #fee2e2;
    color: #dc2626;
}

.stock-card-name {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.stock-card-meta {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    color: #8a7a6c;
    font-size: .78rem;
}

.stock-pill {
    margin-inline-start: auto;
    border-radius: 999px;
    padding: .18rem .6rem;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

.stock-pill-ok { background: #dcfce7; color: #166534; }
.stock-pill-low { background: #fee2e2; color: #b91c1c; }

.stock-card-qty {
    display: flex;
    align-items: baseline;
    gap: .35rem;
    margin-bottom: .35rem;
}

.stock-qty-num {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;
}

.stock-qty-unit {
    color: #8a7a6c;
}

.stock-bar {
    display: flex;
    height: 6px;
    background: #f1e8de;
    border-radius: 99px;
    overflow: hidden;
}

.stock-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--brand));
    border-radius: 99px;
}

.stock-card.is-low .stock-bar span {
    background: #dc2626;
}

.stock-card-hint {
    color: #8a7a6c;
    font-size: .78rem;
    margin: .35rem 0 .7rem;
}

.stock-card-form .form-label {
    font-size: .75rem;
    margin-bottom: .15rem;
    color: #6b5b4b;
}

.stock-card-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: .5rem;
    align-items: end;
}

.stock-card-save .btn {
    min-height: 42px;
    padding-inline: 1.05rem;
    white-space: nowrap;
}

.stock-empty {
    text-align: center;
    background: #fff;
    border-radius: 1.15rem;
    padding: 2.5rem 1rem;
    color: #8a7a6c;
}

.stock-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: .5rem;
    color: var(--brand);
}

@media (max-width: 399.98px) {
    .stock-card-form-row {
        grid-template-columns: 1fr 1fr;
    }
    .stock-card-save {
        grid-column: 1 / -1;
    }
    .stock-card-save .btn {
        width: 100%;
    }
}

@media (min-width: 576px) {
    .stock-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .stock-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 575.98px) {
    h1.h4, h1.h5 {
        font-size: 1.15rem;
    }
    .stat-card .fs-4,
    .stat-card .fs-3 {
        font-size: 1.25rem !important;
    }
}
