:root {
  --app-bg: #f6f8fb;
  --app-surface: #ffffff;
  --app-text: #1f2937;
  --app-muted: #6b7280;
  --app-border: #e8edf3;
  --app-primary: #4f46e5;
  --app-primary-dark: #4338ca;
  --app-sidebar-width: 250px;
  --app-sidebar-collapsed: 74px;
  --app-radius: 16px;
  --app-shadow: 0 10px 30px rgba(31, 41, 55, .07);
  --app-shadow-sm: 0 5px 18px rgba(31, 41, 55, .055);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a { color: inherit; }

.app-shell { min-height: 100vh; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--app-sidebar-collapsed);
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
  box-shadow: 8px 0 24px rgba(31, 41, 55, .035);
  z-index: 1040;
  transition: width .22s ease, transform .22s ease;
  overflow: hidden;
}
.app-sidebar:hover,
.app-sidebar.is-expanded { width: var(--app-sidebar-width); }

.sidebar-brand {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--app-border);
  white-space: nowrap;
}
.brand-mark {
  width: auto;
  height: auto;
  border-radius: 9px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--app-primary), #7c3aed);
  font-weight: 800;
}
.brand-name { font-weight: 750; letter-spacing: -.02em; opacity: 0; transition: opacity .12s ease; }
.app-sidebar:hover .brand-name,
.app-sidebar.is-expanded .brand-name { opacity: 1; }

.sidebar-nav { padding: 18px 12px; }
.sidebar-link {
  display: flex;
  align-items: center;
  min-height: 46px;
  gap: 15px;
  padding: 0 16px;
  margin-bottom: 7px;
  border-radius: 12px;
  color: #667085;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-link:hover { background: #f4f5ff; color: var(--app-primary); }
.sidebar-link.active { background: #eef0ff; color: var(--app-primary); font-weight: 650; }
.sidebar-link i { font-size: 1.2rem; flex: 0 0 18px; text-align: center; }
.sidebar-link span { opacity: 0; transition: opacity .12s ease; }
.app-sidebar:hover .sidebar-link span,
.app-sidebar.is-expanded .sidebar-link span { opacity: 1; }

.app-main {
  min-height: 100vh;
  padding-left: var(--app-sidebar-collapsed);
  transition: padding-left .22s ease;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: 74px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--app-border);
}
.app-header-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
}
.header-title { min-width: 0; }
.header-title h1 { font-size: 1.18rem; margin: 0; font-weight: 750; letter-spacing: -.02em; }
.header-title p { margin: 3px 0 0; color: var(--app-muted); font-size: .86rem; }
.user-button {
  border: 1px solid var(--app-border);
  background: #fff;
  border-radius: 12px;
  padding: 8px 11px;
  box-shadow: var(--app-shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 220px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eef0ff;
  color: var(--app-primary);
  display: grid;
  place-items: center;
  font-weight: 750;
  flex: 0 0 32px;
}
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-menu-button { display: none; }

.app-content { padding: 26px; }
.page-heading { margin-bottom: 22px; }
.page-heading h2 { font-size: 1.55rem; margin-bottom: 6px; font-weight: 780; letter-spacing: -.025em; }
.page-heading p { color: var(--app-muted); margin: 0; }

.panel,
.stat-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
}
.add-panel {
    border-color: orange;
}
.panel { padding: 22px; }
.panel + .panel { margin-top: 22px; }
.panel-title { font-size: 1rem; font-weight: 750; margin: 0 0 4px; }
.panel-subtitle { color: var(--app-muted); margin: 0 0 20px; font-size: .9rem; }
.stat-card { padding: 18px; height: 100%; }
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #f2f3ff;
  color: var(--app-primary);
  font-size: 1.1rem;
  margin-bottom: 14px;
}
.stat-label { color: var(--app-muted); font-size: .86rem; }
.stat-value { margin-top: 4px; font-size: 1.45rem; font-weight: 780; letter-spacing: -.03em; }

.form-label { font-weight: 650; font-size: .89rem; }
.form-control,
.form-select {
  min-height: 44px;
  border-color: #dfe4eb;
  border-radius: 11px;
  box-shadow: none !important;
}
textarea.form-control { min-height: 110px; }
.form-control:focus,
.form-select:focus { border-color: #a9a5f8; }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.btn { border-radius: 11px; font-weight: 650; }
.btn-primary { background: var(--app-primary); border-color: var(--app-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--app-primary-dark); border-color: var(--app-primary-dark); }

.nav-tabs { gap: 7px; border-bottom: 1px solid var(--app-border); }
.nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--app-muted);
  font-weight: 650;
  padding: 10px 13px;
}
.nav-tabs .nav-link:hover { color: var(--app-text); }
.nav-tabs .nav-link.active { color: var(--app-primary); border-bottom-color: var(--app-primary); background: transparent; }
.tab-content { padding-top: 22px; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 13px 12px; border-color: var(--app-border); vertical-align: middle; }
.badge-soft { background: #ecfdf3; color: #087a45; border: 1px solid #d1fadf; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(79,70,229,.08), transparent 28%),
    radial-gradient(circle at 90% 90%, rgba(124,58,237,.07), transparent 26%),
    var(--app-bg);
}
.login-card {
  width: min(100%, 430px);
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 22px;
  box-shadow: var(--app-shadow);
  padding: 32px;
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; font-weight: 800; font-size: 1.05rem;margin-top: -110px; }
.login-card h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: 7px; }
.login-card .intro { color: var(--app-muted); margin-bottom: 25px; }

@media (min-width: 992px) {
  .app-shell.sidebar-pinned .app-sidebar { width: var(--app-sidebar-width); }
  .app-shell.sidebar-pinned .app-main { padding-left: var(--app-sidebar-width); }
  .app-shell.sidebar-pinned .brand-name,
  .app-shell.sidebar-pinned .sidebar-link span { opacity: 1; }
}

@media (max-width: 991.98px) {
  .app-sidebar {
    width: min(86vw, 280px);
    transform: translateX(-105%);
    box-shadow: 15px 0 40px rgba(31,41,55,.14);
  }
  .app-sidebar.is-expanded { width: min(86vw, 280px); transform: translateX(0); }
  .app-sidebar .brand-name,
  .app-sidebar .sidebar-link span { opacity: 1; }
  .app-main { padding-left: 0; }
  .mobile-menu-button { display: inline-flex; align-items: center; justify-content: center; width: 42px; padding: 0; flex: 0 0 42px; }
  .header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .3);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
}

@media (max-width: 767.98px) {
  .app-content { padding: 18px 14px 28px; }
  .app-header-inner { padding: 10px 14px; }
  .header-title p { display: none; }
  .user-name { display: none; }
  .user-button { padding: 6px; border-radius: 12px; }
  .user-button .bi-chevron-down { display: none; }
  .panel { padding: 17px; }
  .page-heading h2 { font-size: 1.35rem; }
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link { white-space: nowrap; }
  .login-card { padding: 25px 20px; }
}

@media (max-width: 420px) {
  .header-title h1 { max-width: 185px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .btn-mobile-full { width: 100%; }
}

.table-search-wrapper {
    width: 300px;
    flex-shrink: 0;
}
@media (max-width: 767.98px) {
    .table-search-wrapper {
        width: 100%;
    }
}
.table-search-clear {
    border-color: #cdcdcd !important;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}


    /* Responsive Tables
-------------------------------------------------- */


/* Mobile / Tablet */
@media (max-width: 767.98px) {

    /* Hide normal table headings */
    .responsive-table thead {
        display: none;
    }

    /* Convert table into stacked records */
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    /* Each table row becomes a card */
    .responsive-table tr {
        margin-bottom: 15px;
        padding: 12px 14px;
        border: 1px solid #e9ecef;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    /* Individual fields */
    .responsive-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 15px;

        width: 100% !important;
        padding: 8px 0;
        border: 0;

        text-align: right !important;

        /* Prevent long emails/text breaking viewport */
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Field labels */
    .responsive-table td::before {
        content: attr(data-label);

        flex-shrink: 0;

        font-size: 12px;
        font-weight: 600;
        line-height: 1.2;

        color: #6c757d;

        text-transform: uppercase;
        letter-spacing: 0.04em;

        text-align: left;
    }

    /* Actions area */
    .responsive-table td[data-label="Actions"] {
        margin-top: 5px;
        padding-top: 12px;

        border-top: 1px solid #eeeeee;
    }

    /* Keep buttons together */
    .responsive-table td[data-label="Actions"] a {
        flex-shrink: 0;
    }

    /* Remove Bootstrap's normal final-row table border */
    .responsive-table tbody tr:last-child td {
        border-bottom: 0;
    }

}

.system-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    transition: opacity .45s ease, visibility .45s ease;
}

.system-loader-inner {
    text-align: center;
    width: min(320px, 80vw);
}

.system-loader-logo {
    max-width: 190px;
    width: 100%;
    height: auto;
    opacity: 0;
    filter: blur(8px);
    transform: scale(.92);
    animation: loaderLogoIn .6s cubic-bezier(.22, 1, .36, 1) forwards;
}

.system-loader-text {
    margin-top: 22px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    color: #6c757d;
    opacity: 0;
    animation: loaderTextIn .4s ease .25s forwards;
}

.system-loader-bar {
    width: 160px;
    height: 3px;
    margin: 14px auto 0;
    background: #e9ecef;
    border-radius: 20px;
    overflow: hidden;
    opacity: 0;
    animation: loaderTextIn .3s ease .3s forwards;
}

.system-loader-progress {
    width: 0;
    height: 100%;
    background: var(--bs-primary, #0d6efd);
    border-radius: inherit;
    animation: loaderProgress 1s cubic-bezier(.65, 0, .35, 1) forwards;
}

.system-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-card {
    opacity: 0;
    transform: translateY(18px) scale(.985);
}

body.login-ready .login-card {
    animation: loginReveal .6s cubic-bezier(.22, 1, .36, 1) forwards;
}

@keyframes loaderLogoIn {
    from {
        opacity: 0;
        filter: blur(8px);
        transform: scale(.92);
    }

    to {
        opacity: 1;
        filter: blur(0);
        transform: scale(1);
    }
}

@keyframes loaderTextIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loaderProgress {
    0% {
        width: 0;
    }

    55% {
        width: 65%;
    }

    100% {
        width: 100%;
    }
}

@keyframes loginReveal {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.thumb {
  width: 80px;
  height: 62px;
  object-fit: cover;
  border-radius: 8px;
}
/* Large image preview overlay */
.thumb-preview {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;

    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
}

.thumb-preview.show {
    display: flex;
}

.thumb-preview img {
    display: block;
    max-width: min(600px, 90vw);
    max-height: 85vh;

    width: auto;
    height: auto;

    object-fit: contain;
    background: #fff;

    border-radius: 10px;
    padding: 8px;

    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
}

/* Don't show the dark full-screen backdrop on desktop hover */
@media (min-width: 992px) {
    .thumb-preview {
        background: rgba(255, 255, 255, 0.15);
        pointer-events: none;
    }
}

.stat-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card-link:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

input:-webkit-autofill, 
 textarea:-webkit-autofill, 
 select:-webkit-autofill { 
 box-shadow: 0 0 0 1000px #fff inset !important; 
 -webkit-box-shadow: 0 0 0 1000px #fff inset !important; 
 -webkit-text-fill-color: #000 !important; 
 transition: background-color 9999s ease-in-out 0s; 
 }

 .stock-good-warning {
    background-color: #00f00459 !important;
    color: #116800;
    border: 1px solid rgba(0, 175, 68, 0.42);
 }
 .stock-low-warning {
    background-color: #ffbf0059 !important;
    color: #7d5800;
    border: 1px solid rgba(236, 177, 0, 0.83);
 }
  .stock-danger-warning {
    background-color: #ff00003d !important;
    color: #882a2a;
    border: 1px solid rgba(255, 0, 0, 0.44);
 }

 /* =========================================================
   FILTER OVERLAY
   ========================================================= */

#filters-holder {
    position: fixed;
    inset: 0;
    z-index: 99999;

    display: none;

    background: rgba(15, 23, 42, 0.45);

    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);

    overflow: hidden;
}


/* =========================================================
   FILTER PANEL
   ========================================================= */

#filters-holder .filters-panel {
    position: absolute;

    top: 20px;
    bottom: 20px;

    left: 50%;
    transform: translateX(-50%);

    width: calc(100% - 40px);
    max-width: 980px;

    background: #ffffff;

    border-radius: 14px;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.08);

    overflow: hidden;
}


/* =========================================================
   HEADER
   ========================================================= */

#filters-holder .filters-header {
    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    height: 70px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 22px;

    background: #ffffff;

    border-bottom: 1px solid #e9ecef;

    font-size: 18px;
    font-weight: 600;

    z-index: 2;
}


/* =========================================================
   CLOSE BUTTON
   ========================================================= */

#filters-holder .filters-close {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;

    padding: 0;

    background: #f5f6f8;

    border: 0;
    border-radius: 8px;

    font-size: 16px;
    line-height: 1;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

#filters-holder .filters-close:hover {
    background: #e9ecef;
}

#filters-holder .filters-close:active {
    transform: scale(0.96);
}


/* =========================================================
   SCROLLABLE CONTENT
   ========================================================= */

#filters-holder .filters-body {
    position: absolute;

    /*
        Header is 70px high
        Footer is 72px high
    */

    top: 70px;
    bottom: 72px;

    left: 0;
    right: 0;

    padding: 22px;

    overflow-y: auto !important;
    overflow-x: hidden;

    -webkit-overflow-scrolling: touch;

    overscroll-behavior: contain;
}


/* =========================================================
   FOOTER
   ========================================================= */

#filters-holder .filters-footer {
    position: absolute;

    bottom: 0;
    left: 0;
    right: 0;

    height: 72px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 12px 22px;

    background: #f8f9fa;

    border-top: 1px solid #e9ecef;

    z-index: 2;
}


/* =========================================================
   FOOTER BUTTONS
   ========================================================= */

#filters-holder .filters-footer .btn {
    white-space: nowrap;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 576px) {

    #filters-holder .filters-panel {
        top: 0;
        bottom: 0;

        left: 0;

        transform: none;

        width: 100%;
        max-width: none;

        border-radius: 0;
    }


    /* Fixed mobile header */

    #filters-holder .filters-header {
        height: 60px;

        padding: 0 16px;

        font-size: 17px;
    }


    /* Fixed mobile footer */

    #filters-holder .filters-footer {
        height: calc(68px + env(safe-area-inset-bottom));

        padding:
            10px
            16px
            calc(10px + env(safe-area-inset-bottom));

        gap: 10px;

        background: #ffffff;
    }


    /* Body occupies EXACTLY the area between them */

    #filters-holder .filters-body {
        top: 60px;

        bottom: calc(68px + env(safe-area-inset-bottom));

        padding: 16px;

        overflow-y: auto !important;
        overflow-x: hidden !important;

        -webkit-overflow-scrolling: touch;
    }


    #filters-holder .filters-footer .btn {
        flex: 1;

        min-width: 0;
    }

}