/* ==========================================================================
   STATISTICS TAB STYLES - MINIMAL DESIGN
   ========================================================================== */

.statistics-container {
    width: 100%;
}

/* Header Section */
.statistics-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(212, 165, 116, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

#statistics .statistics-container .header-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748 !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #2d3748 !important;
    background-clip: initial !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#statistics .statistics-container .header-title h2::before {
    content: "\f080";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: #64748b;
    font-size: 1.25rem;
}

.last-updated {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.5rem;
}

.header-actions .btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(212, 165, 116, 0.2);
    color: #64748b;
}

.header-actions .btn:hover {
    background: rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.3);
    color: #d4a574;
}

/* Overview Cards */
.stats-overview {
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.overview-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.overview-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(212, 165, 116, 0.15);
    border-color: rgba(212, 165, 116, 0.3);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: rgba(212, 165, 116, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d4a574;
    font-size: 1.25rem;
}

.card-content {
    flex: 1;
}

.card-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: #1e293b;
}

.card-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

/* Charts Section */
.charts-section {
    margin-bottom: 2rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-canvas {
    position: relative;
    height: 300px;
}

/* Stats Sections */
.stats-section {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.stats-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Categories Statistics */
.categories-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-card {
    background: rgba(248, 250, 252, 0.6);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: #1e293b;
    transition: all 0.3s ease;
}

.category-card:hover {
    transform: translateY(-1px);
    border-color: rgba(212, 165, 116, 0.3);
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.1);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.category-emoji {
    font-size: 1.25rem;
}

.category-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.category-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #d4a574;
}

.category-percentage {
    font-size: 0.875rem;
    color: #64748b;
    background: rgba(212, 165, 116, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
}

/* Price Statistics */
.price-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.price-stat-card {
    background: rgba(248, 250, 252, 0.6);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.price-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.3);
}

.price-stat-icon {
    font-size: 1.5rem;
    color: #d4a574;
    opacity: 0.8;
}

.price-stat-content {
    flex: 1;
}

.price-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.price-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

/* Detailed Statistics */
.detailed-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detailed-stat-item {
    background: rgba(248, 250, 252, 0.6);
    border: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.detailed-stat-item:hover {
    background: rgba(248, 250, 252, 0.8);
    border-color: rgba(212, 165, 116, 0.25);
    transform: translateY(-1px);
}

.stat-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #d4a574;
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--error-color);
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.notification-close:hover {
    background: var(--glass-bg-hover);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .statistics-container {
      
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .statistics-container {
       
    }

    .header-main {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .overview-card {
        padding: 1.25rem;
        gap: 0.75rem;
    }

    .card-number {
        font-size: 1.5rem;
    }

    .card-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stats-section {
        padding: 1.25rem;
    }

    .chart-canvas {
        height: 250px;
    }
}

/* ==========================================================================
   Период, класации и неизползвани артикули (rebuild 2026-08-25)
   ========================================================================== */

/* Период */
.period-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.period-tab {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 999px;
    color: #475569;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-tab:hover:not(.active) {
    border-color: #d4a574;
    color: #b8874f;
}

.period-tab.active {
    background: linear-gradient(135deg, #d4a574, #c49464);
    border-color: transparent;
    color: #fff;
}

/* Подсказка под числото в картите */
.card-hint {
    margin-top: 4px;
    font-size: 0.78rem;
    color: #94a3b8;
}

/* Информативни блокчета */
.stats-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fffaf3;
    border: 1px solid #f0dcc2;
    border-radius: 14px;
    padding: 16px 18px;
    color: #7c5a33;
    font-size: 0.92rem;
    line-height: 1.5;
}

.stats-note i {
    color: #d4a574;
    margin-top: 2px;
}

.stats-hint {
    margin-top: 12px;
    font-size: 0.82rem;
    color: #94a3b8;
}

.stats-empty {
    padding: 24px;
    text-align: center;
    color: #94a3b8;
    background: #f8fafc;
    border-radius: 12px;
}

/* Обща класация */
.rank-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rank-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 12px;
    transition: background 0.2s ease;
}

.rank-row:hover {
    background: #f1f5f9;
}

.rank-position {
    flex: 0 0 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.rank-position.top {
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: #fff;
}

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

.rank-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.rank-name {
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-count {
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.rank-share {
    font-weight: 500;
    color: #94a3b8;
    font-size: 0.85rem;
}

.rank-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    margin: 8px 0 6px;
    overflow: hidden;
}

.rank-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4a574, #c49464);
    border-radius: 999px;
}

.rank-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.82rem;
    color: #64748b;
}

/* Класация по категории */
.usage-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.usage-cat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 18px;
}

.usage-cat-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.usage-cat-name {
    font-weight: 700;
    color: #1e293b;
}

.usage-cat-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    white-space: nowrap;
}

.usage-cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    counter-reset: usage;
}

.usage-cat-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 70px 42px;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #334155;
}

.usage-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usage-item-bar {
    display: block;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.usage-item-bar > span {
    display: block;
    height: 100%;
    background: #d4a574;
    border-radius: 999px;
}

.usage-item-count {
    text-align: right;
    font-weight: 600;
    color: #64748b;
}

.usage-cat-rest {
    margin-top: 10px;
    font-size: 0.78rem;
    color: #94a3b8;
}

/* Неизползвани артикули */
.unused-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.unused-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 7px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #334155;
}

.unused-chip em {
    font-style: normal;
    font-size: 0.75rem;
    color: #94a3b8;
}

@media (max-width: 768px) {
    .usage-cat-grid {
        grid-template-columns: 1fr;
    }

    .rank-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .rank-name {
        white-space: normal;
    }

    .usage-cat-list li {
        grid-template-columns: minmax(0, 1fr) 48px 38px;
    }
}

/* ==========================================================================
   Подредба "Табло" (30.09.2026) - st-* класове
   Тялото е бялата карта от tab-card.css; тук няма втора карта около него.
   ========================================================================== */

.st-wrap { display: grid; gap: 22px; }

.st-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.st-eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #8a7a6b; }
.st-head h2 { font-size: 1.75rem; line-height: 1.2; color: #3f3328; letter-spacing: -.4px; margin: 2px 0 4px; }
.st-sub { color: #8a7a6b; font-size: .88rem; margin: 0; }
.st-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.st-seg { display: inline-flex; gap: 2px; padding: 4px; background: #fbf4ec; border-radius: 12px; }
.st-seg button {
    border: 0; background: none; padding: 7px 15px; min-height: 0; border-radius: 9px;
    font: inherit; font-weight: 700; font-size: .85rem; color: #5a4a3a; cursor: pointer; transition: background .15s;
}
.st-seg button:hover:not(.on) { background: rgba(255, 255, 255, .7); }
.st-seg button.on { background: #fff; color: #3f3328; box-shadow: 0 2px 8px rgba(160, 110, 70, .16); }
.st-refresh {
    width: 38px; height: 38px; min-height: 0; padding: 0; border: 1px solid #efe4d8; border-radius: 10px;
    background: #fff; color: #a8743f; cursor: pointer;
}
.st-refresh:hover { background: #fbf4ec; }

.st-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.st-kpi { padding: 16px 18px 14px; border-radius: 16px; background: #fbf4ec; display: grid; gap: 2px; align-content: start; }
.st-kpi:first-child { background: #fff; box-shadow: 0 0 0 1.5px #d4a574, 0 0 0 5px rgba(212, 165, 116, .16); }
.st-kpi-num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; color: #3f3328; letter-spacing: -.5px; }
.st-kpi.warn .st-kpi-num { color: #b25e1d; }
.st-kpi-label { font-size: .85rem; font-weight: 600; color: #6b5b4b; }
.st-spark { width: 100%; height: 34px; margin: 8px 0 2px; display: block; }
.st-kpi-hint { font-size: .78rem; color: #9a8a79; margin-top: 4px; }

.st-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.st-box { border: 1px solid #efe4d8; border-radius: 18px; background: #fff; padding: 20px; min-width: 0; }
.st-box h3 { font-size: 1rem; color: #3f3328; margin: 0 0 14px; font-weight: 700; }
.st-box .chart-canvas { height: 250px; }

.st-rank { display: grid; }
.st-rank-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f3ebe2; }
.st-rank-row:last-child { border-bottom: 0; }
.st-rank-n { width: 28px; height: 28px; border-radius: 9px; background: #fbf1e6; color: #a8743f; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.st-rank-n.warn { background: #fff0e0; color: #b25e1d; }
.st-rank-name { min-width: 0; color: #3f3328; font-weight: 700; font-size: .92rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-rank-name em { display: block; font-style: normal; font-weight: 500; font-size: .76rem; color: #9a8a79; }
.st-tag { font-size: .75rem; font-weight: 800; color: #9a6b3d; background: #fbf1e6; border-radius: 7px; padding: 3px 9px; white-space: nowrap; }

.st-more { border: 1px solid #efe4d8; border-radius: 18px; background: #fff; }
.st-more > summary {
    cursor: pointer; list-style: none; padding: 16px 20px; font-weight: 700; color: #5a4a3a; display: flex; align-items: center; gap: 10px;
}
.st-more > summary::-webkit-details-marker { display: none; }
.st-more > summary::after { content: '+'; margin-left: auto; width: 28px; height: 28px; border-radius: 9px; background: #fbf4ec; color: #a8743f; display: grid; place-items: center; font-size: 1.1rem; }
.st-more[open] > summary::after { content: '−'; }
.st-more[open] > summary { border-bottom: 1px solid #efe4d8; }
.st-more > .stats-section { margin: 0; padding: 20px; border-radius: 0; box-shadow: none; border: 0; border-bottom: 1px solid #f3ebe2; background: none; }
.st-more > .stats-section:last-child { border-bottom: 0; }

@media (max-width: 960px) {
    .st-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .st-grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .st-head h2 { font-size: 1.45rem; }
    .st-kpi-num { font-size: 1.55rem; }
    .st-seg button { padding: 7px 11px; }
}
