.badge-dashboard {
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
}

.dashboard-shell {
    padding: 7rem 0 4rem;
    min-height: 70vh;
}

.dashboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.dashboard-toolbar select,
.dashboard-toolbar input {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .dashboard-kpis { grid-template-columns: repeat(2, 1fr); }
}

.dashboard-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
}

.dashboard-kpi__label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-kpi__value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1.1fr 0.9fr;
    }
}

.dashboard-panel--detail {
    max-height: none;
}

@media (min-width: 1100px) {
    .dashboard-panel--detail #runDetail {
        max-height: 75vh;
        overflow-y: auto;
    }
}

.dashboard-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.dashboard-panel__head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.dashboard-panel__head h2 {
    font-size: 1rem;
    margin: 0;
}

.dashboard-panel__meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

.dashboard-table-wrap {
    overflow-x: auto;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.dashboard-table th,
.dashboard-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}

.dashboard-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    background: var(--bg-secondary);
}

.dashboard-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.dashboard-table tbody tr:hover,
.dashboard-table tbody tr.is-selected {
    background: rgba(99, 102, 241, 0.06);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-pill--success { background: #d1fae5; color: #065f46; }
.status-pill--failed { background: #fee2e2; color: #991b1b; }
.status-pill--running { background: #fef3c7; color: #92400e; }

.quality-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.quality-pill--ok { background: #d1fae5; color: #065f46; }
.quality-pill--warn { background: #fef3c7; color: #92400e; }
.quality-pill--dim { background: #f1f5f9; color: #64748b; }
.quality-pill--error { background: #fee2e2; color: #991b1b; }

.run-summary-cell {
    max-width: 220px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.dashboard-summary-box {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.dashboard-summary-box--editor {
    background: rgba(192, 38, 211, 0.06);
    border-color: rgba(192, 38, 211, 0.18);
}

.dashboard-summary-box__title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    margin-bottom: 0.35rem;
    font-weight: 700;
}

.dashboard-summary-box__body {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.dashboard-suboptimal {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.85rem;
}

.dashboard-suboptimal__title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #92400e;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.dashboard-suboptimal__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.8rem;
}

.dashboard-suboptimal__list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.trace-step.is-suboptimal {
    border-color: #fde68a;
}

.trace-step__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.agent-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: lowercase;
}

.agent-tag--research { background: #cffafe; color: #155e75; }
.agent-tag--writer { background: #dbeafe; color: #1e40af; }
.agent-tag--editor { background: #fae8ff; color: #86198f; }
.agent-tag--strategy { background: #fef3c7; color: #92400e; }
.agent-tag--refresh { background: #ffedd5; color: #9a3412; }
.agent-tag--corrector { background: #fee2e2; color: #991b1b; }

.dashboard-detail {
    padding: 1rem 1.25rem 1.25rem;
}

.dashboard-detail__empty {
    color: var(--text-light);
    font-size: 0.9rem;
}

.dashboard-detail__meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

@media (min-width: 900px) {
    .dashboard-detail__meta {
        grid-template-columns: repeat(3, 1fr);
    }
}

.dashboard-detail__heading {
    font-size: 0.95rem;
    margin: 0 0 0.75rem;
}

.dashboard-detail--rich {
    padding: 1rem 1.25rem 1.25rem;
}

.dashboard-note {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    line-height: 1.5;
}

.detail-field {
    margin-bottom: 0.75rem;
}

.detail-field__label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.detail-field__meta {
    font-weight: 500;
    color: var(--text-light);
    text-transform: none;
    letter-spacing: 0;
}

.detail-field__value {
    font-size: 0.82rem;
    color: var(--text-primary);
    word-break: break-word;
}

.detail-field__value--pre {
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
    line-height: 1.55;
}

.detail-field--expandable summary {
    cursor: pointer;
    list-style: none;
}

.detail-field--expandable summary::-webkit-details-marker {
    display: none;
}

.detail-highlights {
    background: rgba(99, 102, 241, 0.04);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.trace-step--iteration {
    border-color: rgba(99, 102, 241, 0.25);
}

.trace-step--iteration .trace-step__head {
    background: rgba(99, 102, 241, 0.06);
}

.trace-turn {
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 0.85rem;
}

.trace-turn__head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: rgba(99, 102, 241, 0.08);
    font-size: 0.84rem;
}

.trace-turn__body {
    padding: 0.85rem 0.9rem 0.95rem;
}

.trace-turn__tools {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.trace-step--nested {
    margin-left: 0.35rem;
}

.dashboard-detail__meta dt {
    color: var(--text-light);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-detail__meta dd {
    margin: 0.15rem 0 0;
    color: var(--text-primary);
    word-break: break-word;
}

.dashboard-error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.trace-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.trace-step {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.trace-step.is-failed {
    border-color: #fecaca;
}

.trace-step__head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--bg-secondary);
    font-size: 0.82rem;
}

.trace-step__body {
    padding: 0.75rem 0.85rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.trace-step pre {
    margin: 0.5rem 0 0;
    padding: 0.65rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.72rem;
    line-height: 1.5;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.25rem;
}

@media (max-width: 700px) {
    .dashboard-stats-grid { grid-template-columns: 1fr; }
}

.dashboard-auth {
    max-width: 420px;
    margin: 0 auto 1.5rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.dashboard-auth label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.dashboard-auth input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.dashboard-loading,
.dashboard-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}
