:root {
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 82px;
    --topbar-height: 68px;

    --sidebar-background: #111827;
    --sidebar-background-secondary: #1f2937;
    --sidebar-text: #d1d5db;
    --sidebar-text-muted: #9ca3af;
    --sidebar-active-background: #ffffff;
    --sidebar-active-text: #111827;

    --page-background: #f4f6f9;
    --border-color: #e5e7eb;

    --transition-speed: 0.25s;
}

html,
body {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background-color: var(--page-background);
    font-family: Nunito, sans-serif;
}

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

.card {
    border: 0;
}

.table th {
    white-space: nowrap;
}

/* =====================================================
   Sidebar
   ===================================================== */

.app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;

    display: flex;
    flex-direction: column;

    width: var(--sidebar-width);
    min-height: 100vh;

    color: var(--sidebar-text);
    background-color: var(--sidebar-background);

    box-shadow: 4px 0 18px rgb(0 0 0 / 8%);

    transition:
        width var(--transition-speed) ease,
        transform var(--transition-speed) ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: var(--topbar-height);
    padding: 0 16px;

    border-bottom: 1px solid rgb(255 255 255 / 8%);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;

    min-width: 0;

    color: #ffffff;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;

    width: 42px;
    height: 42px;

    border-radius: 12px;
    background-color: rgb(255 255 255 / 10%);

    font-size: 1.35rem;
}

.sidebar-brand-text {
    overflow: hidden;

    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-collapse-button,
.sidebar-close-button,
.topbar-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 0;
    background: transparent;
}

.sidebar-collapse-button,
.sidebar-close-button {
    flex: 0 0 34px;

    width: 34px;
    height: 34px;

    color: var(--sidebar-text);
    border-radius: 8px;
}

.sidebar-collapse-button:hover,
.sidebar-close-button:hover {
    color: #ffffff;
    background-color: rgb(255 255 255 / 10%);
}

/* =====================================================
   Navegación
   ===================================================== */

.sidebar-navigation {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;

    padding: 12px 10px;
}

.sidebar-menu {
    margin: 0;
    padding: 0;

    list-style: none;
}

.sidebar-section {
    padding: 20px 14px 7px;
}

.sidebar-section:first-child {
    padding-top: 7px;
}

.sidebar-section-title {
    color: var(--sidebar-text-muted);

    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-item {
    margin-bottom: 4px;
}

.sidebar-link,
.sidebar-logout-link {
    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 46px;
    padding: 10px 13px;

    color: var(--sidebar-text);
    border-radius: 10px;

    text-decoration: none;
    white-space: nowrap;

    transition:
        color 0.18s ease,
        background-color 0.18s ease;
}

.sidebar-link:hover,
.sidebar-logout-link:hover {
    color: #ffffff;
    background-color: rgb(255 255 255 / 8%);
}

.sidebar-link.active {
    color: var(--sidebar-active-text);
    background-color: var(--sidebar-active-background);
    font-weight: 700;
}

.sidebar-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;

    width: 30px;

    font-size: 1.15rem;
}

.sidebar-text {
    opacity: 1;

    transition:
        opacity 0.15s ease,
        visibility 0.15s ease;
}

/* =====================================================
   Usuario
   ===================================================== */

.sidebar-user {
    padding: 12px 10px;

    border-top: 1px solid rgb(255 255 255 / 8%);
}

.sidebar-user-information {
    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 52px;
    padding: 5px 13px 12px;
}

.sidebar-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;

    width: 38px;
    height: 38px;

    color: #ffffff;
    background-color: var(--sidebar-background-secondary);
    border-radius: 50%;

    font-size: 1.1rem;
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;

    min-width: 0;
}

.sidebar-user-name,
.sidebar-user-email {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-user-name {
    color: #ffffff;
    font-size: 0.92rem;
    font-weight: 700;
}

.sidebar-user-email {
    color: var(--sidebar-text-muted);
    font-size: 0.75rem;
}

/* =====================================================
   Contenido y barra superior
   ===================================================== */

.app-content-wrapper {
    min-height: 100vh;
    margin-left: var(--sidebar-width);

    transition: margin-left var(--transition-speed) ease;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;

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

    min-height: var(--topbar-height);
    padding: 0 28px;

    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgb(0 0 0 / 3%);
}

.topbar-page-title {
    overflow: hidden;

    color: #1f2937;

    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 9px;

    color: #4b5563;
    font-size: 0.9rem;
}

.topbar-user-icon {
    font-size: 1.4rem;
}

.topbar-menu-button {
    flex: 0 0 42px;

    width: 42px;
    height: 42px;

    color: #374151;
    border-radius: 10px;

    font-size: 1.5rem;
}

.topbar-menu-button:hover {
    background-color: #f3f4f6;
}

.app-main-content {
    padding: 24px;
}

/* Evita doble separación en vistas que usan container py-4 */
.app-main-content>.container {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* =====================================================
   Sidebar plegado en escritorio
   ===================================================== */

@media (min-width: 992px) {
    body.sidebar-collapsed .app-sidebar {
        width: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .app-content-wrapper {
        margin-left: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .sidebar-text {
        width: 0;
        overflow: hidden;

        opacity: 0;
        visibility: hidden;
    }

    body.sidebar-collapsed .sidebar-header {
        justify-content: center;
        padding: 0 12px;
    }

    body.sidebar-collapsed .sidebar-brand {
        gap: 0;
    }

    body.sidebar-collapsed .sidebar-collapse-button {
        position: absolute;
        top: 17px;
        right: -16px;

        color: #374151;
        background-color: #ffffff;
        border: 1px solid var(--border-color);
        box-shadow: 0 3px 8px rgb(0 0 0 / 10%);
    }

    body.sidebar-collapsed .sidebar-navigation,
    body.sidebar-collapsed .sidebar-user {
        padding-right: 10px;
        padding-left: 10px;
    }

    body.sidebar-collapsed .sidebar-section {
        height: 16px;
        padding: 8px 0 0;
    }

    body.sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-logout-link {
        justify-content: center;
        gap: 0;

        padding-right: 10px;
        padding-left: 10px;
    }

    body.sidebar-collapsed .sidebar-user-information {
        justify-content: center;
        gap: 0;

        padding-right: 0;
        padding-left: 0;
    }
}

/* =====================================================
   Overlay
   ===================================================== */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1030;

    display: none;

    background-color: rgb(17 24 39 / 55%);
    opacity: 0;

    transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* =====================================================
   Tablet y móvil
   ===================================================== */

@media (max-width: 991.98px) {
    .app-sidebar {
        width: min(var(--sidebar-width), 86vw);

        transform: translateX(-105%);
    }

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

    .app-content-wrapper {
        margin-left: 0;
    }

    .app-topbar {
        padding: 0 16px;
    }

    .app-main-content {
        padding: 18px 12px;
    }

    .sidebar-text {
        width: auto !important;

        opacity: 1 !important;
        visibility: visible !important;
    }
}

@media (max-width: 575.98px) {
    .app-topbar {
        gap: 10px;
    }

    .topbar-page-title {
        font-size: 0.95rem;
    }

    .app-main-content {
        padding: 14px 8px;
    }

    .app-main-content .container {
        max-width: 100%;
    }
}

.inventory-kpi-card {
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.inventory-kpi-card:hover {
    transform: translateY(-2px);
}

.inventory-kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;

    width: 48px;
    height: 48px;

    border-radius: 14px;
    font-size: 1.35rem;
}
  .sales-kpi-card {
      transition:
          transform 0.18s ease,
          box-shadow 0.18s ease;
  }

  .sales-kpi-card:hover {
      transform: translateY(-2px);
  }

.sales-kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;

    width: 48px;
    height: 48px;

    border-radius: 14px;
    font-size: 1.35rem;
}

.sale-detail-summary {
    top: 85px;
}