:root {
    --bg-color: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* New modern tokens */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --portal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Subtle background glow effect */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05), transparent 25%);
    background-attachment: fixed;
}


/* --- Typography --- */
h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* --- Glass Header --- */
.top-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), #818cf8);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 18px;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #0f172a, #334155);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #818cf8);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
    background: linear-gradient(135deg, var(--accent-hover), #6366f1);
}

.btn-primary:active {
    transform: translateY(0);
}

/* --- Portal Styles --- */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.portal-item {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.portal-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--portal-shadow);
    border-color: var(--accent-primary);
}

.portal-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.portal-item:hover::before {
    opacity: 1;
}

.portal-icon {
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.portal-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.portal-footer {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
}

.portal-btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    font-weight: 600;
    transition: all 0.2s;
}

.portal-item:hover .portal-btn-sm {
    background: var(--accent-primary);
    color: white;
}

/* --- Main Content --- */
main.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 2.5rem 4rem;
    width: 100%;
    flex: 1;
}

/* --- Sections --- */
.dashboard-section {
    margin-bottom: 2rem;
}

.dashboard-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- Task List & Tree --- */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s ease;
}

.task-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: var(--shadow-sm);
}

.task-header {
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.task-info h3 {
    font-size: 1rem;
    margin: 0;
}

.task-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.task-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-priority {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.badge-status {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

.badge-cost {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.task-expanded-content {
    display: none;
    padding: 0 1.25rem 1rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.03);
    background: rgba(0, 0, 0, 0.01);
}

.task-card.is-expanded .task-expanded-content {
    display: block;
}

/* Tree Structure */
.sequence-item {
    margin-top: 0.75rem;
    border-left: 2px solid rgba(99, 102, 241, 0.2);
    padding-left: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.2rem;
}

.sequence-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.sequence-header:hover {
    color: var(--accent-primary);
}


.action-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.action-item {
    display: grid;
    grid-template-columns: 160px 140px 1fr 80px 130px 80px 28px;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: background 0.2s ease;
    border-left: 3px solid transparent;
}

.action-item:hover {
    background: rgba(99, 102, 241, 0.02);
}

.action-id {
    font-weight: bold;
    color: var(--accent);
    opacity: 0.7;
    font-family: monospace;
}

.action-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-summary {
    opacity: 0.6;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    padding-left: 10px;
}

.action-attempts {
    font-size: 0.85em;
    opacity: 0.5;
    text-align: center;
    font-family: monospace;
}

.action-status-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 800;
    text-align: center;
    border-radius: 4px;
    padding: 3px 8px;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 130px;
    white-space: nowrap;
}

.action-status-label.status-completed {
    background: #10b981;
}

/* Green */
.action-status-label.status-pending {
    background: #94a3b8;
}

/* Blue-Gray */
.action-status-label.status-retrying {
    background: #f59e0b;
}

/* Amber */
.action-status-label.status-error {
    background: #ef4444;
}

/* Red */
.action-status-label.status-plan-proposed {
    background: #8b5cf6;
}

/* Purple */
.action-status-label.status-running {
    background: #3b82f6;
}

/* Blue */
.action-cost {
    text-align: right;
    font-family: monospace;
    font-weight: bold;
    opacity: 0.8;
}

.action-item.status-completed {
    border-left-color: #10b981;
}

.action-item.status-running {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.02);
}

.action-item.status-pending {
    border-left-color: #cbd5e1;
}

/* --- Action Grouping --- */
/* All rows now use 7 columns (last = toggle slot) — no override needed */

.action-group-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
    flex-shrink: 0;
}

.action-group-toggle:hover {
    background: rgba(99, 102, 241, 0.22);
    transform: scale(1.12);
}

.action-group-toggle.is-open {
    content: '−';
    transform: rotate(45deg);
}

.action-group-children {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    margin-left: 20px;
    padding-left: 12px;
    border-left: 2px dashed rgba(99, 102, 241, 0.2);
    margin-top: 2px;
    margin-bottom: 2px;
}

.action-group-children.is-open {
    display: flex;
}

.action-child-item {
    opacity: 0.88;
    font-size: 0.82rem;
}

.action-child-item:hover {
    opacity: 1;
}

/* --- Deletion Icons --- */
.delete-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-secondary);
    opacity: 0.4;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-icon:hover {
    opacity: 1;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}
/* Unified Icon Buttons */
.icon-btn, .delete-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-secondary);
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    line-height: 1;
}

.icon-btn:hover {
    opacity: 1;
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent-primary);
    transform: scale(1.1);
}

.delete-icon:hover {
    background: rgba(239, 68, 68, 0.05);
}

.icon-btn.small, .delete-icon.small {
    width: 24px;
    height: 24px;
    font-size: 0.95rem;
}

.delete-icon.small {
    width: 20px;
    height: 20px;
}

.task-card.is-expanded .expand-icon {
    transform: rotate(180deg);
}

.expand-icon {
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.sequence-item.is-collapsed .action-list {
    display: none;
}

.sequence-item.is-collapsed .sequence-header svg:first-child {
    transform: rotate(-90deg);
}

.sequence-item .sequence-header svg:first-child {
    transition: transform 0.3s ease;
}


/* --- Empty States --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.95rem;
}

/* --- Utility Classes --- */
.alert {
    margin-bottom: 2rem;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.mt-4 {
    margin-top: 4rem;
}

/* --- Modal & Form Styles --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    margin: 5% auto;
    padding: 2rem;
    width: 95%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    background: white;
    color: #1e293b;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-wide {
    max-width: 1100px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-header h3 {
    color: #1e293b;
    margin: 0;
}

.close-modal {
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.4;
    color: #1e293b;
    transition: opacity 0.2s;
}

.close-modal:hover {
    opacity: 0.8;
}

.form-group {
    margin-bottom: 0.8rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* --- Compact Forms for Workflow Settings --- */
.form-group-compact {
    margin-bottom: 0.5rem;
}

.form-group-compact label {
    display: block;
    margin-bottom: 0.1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.form-group-compact input,
.form-group-compact select {
    display: block;
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.context-fields-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 0.5rem;
    padding: 12px;
    background: rgba(0, 0, 0, 0.015);
    border-radius: 8px;
    border: 1px dashed #e2e8f0;
}

.sequence-row {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    position: relative;
    transition: all 0.2s;
}

.sequence-row:hover {
    border-color: #cbd5e1;
    background: #e2e8f0;
}

.remove-sequence {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    opacity: 0.4;
    font-size: 1.5rem;
    transition: opacity 0.2s;
}

.remove-sequence:hover {
    opacity: 1;
    color: #ef4444;
}

.workflow-context-fields {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px dashed #cbd5e1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.workflow-context-fields h5 {
    grid-column: 1 / -1;
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

/* --- Action Detail View --- */
.json-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
    font-family: monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.json-pretty {
    margin: 0;
    color: #1e293b;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h4 {
    margin: 0 0 0.8rem 0;
    color: #64748b;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    font-size: 0.95rem;
}

.action-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.asset-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    background: #f8fafc;
}

.asset-item img {
    max-width: 100%;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.asset-item a {
    font-size: 0.8rem;
    color: #3b82f6;
    text-decoration: none;
}

.detail-large {
    width: 98% !important;
    max-width: 1600px !important;
    margin: 10px auto !important;
    height: calc(100vh - 20px) !important;
    max-height: none !important;
}

.params-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    table-layout: fixed;
}

.params-table th,
.params-table td {
    padding: 6px 10px;
    text-align: left;
    border: 1px solid #e2e8f0;
    vertical-align: top;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.params-table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
}

.params-table th:first-child {
    width: 200px;
}

.params-table td {
    background: white;
    overflow-x: auto;
}

.json-key {
    color: #8b5cf6;
    font-weight: 600;
}

.json-string {
    color: #059669;
}

.json-number {
    color: #d97706;
}

.json-boolean {
    color: #2563eb;
}

.json-null {
    color: #94a3b8;
}

.sequence-item.is-active {
    border-left: 3px solid #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.sequence-item.is-completed {
    border-left: 3px solid #10b981;
    background: rgba(16, 185, 129, 0.03);
}

.sequence-item.is-active .sequence-header {
    color: #3b82f6;
    font-weight: 600;
}

@media (max-width: 600px) {
    .workflow-context-fields {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* --- Animations --- */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}


/* --- AI Chat History Bubbles --- */
.ai-chat-history {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}

.ai-history-interaction {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: all 0.3s ease;
}

.ai-history-interaction.collapsed {
    max-height: 50px;
}

.ai-interaction-header {
    padding: 0.75rem 1rem;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    user-select: none;
}

.ai-interaction-header:hover {
    background: #f1f5f9;
}

.ai-interaction-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-bubble {
    max-width: 85%;
    padding: 0.85rem 1.25rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
}

.ai-bubble-prompt {
    align-self: flex-end;
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-bubble-response {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.ai-bubble pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.ai-bubble-prompt pre {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.interaction-toggle-icon {
    transition: transform 0.3s;
}

.collapsed .interaction-toggle-icon {
    transform: rotate(-90deg);
}

/* --- Action Detail Tabs (Restored) --- */
.detail-tabs-header {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1.5rem;
}

.detail-tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    font-weight: 600;
    cursor: pointer;
    color: #64748b;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.detail-tab-btn:hover {
    color: #334155;
}

.detail-tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.detail-tab-content {
    display: none;
}

.detail-tab-content.active {
    display: block;
}

/* HTML Syntax Highlighting */
.html-pretty {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
    color: #1e293b;
    margin: 10px 0;
}

.html-tag {
    color: #2563eb;
    font-weight: bold;
}

.html-attr {
    color: #9333ea;
}

.html-string {
    color: #16a34a;
}

.html-comment {
    color: #64748b;
    font-style: italic;
}

/* --- Auto-Run Animations --- */
@keyframes btn-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
        transform: scale(1);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(16, 185, 129, 0);
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
        transform: scale(1);
    }
}

.btn-autorun {
    animation: btn-pulse 2s infinite !important;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    position: relative;
    border: 2px solid #fff !important;
    box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39) !important;
}

.btn-autorun:hover {
    transform: scale(1.05) translateY(-2px) !important;
}

.btn-autorun::after {
    content: "AUTO";
    position: absolute;
    top: -12px;
    right: -12px;
    background: #ef4444;
    color: white;
    font-size: 9px;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 900;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}
/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.dash-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.dash-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dash-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, 0.3);
}

.dash-card:hover::before {
    opacity: 1;
}

.dash-card-icon {
    width: 64px;
    height: 64px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--accent-primary);
    transition: all 0.3s ease;
}

.dash-card:hover .dash-card-icon {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.1) rotate(5deg);
}

.dash-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.dash-card-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.dash-card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* --- Log Viewer --- */
.log-viewer-container {
    background: #1e293b;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e2e8f0;
    height: calc(100vh - 250px);
    overflow-y: auto;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    white-space: pre-wrap;
    word-break: break-all;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-ts {
    color: #64748b;
    margin-right: 10px;
}

.log-prefix {
    color: #818cf8;
    font-weight: 600;
    margin-right: 10px;
}

.log-msg {
    color: #cbd5e1;
}

.log-error .log-msg {
    color: #fca5a5;
}

.log-success .log-msg {
    color: #86efac;
}

.log-action {
    color: #fbbf24;
}

/* --- Navigation & Header Tweaks --- */
.brand {
    cursor: pointer;
    text-decoration: none;
}

/* --- Debug Plan Overlay --- */
#debug-plan-overlay {
    position: fixed;
    top: 80px;
    right: -650px; /* Hidden by default */
    width: 600px;
    height: calc(100vh - 100px);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px 0 0 20px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

#debug-plan-overlay.is-visible {
    right: 0;
}

#debug-plan-overlay.is-dragged {
    transition: none;
    box-shadow: -15px 15px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    border-radius: 16px;
}

#debug-plan-overlay.is-minimized {
    height: 56px !important;
    width: 250px;
    overflow: hidden;
}

.debug-plan-header {
    padding: 0.8rem 1.2rem;
    background: rgba(99, 102, 241, 0.08);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.debug-plan-header h3 {
    margin: 0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1e293b;
}

.debug-plan-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.debug-control-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.2s;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-secondary);
}

.debug-control-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.debug-plan-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
}

.debug-worker-card {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.debug-worker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-primary);
}

.debug-worker-cost {
    font-size: 0.75rem;
    opacity: 0.7;
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.debug-action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.debug-action-mini {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(0,0,0,0.03);
    transition: transform 0.2s;
}

.debug-action-mini:hover {
    transform: translateX(-4px);
    border-color: rgba(99, 102, 241, 0.2);
}

.debug-action-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.debug-action-task {
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.debug-action-name {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.debug-action-type {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: normal;
    background: rgba(0,0,0,0.04);
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 5px;
}

.debug-action-params {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
    background: rgba(0,0,0,0.02);
    padding: 2px 6px;
    border-radius: 4px;
}

.debug-action-cost {
    font-family: monospace;
    font-weight: bold;
    color: #d97706;
    flex-shrink: 0;
}

.debug-plan-footer {
    padding: 1rem;
    background: rgba(0,0,0,0.02);
    border-top: 1px solid rgba(0,0,0,0.05);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}
