:root {
    --primary-color: #3b82f6;
    --primary-soft: rgba(59, 130, 246, 0.14);
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --muted-color: #94a3b8;
    --bg-color: #0b1220;
    --bg-accent: radial-gradient(circle at top right, rgba(59, 130, 246, 0.16), transparent 28%), linear-gradient(180deg, #0b1220 0%, #111827 100%);
    --card-bg: rgba(15, 23, 42, 0.88);
    --text-color: #f8fafc;
    --border-color: #334155;
    --surface-color: #0f172a;
}

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

body {
    font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background: var(--bg-accent);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

body[data-view-mode="simple"] .advanced-only {
    display: none !important;
}

body[data-view-mode="simple"] .simple-table-wrap {
    display: block;
}

body[data-view-mode="full"] .simple-table-wrap {
    display: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 20px 40px rgba(2, 8, 23, 0.24);
    backdrop-filter: blur(8px);
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 18px;
}

.hero-copy {
    max-width: 760px;
}

.view-switch {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0;
    margin-bottom: 0;
    background: transparent;
    border: 0;
}

.hero-switch {
    min-width: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.2;
    margin-bottom: 10px;
    color: #dbeafe;
}

h2 {
    font-size: 20px;
}

p {
    color: var(--muted-color);
}

.notice {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 15px;
    border: 1px solid rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.1);
    color: #bfdbfe;
}

.notice.warning {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.1);
    color: #fde68a;
}

.notice-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.notice-close {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: transparent;
    color: inherit;
    padding: 2px 8px;
    font-size: 12px;
}

.notice-close:hover:not(:disabled) {
    background: rgba(148, 163, 184, 0.14);
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    align-items: end;
}

.compact-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.6fr) minmax(0, 1fr) auto;
}

.minimal-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) auto 0;
}

.inline-actions-wrap {
    min-width: 0;
}

.inline-actions {
    flex-wrap: nowrap;
    gap: 8px;
}

.grid.tight {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.preset-grid {
    display: grid;
    grid-template-columns: 1.4fr 1.2fr repeat(3, minmax(0, 0.8fr));
    gap: 14px;
    align-items: end;
    margin-top: 15px;
}

.preset-tools {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.preset-meta {
    color: var(--muted-color);
    font-size: 13px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
    margin-top: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 13px;
    color: var(--muted-color);
}

input,
select {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: white;
    padding: 11px 14px;
    border-radius: 10px;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.toolbar,
.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar {
    margin-bottom: 10px;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.main-actions {
    align-items: center;
}

.secondary-actions {
    margin-top: 12px;
}

body[data-view-mode="simple"] .secondary-actions {
    display: none;
}

body[data-view-mode="simple"] .secondary-actions.is-open {
    display: flex;
}

button {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: white;
}

.btn-outline:hover:not(:disabled) {
    background: rgba(51, 65, 85, 0.6);
}

.btn-export {
    background: #2563eb;
    color: white;
}

.btn-secondary {
    background: #0f766e;
    color: white;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.stat-tile {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 14px;
    padding: 14px 16px;
}

.stat-label {
    color: var(--muted-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    margin-top: 8px;
    font-size: 24px;
    font-weight: 700;
}

.stat-note {
    margin-top: 4px;
    color: var(--muted-color);
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 16px;
}

.simple-table-wrap {
    margin-top: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px;
    color: var(--muted-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
}

th.sortable:hover {
    color: var(--primary-color);
}

td {
    padding: 12px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.7);
    font-size: 14px;
    vertical-align: top;
}

.simple-table-wrap td,
.simple-table-wrap th {
    padding-top: 10px;
    padding-bottom: 10px;
}

tbody tr:hover {
    background: rgba(15, 23, 42, 0.36);
}

.status-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.status-ready {
    background: #475569;
    color: white;
}

.status-success {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
}

.status-error {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
}

.status-testing {
    background: rgba(59, 130, 246, 0.16);
    color: #60a5fa;
}

.status-skipped {
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
}

.status-stopped {
    background: rgba(148, 163, 184, 0.16);
    color: #cbd5e1;
}

.latency-text,
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.detail-cell {
    max-width: 360px;
    color: var(--muted-color);
    white-space: pre-line;
    word-break: break-word;
}

.metric-cell {
    min-width: 180px;
    color: var(--muted-color);
    white-space: pre-line;
}

.table-select {
    min-width: 136px;
    padding: 6px 8px;
    font-size: 12px;
}

.action-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 148px;
}

.model-name {
    font-weight: 700;
    color: #e2e8f0;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.mini-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    font-size: 11px;
    padding: 2px 8px;
}

.stats {
    margin-top: 14px;
    color: var(--muted-color);
    font-size: 13px;
}

.subtext {
    color: var(--muted-color);
    font-size: 12px;
    margin-top: 8px;
}

.empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 40px;
}

.simple-detail-row td {
    background: rgba(15, 23, 42, 0.38);
    padding-top: 0;
}

.simple-detail-card {
    border-top: 1px dashed rgba(148, 163, 184, 0.16);
    padding-top: 12px;
    color: var(--muted-color);
    white-space: pre-line;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    background: #111827;
    border: 1px solid var(--primary-color);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 1000;
    max-width: 460px;
    white-space: pre-line;
}

body[data-view-mode="simple"] .card {
    padding: 20px;
}

body[data-view-mode="simple"] .hero {
    margin-bottom: 14px;
}

body[data-view-mode="simple"] h1 {
    font-size: 24px;
}

body[data-view-mode="simple"] .hero-copy p {
    display: none;
}

body[data-view-mode="simple"] .view-switch {
    margin-bottom: 0;
}

body[data-view-mode="simple"] .hero-switch {
    margin-bottom: 0;
}

body[data-view-mode="simple"] .main-actions {
    width: auto;
    flex-wrap: nowrap;
    gap: 8px;
}

body[data-view-mode="simple"] .main-actions button {
    flex: 0 0 auto;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 9px;
    min-width: 0;
}

body[data-view-mode="simple"] .table-wrap {
    margin-top: 12px;
}

body[data-view-mode="simple"] .stats {
    margin-top: 10px;
}

.loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

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

@media (max-width: 1180px) {
    .grid,
    .grid.tight,
    .filter-grid,
    .quick-stats,
    .preset-grid,
    .compact-grid,
    .minimal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    body {
        padding: 14px;
    }

    .card {
        padding: 18px;
    }

    .hero {
        flex-direction: column;
    }

    .grid,
    .grid.tight,
    .filter-grid,
    .quick-stats,
    .preset-grid,
    .compact-grid,
    .minimal-grid {
        grid-template-columns: 1fr;
    }

    .preset-tools {
        flex-direction: column;
        align-items: stretch;
    }

    .view-switch {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-switch {
        min-width: 0;
        width: 100%;
    }

    .inline-actions {
        flex-wrap: wrap;
    }

    .table-wrap {
        margin-left: -4px;
        margin-right: -4px;
    }
}
