* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #f5f5f5;
    color: #000;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    width: 100%;
}

.app-container {
    max-width: min(100%, 1320px);
    margin: 0 auto;
    padding: 32px 24px;
}

/* Переключатель годов (табы) */
.year-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.year-tab {
    padding: 10px 24px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    outline: none;
}

.year-tab:hover {
    border-color: #333;
    color: #333;
}

.year-tab.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* Секция компаний */
.companies-section {
    width: 100%;
}

#companiesData {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 380px));
    gap: 20px;
    width: 100%;
    justify-content: center;
}

/* Карточка компании — уже, без лишней ширины между числом и бейджем */
.company-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 380px;
    justify-self: center;
}

.company-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Верхняя часть карточки с логотипом */
.company-header {
    position: relative;
    padding: 24px 20px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.company-logo-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 50%;
    background: #f5f5f5;
    padding: 8px;
}

.company-info {
    flex: 1;
}

.company-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #000;
}

.company-founded {
    font-size: 13px;
    color: #666;
    margin-bottom: 2px;
}

.company-entity {
    font-size: 12px;
    color: #999;
}

/* Тело карточки с метриками */
.company-body {
    padding: 20px;
}

/* Правая часть — по ширине контента (число + бейдж), без пустой «долины» */
.metric-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: 8px 10px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 0;
    padding-right: 4px;
    line-height: 1.35;
}

.metric-label-hint {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted #999;
    cursor: help;
}

.metric-label-hint::before {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 20;
    width: min(300px, 70vw);
    padding: 10px 12px;
    background: #111;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: normal;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-2px);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.metric-label-hint:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.metric-value-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    width: max-content;
    max-width: 100%;
}

/* Фиксированная ширина под число — левые края ровные, бейдж сразу справа */
.metric-value-main {
    flex: 0 0 16ch;
    width: 16ch;
    display: block;
    padding: 0;
    box-sizing: border-box;
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    color: #000;
    font-variant-numeric: tabular-nums;
    text-align: left;
    min-width: 16ch;
    max-width: 100%;
}

/* Компактные бейджи (~половина прежней ширины) */
.metric-change {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    flex: 0 0 3.75rem;
    width: 3.75rem;
    min-width: 3.75rem;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
}

.metric-change.positive {
    color: #16a34a;
    background: #dcfce7;
}

.metric-change.negative {
    color: #dc2626;
    background: #fee2e2;
}

.metric-change.neutral {
    color: #666;
    background: #f5f5f5;
}

.no-report-message {
    color: #666;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    padding: 24px 0;
}

/* Пустое состояние */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

/* Десктоп: сетка карточек компактная по ширине */
@media (min-width: 1024px) {
    .app-container {
        max-width: min(100%, 1200px);
        padding: 36px 28px;
    }

    #companiesData {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 380px));
        gap: 22px;
    }
}

/* Tablet responsiveness */
@media (max-width: 1024px) {
    .app-container {
        padding: 24px 16px;
    }

    #companiesData {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
        gap: 18px;
    }

    .company-name {
        font-size: 18px;
    }

    .company-logo {
        width: 70px;
        height: 70px;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding: 20px 12px;
    }

    .year-tabs {
        gap: 8px;
        margin-bottom: 24px;
    }

    .year-tab {
        padding: 8px 16px;
        font-size: 14px;
    }

    #companiesData {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .company-header {
        padding: 20px 16px 16px;
    }

    .company-logo-wrapper {
        gap: 12px;
    }

    .company-logo {
        width: 60px;
        height: 60px;
    }

    .company-name {
        font-size: 17px;
    }

    .company-founded {
        font-size: 12px;
    }

    .company-entity {
        font-size: 11px;
    }

    .company-body {
        padding: 16px;
    }

    .metric-row {
        padding: 10px 0;
        grid-template-columns: minmax(0, 1fr) max-content;
        gap: 6px 8px;
    }

    .metric-label {
        font-size: 12px;
        min-width: 0;
    }

    .metric-value-main {
        flex: 0 0 14ch;
        width: 14ch;
    }

    .metric-value {
        font-size: 16px;
        min-width: 0;
    }

    .metric-change {
        font-size: 9px;
        width: 3.375rem;
        min-width: 3.375rem;
        flex-basis: 3.375rem;
        padding: 2px 3px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .app-container {
        padding: 16px 10px;
    }

    .year-tabs {
        gap: 6px;
        margin-bottom: 20px;
    }

    .year-tab {
        padding: 7px 14px;
        font-size: 13px;
    }

    .company-header {
        padding: 16px 14px;
    }

    .company-logo {
        width: 56px;
        height: 56px;
    }

    .company-name {
        font-size: 16px;
    }

    .company-founded {
        font-size: 11px;
    }

    .company-entity {
        font-size: 10px;
    }

    .company-body {
        padding: 14px;
    }

    .metric-row {
        padding: 9px 0;
        grid-template-columns: minmax(0, 1fr) max-content;
        gap: 4px 6px;
    }

    .metric-label {
        font-size: 11px;
        min-width: 0;
    }

    .metric-value-main {
        flex: 0 0 12ch;
        width: 12ch;
    }

    .metric-change {
        width: 3.125rem;
        min-width: 3.125rem;
        flex-basis: 3.125rem;
        font-size: 8px;
        padding: 2px 2px;
    }

    .metric-value {
        font-size: 15px;
        min-width: 0;
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#companiesData {
    animation: fadeIn 0.4s ease-out;
}
