/* ============================================
   Safety World ERP — Premium Design System
   ============================================ */

/* --- Design Tokens --- */
:root {
    /* Primary Palette */
    --primary: hsl(245, 58%, 51%);
    --primary-dark: hsl(245, 62%, 43%);
    --primary-light: hsl(245, 80%, 95%);
    --primary-glow: hsla(245, 58%, 51%, 0.15);

    /* Accent */
    --accent: hsl(210, 100%, 56%);
    --accent-light: hsl(210, 100%, 94%);

    /* Semantic */
    --success: hsl(160, 72%, 42%);
    --success-light: hsl(160, 60%, 93%);
    --warning: hsl(38, 92%, 55%);
    --warning-light: hsl(38, 80%, 93%);
    --danger: hsl(0, 78%, 58%);
    --danger-light: hsl(0, 70%, 95%);
    --info: hsl(187, 85%, 43%);
    --info-light: hsl(187, 70%, 93%);

    /* Neutrals */
    --bg-body: hsl(220, 20%, 97%);
    --bg-card: hsl(0, 0%, 100%);
    --bg-card-hover: hsl(220, 20%, 99%);
    --bg-subtle: hsl(220, 14%, 96%);
    --text-main: hsl(222, 47%, 14%);
    --text-secondary: hsl(220, 15%, 35%);
    --text-muted: hsl(220, 12%, 55%);
    --text-faint: hsl(220, 10%, 70%);
    --border-color: hsl(220, 16%, 90%);
    --border-hover: hsl(220, 16%, 82%);
    --divider: hsl(220, 14%, 93%);

    /* Shadows */
    --shadow-xs: 0 1px 2px hsla(220, 40%, 10%, 0.04);
    --shadow-sm: 0 1px 3px hsla(220, 40%, 10%, 0.06), 0 1px 2px hsla(220, 40%, 10%, 0.04);
    --shadow: 0 4px 12px hsla(220, 40%, 10%, 0.08), 0 1px 3px hsla(220, 40%, 10%, 0.04);
    --shadow-md: 0 8px 24px hsla(220, 40%, 10%, 0.1), 0 2px 6px hsla(220, 40%, 10%, 0.05);
    --shadow-lg: 0 16px 48px hsla(220, 40%, 10%, 0.12), 0 4px 12px hsla(220, 40%, 10%, 0.06);
    --shadow-primary: 0 4px 14px hsla(245, 58%, 51%, 0.25);

    /* Radii */
    --radius-sm: 0.5rem;
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --radius-full: 9999px;

    /* Layout */
    --sidebar-width: 264px;
    --sidebar-collapsed: 72px;
    --navbar-height: 68px;

    /* Transitions */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration: 250ms;
    --duration-slow: 400ms;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--duration) var(--ease-smooth);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* --- Scrollbar --- */
html {
    scrollbar-width: auto;
    scrollbar-color: hsl(220, 16%, 74%) var(--bg-subtle);
}
::-webkit-scrollbar {
    width: 12px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg-subtle);
}
::-webkit-scrollbar-thumb {
    background: hsl(220, 16%, 74%);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-subtle);
}
::-webkit-scrollbar-thumb:hover {
    background: hsl(220, 16%, 56%);
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow-x: hidden;
}

.main-content {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    margin-left: var(--sidebar-width);
    padding: 0 2rem 2rem;
    transition: margin-left var(--duration-slow) var(--ease-smooth);
    min-height: 100vh;
}

/* --- Page Content Wrapper --- */
.page-content {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.15rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, hsl(222, 47%, 14%) 0%, hsl(222, 40%, 18%) 100%);
    color: hsl(220, 15%, 85%);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all var(--duration-slow) var(--ease-smooth);
    border-right: 1px solid hsla(220, 30%, 25%, 0.3);
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid hsla(220, 30%, 30%, 0.25);
    min-height: 68px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, hsl(260, 65%, 55%) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px hsla(245, 58%, 51%, 0.3);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

/* Nav Group Labels */
.nav-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: hsla(220, 15%, 55%, 0.6);
    padding: 1rem 0.75rem 0.4rem;
    margin-top: 0.25rem;
}

.nav-divider {
    height: 1px;
    background: hsla(220, 30%, 30%, 0.2);
    margin: 0.5rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    gap: 0.75rem;
    color: hsla(220, 15%, 75%, 0.85);
    font-weight: 500;
    font-size: 0.875rem;
    position: relative;
    transition: all var(--duration) var(--ease-smooth);
    cursor: pointer;
}

.nav-item i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity var(--duration) var(--ease-smooth);
}

.nav-item:hover {
    background: hsla(220, 30%, 40%, 0.15);
    color: hsl(220, 15%, 95%);
}

.nav-item:hover i {
    opacity: 1;
}

.nav-item.active {
    background: linear-gradient(135deg, hsla(245, 58%, 51%, 0.2) 0%, hsla(245, 58%, 51%, 0.1) 100%);
    color: hsl(245, 80%, 80%);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item.active i {
    opacity: 1;
    color: hsl(245, 80%, 75%);
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
    line-height: 1.5;
}

/* ============================================
   NAVBAR / TOP BAR
   ============================================ */

.navbar {
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
    backdrop-filter: blur(12px);
    background: hsla(0, 0%, 100%, 0.85);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breadcrumbs a {
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumbs a:hover {
    color: var(--primary);
}

.breadcrumbs .separator {
    color: var(--text-faint);
    font-size: 0.7rem;
}

.breadcrumbs .current {
    color: var(--text-main);
    font-weight: 600;
}

/* Sidebar Toggle Button */
#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration) var(--ease-smooth);
}

#sidebar-toggle:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    transition: all var(--duration) var(--ease-smooth);
}

.user-profile:hover {
    background: var(--bg-subtle);
}

.user-info {
    text-align: right;
}

.user-info p:first-child {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.3;
}

.user-info p:last-child {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 2px solid var(--primary-light);
    transition: border-color var(--duration) var(--ease-smooth);
}

.user-profile:hover .user-avatar {
    border-color: var(--primary);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    transition: all var(--duration) var(--ease-smooth);
}

.btn-logout:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--duration) var(--ease-smooth);
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--divider);
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.card-header h2 i {
    color: var(--primary);
    width: 20px;
    height: 20px;
}

.card-header .card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Stat Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: all var(--duration) var(--ease-smooth);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.03;
    transform: translate(20px, -20px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon i {
    width: 22px;
    height: 22px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.3;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin-top: 0.15rem;
    letter-spacing: -0.02em;
}

.stat-value.mono {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 1.35rem;
}

/* Interactive Card (warehouse cards, vendor cards, etc) */
.interactive-card {
    transition: all var(--duration) var(--ease-smooth);
    cursor: default;
}

.interactive-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

/* ============================================
   TABLES
   ============================================ */

.table-container,
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 100%;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    text-align: left;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-subtle);
    white-space: nowrap;
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--divider);
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--duration-fast) var(--ease-smooth);
}

tbody tr:hover {
    background: hsla(220, 20%, 97%, 0.7);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Striped variant */
.table-striped tbody tr:nth-child(even) {
    background: hsla(220, 16%, 96%, 0.5);
}

.table-striped tbody tr:nth-child(even):hover {
    background: hsla(220, 20%, 95%, 0.7);
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
    margin-bottom: 1.25rem;
}

.label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 550;
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.label .required {
    color: var(--danger);
    margin-left: 2px;
}

.input, .form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all var(--duration) var(--ease-smooth);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.875rem;
}

.input::placeholder, .form-control::placeholder {
    color: var(--text-faint);
}

.input:hover, .form-control:hover {
    border-color: var(--border-hover);
}

.input:focus, .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input.error, .form-control.error, .form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px hsla(0, 78%, 58%, 0.1);
}

select.input, select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

textarea.input, textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.invalid-feedback {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.3rem;
    display: block;
    font-weight: 500;
}

/* Form Hint */
.form-hint {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-top: 0.3rem;
}

/* Form Error */
.form-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

/* Form Sections */
.form-section {
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
}

.form-section-title {
    font-size: 0.9rem;
    font-weight: 650;
    color: var(--text-main);
    margin-bottom: 1rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section-title i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

/* Form Grid Layouts */
.form-row {
    display: grid;
    gap: 1rem;
}

.form-row-2 {
    grid-template-columns: 1fr 1fr;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

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

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--duration) var(--ease-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: nowrap;
    text-decoration: none;
}

.btn i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px hsla(245, 58%, 51%, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-primary);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 1px 3px hsla(160, 72%, 42%, 0.3);
}

.btn-success:hover {
    background: hsl(160, 72%, 36%);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: hsl(0, 78%, 50%);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: hsl(187, 85%, 36%);
}

.btn-secondary {
    background: hsl(220, 13%, 46%);
    color: white;
}

.btn-secondary:hover {
    background: hsl(220, 13%, 38%);
}

.btn-outline {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 0.4rem 0.65rem;
}

.btn-ghost:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.btn-icon {
    padding: 0.45rem;
    width: 34px;
    height: 34px;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-sm i {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 0.95rem;
}

/* Button Groups */
.btn-group {
    display: flex;
    gap: 0.35rem;
}

/* ============================================
   BADGES / STATUS PILLS
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.5;
}

.badge i {
    width: 12px;
    height: 12px;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: hsl(30, 80%, 40%);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background: var(--info-light);
    color: hsl(187, 85%, 33%);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-neutral {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid hsl(0, 60%, 88%);
    color: hsl(0, 65%, 35%);
}

.alert-success {
    background: var(--success-light);
    border: 1px solid hsl(160, 45%, 85%);
    color: hsl(160, 60%, 30%);
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid hsl(38, 60%, 85%);
    color: hsl(30, 65%, 30%);
}

.alert-info {
    background: var(--info-light);
    border: 1px solid hsl(187, 45%, 85%);
    color: hsl(187, 70%, 28%);
}

/* ============================================
   TOAST NOTIFICATION SYSTEM
   ============================================ */

.toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.875rem;
    font-weight: 550;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    opacity: 0;
    transition: all var(--duration-slow) var(--ease-smooth);
    max-width: 400px;
    backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast-success {
    background: hsla(160, 72%, 42%, 0.95);
    color: white;
}

.toast-error {
    background: hsla(0, 78%, 58%, 0.95);
    color: white;
}

.toast-warning {
    background: hsla(38, 92%, 50%, 0.95);
    color: white;
}

.toast-info {
    background: hsla(245, 58%, 51%, 0.95);
    color: white;
}

/* ============================================
   MODAL SYSTEM
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: hsla(222, 47%, 8%, 0.5);
    backdrop-filter: blur(6px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration) var(--ease-smooth);
    padding: 2rem;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.97);
    transition: transform var(--duration-slow) var(--ease-bounce);
}

.modal-overlay.show .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--divider);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 650;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--divider);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ============================================
   WELCOME BANNER (Dashboard)
   ============================================ */

.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, hsl(260, 55%, 40%) 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-primary);
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    right: -60px;
    bottom: -60px;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: hsla(0, 0%, 100%, 0.05);
    pointer-events: none;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    right: 60px;
    top: -30px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: hsla(0, 0%, 100%, 0.03);
    pointer-events: none;
}

.welcome-banner h1 {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ============================================
   QUICK ACTION BUTTONS
   ============================================ */

.quick-action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    box-shadow: var(--shadow-xs);
    transition: all var(--duration) var(--ease-smooth);
    text-decoration: none;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-glow);
    background: var(--bg-card-hover);
}

.quick-action-btn i {
    width: 18px;
    height: 18px;
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--duration-slow) var(--ease-smooth);
}

/* ============================================
   STOCK LEVEL INDICATOR
   ============================================ */

.stock-level {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stock-bar {
    flex: 1;
    height: 5px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
    max-width: 80px;
}

.stock-bar .stock-fill {
    height: 100%;
    border-radius: var(--radius-full);
}

.stock-fill.high { background: var(--success); }
.stock-fill.medium { background: var(--warning); }
.stock-fill.low { background: var(--danger); }

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state i {
    width: 48px;
    height: 48px;
    color: var(--text-faint);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ============================================
   FILE DROP ZONE
   ============================================ */

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--duration) var(--ease-smooth);
    background: var(--bg-subtle);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.drop-zone i {
    width: 32px;
    height: 32px;
    color: var(--text-faint);
    margin-bottom: 0.5rem;
}

.drop-zone p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.drop-zone .browse-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ============================================
   FILTER BAR
   ============================================ */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.filter-actions {
    display: flex;
    gap: 0.35rem;
    align-items: flex-end;
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    border-bottom: 2px solid var(--divider);
    gap: 0;
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all var(--duration) var(--ease-smooth);
}

.tab:hover {
    color: var(--text-main);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ============================================
   TIMELINE (Movement Logs)
   ============================================ */

.timeline-item {
    display: flex;
    gap: 0.85rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--divider);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.timeline-dot i {
    width: 14px;
    height: 14px;
}

.timeline-body {
    flex: 1;
    min-width: 0;
}

.timeline-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.timeline-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.5;
}

.timeline-meta {
    font-size: 0.7rem;
    color: var(--text-faint);
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   SPINNER
   ============================================ */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid hsla(0, 0%, 100%, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   METRIC GRID
   ============================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.warehouse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 1.25rem;
}

/* ============================================
   MINI STATS BOX (Inside cards)
   ============================================ */

.mini-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    background: var(--bg-subtle);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-color);
}

.mini-stat {
    text-align: center;
}

.mini-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 550;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mini-stat-value {
    font-size: 1rem;
    font-weight: 700;
    margin-top: 0.1rem;
    line-height: 1.3;
}

/* ============================================
   CARD ACTIONS
   ============================================ */

.card-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    align-items: center;
    border-top: 1px solid var(--divider);
    padding-top: 1rem;
    margin-top: 0.75rem;
}

/* ============================================
   MONOSPACE VALUES
   ============================================ */

.mono {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: hsl(30, 80%, 40%); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-main { color: var(--text-main); }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.text-right { text-align: right; }
.text-center { text-align: center; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   AUTH PAGES
   ============================================ */

.auth-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, hsl(220, 20%, 97%) 0%, hsl(220, 16%, 90%) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

/* ============================================
   RESPONSIVE DESIGN SYSTEM (BOOTSTRAP ALIGNED)
   ============================================ */

/* --- Mobile Drawer Backdrop & Close Button --- */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: hsla(222, 47%, 8%, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--duration) var(--ease-smooth), visibility var(--duration);
}

.sidebar-close-btn {
    background: hsla(0, 0%, 100%, 0.08);
    border: 1px solid hsla(0, 0%, 100%, 0.12);
    color: hsl(220, 15%, 85%);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
}

.sidebar-close-btn:hover {
    background: hsla(0, 0%, 100%, 0.2);
    color: #fff;
    transform: scale(1.05);
}

/* --- Large Desktops (<= 1280px) --- */
@media (max-width: 1280px) {
    .form-row-3 {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Tablets & Mobile Drawer Navigation (<= 1024px) --- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        max-width: 85vw;
        box-shadow: 0 20px 40px hsla(222, 47%, 8%, 0.5);
        z-index: 1000;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 1.25rem 1.75rem;
        width: 100%;
        max-width: 100%;
    }

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

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

    .navbar {
        padding: 0 1.25rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1rem;
    }

    /* Auto-collapse dual/triple column inline grid layouts */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 360px 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"],
    div[style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr !important;
    }
}

/* --- Medium Devices & Tablets (<= 991.98px) --- */
@media (max-width: 991.98px) {
    .split-layout,
    .page-detail-layout {
        flex-direction: column !important;
    }

    .split-layout > div,
    .page-detail-layout > div {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Competitor sidebar & sticky side panels */
    #competitor-sidebar,
    .sticky-side-panel {
        position: static !important;
        width: 100% !important;
        min-width: 0 !important;
        min-height: auto !important;
    }
}

/* --- Mobile Landscape & Standard Phones (<= 768px) --- */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
        height: 62px;
    }

    .main-content {
        padding: 0 0.85rem 1.5rem;
    }

    .page-content {
        margin-top: 1rem;
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.45rem;
    }

    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .page-actions .btn {
        flex: 1 1 auto;
        min-width: 130px;
    }

    .card {
        padding: 1rem;
        border-radius: var(--radius-sm);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Clear all hardcoded inline min-widths that cause horizontal blowout */
    div[style*="min-width"],
    aside[style*="min-width"],
    section[style*="min-width"],
    form[style*="min-width"] {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .form-row-2,
    .form-row-3,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Responsive Filter Bars */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        padding: 1rem !important;
        width: 100% !important;
    }

    .filter-bar .form-group {
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
        margin-bottom: 0 !important;
    }

    .filter-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: 0.25rem;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .warehouse-grid {
        grid-template-columns: 1fr !important;
    }

    .mini-stats {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    /* Modals Responsive */
    .modal-overlay {
        padding: 0.75rem;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: var(--radius) var(--radius) 0 0;
        margin: 0;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-body {
        padding: 1rem 1.25rem;
    }

    .modal-footer {
        padding: 0.75rem 1.25rem;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }

    /* Lightbox modal on mobile */
    .lightbox-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .lightbox-prev, .lightbox-next {
        width: 44px;
        height: 44px;
        font-size: 2rem;
    }
    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
}

/* --- Small Smartphones (<= 576px) --- */
@media (max-width: 576px) {
    .navbar {
        padding: 0 0.75rem;
        height: 56px;
    }

    .main-content {
        padding: 0 0.5rem 1.25rem;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    .welcome-banner {
        padding: 1.25rem !important;
    }

    .welcome-banner h1 {
        font-size: 1.35rem !important;
    }

    /* Compact Metrics / Stat Cards */
    .metrics-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .stat-card {
        padding: 0.85rem !important;
        gap: 0.65rem !important;
    }

    .stat-icon {
        width: 38px !important;
        height: 38px !important;
        border-radius: 8px !important;
    }

    .stat-icon i {
        width: 18px !important;
        height: 18px !important;
    }

    .stat-value {
        font-size: 1.2rem !important;
    }

    /* Tables in responsive containers */
    th, td {
        padding: 0.55rem 0.65rem;
        font-size: 0.8rem;
    }

    .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.8rem;
    }

    .quick-action-btn {
        padding: 0.65rem;
        font-size: 0.8rem;
    }

    /* Form controls touch target sizing */
    .input, select.input, textarea.input,
    .form-control, .form-select {
        font-size: 16px !important; /* Prevents auto-zoom on iOS Safari */
        padding: 0.65rem 0.75rem;
    }
}

/* --- Extra Small Phones (<= 400px) --- */
@media (max-width: 400px) {
    .metrics-grid {
        grid-template-columns: 1fr !important;
    }

    .page-actions .btn {
        width: 100%;
        flex: 1 1 100%;
    }
}

/* ============================================
   ERP PAGINATION COMPONENT
   ============================================ */
.erp-pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.erp-pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.erp-pagination-info strong {
    color: var(--text-main);
    font-weight: 600;
}

.erp-pagination-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.erp-pagination-per-page {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.825rem;
    color: var(--text-muted);
}

.erp-per-page-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    transition: border-color var(--duration-fast);
}

.erp-per-page-select:focus {
    border-color: var(--primary);
}

.erp-pagination-nav {
    display: inline-flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.25rem;
}

.erp-page-item {
    display: inline-flex;
}

.erp-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.4rem;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
    user-select: none;
}

.erp-page-link svg {
    pointer-events: none;
}

.erp-page-link:hover {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
    color: var(--primary);
}

.erp-page-item.active .erp-page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    cursor: default;
    box-shadow: var(--shadow-xs);
}

.erp-page-item.disabled .erp-page-link {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--bg-subtle);
}

.erp-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 32px;
    color: var(--text-muted);
    font-size: 0.85rem;
    user-select: none;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .sidebar,
    .navbar,
    .page-actions,
    .btn,
    .filter-bar,
    #sidebar-toggle,
    .quick-action-btn,
    .nav-item {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }

    body {
        background: white;
        color: black;
        font-size: 12pt;
    }

    table {
        font-size: 10pt;
    }

    th {
        background: #f0f0f0 !important;
    }

    .badge {
        border: 1px solid currentColor;
    }
}
