.stats-page {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 16px 24px 40px;
}
.stats-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #e8eef5;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .04);
}
.stats-search-group {
    flex: 0 1 320px;
    min-width: 0;
}
.stats-search-label {
    display: block;
    margin: 0 0 6px 2px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}
.stats-search-wrapper { position: relative; }
.stats-search-input {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px 10px 40px;
    color: #334155;
    font: inherit;
    font-size: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    transition: background-color .18s, border-color .18s, box-shadow .18s;
}
.stats-search-input::placeholder { color: #94a3b8; }
.stats-search-input:hover { border-color: #cbd5e1; }
.stats-search-input:focus {
    background: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .1);
}
.stats-search-input:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.stats-search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    z-index: 1;
    width: 18px;
    height: 18px;
    color: #94a3b8;
    pointer-events: none;
    transform: translateY(-50%);
}
.stats-count {
    flex: none;
    padding: 0 2px 12px;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.stats-table-scroll {
    max-height: none;
    min-height: 0;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    background: #fff;
    border: 1px solid #e8eef5;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .04);
    scrollbar-color: #cbd5e1 #f8fafc;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.stats-table-scroll.is-empty { min-height: 0; }
.stats-table {
    width: 100%;
    min-width: 880px;
    table-layout: fixed;
    border-spacing: 0;
    border-collapse: separate;
    color: #475569;
    font-variant-numeric: tabular-nums;
}
.stats-table th,
.stats-table td {
    height: 58px;
    padding: 6px 12px;
    text-align: center;
    border-bottom: 1px solid #eef2f7;
}
.stats-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 56px;
    padding: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    background: #f8fafc;
}
.stats-table th button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    color: inherit;
    font: inherit;
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: 8px;
    transition: color .18s, background-color .18s;
}
.stats-table th button:hover { color: #2563eb; background: #eff6ff; }
.stats-table th button:focus-visible { outline: 2px solid #3b82f6; outline-offset: -3px; }
.stats-table th.is-sorted,
.stats-table th.is-sorted button,
.stats-table td.is-sorted { color: #2563eb; background: #eff6ff; }
.stats-table th.is-sorted { box-shadow: inset 0 1px #dbeafe; }
.stats-table td.is-sorted { font-weight: 700; }
.stats-sort-arrow { width: 12px; font-size: 13px; line-height: 1; }
.stats-table .stats-order-column {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 56px;
    min-width: 56px;
    padding-inline: 8px;
    color: #64748b;
    background: #fff;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}
.stats-table th.stats-order-column { z-index: 5; background: #f8fafc; }
.stats-table .stats-name-column {
    position: sticky;
    left: 56px;
    z-index: 2;
    width: 34%;
    min-width: 240px;
    padding-left: 20px;
    text-align: left;
    background: #fff;
    box-shadow: 4px 0 8px rgba(15, 23, 42, .025);
}
.stats-table th.stats-name-column { z-index: 5; background: #f8fafc; }
.stats-table tbody tr:last-child td { border-bottom: 0; }
.stats-table tbody tr:hover td { background: #f8fafc; }
.stats-table tbody tr:hover td.is-sorted { background: #e5efff; }
.stats-character {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    color: #334155;
    text-decoration: none;
    border-radius: 10px;
}
.stats-character:hover strong { color: #2563eb; }
.stats-character:focus-visible { outline: 2px solid #3b82f6; outline-offset: 3px; }
.stats-character img {
    flex: none;
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 50%;
}
.stats-character strong,
.stats-character small { display: block; }
.stats-character strong { font-size: 14px; font-weight: 700; transition: color .18s; }
.stats-character small { margin-top: 3px; color: #94a3b8; font-size: 11px; }
.stats-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 56px 20px;
    color: #64748b;
    text-align: center;
}
.stats-empty[hidden] { display: none; }
.stats-empty strong { color: #334155; font-size: 16px; }
.stats-empty span { font-size: 14px; }

@media (max-width: 768px) {
    .stats-page { padding: 8px 12px 28px; }
    .stats-toolbar { gap: 12px; margin-bottom: 16px; padding: 12px; border-radius: 16px; }
    .stats-search-group { flex: 1 1 auto; max-width: 320px; }
    .stats-count { padding-bottom: 13px; }
    .stats-table-scroll { border-radius: 16px; }
    .stats-table { min-width: 760px; }
    .stats-table .stats-order-column { width: 44px; min-width: 44px; }
    .stats-table .stats-name-column { left: 44px; width: 144px; min-width: 144px; padding-left: 12px; }
    .stats-table th,
    .stats-table td { height: 56px; padding-inline: 8px; }
    .stats-character { gap: 8px; }
    .stats-character img { width: 36px; height: 36px; }
}
@media (max-width: 420px) {
    .stats-toolbar { gap: 8px; }
    .stats-search-input { padding-left: 36px; font-size: 13px; }
    .stats-search-icon { left: 12px; width: 16px; height: 16px; }
    .stats-count { font-size: 11px; }
    .stats-table { min-width: 688px; }
    .stats-table .stats-order-column { width: 32px; min-width: 32px; padding-inline: 4px; }
    .stats-table .stats-name-column { left: 32px; width: 104px; min-width: 104px; padding-left: 8px; padding-right: 6px; }
    .stats-character { gap: 4px; }
    .stats-character img { width: 28px; height: 28px; }
}
@media (prefers-reduced-motion: reduce) {
    .stats-search-input,
    .stats-table th button,
    .stats-character strong { transition: none; }
}
