:root {

    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --bg-dark: #0f172a;
    --glass: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-red: #ef4444;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;
    --sidebar-width: 260px;
    --header-height: 80px;
    --transition-fast: 0.2s ease;
    --transition-mid: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 16px;
    --radius-md: 12px;

    /* Executive Dashboard Colors */
    --exec-red: #ef4444;
    --exec-orange: #f97316;
    --exec-yellow: #facc15;
    --exec-blue: #3b82f6;
    --exec-bg: #f3f4f6;
    --exec-card-bg: #ffffff;
    --exec-text-dark: #1f2937;
    --exec-text-light: #6b7280;
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Pretendard', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
}

.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: radial-gradient(circle at 0% 0%, #1e1b4b 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, #0c4a6e 0%, transparent 40%);
    opacity: 0.6;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 2rem 3rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo-icon {
    color: var(--primary);
}

nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Custom Scrollbar for Nav */
nav::-webkit-scrollbar {
    width: 4px;
}

nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.sidebar-footer {
    padding: 2rem;
    border-top: 1px solid var(--glass-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent-blue));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    margin-left: auto;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-red);
    transform: scale(1.05);
}

.logout-btn i {
    width: 18px;
    height: 18px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
}

.top-bar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3rem;
    border-bottom: 1px solid var(--glass-border);
}

.search-bar {
    position: relative;
    width: 400px;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 12px 1rem 12px 3rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    color: #fff;
    outline: none;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-btn {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
}

.date-selector {
    padding: 8px 1.5rem;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem;
}


/* Dashboard Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--glass);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    transition: var(--transition-mid);
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-trend {
    font-size: 0.8rem;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up {
    color: var(--accent-green);
}

.trend-down {
    color: var(--accent-red);
}

/* Chart Containers */
.chart-container {
    background: var(--glass);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    margin-bottom: 2rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Predict Alert Area */
.predict-alert-area {
    background: var(--glass);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    margin-top: 2rem;
}

.predict-alert-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.alert-item.warning {
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.1);
}

/* Matrix Grid View - Base Styles */
.matrix-container {
    background: var(--glass);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    margin-top: 1rem;
    overflow: auto;
    max-height: calc(100vh - 250px);
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.matrix-table {
    width: max-content;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 100%;
}

.matrix-table th,
.matrix-table td {
    padding: 6px 1px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    font-size: 0.7rem;
    font-weight: 200;
    white-space: nowrap;
}

.matrix-table th {
    background: #1e293b;
    font-size: 0.62rem;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--glass-border);
}

/* Sticky Column logic */
.matrix-table .sticky-col {
    position: sticky;
    left: 0;
    background: #1e293b;
    z-index: 10;
}

.matrix-table th.sticky-col {
    z-index: 30;
}

.matrix-table .first-col {
    left: 0;
    min-width: 60px;
}

.matrix-table .second-col {
    left: 60px;
    min-width: 120px;
    text-align: left !important;
}

.matrix-table .third-col {
    left: 180px;
    min-width: 60px;
    border-right: 2px solid var(--primary);
    background: #1a2332 !important;
}

/* Secondary Header Row logic (for Sales Analysis) */
.matrix-table thead tr:nth-child(2) th {
    top: 25px;
    /* Adjust based on your header height */
}

.matrix-table thead tr:nth-child(2) th.sticky-col {
    top: 25px;
}


/* Cell Heatmap */
.cell-high {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #4ade80;
    font-weight: 600;
}

.cell-mid {
    background: rgba(59, 130, 246, 0.1) !important;
    color: #60a5fa;
}

.cell-low {
    background: rgba(239, 68, 68, 0.05) !important;
    color: #f87171;
}

.year-header-2025 {
    background: rgba(99, 102, 241, 0.3) !important;
    color: #fff;
}

.year-header-2024 {
    background: rgba(245, 158, 11, 0.3) !important;
    color: #fff;
}

.year-header-2023 {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff;
}

.content-body>div {
    animation: fadeIn 0.6s var(--transition-mid);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}


/* Matrix Analysis Styles - Redundant ones removed */
.matrix-scroll-wrapper {
    overflow: auto;
    background: var(--glass-bg);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-top: 1.5rem;
    position: relative;
    max-height: calc(100vh - 220px);
}

.year-group-label {
    background: rgba(99, 102, 241, 0.2) !important;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.8rem !important;
    text-align: center;
}

.month-col {
    min-width: 38px;
}

.total-highlight,
.year-total-col {
    min-width: 40px;
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    color: var(--primary);
}

.dynamic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 500;
}

.year-checkbox-group {
    background: var(--glass-bg);
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.selector-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.year-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.year-checkbox-label:hover {
    color: var(--primary);
}

.year-checkbox-label input {
    accent-color: var(--primary);
}

/* Updated Sticky Columns for Matrix */
.matrix-table .sticky-col {
    position: sticky;
    z-index: 10;
    background: #1e293b;
}

/* Specific z-index for top-left sticky cells */
/* Specific z-index for top-left sticky cells */
.matrix-table th.sticky-col {
    z-index: 30;
    top: 0;
    background: #1e293b;
    /* Ensure opaque background */
}

/* Multi-row Header Fix */
.matrix-table thead tr:first-child th {
    height: 45px;
    top: 0;
    position: sticky;
    background: #1e293b;
    z-index: 20;
    white-space: nowrap;
}

.matrix-table thead tr:nth-child(2) th {
    position: sticky;
    top: 45px;
    /* Match first row height */
    background: #1e293b;
    z-index: 15;
}

/* Specific z-index for multi-header sticky cells (Corner) */
.matrix-table thead tr:nth-child(2) th.sticky-col {
    top: 45px;
    z-index: 50;
    /* Highlighted corner cells must be on top */
}

.matrix-table .first-col {
    left: 0;
}

.matrix-table .second-col {
    left: 60px;
}

.matrix-table .third-col {
    left: 180px;
}

.highlight-stock-cell {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #60a5fa;
    font-weight: 200;
    font-size: 0.75rem;
}

/* --- Info Modal Styles --- */
.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.info-modal-content {
    width: 90%;
    max-width: 550px;
    padding: 1.5rem;
    border: 1px solid var(--glass-border);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--danger);
}

.info-section {
    margin-bottom: 1.5rem;
}

.info-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
}

.color-box {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    vertical-align: middle;
}

.heatmap-sample {
    background: linear-gradient(to right, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 1));
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.analysis-list {
    list-style: none;
    padding: 0;
}

.analysis-list li {
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    position: relative;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.analysis-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary);
}

.analysis-list li strong {
    color: var(--text-main);
}

.info-footer {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-muted);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.matrix-table thead tr:first-child th.sticky-col {
    z-index: 30;
}

/* Multi-row header support: Only apply top offset to the second row if it exists */
.matrix-table thead tr:nth-child(2) th {
    top: 45px;
    /* Height of the first header row (Year names) */
}

/* Ensure first row is always at top 0 */
.matrix-table thead tr:first-child th {
    top: 0;
}

/* Status Chips and Premium Table refinements */
.premium-table {
    width: 100%;
    border-collapse: collapse;
}

.premium-table th {
    padding: 1rem;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 2px solid var(--glass-border);
}

.premium-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.status-chip {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-chip.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-chip.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.status-chip.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.data-table-container {
    background: var(--glass);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    padding: 1rem;
    overflow: hidden;
}

.edit-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 10px;
    color: #fff;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.edit-input:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.7);
    outline: none;
}

.save-row-btn,
.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon.primary {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
}

.btn-icon.danger {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-icon:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.btn-icon.primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-icon.danger:hover {
    background: var(--accent-red);
    color: #fff;
}

.product-edit-table input[type="number"] {
    -moz-appearance: textfield;
}

.product-edit-table input::-webkit-outer-spin-button,
.product-edit-table input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}


/* Excel Actions */
.sidebar-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 1rem;
}

.excel-actions {
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 5px;
    padding-left: 0.5rem;
}

.excel-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 1rem;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.excel-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--text-muted);
}

.excel-btn.primary {
    background: var(--primary);
    border-color: transparent;
    font-weight: 600;
}

.excel-btn.primary:hover {
    box-shadow: 0 4px 15px var(--primary-glow);
    transform: translateY(-2px);
}

.matrix-container::-webkit-scrollbar-corner {
    background: transparent;
}

/* Settings View */
.settings-view {
    max-width: 900px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.page-desc {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 3rem;
}

.settings-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-header i {
    color: var(--primary);
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.path-input-group {
    display: flex;
    gap: 10px;
}

.path-input-group input {
    flex: 1;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 10px 1rem;
    color: var(--text-main);
    font-size: 0.85rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}

.hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 8px;
}

.toggle-switch {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary:hover {
    box-shadow: 0 4px 15px var(--primary-glow);
    transform: translateY(-2px);
}

/* Custom Multi-Select Dropdown */
.multi-select-container {
    position: relative;
    display: inline-block;
}

.multi-select-trigger {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-main);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 120px;
    justify-content: space-between;
}

.multi-select-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 0;
    width: 160px;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.multi-select-dropdown.show {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

.multi-select-option {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main);
    font-size: 0.85rem;
}

.multi-select-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.multi-select-option input[type="checkbox"] {
    margin-right: 10px;
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stock Level Color Coding */
.stock-zero {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
    font-weight: 700 !important;
}

.stock-low {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
    font-weight: 700 !important;
}

.stock-medium {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #3b82f6 !important;
    font-weight: 700 !important;
}

.stock-high {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #22c55e !important;
    font-weight: 700 !important;
}

/* --- Explainable AI (XAI) UI --- */
.xai-badge {
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.xai-factor-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px dashed var(--glass-border);
}

.xai-factor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
}

.xai-factor-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    margin: 0 12px;
    position: relative;
    overflow: hidden;
}

.xai-factor-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.impact-positive {
    color: var(--accent-green);
}

.impact-negative {
    color: var(--accent-red);
}

.smart-order-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.smart-order-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    pointer-events: none;
    animation: pulse-glow 4s infinite alternate;
}

@keyframes pulse-glow {
    0% {
        transform: translate(0, 0);
        opacity: 0.3;
    }

    100% {
        transform: translate(10%, 10%);
        opacity: 0.6;
    }
}

/* --- What-If Simulation UI --- */
.simulation-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    margin-top: 15px;
}

.sim-controls {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sim-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sim-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
}

.sim-value {
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
}

.sim-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.sim-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-glow);
}

.sim-result-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.sim-impact-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.impact-bad {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.impact-good {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.root-cause-box {
    margin-top: 10px;
    padding: 10px 15px;
    background: rgba(239, 68, 68, 0.05);
    border-left: 3px solid var(--accent-red);
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
}

/* --- Smart Notification System --- */
.notification-bell-container {
    position: relative;
    cursor: pointer;
    margin-right: 15px;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-red);
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: bold;
    border: 2px solid var(--bg-deep);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.smart-alert-drawer {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 350px;
    background: rgba(15, 15, 25, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    z-index: 1000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    display: none;
    animation: slideInRight 0.3s var(--transition-mid);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-item-rich {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.2s;
    display: flex;
    align-items: flex-start;
}

.alert-item-rich:hover {
    background: rgba(255, 255, 255, 0.05);
}

.alert-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

/* --- Dead Stock UI --- */
.dead-stock-row {
    margin-bottom: 25px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), rgba(0, 0, 0, 0.2));
    padding: 18px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-left: 4px solid var(--accent-red);
}

.cost-tag {
    font-size: 0.75rem;
    color: var(--accent-red);
    font-weight: bold;
    background: rgba(239, 68, 68, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.strategy-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 10px;
}

/* --- Channel Integration Hub --- */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.channel-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: all 0.3s var(--transition-mid);
}

.channel-card.connected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.channel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
}

.channel-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.status-online {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-offline {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* --- Purchase Order (PO) Document --- */
.po-document {
    background: #fff;
    color: #1f2937;
    padding: 60px;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Inter', sans-serif;
}

.po-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.po-table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
}

.po-table th {
    background: #f3f4f6;
    padding: 12px;
    text-align: left;
    font-size: 0.85rem;
}

.po-table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

.po-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 50px;
}

.signature-box {
    width: 200px;
    border-top: 1px solid #9ca3af;
    text-align: center;
    padding-top: 10px;
    font-size: 0.8rem;
    color: #6b7280;
}

.sync-pulse {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* --- Customizable Excel Export UI --- */
.export-config-container {
    display: flex;
    gap: 20px;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.column-list-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: bold;
}

.column-select-list {
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    overflow-y: auto;
    padding: 10px;
}

.column-item {
    padding: 8px 12px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.column-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.column-item.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.list-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sort-config-area {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.sort-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.sort-select {
    background: var(--bg-deep);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* --- Private Auth Page --- */
#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: var(--bg-dark);
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition-mid);
}

.auth-card {
    width: 400px;
    background: var(--glass);
    backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: auth-slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes auth-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: white;
    filter: drop-shadow(0 4px 10px var(--primary-glow));
}

.auth-header h1 {
    font-size: 1.5rem;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.auth-form-group {
    margin-bottom: 1.5rem;
}

.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    width: 18px;
}

.auth-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 12px 12px 2.8rem;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.auth-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.btn-auth {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: 1rem;
}

.btn-auth:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px -5px var(--primary-glow);
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-footer span {
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    margin-left: 0.5rem;
}

.auth-footer span:hover {
    text-decoration: underline;
}

.auth-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

#app-container {
    display: none;
    width: 100%;
}

#app-container.visible {
    display: flex;
}

/* --- Advanced Insights Styles --- */
.matrix-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 5px;
}

.matrix-tab-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.matrix-tab-btn:hover {
    color: var(--text-main);
}

.matrix-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    text-align: center;
    min-width: 60px;
}

.badge-blue {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-green {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-gray {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-orange {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.compact-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.compact-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}


/* --- Hyper-Premium Product Center Modal --- */
.premium-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    /* Deep slate mask */
    backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: modal-backdrop-fade 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-modal-container {
    width: 95%;
    max-width: 1050px;
    height: 85vh;
    background: rgba(30, 41, 59, 0.7);
    /* Translucent Navy */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: modal-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.premium-modal-header {
    padding: 24px 32px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-meta .p-badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.premium-modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar Tabs */
.modal-tabs-sidebar {
    width: 180px;
    padding: 32px 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(15, 23, 42, 0.2);
}

.m-tab-item {
    padding: 14px 18px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.m-tab-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.m-tab-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 20px var(--primary-glow);
}

.modal-content-panel {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
}

/* Grid layout for info */
.modal-grid-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.modal-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-input-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.modal-input-group input,
.modal-input-group select,
.modal-input-group textarea {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input-group input:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.6);
}

/* Smart Components */
.quick-copy-box {
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 700;
    transition: opacity 0.2s;
}

.quick-copy-box:hover {
    opacity: 0.8;
}

.margin-intelligence-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(59, 130, 246, 0.05));
    border-radius: 20px;
    padding: 24px;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

@keyframes modal-backdrop-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modal-slide-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Hover effects for main table */
.clickable-item {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.clickable-item:hover {
    color: white;
    text-shadow: 0 0 10px var(--primary);
}

.clickable-item::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--primary);
    transition: width 0.3s;
}

.clickable-item:hover::after {
    width: 100%;
}

/* --- DaNexAi Prime Dashboard Styles --- */
.prime-dashboard {
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.prime-status-bar {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.status-tile {
    transition: background 0.3s ease;
}

.status-tile:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

.ad-tile {
    position: relative;
    overflow: hidden;
}

.ad-tile::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

.process-flow-container {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
}

.process-step {
    transition: transform 0.3s ease;
}

.process-step:hover {
    transform: translateY(-5px);
}

.process-step i {
    filter: drop-shadow(0 0 8px currentColor);
}

.widget-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.widget-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.blur-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.shadow-premium {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* Logo Premium Hover Effect */
.logo {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.logo:hover {
    transform: scale(1.05);
}

.logo:hover .logo-icon {
    filter: drop-shadow(0 0 12px var(--primary));
    transform: rotate(10deg);
}

.logo:hover span {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.logo::after {
    content: 'PRIME';
    position: absolute;
    top: -5px;
    right: 0;
    font-size: 0.6rem;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 900;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.logo:hover::after {
    opacity: 1;
    transform: translateY(0);
}