:root {
    --bg: #0C1117;
    --bg-card: rgba(22, 27, 34, 0.8);
    --bg-elevated: #1C2333;
    --bg-input: rgba(12, 17, 23, 0.9);
    --text: #E6EDF3;
    --text-sec: #8B949E;
    --text-muted: #484F58;
    --border: rgba(139, 148, 158, 0.08);
    --radius: 10px;
    --radius-sm: 6px;
    --dns: #4A9AF5;
    --connect: #F5A623;
    --ssl: #7ED321;
    --ttfb: #BD10E0;
    --download: #50E3C2;
    --type-doc: #E74C3C;
    --type-js: #F39C12;
    --type-css: #3498DB;
    --type-img: #2ECC71;
    --type-xhr: #9B59B6;
    --type-font: #1ABC9C;
    --type-other: #95A5A6;
    --font: 'Inter', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(12, 17, 23, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.25rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(74, 154, 245, 0.12);
    border-radius: var(--radius-sm);
}

.app-title {
    font-size: 1rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--dns), var(--download));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 0.625rem;
    color: var(--text-sec);
}

.header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.header-select,
.header-input {
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.6875rem;
    outline: none;
}

.header-input {
    width: 110px;
}

.header-select:focus,
.header-input:focus {
    border-color: var(--dns);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--dns), #2171D9);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 3px 12px rgba(74, 154, 245, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-sec);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Upload */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 250ms ease;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--dns);
    background: rgba(74, 154, 245, 0.04);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.upload-area h2 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.upload-area p {
    font-size: 0.75rem;
    color: var(--text-sec);
    margin-bottom: 12px;
}

/* Summary */
.summary-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.summary-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--dns);
}

.summary-label {
    font-size: 0.5625rem;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Size breakdown */
.size-bars {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.size-bar-segment {
    height: 100%;
    min-width: 2px;
    transition: width 300ms ease;
}

/* Waterfall */
.waterfall-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.waterfall-header {
    display: grid;
    grid-template-columns: 200px 50px 60px 60px 60px 1fr;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.5625rem;
    font-weight: 700;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.waterfall-body {
    max-height: 600px;
    overflow-y: auto;
}

.wf-row {
    display: grid;
    grid-template-columns: 200px 50px 60px 60px 60px 1fr;
    gap: 4px;
    padding: 4px 12px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: background 100ms;
}

.wf-row:hover {
    background: rgba(74, 154, 245, 0.04);
}

.wf-row.critical {
    background: rgba(189, 16, 224, 0.04);
}

.wf-name {
    font-size: 0.6875rem;
    font-family: var(--mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-status {
    font-size: 0.625rem;
    font-weight: 600;
}

.wf-status.s2xx {
    color: #2ECC71;
}

.wf-status.s3xx {
    color: var(--connect);
}

.wf-status.s4xx {
    color: #E74C3C;
}

.wf-status.s5xx {
    color: #E74C3C;
}

.wf-type {
    font-size: 0.5625rem;
}

.wf-size {
    font-size: 0.625rem;
    font-family: var(--mono);
    color: var(--text-sec);
}

.wf-time {
    font-size: 0.625rem;
    font-family: var(--mono);
}

.wf-bar {
    position: relative;
    height: 14px;
}

.timing-bar {
    position: absolute;
    height: 14px;
    border-radius: 2px;
    min-width: 1px;
}

.type-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.5rem;
    font-weight: 700;
}

/* Detail */
.detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    z-index: 60;
    overflow-y: auto;
    transition: transform 300ms ease;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
}

.detail-title {
    font-size: 0.875rem;
    font-weight: 700;
}

.detail-body {
    padding: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.detail-label {
    font-size: 0.6875rem;
    color: var(--text-sec);
}

.detail-value {
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--mono);
}

.detail-section {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--dns);
    margin: 12px 0 6px;
}

.timing-breakdown {
    margin: 8px 0;
}

.timing-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.timing-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.timing-name {
    font-size: 0.6875rem;
    flex: 1;
}

.timing-val {
    font-size: 0.6875rem;
    font-family: var(--mono);
    font-weight: 600;
}

/* Legend */
.legend-bar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 16px;
    width: 100%;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.625rem;
    color: var(--text-sec);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.app-footer {
    text-align: center;
    padding: 12px;
    font-size: 0.625rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-bar {
        grid-template-columns: repeat(3, 1fr);
    }

    .waterfall-header,
    .wf-row {
        grid-template-columns: 1fr 40px 50px 1fr;
    }

    .wf-type,
    .wf-size {
        display: none;
    }

    .detail-panel {
        width: 100%;
    }
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 148, 158, 0.15);
    border-radius: 3px;
}