.agents-page {
    --agents-ink: #1f2937;
    --agents-muted: #64748b;
    --agents-border: #e2e8ee;
    --agents-surface: #f5f9fc;
    padding: 24px;
    color: var(--agents-ink);
    min-width: 0;
}

.agents-page-header,
.agents-well-heading,
.agents-agent-heading,
.agents-message-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.agents-page-header h3 { margin: 0; }
.agents-page-description { color: var(--agents-muted); margin: 12px 0 24px; }
.agents-eyebrow {
    display: block;
    color: var(--agents-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.agents-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.agents-main, .agents-detail, .agents-overview, .agents-run-detail { min-width: 0; }
.agents-page [hidden] { display: none !important; }
.agents-back { margin-bottom: 20px; }
.agents-overview-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.agents-well {
    background: #fff;
    border: 1px solid var(--agents-border);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 3px 12px rgba(31, 41, 55, .035);
}

.agents-well-heading { margin-bottom: 20px; }
.agents-well-heading h4, .agents-message-heading h4 { margin: 0; font-size: 19px; }
.agents-count {
    background: #e2f9ff;
    color: #245e70;
    border: 1px solid #c9e8f0;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}

.agents-page .btn { border-radius: 6px; font-size: 12px; padding: 9px 14px; text-transform: none; }
.agents-page .btn-primary { background-color: var(--agents-ink); border-color: var(--agents-ink); color: #fff; }
.agents-page .btn-primary:hover { background-color: #19212c; border-color: #19212c; }
.agents-page .btn-secondary { background-color: #e2f9ff; border-color: #438ea2; color: var(--agents-ink); }
.agents-page .btn-secondary:hover { background-color: #bee1ff; }
.agents-view-toggle { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--agents-border); border-radius: 8px; background: var(--agents-surface); }
.agents-page .agents-view-toggle .btn { padding: 7px 10px; border-color: transparent; background: transparent; color: var(--agents-ink); }
.agents-page .agents-view-toggle .btn[aria-pressed="true"] { background: var(--agents-ink); color: #fff; }
.agents-page .agents-view-toggle .btn[aria-pressed="false"]:hover { background: #e2f9ff; }
.agents-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.agents-list[data-view="grid"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.agents-list-empty { grid-column: 1 / -1; margin: 0; line-height: 1.6; }
.agents-list-item {
    border: 1px solid var(--agents-border);
    border-radius: 8px;
    background: #fff;
    color: var(--agents-ink);
    padding: 20px;
    text-align: left;
    width: 100%;
    transition: background .15s, border-color .15s;
}

.agents-list-item:hover { background: var(--agents-surface); border-color: #aac5d1; }
.agents-list-item[aria-current="true"] { background: #edf8fc; border-color: #438ea2; box-shadow: inset 3px 0 #438ea2; }
.agents-list-title { display: block; font-weight: 600; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; margin-bottom: 14px; }
.agents-list-meta { display: block; color: var(--agents-muted); font-size: 11px; line-height: 1.6; margin-top: 10px; }
.agents-list-meta small { display: block; }
.agents-list[data-view="list"] .agents-list-item { display: grid; grid-template-columns: minmax(0, 1fr) 120px 190px; align-items: center; gap: 24px; }
.agents-list[data-view="list"] .agents-list-title,
.agents-list[data-view="list"] .agents-list-meta { margin: 0; }
.agents-list[data-view="list"] .agents-status { justify-self: start; }
.agents-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: #eef2f6;
    color: #475569;
}
.agents-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.agents-status-positive { background: #eaf5ef; color: #28704c; }
.agents-status-warning { background: #fff5df; color: #8b641d; }
.agents-status-negative { background: #fcecee; color: #a33e49; }
.agents-detail { display: grid; gap: 20px; }
.agents-agent-heading { align-items: flex-start; }
.agents-agent-heading > div:first-child { flex: 1; min-width: 160px; }
.agents-agent-heading h3 { font-size: 25px; line-height: 1.4; margin: 0; overflow-wrap: anywhere; }
.agents-agent-id { font-size: 11px; color: var(--agents-muted); margin: 8px 0 0; overflow-wrap: anywhere; }
.agents-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.agents-admin-icon { font-size: 10px; margin-left: 6px; vertical-align: super; }
.agents-actions .agents-delete { background: #fff; color: #a33e49; border: 1px solid #ecd0d4; }
.agents-actions .agents-delete:hover { background: #fcecee; border-color: #a33e49; }
.agents-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0 0; }
.agents-stat { border: 1px solid var(--agents-border); border-radius: 8px; padding: 14px; background: var(--agents-surface); min-width: 0; }
.agents-stat dt { color: var(--agents-muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.agents-stat dd { margin: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.6; }
.agents-stat small { display: block; color: var(--agents-muted); font-size: 10px; font-weight: 400; }
.agents-message-heading { padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--agents-border); }
.agents-message-date { color: var(--agents-muted); font-size: 12px; }
.agents-message-body { line-height: 1.8; font-size: 14px; overflow-wrap: anywhere; }
.agents-message-body > .border { border: 0 !important; padding: 0 !important; background: transparent !important; }
.agents-message-body h1 { font-size: 24px; }
.agents-message-body h2 { font-size: 21px; }
.agents-message-body h3 { font-size: 18px; }
.agents-message-body h4 { font-size: 16px; }
.agents-message-body h1, .agents-message-body h2, .agents-message-body h3 { margin: 24px 0 14px; }
.agents-message-body h1:first-child, .agents-message-body h2:first-child, .agents-message-body h3:first-child { margin-top: 0; }
.agents-message-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 18px 0; font-size: 12px; }
.agents-message-body th, .agents-message-body td { padding: 10px 12px; border: 1px solid var(--agents-border); }
.agents-message-body th { background: var(--agents-surface); }
.agents-message-body pre { overflow-x: auto; background: var(--agents-surface); border-radius: 6px; padding: 16px; }
.agents-message-body img { max-width: 100%; height: auto; }
.agents-message-body blockquote { border-left: 3px solid #438ea2; padding: 8px 16px; background: var(--agents-surface); }
.agents-run-workspace { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; }
.agents-run-detail { display: grid; gap: 20px; }
.agents-runs { position: sticky; top: 24px; min-width: 0; }
.agents-history { display: grid; gap: 8px; max-height: 65vh; overflow-y: auto; }
.agents-history-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; border: 1px solid var(--agents-border); border-radius: 7px; background: var(--agents-surface); padding: 12px; color: var(--agents-ink); text-align: left; font-size: 12px; }
.agents-history-item:hover, .agents-history-item[aria-current="true"] { background: #edf8fc; border-color: #438ea2; }
.agents-history-item span:first-child { min-width: 0; overflow-wrap: anywhere; }
.agents-history-date { display: block; }
.agents-history-date small { display: block; color: var(--agents-muted); font-size: 10px; margin-bottom: 4px; }
.agents-history-date > span { display: block; }
.agents-history-item > .agents-status { flex-shrink: 0; }
.agents-config .border { background: var(--agents-surface) !important; border-color: var(--agents-border) !important; }
.agents-empty { text-align: center; padding: 48px 24px; color: var(--agents-muted); background: #fff; border: 1px dashed #ccd9e2; border-radius: 12px; }
.agents-empty > i { font-size: 28px; color: #438ea2; margin-bottom: 16px; }
.agents-empty h4 { color: var(--agents-ink); margin-bottom: 10px; }
.agents-empty p { margin-bottom: 0; font-size: 13px; }
.agents-loading { color: var(--agents-muted); font-size: 13px; padding: 24px; }
.agents-editor { margin-bottom: 20px; }
.agents-editor .form-control { font-size: 13px; }
.agents-editor .form-label { font-size: 12px; font-weight: 600; }
.agents-editor-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--agents-border); padding-top: 18px; }
.agents-delete-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--agents-border); border-radius: 12px; color: var(--agents-ink); background: #fff; box-shadow: 0 16px 48px #0003; }
.agents-delete-dialog::backdrop { background: #142c3c80; }
.agents-delete-dialog h4 { font-size: 20px; margin: 0 0 16px; }
.agents-delete-dialog p { font-size: 14px; line-height: 1.7; margin-bottom: 20px; }
.agents-page button:focus-visible, .agents-page summary:focus-visible { outline: 2px solid #438ea2; outline-offset: 3px; }

@media (max-width: 1250px) {
    .agents-list[data-view="grid"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .agents-run-workspace { grid-template-columns: 300px minmax(0, 1fr); gap: 18px; }
    .agents-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
    .agents-list[data-view="list"] .agents-list-item { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
    .agents-list[data-view="list"] .agents-list-title { grid-column: 1 / -1; }
    .agents-list[data-view="list"] .agents-list-meta { text-align: right; }
}
@media (max-width: 767px) {
    .agents-page { padding: 16px 8px; }
    .agents-run-workspace { grid-template-columns: minmax(0, 1fr); }
    .agents-runs { position: static; }
    .agents-well { padding: 18px; }
    .agents-list[data-view="grid"] { grid-template-columns: minmax(0, 1fr); }
    .agents-history { max-height: 240px; }
    .agents-agent-heading h3 { font-size: 22px; }
    .agents-actions { width: 100%; }
    .agents-page-header .btn-group { max-width: 100%; }
    .agents-page-header .account-button { overflow-wrap: anywhere; white-space: normal; }
    .agents-message-heading { gap: 10px; }
}
