﻿*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    background: #fafaf9;
    color: #1c1917;
    line-height: 1.5;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 0.875rem;
    color: #78716c;
    margin-bottom: 2rem;
}

/* Main Tabs Navigation */
.main-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 2px solid #1c1917;
    flex-wrap: wrap;
}

.main-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    color: #78716c;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

    .main-tab:hover {
        color: #1c1917;
    }

    .main-tab.active {
        color: #1c1917;
        border-bottom-color: #1c1917;
    }

/* Tab Badge */
.tab-badge {
    display: inline-block;
    background: #dc2626;
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    margin-left: 0.375rem;
    vertical-align: middle;
}

/* Feed Messages */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feed-message {
    padding: 1rem;
    background: white;
    border: 1px solid #e7e5e4;
    border-left: 4px solid #78716c;
}

    .feed-message.unread {
        background: #fefce8;
    }

    .feed-message.type-info {
        border-left-color: #3b82f6;
    }

    .feed-message.type-success {
        border-left-color: #16a34a;
    }

    .feed-message.type-warning {
        border-left-color: #ca8a04;
    }

    .feed-message.type-error {
        border-left-color: #dc2626;
    }

    .feed-message.type-request {
        border-left-color: #8b5cf6;
    }

.feed-message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.feed-message-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.feed-message-meta {
    font-size: 0.75rem;
    color: #78716c;
    text-align: right;
}

.feed-message-agent {
    font-weight: 500;
}

.feed-message-body {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #44403c;
    white-space: pre-wrap;
}

    .feed-message-body code {
        background: #f5f5f4;
        padding: 0.125rem 0.375rem;
        border-radius: 3px;
        font-family: 'SF Mono', 'Consolas', monospace;
        font-size: 0.8125rem;
    }

.feed-message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e7e5e4;
}

.feed-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f5f5f4;
    margin-bottom: 1rem;
    border: 1px solid #e7e5e4;
}

.feed-filters {
    display: flex;
    gap: 0.5rem;
}

.feed-filter {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border: 1px solid #e7e5e4;
    background: white;
    cursor: pointer;
}

    .feed-filter.active {
        background: #1c1917;
        color: white;
        border-color: #1c1917;
    }

/* Sub Tabs Navigation */
.sub-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e7e5e4;
    flex-wrap: wrap;
    background: #f5f5f4;
    padding: 0 1rem;
}

.sub-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    color: #78716c;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

    .sub-tab:hover {
        color: #1c1917;
    }

    .sub-tab.active {
        color: #1c1917;
        border-bottom-color: #1c1917;
        background: white;
    }

/* Agent Selector */
.agent-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f5f5f4;
    margin-bottom: 1rem;
    border: 1px solid #e7e5e4;
}

    .agent-selector label {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #57534e;
    }

    .agent-selector select {
        padding: 0.375rem 0.75rem;
        font-family: inherit;
        font-size: 0.875rem;
        border: 1px solid #e7e5e4;
        background: white;
        min-width: 200px;
    }

/* Panels */
.panel {
    display: none;
}

    .panel.active {
        display: block;
    }

.sub-panel {
    display: none;
}

    .sub-panel.active {
        display: block;
    }

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 2rem;
    padding: 1rem;
    background: #f5f5f4;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    gap: 0.5rem;
}

.stat-label {
    color: #78716c;
}

.stat-value {
    font-weight: 600;
}

    .stat-value.ok {
        color: #16a34a;
    }

    .stat-value.warn {
        color: #ca8a04;
    }

    .stat-value.error {
        color: #dc2626;
    }

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.card {
    padding: 1rem;
    background: white;
    border: 1px solid #e7e5e4;
}

    .card.disabled {
        opacity: 0.5;
    }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.card-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: #f5f5f4;
    border: 1px solid #e7e5e4;
    color: #57534e;
}

    .card-badge.success {
        background: #dcfce7;
        border-color: #86efac;
        color: #166534;
    }

    .card-badge.warning {
        background: #fef9c3;
        border-color: #fde047;
        color: #854d0e;
    }

    .card-badge.error {
        background: #fee2e2;
        border-color: #fca5a5;
        color: #991b1b;
    }

    .card-badge.global {
        background: #dbeafe;
        border-color: #93c5fd;
        color: #1e40af;
    }

    .card-badge.private {
        background: #fae8ff;
        border-color: #e879f9;
        color: #86198f;
    }

.card-description {
    font-size: 0.8125rem;
    color: #57534e;
    margin-bottom: 0.75rem;
}

.card-meta {
    font-size: 0.75rem;
    color: #78716c;
    margin-bottom: 0.75rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.375rem 0.75rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #e7e5e4;
    background: white;
    cursor: pointer;
}

    .btn:hover {
        background: #f5f5f4;
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn.primary {
        background: #1c1917;
        color: white;
        border-color: #1c1917;
    }

        .btn.primary:hover {
            background: #292524;
        }

    .btn.success {
        background: #16a34a;
        color: white;
        border-color: #16a34a;
    }

    .btn.danger {
        color: #dc2626;
        border-color: #fecaca;
    }

        .btn.danger:hover {
            background: #fef2f2;
        }

/* Forms */
.form-section {
    padding: 1.5rem;
    background: white;
    border: 1px solid #e7e5e4;
    margin-bottom: 1.5rem;
}

.form-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

    .form-group.full-width {
        grid-column: span 2;
    }

    .form-group label {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #57534e;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.5rem;
        font-family: inherit;
        font-size: 0.875rem;
        border: 1px solid #e7e5e4;
        background: white;
    }

    .form-group textarea {
        min-height: 100px;
        resize: vertical;
    }

        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #1c1917;
        }

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e7e5e4;
}

th {
    background: #f5f5f4;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:hover {
    background: #fafaf9;
}

tr[style*="cursor:pointer"]:hover {
    background: #f5f5f0;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

    .search-box input {
        flex: 1;
        padding: 0.5rem;
        font-family: inherit;
        font-size: 0.875rem;
        border: 1px solid #e7e5e4;
    }

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 1px solid #e7e5e4;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 101;
}

.modal.modal-wide {
    max-width: 750px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e7e5e4;
}

    .modal-header h2 {
        font-size: 1rem;
        font-weight: 600;
    }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #78716c;
}

.modal-body {
    padding: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid #e7e5e4;
}

.hidden {
    display: none !important;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
}

.toast {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: #1c1917;
    color: white;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

    .toast.show {
        opacity: 1;
        transform: translateX(0);
    }

    .toast.success {
        background: #16a34a;
    }

    .toast.error {
        background: #dc2626;
    }

    .toast.warning {
        background: #ca8a04;
    }

/* Response Display */
.response-box {
    background: #f5f5f4;
    border: 1px solid #e7e5e4;
    padding: 1rem;
    font-size: 0.875rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 1rem;
}

/* Loading */
.loading {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid #e7e5e4;
    border-top-color: #1c1917;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #78716c;
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* Modal Table (queue inside agent details) */
.modal .table-container {
    max-height: 200px;
    overflow-y: auto;
}

.modal .table-container table {
    font-size: 0.8125rem;
}

/* Usage Tab */
.usage-cost {
    font-weight: 600;
    color: #059669;
}

/* Run Result Modal */
.run-result-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e7e5e4;
}

.run-result-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.run-result-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #57534e;
    margin-bottom: 0.5rem;
}

.run-result-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.run-result-badges .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border: 1px solid #e7e5e4;
    background: #f5f5f4;
    color: #57534e;
}

.run-result-badges .badge.status-completed {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.run-result-badges .badge.status-error {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.run-result-badges .badge.status-timeout,
.run-result-badges .badge.status-max_turns {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
}

.run-result-badges .badge.mode-atomic {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.run-result-table {
    width: 100%;
    font-size: 0.8125rem;
    border-collapse: collapse;
}

.run-result-table td {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #f5f5f4;
}

.run-result-table td:first-child {
    color: #78716c;
    width: 120px;
    font-weight: 500;
}

/* Trace Timeline */
.trace-timeline {
    width: 100%;
    font-size: 0.75rem;
    border-collapse: collapse;
}

.trace-timeline th {
    padding: 0.375rem 0.5rem;
    background: #f5f5f4;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.6875rem;
    text-align: left;
    border-bottom: 1px solid #e7e5e4;
}

.trace-timeline td {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #f5f5f4;
    vertical-align: top;
}

.trace-timeline td:first-child {
    width: 40px;
    text-align: center;
    color: #78716c;
}

.trace-timeline td:nth-child(2) {
    width: 60px;
    color: #78716c;
}

.trace-event-badge {
    display: inline-block;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-weight: 500;
}

.trace-event-badge.plan_created {
    background: #dbeafe;
    color: #1e40af;
}

.trace-event-badge.step_started {
    background: #dcfce7;
    color: #166534;
}

.trace-event-badge.step_completed {
    background: #bbf7d0;
    color: #14532d;
}

.trace-event-badge.replan {
    background: #fef9c3;
    color: #854d0e;
}

.trace-event-badge.reflection_triggered {
    background: #fae8ff;
    color: #86198f;
}

/* Plan Steps */
.plan-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8125rem;
}

.plan-steps li {
    padding: 0.375rem 0;
    border-bottom: 1px solid #f5f5f4;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.plan-steps li:last-child {
    border-bottom: none;
}

.plan-steps .step-icon {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
}

.plan-steps .step-meta {
    margin-left: auto;
    font-size: 0.6875rem;
    color: #78716c;
    white-space: nowrap;
}

/* Collapsible Sections (native details/summary) */
.section-toggle {
    border: 1px solid #e7e5e4;
    margin-bottom: 0.5rem;
}

.section-toggle summary {
    padding: 0.5rem 0.75rem;
    background: #f5f5f4;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #57534e;
    list-style: none;
}

.section-toggle summary::-webkit-details-marker {
    display: none;
}

.section-toggle summary::before {
    content: "+ ";
    font-weight: 700;
}

.section-toggle[open] summary::before {
    content: "- ";
}

.section-toggle .section-content {
    padding: 0.5rem 0.75rem;
}

/* Reflection decision badges */
.reflection-decision {
    display: inline-block;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-weight: 500;
}

.reflection-decision.continue {
    background: #dcfce7;
    color: #166534;
}

.reflection-decision.adjust {
    background: #fef9c3;
    color: #854d0e;
}

.reflection-decision.pivot {
    background: #fee2e2;
    color: #991b1b;
}

.reflection-decision.escalate {
    background: #fae8ff;
    color: #86198f;
}

.reflection-decision.terminate {
    background: #fee2e2;
    color: #991b1b;
}

/* Responsive */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: span 1;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }
}