:root {
    --stats-bg: #0a0a0a;
    --stats-panel: rgba(28, 28, 31, 0.92);
    --stats-panel-border: rgba(85, 85, 92, 0.45);
    --stats-soft: rgba(255, 255, 255, 0.06);
    --stats-muted: #9ca3af;
    --stats-text: #f4f5f7;
    --stats-banana: var(--accent, #d4ff26);
}

* {
    box-sizing: border-box;
}

body {
    background:
        radial-gradient(circle at top left, rgba(212, 255, 38, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(115, 169, 255, 0.16), transparent 24%),
        linear-gradient(180deg, #070708 0%, #0f1013 100%);
    color: var(--stats-text);
}

.stats-shell {
    width: min(1480px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.stats-topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stats-title-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.stats-topbar-link,
.stats-refresh-btn,
.stats-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--stats-panel-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--stats-text);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.stats-topbar-link:hover,
.stats-refresh-btn:hover,
.stats-icon-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(212, 255, 38, 0.42);
    background: rgba(212, 255, 38, 0.08);
}

.stats-eyebrow {
    color: var(--stats-banana);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 6px;
}

.stats-page-title {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 800;
    line-height: 1;
    margin: 0;
}

.stats-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stats-userbar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 4px 12px;
    border-radius: 16px;
    background: var(--stats-panel);
    border: 1px solid var(--stats-panel-border);
    backdrop-filter: blur(18px);
}

.stats-userbar-copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d8dbe1;
    font-size: 14px;
}

.stats-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(212, 255, 38, 0.28);
    background: rgba(212, 255, 38, 0.1);
    color: var(--stats-banana);
    font-size: 13px;
    font-weight: 700;
}

.stats-company-select {
    height: 42px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.stats-company-select:hover {
    border-color: rgba(212, 255, 38, 0.35);
}

.stats-company-select option {
    background: #1c1c1f;
    color: #e5e7eb;
}

.stats-content {
    display: grid;
    gap: 20px;
}

.stats-hero-panel,
.stats-panel,
.stats-loading-panel,
.stats-error-panel {
    border-radius: 28px;
    padding: 22px;
    background: var(--stats-panel);
    border: 1px solid var(--stats-panel-border);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.stats-hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 430px);
    gap: 24px;
    align-items: flex-start;
}

.stats-hero-copy {
    min-width: 0;
    display: grid;
    gap: 10px;
    align-content: start;
    padding-top: 6px;
}

.stats-hero-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.stats-hero-subtitle {
    color: var(--stats-muted);
    max-width: 840px;
}

.stats-range-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(8, 9, 11, 0.74), rgba(14, 15, 18, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.stats-range-head,
.stats-range-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.stats-range-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stats-range-hint {
    color: var(--stats-muted);
    font-size: 13px;
    line-height: 1.45;
}

.stats-range-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.stats-range-actions {
    width: 100%;
}

.stats-range-field {
    display: grid;
    gap: 8px;
}

.stats-range-field span {
    color: #d8dbe1;
    font-size: 12px;
    font-weight: 700;
}

.stats-range-input {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f4f5f7;
    font-size: 14px;
    color-scheme: dark;
}

.stats-range-input:focus {
    outline: none;
    border-color: rgba(212, 255, 38, 0.44);
    box-shadow: 0 0 0 3px rgba(212, 255, 38, 0.08);
}

.stats-range-input:disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

.stats-range-reset,
.stats-range-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.stats-range-reset {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #c9ced8;
}

.stats-range-reset:hover {
    border-color: rgba(255, 255, 255, 0.16);
}

.stats-range-apply {
    background: rgba(212, 255, 38, 0.12);
    border: 1px solid rgba(212, 255, 38, 0.28);
    color: var(--stats-banana);
    width: 100%;
    min-height: 44px;
    font-size: 13px;
}

.stats-range-apply:hover {
    border-color: rgba(212, 255, 38, 0.48);
    background: rgba(212, 255, 38, 0.16);
}

.stats-range-coverage {
    display: grid;
    gap: 6px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-range-coverage strong {
    display: block;
    font-size: 18px;
}

.stats-range-coverage p {
    color: #d8dbe1;
    font-size: 14px;
    line-height: 1.45;
}

.stats-range-reset:disabled,
.stats-range-apply:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.stats-coverage-card strong {
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
}

.stats-coverage-card p {
    color: #d8dbe1;
    font-size: 14px;
}

.stats-loading-panel,
.stats-error-panel {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stats-spinner {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(212, 255, 38, 0.2);
    border-top-color: var(--stats-banana);
    animation: stats-spin 0.8s linear infinite;
}

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

.stats-error-panel {
    color: #ffd7dc;
    border-color: rgba(255, 107, 125, 0.26);
    background: rgba(70, 20, 28, 0.78);
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.stats-summary-grid-hero {
    margin-top: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.stats-summary-grid-hero .stats-card {
    min-height: 0;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
}

.stats-summary-grid-hero .stats-card-label {
    margin-bottom: 8px;
}

.stats-summary-grid-hero .stats-card-value {
    font-size: clamp(18px, 2vw, 26px);
}

.stats-card {
    border-radius: 22px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-card-label {
    display: block;
    color: var(--stats-muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.stats-card-value {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    line-height: 1.1;
}

.stats-panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.stats-panel-subtitle {
    color: var(--stats-muted);
    font-size: 14px;
}

.stats-chart-grid,
.stats-model-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
    gap: 18px;
}

.stats-chart-card {
    border-radius: 22px;
    padding: 18px;
    background: rgba(8, 9, 11, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-chart-title-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.stats-chart-title-row h2 {
    font-size: 15px;
    font-weight: 700;
}

.stats-chart-note,
.stats-group-meta,
.stats-person-meta,
.stats-user-meta,
.stats-unmatched-meta {
    color: var(--stats-muted);
    font-size: 13px;
}

.stats-chart-frame {
    position: relative;
    min-height: 340px;
}

.stats-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.stats-tab-btn {
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #c9ced8;
    font-size: 13px;
    font-weight: 600;
}

.stats-tab-btn.is-active {
    color: #111214;
    background: var(--stats-banana);
    border-color: rgba(212, 255, 38, 0.55);
}

.stats-tab-panel {
    display: none;
}

.stats-tab-panel.is-active {
    display: grid;
    gap: 18px;
}

.stats-model-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stats-model-summary-card {
    padding: 16px;
    border-radius: 18px;
    background: rgba(8, 9, 11, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-model-summary-card strong {
    display: block;
    font-size: 22px;
    margin-top: 6px;
}

.stats-group-list,
.stats-people-list,
.stats-unmatched-list,
.stats-user-list {
    display: grid;
    gap: 12px;
}

.stats-group-card,
.stats-person-card,
.stats-unmatched-card,
.stats-user-card {
    border-radius: 20px;
    padding: 16px;
    background: rgba(8, 9, 11, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-group-head,
.stats-person-head,
.stats-unmatched-head,
.stats-user-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.stats-person-head > div {
    flex: 1 1 auto;
    min-width: 0;
}

.stats-person-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 6px;
}

.stats-group-head strong,
.stats-person-head strong,
.stats-user-head strong,
.stats-unmatched-head strong {
    font-size: 16px;
    font-weight: 700;
}

.stats-person-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
    justify-content: flex-end;
}

.stats-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #d8dbe1;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.stats-edit-btn:hover {
    border-color: rgba(212, 255, 38, 0.34);
    background: rgba(212, 255, 38, 0.08);
    color: var(--stats-banana);
}

.stats-badge-row,
.stats-inline-users,
.stats-person-models {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stats-badge,
.stats-inline-user,
.stats-person-model-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-badge.is-banana {
    color: var(--stats-banana);
    border-color: rgba(212, 255, 38, 0.24);
    background: rgba(212, 255, 38, 0.08);
}

.stats-badge.is-danger {
    color: #ff9baa;
    border-color: rgba(255, 107, 125, 0.24);
    background: rgba(255, 107, 125, 0.08);
}

.stats-inline-user strong {
    color: white;
}

.stats-sort-switcher {
    display: inline-flex;
    gap: 8px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-sort-btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    color: #c9ced8;
    font-size: 13px;
    font-weight: 700;
}

.stats-sort-btn.is-active {
    background: rgba(212, 255, 38, 0.16);
    color: var(--stats-banana);
}

.stats-person-model-chip i {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
}

.stats-dimensions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.stats-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.stats-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 4, 6, 0.72);
    backdrop-filter: blur(8px);
}

.stats-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    border-radius: 28px;
    padding: 22px;
    background: rgba(18, 19, 23, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.stats-modal-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.stats-modal-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stats-modal-meta-card {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-modal-meta-card strong {
    display: block;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
}

.stats-editor-form {
    display: grid;
    gap: 14px;
}

.stats-editor-field {
    display: grid;
    gap: 8px;
}

.stats-editor-field span {
    color: #d8dbe1;
    font-size: 13px;
    font-weight: 700;
}

.stats-editor-input {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 16px;
    background: rgba(8, 9, 11, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f4f5f7;
    font-size: 14px;
}

.stats-editor-input:focus {
    outline: none;
    border-color: rgba(212, 255, 38, 0.44);
    box-shadow: 0 0 0 3px rgba(212, 255, 38, 0.08);
}

.stats-editor-select-shell {
    position: relative;
}

.stats-editor-select-button {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 16px;
    background: rgba(8, 9, 11, 0.72);
    border: 1px solid rgba(212, 255, 38, 0.34);
    color: #f4f5f7;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.stats-editor-select-button:hover {
    border-color: rgba(212, 255, 38, 0.52);
    background: rgba(12, 14, 9, 0.9);
}

.stats-editor-select-button:focus {
    outline: none;
    border-color: rgba(212, 255, 38, 0.64);
    box-shadow: 0 0 0 3px rgba(212, 255, 38, 0.08);
}

.stats-editor-select-button.is-open {
    border-color: rgba(212, 255, 38, 0.72);
    box-shadow: 0 0 0 3px rgba(212, 255, 38, 0.08);
}

.stats-editor-select-button.is-placeholder .stats-editor-select-value {
    color: #9ca3af;
}

.stats-editor-select-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.stats-editor-select-value {
    text-align: left;
}

.stats-editor-select-chevron {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-right: 2px solid rgba(255, 255, 255, 0.72);
    border-bottom: 2px solid rgba(255, 255, 255, 0.72);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s ease;
}

.stats-editor-select-button.is-open .stats-editor-select-chevron {
    transform: rotate(-135deg) translateY(-1px);
}

.stats-editor-select-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 6;
    display: none;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 18px;
    background: rgba(18, 19, 23, 0.98);
    border: 1px solid rgba(212, 255, 38, 0.18);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

.stats-editor-select-menu.is-open {
    display: grid;
    gap: 6px;
}

.stats-editor-select-option,
.stats-editor-select-empty {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    font-size: 14px;
}

.stats-editor-select-option {
    width: 100%;
    border: 1px solid transparent;
    color: #f4f5f7;
    background: rgba(255, 255, 255, 0.02);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.stats-editor-select-option:hover {
    border-color: rgba(212, 255, 38, 0.24);
    background: rgba(212, 255, 38, 0.08);
}

.stats-editor-select-option.is-active {
    color: #111214;
    border-color: rgba(212, 255, 38, 0.6);
    background: linear-gradient(135deg, rgba(212, 255, 38, 0.92), rgba(177, 232, 34, 0.9));
}

.stats-editor-select-empty {
    color: #9ca3af;
    background: rgba(255, 255, 255, 0.03);
}

.stats-editor-status {
    min-height: 20px;
    color: #ffb7c2;
    font-size: 13px;
}

.stats-editor-status.is-success {
    color: var(--stats-banana);
}

.stats-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.stats-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 42px;
    padding: 0 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #d8dbe1;
    font-size: 13px;
    font-weight: 700;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.stats-modal-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.14);
}

.stats-modal-btn.is-primary {
    color: #111214;
    background: var(--stats-banana);
    border-color: rgba(212, 255, 38, 0.52);
}

.stats-modal-btn.is-primary:hover {
    border-color: rgba(212, 255, 38, 0.74);
}

.stats-modal-btn:disabled,
.stats-edit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.hidden {
    display: none !important;
}

@media (max-width: 1200px) {
    .stats-summary-grid-hero,
    .stats-hero-panel,
    .stats-chart-grid,
    .stats-model-grid,
    .stats-dimensions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .stats-shell {
        width: min(100vw - 20px, 1480px);
        padding-top: 16px;
    }

    .stats-topbar-actions,
    .stats-title-wrap {
        width: 100%;
    }

    .stats-refresh-btn,
    .stats-topbar-link,
    .stats-userbar {
        width: 100%;
        justify-content: center;
    }

    .stats-person-topline {
        display: grid;
    }

    .stats-person-actions,
    .stats-modal-meta-grid {
        width: 100%;
    }

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

    .stats-range-actions {
        justify-content: stretch;
    }

    .stats-range-apply,
    .stats-range-reset {
        width: 100%;
    }

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

    .stats-modal {
        padding: 14px;
    }

    .stats-modal-dialog {
        padding: 18px;
    }
}
