:root {
    /* Gold Accent — from Colors.xaml */
    --gold-primary: #D4A520;
    --gold-light: #E8C04A;
    --gold-dark: #B08A18;
    --gold-subtle: rgba(212, 165, 32, 0.2);

    /* Dark Theme Backgrounds — from Colors.xaml */
    --bg-primary: #131318;
    --bg-secondary: #1A1A22;
    --bg-tertiary: #22222E;
    --surface: #1C1C26;
    --border: #2E2E3A;

    /* Text Colors — from Colors.xaml */
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --text-muted: #707070;

    /* Grade Colors — from Colors.xaml */
    --grade-perfect: #00D4FF;
    --grade-excellent: #00CC66;
    --grade-good: #66CC00;
    --grade-acceptable: #FFCC00;
    --grade-fail: #FF3333;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
}

.brand-title {
    color: var(--gold-primary);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.3em;
    margin-bottom: 4px;
}

.brand-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

/* Main Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
    flex: 1;
    width: 100%;
}

.page-description {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
}

/* Card */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.table-card {
    padding: 16px 12px;
    overflow-x: auto;
}

/* Controls Bar */
.controls-row {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-right {
    margin-left: auto;
}

.stat-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.entry-count {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 10px;
}

/* Dark Select */
.dark-select {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    min-width: 140px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23707070' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.dark-select:hover,
.dark-select:focus {
    border-color: var(--gold-primary);
    outline: none;
}

/* Buttons */
.btn-secondary {
    background: transparent;
    color: var(--gold-primary);
    border: 1px solid var(--gold-primary);
    border-radius: 4px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: var(--gold-subtle);
}

/* Loading */
.loading-text {
    color: var(--gold-primary);
    font-size: 14px;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Error Banner */
.error-banner {
    background: rgba(255, 51, 51, 0.1);
    border: 1px solid var(--grade-fail);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--grade-fail);
    font-size: 13px;
}

/* Table Header */
.table-header {
    display: grid;
    grid-template-columns: 42px 130px 140px 120px 120px 1fr 80px;
    gap: 4px;
    padding: 0 4px 8px;
}

.table-header span {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin-bottom: 4px;
}

/* Entry Row */
.entry-summary {
    display: grid;
    grid-template-columns: 42px 130px 140px 120px 120px 1fr 80px;
    gap: 4px;
    align-items: center;
    padding: 8px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
}

.entry-summary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.entry-summary:focus-visible {
    outline: 1px solid var(--gold-primary);
    outline-offset: -1px;
}

/* Column styles */
.col-rank {
    color: var(--text-muted);
    font-size: 13px;
}

.col-user {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-card {
    color: var(--text-secondary);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-throughput {
    font-size: 13px;
    font-weight: 600;
}

.col-throughput .value {
    color: var(--gold-primary);
}

.col-throughput .unit,
.col-latency .unit {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 400;
}

.col-latency {
    color: var(--text-secondary);
    font-size: 13px;
}

.col-hint {
    color: var(--text-muted);
    font-size: 11px;
}

.col-grade {
    display: flex;
    align-items: center;
}

/* Grade Badges */
.grade-badge {
    display: inline-block;
    border-radius: 8px;
    padding: 2px 8px;
    font-weight: 700;
    font-size: 10px;
    color: white;
    background: gray;
}

.grade-badge[data-grade="PERFECT"]    { background: var(--grade-perfect); }
.grade-badge[data-grade="EXCELLENT"]  { background: var(--grade-excellent); }
.grade-badge[data-grade="GOOD"]       { background: var(--grade-good); }
.grade-badge[data-grade="ACCEPTABLE"] { background: var(--grade-acceptable); }
.grade-badge[data-grade="FAIL"]       { background: var(--grade-fail); }

.grade-badge-small {
    display: inline-block;
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: 700;
    font-size: 9px;
    color: white;
    background: gray;
    margin-right: 6px;
}

.grade-badge-small[data-grade="PERFECT"]    { background: var(--grade-perfect); }
.grade-badge-small[data-grade="EXCELLENT"]  { background: var(--grade-excellent); }
.grade-badge-small[data-grade="GOOD"]       { background: var(--grade-good); }
.grade-badge-small[data-grade="ACCEPTABLE"] { background: var(--grade-acceptable); }
.grade-badge-small[data-grade="FAIL"]       { background: var(--grade-fail); }

/* Expandable Detail Panel */
.entry-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    margin-left: 42px;
    margin-right: 4px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.entry-detail.expanded {
    max-height: 300px;
    padding: 12px;
    margin-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.detail-section-title {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.detail-primary {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.detail-secondary {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 2px;
}

.detail-badges {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 16px;
}

.empty-title {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 4px;
}

.empty-subtitle {
    color: var(--text-muted);
    font-size: 13px;
}

/* Footer */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
}

.site-footer p {
    color: var(--text-muted);
    font-size: 12px;
}

/* Responsive — Tablet */
@media (max-width: 900px) {
    .table-header,
    .entry-summary {
        grid-template-columns: 36px 100px 110px 100px 100px 0px 70px;
    }

    .col-hint {
        display: none;
    }

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

/* Responsive — Mobile */
@media (max-width: 640px) {
    .container {
        padding: 16px 12px;
    }

    .controls-row {
        gap: 12px;
    }

    .control-right {
        margin-left: 0;
    }

    .table-header {
        display: none;
    }

    .table-divider {
        display: none;
    }

    .entry-summary {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 12px;
        padding: 12px 8px;
        border-bottom: 1px solid var(--border);
    }

    .col-rank {
        font-weight: 700;
        min-width: 32px;
    }

    .col-user {
        flex: 1;
    }

    .col-grade {
        margin-left: auto;
    }

    .col-card {
        width: 100%;
        order: 10;
    }

    .col-throughput {
        order: 11;
    }

    .col-latency {
        order: 12;
    }

    .col-hint {
        display: none;
    }

    .entry-detail {
        margin-left: 0;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .entry-detail.expanded {
        max-height: 500px;
    }
}
