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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #fafafa;
    color: #333;
    padding: 16px 20px;
    overflow-y: scroll;
    overflow-anchor: none;
    font-size: 14px;
}

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

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

h1 {
    font-size: 1.4em;
    font-weight: 500;
    color: #111;
    margin: 0;
}

.header-controls {
    display: flex;
    gap: 8px;
}

#project-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 32px 8px 12px;
    font-size: 0.85em;
    font-weight: 500;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    min-width: 140px;
}

#project-select:hover {
    border-color: #bbb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

#project-select:focus {
    outline: none;
    border-color: #5c6bc0;
    box-shadow: 0 0 0 3px rgba(92, 107, 192, 0.15);
}

.stats {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 20px;
}

.chart-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.chart-header:hover {
    background: #f5f5f5;
}

.chart-toggle {
    font-size: 0.75em;
    color: #666;
    transition: transform 0.2s ease;
}

.chart-section:not(.collapsed) .chart-toggle {
    transform: rotate(90deg);
}

.chart-title {
    font-size: 0.85em;
    font-weight: 500;
    color: #555;
}

.chart-container {
    height: 350px;
    padding: 16px;
}

.chart-section.collapsed .chart-container {
    display: none;
}

.chart-section.collapsed .chart-header {
    border-bottom: none;
}

.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.details {
    margin-top: 12px;
    font-size: 0.82em;
}

.details-header {
    color: #111;
    font-weight: 500;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

/* Group cards (generic) */
.group-card {
    --accent-color: #666;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.group-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-color);
    opacity: 0.7;
}

.group-card:hover {
    border-color: #bbb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.group-card.selected {
    border-color: var(--accent-color);
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.group-card.selected::before {
    opacity: 1;
}

.group-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.group-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-color);
    flex-shrink: 0;
}

.group-icon svg {
    width: 100%;
    height: 100%;
}

.group-title {
    flex: 1;
    min-width: 0;
}

.group-name {
    font-weight: 600;
    font-size: 0.88em;
    color: #111;
    line-height: 1.2;
}

.group-subtitle {
    font-size: 0.75em;
    color: #888;
    margin-top: 2px;
    font-family: monospace;
}

.group-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: 600;
    flex-shrink: 0;
}

.group-badge.healthy {
    background: #e8f5e9;
    color: #2e7d32;
}

.group-badge.issues {
    background: #ffebee;
    color: #c62828;
}

.group-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
}

.group-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
}

.stat-icon {
    width: 14px;
    height: 14px;
    color: #bbb;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 100%;
    height: 100%;
}

.stat-label {
    flex: 1;
    color: #666;
}

.stat-value {
    font-weight: 500;
    color: #333;
    font-variant-numeric: tabular-nums;
}

.stat-value.has-errors {
    color: #e53935;
}

.hint {
    color: #999;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

/* Items section */
.items-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    table-layout: fixed;
}

.items-table th,
.items-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.items-table th {
    color: #666;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 40px;
    background: #fafafa;
    z-index: 5;
}

.items-table th:hover {
    color: #333;
}

.items-table th .sort-arrow {
    margin-left: 4px;
    opacity: 0.4;
}

.items-table th.sorted .sort-arrow {
    opacity: 1;
}

.items-table td {
    color: #333;
}

.items-table .name {
    font-family: monospace;
    font-size: 0.85em;
    width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.items-table .num {
    text-align: right;
}

.items-table .has-errors {
    color: #e53935;
}

.items-table tr.clickable {
    cursor: pointer;
}

.items-table tr.clickable:hover {
    background: #f5f5f5;
}

.items-table tr.expanded {
    background: #f5f5f5;
}

/* Item details (nested) */
.item-details-row td {
    padding: 0 !important;
    background: #fafafa;
}

.detail-list {
    font-family: monospace;
    font-size: 0.85em;
    padding: 0;
    width: 100%;
}

.detail-item {
    padding: 4px 8px;
    display: flex;
    gap: 16px;
    border-bottom: 1px solid #eee;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item.has-errors {
    color: #e53935;
}

.detail-name {
    min-width: 100px;
}

.detail-metrics {
    color: #666;
}

/* Failure details (assertion failures) */
.failure-detail {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 4px 0;
    background: #fff8f8;
    border-left: 3px solid #e53935;
    border-radius: 0 4px 4px 0;
}

.failure-content {
    flex: 1;
    min-width: 0;
}

.copy-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-left: 12px;
    padding: 3px 6px;
    min-height: 22px;
    min-width: 22px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 10px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    box-sizing: border-box;
}

.copy-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #333;
}

.copy-btn.copied {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: #4caf50;
    color: #2e7d32;
}

.copy-btn.copied span {
    font-weight: 500;
}

.failure-detail + .failure-detail {
    margin-top: 8px;
}

.failure-location {
    font-family: monospace;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 6px;
}

.failure-condition {
    margin-bottom: 8px;
}

.failure-condition code {
    background: #ffebee;
    padding: 2px 6px;
    border-radius: 3px;
    color: #c62828;
}

.failure-expected,
.failure-actual {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

.failure-label {
    font-size: 0.8em;
    color: #666;
    min-width: 60px;
}

.failure-expected code,
.failure-actual code {
    font-family: monospace;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
}

.failure-expected code {
    background: #e8f5e9;
    color: #2e7d32;
}

.failure-actual code {
    background: #ffebee;
    color: #c62828;
}

/* Error details (pytest style) */
.error-detail {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.error-detail .failure-content {
    width: 100%;
}

.error-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    width: 100%;
}

.error-header-row .copy-btn {
    margin-left: auto;
    position: static;
    opacity: 0.7;
    padding: 2px 6px;
}

.error-header-row .copy-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.05);
}

.error-header-row .copy-btn.copied {
    opacity: 1;
}

.error-type {
    display: inline-block;
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
}

.error-message {
    font-weight: 600;
    margin-bottom: 2px;
    color: #dc2626;
    font-size: 0.85em;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
}

.error-stack {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 6px 8px;
    border-radius: 0;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
}

.error-stack pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 10px;
    line-height: 1.2;
}

/* Collapsible stack trace */
.stack-trace-section {
    margin-top: 4px;
    width: 100%;
}

.stack-trace-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #2d2d2d;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    user-select: none;
}

.stack-trace-header:hover {
    background: #3d3d3d;
}

.stack-toggle {
    color: #888;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 10px;
}

.stack-label {
    color: #999;
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
}

.stack-count {
    color: #666;
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
    margin-left: auto;
}

/* Collapsed state */
.error-stack.collapsed {
    display: none;
}

/* Expanded state */
.error-stack {
    border-radius: 0 0 4px 4px;
}

/* Natural language explanation */
.error-explanation {
    display: flex;
    gap: 4px;
    padding: 3px 8px;
    margin: 2px 0;
    background: linear-gradient(135deg, #fff8e1 0%, #fffde7 100%);
    border-left: 2px solid #ffc107;
    border-radius: 0 3px 3px 0;
    font-size: 10px;
    line-height: 1.3;
}

.explanation-icon {
    flex-shrink: 0;
    font-size: 10px;
}

.explanation-text {
    color: #5d4037;
}

/* Breadcrumb navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 0.85em;
    color: #666;
    position: sticky;
    top: 0;
    background: #fafafa;
    z-index: 10;
    padding: 8px 0;
}

.breadcrumb-link {
    color: #1976d2;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.2s;
}

.breadcrumb-link:hover {
    background: #e3f2fd;
    text-decoration: underline;
}

.breadcrumb-sep {
    color: #999;
    font-weight: 300;
}

.breadcrumb-current {
    color: #333;
    font-weight: 500;
}

/* Drill indicator for items with children */
.drill-icon {
    display: inline-block;
    margin-right: 6px;
    color: #1976d2;
    font-weight: bold;
    transition: transform 0.2s;
}

.items-table tr:hover .drill-icon {
    transform: translateX(2px);
}

.items-table td.drillable {
    color: #1976d2;
}

/* Items footer */
.items-footer {
    text-align: right;
    font-size: 0.8em;
    color: #666;
    padding: 8px 0;
    margin-top: 8px;
}

/* Tree filter */
.tree-filter {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

/* iOS-style toggle switch (small) */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 34px;
    height: 20px;
    background: #e9e9eb;
    border-radius: 20px;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.15),
        0 1px 1px rgba(0, 0, 0, 0.12);
}

.toggle-switch input:checked + .toggle-slider {
    background: #e53935;
}

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

.toggle-switch:active .toggle-slider::before {
    width: 19px;
}

.toggle-switch:active input:checked + .toggle-slider::before {
    transform: translateX(11px);
}

.toggle-label {
    font-size: 0.8em;
    font-weight: 500;
    color: #555;
}

.toggle-switch input:checked ~ .toggle-label {
    color: #c62828;
}

/* Tree view - table-like layout for proper alignment */
.tree-header {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    background: #f5f5f5;
    border-left: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
    font-size: 0.8em;
    font-weight: 500;
    color: #666;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tree-header > span {
    cursor: pointer;
}

.tree-header > span:hover {
    color: #333;
}

.tree-header-toggle {
    width: 24px;
    flex-shrink: 0;
}

.tree-header-name {
    flex: 1;
    min-width: 200px;
}

.tree-header-status {
    width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.tree-header-metrics {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.tree-header-metric {
    width: 90px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.tree-header .sort-arrow {
    margin-left: 2px;
    opacity: 0.4;
    font-size: 0.8em;
}

.tree-header .sorted .sort-arrow {
    opacity: 1;
}

.tree-container {
    font-size: 0.82em;
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
    border-left: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
    border-radius: 0 0 6px 6px;
    background: #fff;
}

/* Group items - flex layout matching header */
.tree-item.group-item {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.tree-item.group-item.clickable {
    cursor: pointer;
}

.tree-item.group-item.clickable:hover {
    background: #f5f5f5;
}

.tree-item.group-item.expanded {
    background: #f0f0f0;
}

.tree-toggle {
    width: 16px;
    flex-shrink: 0;
    color: #666;
    font-size: 0.8em;
    margin-right: 4px;
}

.tree-toggle-spacer {
    width: 16px;
    flex-shrink: 0;
    margin-right: 4px;
}

.tree-name-cell {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.tree-name {
    font-family: monospace;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Depth-based indentation via margin on toggle */
.tree-item.group-item.depth-1 .tree-toggle,
.tree-item.group-item.depth-1 .tree-toggle-spacer { margin-left: 20px; }
.tree-item.group-item.depth-2 .tree-toggle,
.tree-item.group-item.depth-2 .tree-toggle-spacer { margin-left: 40px; }
.tree-item.group-item.depth-3 .tree-toggle,
.tree-item.group-item.depth-3 .tree-toggle-spacer { margin-left: 60px; }
.tree-item.group-item.depth-4 .tree-toggle,
.tree-item.group-item.depth-4 .tree-toggle-spacer { margin-left: 80px; }

.tree-status {
    width: 60px;
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
    flex-shrink: 0;
}

.tree-status.pass {
    background: #e8f5e9;
    color: #2e7d32;
}

.tree-status.fail {
    background: #ffebee;
    color: #c62828;
}

.tree-metrics {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    font-size: 0.85em;
    color: #333;
}

.tree-metric {
    width: 90px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tree-metric.has-errors {
    color: #c62828;
    font-weight: 500;
}

.tree-children {
    /* Nested items container */
}

/* Leaf items (individual tests) - same structure as group items */
.tree-item.leaf-item {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.tree-item.leaf-item.clickable {
    cursor: pointer;
}

.tree-item.leaf-item:hover {
    background: #f5f5f5;
}

.tree-item.leaf-item.expanded {
    background: #f0f0f0;
}

/* Depth indentation for leaf items - same as group items */
.tree-item.leaf-item.depth-1 .tree-toggle-spacer,
.tree-item.leaf-item.depth-1 .tree-toggle { margin-left: 20px; }
.tree-item.leaf-item.depth-2 .tree-toggle-spacer,
.tree-item.leaf-item.depth-2 .tree-toggle { margin-left: 40px; }
.tree-item.leaf-item.depth-3 .tree-toggle-spacer,
.tree-item.leaf-item.depth-3 .tree-toggle { margin-left: 60px; }
.tree-item.leaf-item.depth-4 .tree-toggle-spacer,
.tree-item.leaf-item.depth-4 .tree-toggle { margin-left: 80px; }

.tree-details {
    margin-left: 20px;
    margin-right: 8px;
    margin-bottom: 2px;
    padding: 4px 8px;
    background: #fff8f8;
    border-left: 3px solid #e53935;
    border-radius: 0 4px 4px 0;
}

.tree-details .failure-detail {
    border-left: none;
    background: transparent;
    padding: 2px 0;
    margin: 0;
}

.tree-details .failure-detail + .failure-detail {
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid #f0e0e0;
}

.failure-inline {
    font-family: monospace;
    font-size: 0.85em;
}

.failure-inline code {
    background: #f5f5f5;
    padding: 1px 4px;
    border-radius: 3px;
    margin-right: 6px;
}
