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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d3a;
    --text: #e1e4ed;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
    --log-bg: #0a0b0f;
    --thead-bg: rgba(255, 255, 255, 0.03);
    --row-hover: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #d8dae0;
    --text: #1a1d27;
    --text-muted: #5f6371;
    --primary: #4f46e5;
    --primary-hover: #6366f1;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --log-bg: #f0f1f3;
    --thead-bg: rgba(0, 0, 0, 0.02);
    --row-hover: rgba(0, 0, 0, 0.02);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

nav .logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    text-decoration: none;
}

nav .nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

nav .nav-links {
    display: flex;
    gap: 1.5rem;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    margin: 0;
    flex-shrink: 0;
}

.theme-switch input {
    display: none;
}

.theme-slider {
    position: absolute;
    inset: 0;
    background: #2a2d3a;
    border-radius: 26px;
    cursor: pointer;
    transition: background 0.3s;
}

/* Knob */
.theme-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    z-index: 1;
}

/* Sun icon (dark mode — unchecked, shown on right side) */
.theme-slider::after {
    content: "\2600\FE0E";
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    line-height: 1;
    color: #f59e0b;
}

/* Moon icon (light mode — checked, shown on left side) */
.theme-switch input:checked + .theme-slider::after {
    content: "\263E";
    right: auto;
    left: 7px;
    color: #fff;
}

.theme-switch input:checked + .theme-slider {
    background: #3b82f6;
}

.theme-switch input:checked + .theme-slider::before {
    transform: translateX(22px);
}

nav .nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

nav .nav-links a:hover {
    color: var(--text);
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

h1 code {
    font-size: 1.1rem;
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 400;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group > label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

input[type="text"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

textarea {
    resize: vertical;
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    font-size: 0.8rem;
}

.hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.form-error {
    padding: 0.625rem 0.875rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Queue */
.queue-section {
    margin-top: 2rem;
}

.queue-section h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.queue-item a {
    color: var(--primary);
    text-decoration: none;
}

.queue-item a:hover {
    text-decoration: underline;
}

/* Radio button group */
.radio-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.radio-btn {
    display: block;
    margin: 0;
}

.radio-btn input {
    display: none;
}

.radio-btn span {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    cursor: pointer;
    border-right: 1px solid var(--border);
    transition: all 0.15s;
    user-select: none;
}

.radio-btn:last-child span {
    border-right: none;
}

.radio-btn input:checked + span {
    background: var(--primary);
    color: #fff;
}

.radio-btn span:hover {
    background: var(--surface);
}

.radio-btn input:checked + span:hover {
    background: var(--primary-hover);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.btn:hover {
    background: var(--border);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.3rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    background: transparent;
    border-color: transparent;
}

.btn-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}
.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}
.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}
.badge-secondary {
    background: rgba(139, 143, 163, 0.15);
    color: var(--text-muted);
}

/* Results grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.results-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.result-card h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.result-value.pass {
    color: var(--success);
}
.result-value.fail {
    color: var(--danger);
}

.result-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Check detail */
.check-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.check-title-row h1 {
    margin-bottom: 0;
}

.check-meta {
    display: flex;
    gap: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.check-meta code {
    font-size: 0.8rem;
    background: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

/* History header */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.history-header h1 {
    margin-bottom: 0;
}

/* Log box */
.log-box {
    background: var(--log-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    font-size: 0.8rem;
    line-height: 1.8;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-muted);
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

thead {
    background: var(--thead-bg);
}

th {
    text-align: left;
    padding: 0.75rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: var(--row-hover);
}

td code {
    font-size: 0.8rem;
    background: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.actions-cell {
    white-space: nowrap;
    text-align: right;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 0;
}

.empty-state a {
    color: var(--primary);
}

/* Test Report */
.test-report {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.report-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.report-test-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.report-metrics {
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 0.35rem;
}

.report-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.report-log-details {
    margin-top: 0.5rem;
}

.report-log-details summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.report-log-details summary:hover {
    color: var(--text);
}

.report-log {
    background: var(--log-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.report-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
    font-size: 0.9rem;
}

.log-section {
    margin-top: 1.5rem;
}

.log-section > summary {
    cursor: pointer;
    user-select: none;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 800px) {
    .results-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    main {
        padding: 0 1rem;
    }
    .results-grid {
        grid-template-columns: 1fr;
    }
    .results-grid-4 {
        grid-template-columns: 1fr;
    }
    .check-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    .check-title-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    nav {
        padding: 0.75rem 1rem;
    }
    .radio-group {
        flex-wrap: wrap;
    }
}
