:root {
    --bg-color: #0f111a;
    --card-bg: rgba(26, 29, 41, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --danger: #ef4444;
    --table-header-bg: rgba(15, 17, 26, 0.8);
    --table-row-hover: rgba(255, 255, 255, 0.03);
    --transition-fast: 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
    overflow-x: hidden;
}

.dashboard-container {
    width: 100%;
    max-width: 98%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header & Search */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    background: rgba(15, 17, 26, 0.5);
    border-radius: 12px;
    padding: 0.3rem;
    gap: 0.2rem;
    border: 1px solid var(--card-border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

/* Search Area */
.search-area {
    position: relative;
    width: 300px;
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.search-area input {
    width: 100%;
    max-width: 300px;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(15, 17, 26, 0.5);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.search-area input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: rgba(15, 17, 26, 0.8);
}

.search-icon {
    position: absolute;
    left: calc(100% - 286px); /* Adjusting to fit max-width */
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}
@media (min-width: 769px) {
    .search-icon {
        left: auto;
        right: 268px; /* Position icon correctly relative to the input */
    }
}


/* Tab Content Visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Table Container (Reused for Empty Tab too) */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-tab {
    min-height: 400px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--card-border);
}

.table-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.badge {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.table-wrapper {
    overflow-x: auto;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

/* Custom Scrollbar */
.table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: rgba(15, 17, 26, 0.5); 
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--card-border); 
    border-radius: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted); 
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

th {
    background: var(--table-header-bg);
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 1rem 2rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
}

.clickable-cell {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.clickable-cell:hover {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-hover);
}

td {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: background var(--transition-fast);
}

td:first-child {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Make rows hoverable */
tbody tr {
    transition: var(--transition-fast);
}

tbody tr:hover td {
    background: var(--table-row-hover);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

/* Empty & Loading States */
.empty-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    color: var(--text-muted);
    text-align: center;
    height: 100%;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h2 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Highlight matching text */
.highlight {
    background-color: rgba(139, 92, 246, 0.4);
    color: #fff;
    border-radius: 2px;
    padding: 0 2px;
}

/* Modal Popup Styles */
.modal {
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 17, 26, 0.85); /* Overlay */
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    max-width: 800px;
    width: 90%;
    color: var(--text-main);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-fast);
}

.close-btn:hover,
.close-btn:focus {
    color: #fff;
    text-decoration: none;
}

/* Campaigns Cards Styles */
.campaigns-cards-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.campaigns-cards-container::-webkit-scrollbar {
    width: 8px;
}
.campaigns-cards-container::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

.campaign-card {
    background: rgba(15, 17, 26, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 15px;
    min-width: 250px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.campaign-card:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.campaign-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.campaign-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #fff;
}

.campaign-details {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--card-border);
    display: none;
    font-size: 0.85rem;
}

.campaign-details table {
    width: 100%;
    margin-top: 10px;
    border-collapse: separate;
    border-spacing: 0;
}

.campaign-details th, .campaign-details td {
    padding: 6px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.campaign-details th {
    color: var(--text-muted);
    font-weight: 500;
}

/* Responsive */
@media (max-width: 992px) {
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-area {
        width: 100%;
        max-width: 100%;
        justify-content: center;
    }
    .search-area input {
        max-width: 100%;
    }
    .search-icon {
        left: 14px;
        right: auto;
    }
}

/* --- Reports Tab Styles --- */
.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    margin-bottom: 2rem;
}

.upload-form {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.upload-form input[type="date"] {
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(15, 17, 26, 0.5);
    color: var(--text-main);
    color-scheme: dark;
}

.file-upload-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-upload-wrapper input[type="file"] {
    display: none;
}

.btn-primary, .btn-success {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    border: none;
    color: white;
}

.btn-primary {
    background: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: #10b981;
}
.btn-success:hover {
    background: #059669;
}

#fileName {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.upload-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(99, 102, 241, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.small-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}
.status-message {
    margin-bottom: 1rem;
    font-weight: 500;
}

.report-details {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1rem;
}
.report-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
}
.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.btn-close:hover {
    color: var(--text-main);
}
.report-history-container {
    overflow-x: auto;
}
.report-card {
    background: rgba(15, 17, 26, 0.5);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.report-card-date {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}
.metric-item {
    display: flex;
    flex-direction: column;
}
.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.metric-value {
    font-weight: 500;
}

/* History Dates List */
.reports-history-list-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
}
.reports-history-list-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.history-dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.date-card {
    background: rgba(15, 17, 26, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.date-card:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}
.date-card.selected {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--primary);
}

/* Tree Table Grouping */
.report-history-container table tr.group-header td {
    background: #f1f5f9;
    font-weight: 600;
    text-align: left;
    color: #1e293b;
    border-top: 2px solid #cbd5e1;
    border-bottom: 2px solid #cbd5e1;
    cursor: pointer;
}
.report-history-container table tr.group-header:hover td {
    background: #e2e8f0;
}
.group-toggle-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 8px;
    transition: transform 0.2s;
}
.group-header.collapsed .group-toggle-icon {
    transform: rotate(-90deg);
}
.report-history-container table tr.group-child td:first-child {
    padding-left: 2rem; /* Indent the date child rows */
    font-weight: 500;
    background: #fafafa;
}
.hidden {
    display: none !important;
}
.date-card-title {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.2rem;
}
.date-card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Column Selector */
.column-selector-area {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(15, 17, 26, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 8px;
}
/* Grouped Column Selector */
.column-selector-area {
    min-width: 600px;
}
.column-group-container {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f3f4f6;
}
.column-group-container:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.column-group-title {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    color: #111827;
}
.column-group-checkboxes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
}
@media (max-width: 1024px) {
    .column-group-checkboxes {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .column-group-checkboxes {
        grid-template-columns: repeat(2, 1fr);
    }
}
.column-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}
.column-checkbox-label input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    cursor: pointer;
}

/* Excel-like Compact Table for Report Details */
.report-history-container {
    background: #ffffff; /* Light background for excel look */
    border-radius: 4px;
    padding: 0 1rem 1rem 1rem; /* Removed top padding to make sticky header flush */
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 200px); /* Enforce height so it scrolls internally */
}

.report-history-container table {
    border-collapse: separate;
    border-spacing: 0;
    color: #000000 !important;
    font-family: Arial, sans-serif;
    table-layout: auto;
    width: auto;
}

.report-history-container table th,
.report-history-container table td {
    padding: 0.15rem 0.3rem;
    font-size: 0.65rem;
    border: 1px solid #7a7a7a;
    text-align: center;
    color: #000000 !important;
    white-space: nowrap;
}

.report-history-container table th {
    background: #e0e6f8;
    font-weight: bold;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 #7a7a7a;
    color: #000000 !important;
    white-space: normal;
    max-width: 55px;
    word-wrap: break-word;
    min-width: 30px;
}

.report-history-container table td {
    white-space: nowrap;
}

/* Hover effect optimized for performance and smoothness */
.report-history-container table tbody tr td {
    transition: filter 0.15s ease-out;
}
body.enable-row-hover .report-history-container table tbody tr:hover td {
    filter: brightness(0.92);
}

/* Fixed narrow width for рейтинг column */
.report-history-container table td[data-col="рейтинг"],
.report-history-container table th[title="рейтинг"] {
    max-width: 38px !important;
    min-width: 30px !important;
    width: 38px !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-history-container table th:first-child,
.report-history-container table td:first-child,
.report-history-container table th.col-first,
.report-history-container table td.col-first,
.report-history-container table th[title="Артикул"],
.report-history-container table td[data-col="Артикул"],
.report-history-container table th[title="Артикул продавца"],
.report-history-container table td[data-col="Артикул продавца"],
.report-history-container table th[title="Артикул WB"],
.report-history-container table td[data-col="Артикул WB"] {
    text-align: left;
    max-width: 210px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    background: #fdfdfd;
}
.report-history-container table th:first-child,
.report-history-container table th.col-first,
.report-history-container table th[title="Артикул"],
.report-history-container table th[title="Артикул продавца"],
.report-history-container table th[title="Артикул WB"] {
    background: #e0e6f8;
}

.report-history-container table td.col-first .product-name-text,
.report-history-container table td.col-first .collapsed-title .product-name-text {
    max-width: 155px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    display: inline-block;
    vertical-align: middle;
}

/* Fullscreen mode */
body.report-fullscreen-active,
html:has(.report-details.fullscreen-mode),
body:has(.report-details.fullscreen-mode) {
    overflow: hidden !important;
}

.report-details.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    margin: 0;
    border-radius: 0;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    background: #0f172a !important;
}
.report-details.fullscreen-mode .report-details-header {
    padding: 6px 16px;
    flex-shrink: 0;
    box-sizing: border-box;
    margin: 0;
}
.report-details.fullscreen-mode .report-history-container {
    flex: 1;
    min-height: 0;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0;
    box-sizing: border-box;
    background: #ffffff !important;
}
.report-details.fullscreen-mode .report-history-container .table-wrapper,
.report-details.fullscreen-mode .report-history-container table {
    max-height: none !important;
    min-height: 100%;
}

/* Ensure table-wrapper doesn't trap sticky header */
.report-history-container .table-wrapper {
    overflow: visible !important;
}

/* For color coding (applied via JS) */
.cell-green { background-color: #92d050 !important; }
.cell-red { background-color: #ff9999 !important; }
.cell-yellow { background-color: #ffff00 !important; }
.cell-orange { background-color: #ffc000 !important; }
.cell-purple { background-color: #e0aaff !important; }
.cell-magenta { background-color: #ff00ff !important; }

/* Tooltip for articles */
.item-name-wrapper {
    position: relative;
    display: inline-block;
    cursor: help;
}
.item-name-wrapper .articles-tooltip {
    visibility: hidden;
    background-color: #1f2937;
    color: #f3f4f6;
    text-align: left;
    border-radius: 6px;
    padding: 6px 10px;
    position: absolute;
    z-index: 1000;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    font-weight: normal;
}
.item-name-wrapper:hover .articles-tooltip {
    visibility: visible;
    opacity: 1;
}

/* Dropdown Column Selector */
.column-settings-dropdown {
    position: relative;
    display: inline-block;
}
.column-settings-dropdown .column-selector-area {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2000;
    background: #ffffff;
    color: #000000;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    width: max-content;
    max-width: 90vw;
}

/* Thick border for last row of expanded items */
.report-history-container table tr.expanded-last-row td {
    border-bottom: 2px solid #000 !important;
}

/* Custom Scrollbar for better visibility */
.report-history-container::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}
.report-history-container::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 8px;
}
.report-history-container::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
    border: 3px solid #e2e8f0;
}
.report-history-container::-webkit-scrollbar-thumb:hover,
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

#filterGroupSelect, #filterManagerSelect, #filterStoreSelect {
    background-color: rgba(30, 30, 40, 0.95) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}
#filterGroupSelect option, #filterManagerSelect option {
    background-color: #1e1e2d !important;
    color: #ffffff !important;
}

/* =============================================
   MOBILE LAYOUT (phones only, <= 768px)
   Desktop is COMPLETELY UNTOUCHED.
   ============================================= */
@media (max-width: 768px) {
    /* --- Global mobile adjustments --- */
    body {
        padding: 0.3rem;
    }
    .dashboard-container {
        gap: 0.4rem;
        max-width: 100%;
    }

    /* Hide dashboard header and upload header on mobile */
    .dashboard-header,
    .reports-header {
        display: none !important;
    }

    /* --- History list section --- */
    .reports-history-list-section {
        padding: 0.6rem;
        border-radius: 8px;
        margin-top: 0.4rem;
    }
    .reports-history-list-section > div:first-child {
        flex-direction: column;
        gap: 0.4rem;
    }
    .reports-history-list-section h3 {
        font-size: 0.85rem;
    }
    #historyTypeTabs {
        flex-wrap: wrap;
        gap: 6px !important;
    }
    #historyTypeTabs button {
        font-size: 0.7rem !important;
    }
    .history-dates-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
    .date-card {
        padding: 0.5rem;
        border-radius: 6px;
    }
    .date-card-title {
        font-size: 0.8rem;
    }

    /* --- Report details area --- */
    .report-details {
        padding: 0.4rem;
        border-radius: 8px;
        margin-top: 0.4rem;
    }
    .report-details-header {
        flex-wrap: wrap;
        gap: 0.3rem;
        padding-bottom: 0.4rem;
        margin-bottom: 0.3rem;
    }
    .report-details-header h3 {
        font-size: 0.8rem;
    }
    .report-details-header .btn-primary,
    .report-details-header .btn-secondary {
        padding: 0.2rem 0.4rem;
        font-size: 0.65rem;
    }

    /* --- Column selector dropdown --- */
    .column-settings-dropdown .column-selector-area {
        min-width: unset;
        width: 95vw;
        max-width: 95vw;
        left: -10px;
    }
    .column-group-checkboxes {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.3rem;
    }
    .column-checkbox-label {
        font-size: 0.7rem;
    }
    
    #toggleColumnSelectorBtn {
        display: none !important;
    }
    #mobileTableSearch {
        display: inline-block !important;
    }

    /* =============================================
       REPORT TABLE — MOBILE CARD LAYOUT
       ============================================= */

    /* Hide the letter row (A, D, E...) */
    .report-history-container table .header-letters-row {
        display: none;
    }

    /* Make table auto-width, container scrolls */
    .report-history-container {
        padding: 0.2rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .report-history-container table {
        width: auto;
        min-width: 100%;
    }

    /* Compact cells */
    .report-history-container table th,
    .report-history-container table td {
        padding: 0.1rem 0.15rem;
        font-size: 0.55rem;
        white-space: nowrap;
    }
    .report-history-container table th {
        max-width: 40px;
        white-space: normal;
        word-break: break-word;
    }

    /* ----- FIRST COLUMN (dates / name) ----- */
    /* Header: hide long text, show short version */
    .report-history-container table th.col-first {
        position: -webkit-sticky !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 11 !important;
        background: #e0e6f8;
        max-width: 180px !important;
        min-width: 180px !important;
        width: 180px !important;
        font-size: 0.36rem;
        color: transparent !important; /* Hide 'НАИМЕНОВАНИЕ В ОТЧЕТЕ' text */
    }
    /* Data rows: first column contains name (collapsed) or date (expanded) */
    .report-history-container table td.col-first {
        position: static !important;
        z-index: auto !important;
        background: #fdfdfd;
        max-width: 180px !important;
        min-width: 180px !important;
        width: 180px !important;
        font-size: 0.36rem;
        text-align: left !important;
        padding-left: 4px !important;
        padding-right: 2px !important;
        border-right: 1px solid #7a7a7a;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* ----- COMBINED MODE: Product name rows ----- */
    .report-history-container table tr.group-header td {
        font-size: 0.36rem;
        padding: 0.15rem 0.25rem;
        background: #f1f5f9;
        border-top: 1px solid #7a7a7a;
        border-bottom: 1px solid #7a7a7a;
    }
    
    .mobile-group-header-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    .product-name-text {
        white-space: nowrap;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex: 1;
        text-align: left;
        max-width: 140px !important;
        font-weight: bold;
    }
    
    .info-btn {
        display: none !important; /* Hide info icon on mobile */
    }

    /* Show the collapsed-title (product name inside last data row) like on PC */
    .collapsed-title {
        display: flex !important;
        align-items: center;
        gap: 3px;
        font-size: 0.36rem;
    }
    .collapsed-title .product-name-text {
        max-width: 140px !important;
        font-weight: normal;
    }
    
    /* Always show the date when expanded */
    .expanded-date {
        font-size: 0.36rem;
    }

    /* ----- SINGLE MODE: truncate product name ----- */
    .report-history-container table td.col-first .item-name-wrapper {
        max-width: 240px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        display: block;
        font-size: 0.36rem;
    }

    /* --- Modal --- */
    .modal-content {
        margin: 1vh auto !important;
        width: 97% !important;
        padding: 10px !important;
        max-height: 98vh !important;
    }
    .modal-content h2 {
        font-size: 0.95rem;
    }
    .modal-content > div {
        flex-direction: column !important;
    }
    .modal-content > div > div {
        min-width: unset !important;
    }

    /* --- Fullscreen --- */
    .report-details.fullscreen-mode .report-details-header {
        padding: 0.4rem;
    }
}

/* Completeness Modal Styles */
.completeness-link {
    color: #60a5fa;
    cursor: pointer;
    text-decoration: underline;
    font-weight: 500;
}
.completeness-link:hover {
    color: #3b82f6;
}

.completeness-cards-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding-bottom: 20px;
}

@media (max-width: 1200px) {
    .completeness-cards-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .completeness-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

.completeness-card {
    background-color: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.completeness-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.completeness-card.unfilled {
    border-color: rgba(239, 68, 68, 0.6);
    background-color: rgba(239, 68, 68, 0.08);
}

.completeness-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.completeness-card-value {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    word-break: break-word;
    line-height: 1.4;
}

.completeness-card.unfilled .completeness-card-value {
    color: #ef4444 !important;
    font-style: italic;
    font-weight: 500;
}

.star-icon {
    color: #fbbf24;
    font-size: 1.1rem;
}

@media (max-width: 480px) {
    .completeness-cards-container {
        grid-template-columns: 1fr;
    }
}

/* Beautiful Main Navigation */
.main-navigation {
    display: flex;
    background: rgba(15, 17, 26, 0.4);
    border-radius: 16px;
    padding: 6px;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.nav-pill {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 8px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.nav-pill::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-pill:hover::before {
    opacity: 1;
}

.nav-pill:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.nav-pill.active {
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.nav-pill-crm {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.nav-pill-crm:hover {
    background: rgba(139, 92, 246, 0.25);
    color: #fff;
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}


.parsing-clickable-cell {
    cursor: pointer !important;
    position: relative;
    user-select: none;
}
.parsing-clickable-cell:hover {
    background-color: rgba(99, 102, 241, 0.15) !important;
}

.custom-tooltip-cell {
    position: relative;
    cursor: help;
}
.custom-tooltip-cell:hover .fbo-fbs-tooltip {
    display: block;
}
.fbo-fbs-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e24;
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 5px 8px;
    color: #fff;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    margin-bottom: 8px;
    text-align: center;
    line-height: 1.4;
}
.fbo-fbs-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--accent) transparent transparent transparent;
}
.tt-fbo {
    color: #3b82f6; /* Blue */
    font-weight: 600;
}
.tt-fbs {
    color: #10b981; /* Green */
    font-weight: 600;
}
.tt-date {
    color: #a1a1aa;
    font-size: 0.8rem;
    margin: 6px 0;
    border-bottom: 1px dashed #444;
    padding-bottom: 4px;
}

#price-refresh-header-row th {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

#price-refresh-header-row th[colspan] {
    border: 1px solid #7a7a7a !important;
    background: #ffffff !important;
    padding: 4px 8px !important;
    vertical-align: middle !important;
}


