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

:root {
    /* Layout + typography tokens */
    --page-bg-start: #0a3d4d;
    --page-bg-end: #1a5f73;
    --text-primary: #333333;
    --text-strong: #0a3d4d;
    --text-secondary: #555555;
    --text-muted: #666666;
    --text-inverse: #ffffff;
    --text-glass-muted: rgba(255, 255, 255, 0.7);
    --text-glass-subtle: rgba(255, 255, 255, 0.6);

    /* Surfaces + borders */
    --surface-primary: #ffffff;
    --surface-alt: #fafafa;
    --surface-muted: #f5f5f5;
    --surface-neutral: #f0f0f0;
    --surface-neutral-strong: #e8e8e8;
    --surface-soft: #f7fafc;
    --surface-soft-strong: #edf2f7;
    --surface-soft-border: #e2e8f0;
    --surface-warning: #fff5f5;
    --surface-panel: #f8f9fa;
    --surface-contrast: #0b2230;
    --border-strong: #e0e0e0;
    --border-muted: #dddddd;
    --shadow-soft: rgba(0, 0, 0, 0.15);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --glass-overlay: rgba(255, 255, 255, 0.15);
    --glass-overlay-strong: rgba(255, 255, 255, 0.25);
    --glass-border-light: rgba(255, 255, 255, 0.2);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-border-strong: rgba(255, 255, 255, 0.5);
    --overlay-dark: rgba(0, 0, 0, 0.3);
    --overlay-dark-strong: rgba(0, 0, 0, 0.4);
    --overlay-darker: rgba(0, 0, 0, 0.5);
    --overlay-backdrop: rgba(0, 0, 0, 0.6);
    --brand-primary-tint: rgba(23, 162, 184, 0.15);
    --brand-primary-tint-strong: rgba(23, 162, 184, 0.2);
    --brand-primary-tint-soft: rgba(23, 162, 184, 0.05);

    /* Brand + semantic colors */
    --brand-primary: #17a2b8;
    --brand-primary-strong: #138496;
    --brand-primary-glow: rgba(23, 162, 184, 0.3);
    --success-primary: #28a745;
    --success-strong: #218838;
    --warning-primary: #ffc107;
    --warning-strong: #e0a800;
    --danger-primary: #dc3545;
    --danger-strong: #c82333;
    --violet-primary: #6f42c1;
    --violet-strong: #5a32a3;
    --info-contrast: #2c3e50;
    --chip-more-bg: #6c757d;
    --chip-more-bg-hover: #5a6268;
    --status-error: #ffb3b3;
    --status-success: #b3ffd5;
    --status-warning-text: #dc3545;
    --badge-neutral-bg: #e0e0e0;
    --badge-neutral-text: #333333;
    --badge-success-bg: #27ae60;

    /* Contextual helpers */
    --group-accent-fallback: var(--brand-primary);
    --tool-chip-bg-fallback: #999999;
    --context-menu-divider: rgba(255, 255, 255, 0.08);
    --context-menu-text: #f2f7fb;
    --context-menu-border: #142f3c;
    --focus-outline: #0f4c5c;
    --info-bg: #f0fafc;
    --info-bg-strong: #f0f9fb;
    --info-border: #d0d0d0;
    --journey-tooltip-bg: #2c3e50;
    --warning-text: #e74c3c;
    --warning-strong-text: #c0392b;
    --text-dark-contrast: #2d3748;
    --text-subtle: #999999;
    --text-helper: #777777;

    /* Progress gradients */
    --progress-purple-start: #667eea;
    --progress-purple-end: #764ba2;
    --progress-green-start: #48bb78;
    --progress-green-end: #38a169;
    --progress-orange-start: #f6ad55;
    --progress-orange-end: #ed8936;
    --progress-purple-shadow: rgba(102, 126, 234, 0.3);
    --progress-green-shadow: rgba(72, 187, 120, 0.3);
    --progress-orange-shadow: rgba(246, 173, 85, 0.3);

    /* Tool colors - static definitions */
    --tool-cyan: #17a2b8;
    --tool-blue: #3776ab;
    --tool-orange: #e67e22;
    --tool-green: #27ae60;
    --tool-purple: #8e44ad;
    --tool-red: #c0392b;
    --tool-gray: #999999;
}

/* Utility classes */
.u-flex {
    display: flex;
}

.u-inline-flex {
    display: inline-flex;
}

.u-flex-column {
    flex-direction: column;
}

.u-align-center {
    align-items: center;
}

.u-align-start {
    align-items: flex-start;
}

.u-justify-between {
    justify-content: space-between;
}

.u-gap-sm {
    gap: 8px;
}

.u-gap-md {
    gap: 12px;
}

.u-gap-lg {
    gap: 20px;
}

.u-wrap {
    flex-wrap: wrap;
}

.u-full-width {
    width: 100%;
}

.u-relative {
    position: relative;
}

.u-flex-1 {
    flex: 1 1 auto;
}

.is-hidden {
    display: none !important;
}

.surface-card {
    background: var(--surface-bg, var(--surface-primary));
    border-radius: var(--surface-radius, 12px);
    padding: var(--surface-padding, 24px);
    border: var(--surface-border, none);
    box-shadow: var(--surface-shadow, 0 8px 16px var(--shadow-soft));
}

.surface-panel {
    background: var(--surface-bg, var(--surface-alt));
    border-radius: var(--surface-radius, 10px);
    padding: var(--surface-padding, 16px);
    border: var(--surface-border, 1px solid var(--border-strong));
    box-shadow: var(--surface-shadow, none);
    transition: var(--surface-transition, all 0.3s ease);
}

.surface-glass {
    background: var(--glass-overlay);
    border: 1px solid var(--glass-border);
    color: var(--text-inverse);
    backdrop-filter: blur(12px);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.75em;
    font-weight: 600;
    background: var(--chip-bg, var(--surface-muted));
    color: var(--chip-text, var(--text-primary));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chip i[data-lucide] {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 700;
    background: var(--badge-bg, var(--badge-neutral-bg));
    color: var(--badge-text, var(--badge-neutral-text));
}

.tool-chip-unknown {
    --chip-bg: var(--tool-chip-bg-fallback);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--page-bg-start) 0%, var(--page-bg-end) 100%);
    padding: 40px 20px;
    color: var(--text-primary);
}

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

.header {
    margin-bottom: 30px;
    color: var(--text-inverse);
}

.header h1 {
    font-size: 2em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.agent-count-inline {
    font-size: 0.85em;
    font-weight: 500;
    background: var(--glass-overlay);
    padding: 6px 14px;
    border-radius: 20px;
    margin: 0;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    color: var(--text-inverse);
}

.document-controls-compact {
    position: relative;
}

.document-controls-compact select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--glass-border-light);
    font-size: 0.9em;
    font-weight: 500;
    background: var(--overlay-dark);
    color: var(--text-inverse);
    cursor: pointer;
}

.document-controls-compact select:hover {
    background: var(--overlay-dark-strong);
}

.document-controls-compact select:disabled {
    opacity: 0.6;
    cursor: wait;
}

.menu-panel {
    border-radius: 12px;
    box-shadow: 0 12px 30px var(--overlay-darker);
    padding: 12px;
    min-width: 200px;
    display: none;
    z-index: 2000;
    background: var(--menu-bg, var(--surface-primary));
    color: var(--menu-text, var(--text-primary));
    border: 1px solid var(--menu-border, var(--border-strong));
    --menu-divider-color: var(--border-strong);
    --menu-hover-bg: var(--surface-muted);
    --menu-danger-color: var(--danger-primary);
}

.menu-panel.open {
    display: block;
}

.document-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    --menu-bg: var(--surface-contrast);
    --menu-text: var(--text-inverse);
    --menu-border: var(--context-menu-border);
    --menu-hover-bg: var(--glass-overlay);
    --menu-divider-color: var(--context-menu-divider);
    --menu-danger-color: var(--status-error);
}

.context-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.menu-item:hover:not(:disabled) {
    background: var(--menu-hover-bg, var(--surface-muted));
}

.menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-item.danger {
    color: var(--menu-danger-color, var(--danger-primary));
}

.menu-item.danger:hover:not(:disabled) {
    background: var(--surface-warning);
}

.menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.menu-link {
    text-decoration: none;
}

.menu-link:hover {
    text-decoration: none;
}

.menu-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-glass-subtle);
    margin-bottom: 4px;
}

.menu-divider {
    height: 1px;
    background: var(--menu-divider-color, var(--border-strong));
    margin: 10px 0;
}

.header-meta {
    margin-top: 10px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.document-meta {
    margin: 0;
    font-size: 0.85em;
    color: var(--text-glass-muted);
    font-weight: 400;
}

.document-status {
    margin: 0;
    font-size: 0.85em;
    color: var(--text-glass-muted);
}

.document-status[data-state="info"] {
    color: var(--brand-primary);
}

.document-status[data-state="error"] {
    color: var(--status-error);
}

.document-status[data-state="success"] {
    color: var(--status-success);
}

#documentFileInput {
    display: none;
}

.agent-groups {
    display: grid;
    gap: 30px;
    padding-top: 20px;
}

.agent-group {
    --surface-padding: 30px;
    --surface-shadow: 0 8px 16px var(--shadow-medium);
    position: relative;
    overflow: visible;
    opacity: 1 !important;
}

.group-header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    margin-top: 10px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--group-accent, var(--group-accent-fallback));
    cursor: pointer;
    user-select: none;
}

/* Section collapse toggle */
.section-collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    color: var(--text-muted);
    transition: transform 0.3s ease, color 0.2s ease;
}

.section-collapse-toggle svg {
    width: 24px;
    height: 24px;
}

.group-header:hover .section-collapse-toggle {
    color: var(--text-primary);
}

.agent-group.collapsed .section-collapse-toggle {
    transform: rotate(-90deg);
}

/* Agent count badge */
.agent-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    margin-left: 12px;
    background: var(--badge-neutral-bg);
    color: var(--badge-neutral-text);
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
}

/* Enhanced badge when section is collapsed */
.agent-group.collapsed .agent-count-badge {
    min-width: 32px;
    height: 32px;
    padding: 0 12px;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-strong) 100%);
    color: var(--text-inverse);
    font-size: 0.9em;
    font-weight: 700;
    box-shadow: 0 2px 8px var(--brand-primary-glow);
}

/* Agent Pills Container */
.agent-pills-container {
    display: none !important;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.agent-group.collapsed .agent-pills-container {
    display: flex !important;
}

/* Individual Agent Name Pills */
.agent-pills-container .agent-name-pill {
    --chip-bg: var(--pill-bg, var(--brand-primary));
    --chip-text: var(--pill-text, var(--text-inverse));
    border: 1px solid var(--pill-bg, var(--brand-primary));
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
}

.agent-name-pill.pill-palette-0 { --pill-bg: var(--brand-primary); --pill-text: var(--text-inverse); }
.agent-name-pill.pill-palette-1 { --pill-bg: var(--success-primary); --pill-text: var(--text-inverse); }
.agent-name-pill.pill-palette-2 { --pill-bg: var(--warning-primary); --pill-text: var(--text-primary); }
.agent-name-pill.pill-palette-3 { --pill-bg: var(--danger-primary); --pill-text: var(--text-inverse); }
.agent-name-pill.pill-palette-4 { --pill-bg: var(--violet-primary); --pill-text: var(--text-inverse); }

.agent-pills-container .agent-name-pill:hover {
    filter: brightness(0.92);
}

.agent-name-pill.more-pill {
    --chip-bg: var(--chip-more-bg);
    --chip-text: var(--text-inverse);
    border-color: var(--chip-more-bg);
    font-style: italic;
}

.agent-name-pill.more-pill:hover {
    --chip-bg: var(--chip-more-bg-hover);
    border-color: var(--chip-more-bg-hover);
}

/* Collapsible container */
.agents-grid-container {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease;
    overflow: hidden;
}

.agent-group.collapsed .agents-grid-container {
    grid-template-rows: 0fr;
}

.agent-group.collapsed .agents-grid-container > * {
    overflow: hidden;
}

.group-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    color: var(--text-inverse);
    box-shadow: 0 4px 12px var(--shadow-soft);
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
    background: var(--group-accent, var(--group-accent-fallback));
}

.group-icon:hover {
    transform: scale(1.1);
}

.group-icon svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5;
}

.group-title {
    flex: 1;
}

.group-title h2 {
    font-size: 1.8em;
    margin: 0 0 5px 0;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.agent-card {
    --surface-padding: 20px;
    --surface-border: 2px solid var(--border-strong);
    --surface-bg: var(--surface-alt);
    cursor: pointer;
    position: relative;
}

.agent-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--shadow-soft);
    border-color: var(--brand-primary);
}

.agent-number {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-strong));
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.agent-card h3 {
    font-size: 1.3em;
    margin-bottom: 8px;
    margin-top: 35px;
    color: var(--text-strong);
    padding-right: 45px;
}

.agent-objective {
    font-weight: bold;
    color: var(--brand-primary);
    margin-bottom: 8px;
    font-size: 0.95em;
}

.agent-description {
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.5;
    font-size: 0.9em;
}

.tools-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.tool-chip {
    --chip-bg: var(--tool-chip-bg, var(--tool-chip-bg-fallback));
    --chip-text: var(--text-inverse);
}

/* Static tool colors using data attributes - NO dynamic CSS generation */
.tool-chip[data-color="cyan"] { --chip-bg: var(--tool-cyan); }
.tool-chip[data-color="blue"] { --chip-bg: var(--tool-blue); }
.tool-chip[data-color="orange"] { --chip-bg: var(--tool-orange); }
.tool-chip[data-color="green"] { --chip-bg: var(--tool-green); }
.tool-chip[data-color="purple"] { --chip-bg: var(--tool-purple); }
.tool-chip[data-color="red"] { --chip-bg: var(--tool-red); }
.tool-chip[data-color="gray"] { --chip-bg: var(--tool-gray); }

.icon-panel {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-strong);
    justify-content: flex-start;
}

.icon-panel-item {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-secondary);
}

.icon-panel-item:hover {
    background: var(--brand-primary);
    color: var(--text-inverse);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-soft);
}

.icon-panel-item svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.journey-tooltip {
    display: none;
    position: fixed;
    background: var(--journey-tooltip-bg);
    color: var(--text-inverse);
    padding: 15px;
    border-radius: 8px;
    width: 300px;
    z-index: 10000;
    box-shadow: 0 8px 24px var(--overlay-darker);
    font-size: 0.85em;
    line-height: 1.6;
    white-space: normal;
    pointer-events: none;
}

.journey-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 18px;
    border: 8px solid transparent;
    border-bottom-color: var(--journey-tooltip-bg);
}

.metrics-tooltip {
    display: none;
    position: fixed;
    background: linear-gradient(135deg, var(--surface-primary), var(--surface-panel));
    color: var(--text-primary);
    padding: 24px;
    border-radius: 16px;
    width: 340px;
    z-index: 10000;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25), 0 0 1px rgba(0,0,0,0.1);
    font-size: 0.9em;
    pointer-events: none;
    border: 1px solid rgba(0,0,0,0.08);
}

.metrics-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-bottom-color: var(--surface-primary);
}

.metrics-tooltip-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-strong);
}

.metrics-tooltip-header h4 {
    margin: 0;
    font-size: 1.1em;
    color: var(--text-strong);
    display: flex;
    align-items: center;
    gap: 8px;
}

.metrics-tooltip-header i {
    display: inline-flex;
    width: 18px;
    height: 18px;
    margin-right: 6px;
}

.metrics-tooltip-header h4 svg {
    flex-shrink: 0;
}

.metrics-tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metrics-tooltip .metric-row {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metrics-tooltip .metric-row:last-child {
    margin-bottom: 0;
}

.metrics-tooltip .metric-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.metrics-tooltip .progress-bar {
    height: 26px;
    background: linear-gradient(90deg, var(--surface-neutral), var(--surface-neutral-strong));
    border-radius: 13px;
    overflow: hidden;
    margin: 8px 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-muted);
}

.metrics-tooltip .progress-fill {
    height: 100%;
    border-radius: 11px;
    transition: width 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.metrics-tooltip .progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.metrics-tooltip .progress-fill.usage {
    background: linear-gradient(90deg, var(--progress-purple-start), var(--progress-purple-end));
    box-shadow: 0 2px 4px var(--progress-purple-shadow);
}

.metrics-tooltip .progress-fill.time-saved {
    background: linear-gradient(90deg, var(--progress-green-start), var(--progress-green-end));
    box-shadow: 0 2px 4px var(--progress-green-shadow);
}

.metrics-tooltip .progress-fill.roi-contribution {
    background: linear-gradient(90deg, var(--progress-orange-start), var(--progress-orange-end));
    box-shadow: 0 2px 4px var(--progress-orange-shadow);
}

.metrics-tooltip .metric-value {
    font-size: 1em;
    font-weight: 700;
    color: var(--text-dark-contrast);
    background: linear-gradient(90deg, var(--surface-soft), var(--surface-soft-strong));
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--surface-soft-border);
}

.handover-badge {
    --badge-bg: var(--badge-success-bg);
    --badge-text: var(--text-inverse);
    margin-left: 8px;
}

/* Context menu icon for cards and sections */
.context-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    cursor: pointer;
    color: var(--context-trigger-color, var(--text-subtle));
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    border-radius: 6px;
    flex-shrink: 0;
    position: relative;
}

.agent-card:hover .context-menu-trigger,
.group-header:hover .context-menu-trigger,
.title-section:hover .context-menu-trigger {
    opacity: 1;
}

.context-menu-trigger:hover {
    background: var(--brand-primary-tint);
    color: var(--brand-primary);
}

.context-menu-trigger.active {
    background: var(--brand-primary-tint-strong);
    color: var(--brand-primary);
    opacity: 1;
}

.context-menu-trigger svg {
    width: 18px;
    height: 18px;
}

.group-header-edit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-backdrop);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    --surface-padding: 30px;
    --surface-shadow: 0 12px 40px var(--overlay-dark);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-narrow {
    max-width: 500px;
}

.modal-large {
    max-width: 900px;
    max-height: 90vh;
}

.modal-large .yaml-input {
    min-height: 500px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-strong);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-strong);
}

.modal-view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.yaml-editor {
    display: none;
}

.yaml-editor textarea {
    width: 100%;
    min-height: 300px;
    font-family: 'Fira Code', 'Courier New', monospace;
    background: var(--surface-contrast);
    color: var(--context-menu-text);
    border-radius: 8px;
    padding: 12px;
    border: 2px solid var(--context-menu-border);
    resize: vertical;
    line-height: 1.4;
}

.yaml-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.yaml-status {
    font-size: 0.9em;
    color: var(--status-success);
}

.yaml-error {
    margin-top: 8px;
    color: var(--status-error);
    font-size: 0.9em;
    min-height: 1em;
}

.yaml-input {
    width: 100%;
    min-height: 300px;
    font-family: 'Fira Code', 'Courier New', monospace;
    background: var(--surface-contrast);
    color: var(--context-menu-text);
    border-radius: 8px;
    padding: 12px;
    border: 2px solid var(--context-menu-border);
    resize: vertical;
    line-height: 1.4;
}

.help-text {
    margin-bottom: 16px;
    color: var(--text-muted);
    font-size: 0.95em;
    line-height: 1.6;
}

.help-text code {
    background: var(--surface-contrast);
    color: var(--brand-primary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

.empty-state-message {
    color: var(--text-inverse);
    text-align: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--surface-muted);
    color: var(--warning-text);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-strong);
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.85em;
}

.generated-field {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px dashed var(--interactive-teal, var(--brand-primary));
    border-radius: 6px;
    font-size: 0.9em;
    color: var(--focus-outline);
    background: var(--info-bg);
}

.tool-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tool-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 2px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tool-checkbox-label:hover {
    border-color: var(--brand-primary);
    background: var(--info-bg-strong);
}

.tool-checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-strong);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-strong));
    color: var(--text-inverse);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-medium);
}

.btn-secondary {
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-strong);
}

.btn-danger {
    background: var(--warning-text);
    color: var(--text-inverse);
}

.btn-danger:hover {
    background: var(--warning-strong-text);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-medium);
}

.btn-glass {
    background: var(--glass-overlay);
    color: var(--text-inverse);
    border-color: var(--glass-border);
    font-size: 0.9em;
}

.btn-glass:hover {
    background: var(--glass-overlay-strong);
    border-color: var(--glass-border-strong);
    transform: translateY(-1px);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 6px;
    background: var(--overlay-dark);
    border-color: var(--glass-border-light);
    color: var(--text-inverse);
}

.btn-icon:hover {
    background: var(--overlay-darker);
    border-color: var(--glass-border);
}

.btn-toggle {
    flex: 1;
    background: var(--surface-muted);
    border: 1px solid var(--border-strong);
}

.btn-toggle.active {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-strong));
    color: var(--text-inverse);
    border-color: var(--brand-primary);
    box-shadow: 0 4px 10px var(--brand-primary-glow);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 20, 30, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    text-align: center;
    color: var(--text-inverse);
}

.loading-spinner i[data-lucide] {
    width: 64px;
    height: 64px;
    stroke-width: 2;
    color: var(--brand-primary);
    animation: spin 1s linear infinite;
    display: block;
    margin: 0 auto 16px;
}

.loading-spinner p {
    font-size: 1.1em;
    font-weight: 500;
    margin: 0;
    color: var(--text-inverse);
}

/* Button loading state */
.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading i[data-lucide="loader-2"] {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Animated Transitions */
.agent-card,
.agent-group,
.tool-chip {
    transition: all 0.3s ease;
}

.agent-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 24px var(--shadow-medium);
}

.tool-chip:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px var(--shadow-medium);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}

.agent-group {
    overflow: visible;
    max-height: 5000px;
    transition: max-height 0.5s ease, opacity 0.3s ease;
}

.agent-group.collapsed {
    max-height: 100px;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .title-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .document-controls-compact {
        width: 100%;
    }

    .document-controls-compact select {
        flex: 1;
    }

    .agents-grid {
        grid-template-columns: 1fr;
    }

    .journey-tooltip {
        width: 280px;
    }
}

/* Login form styles - for white card on dark background */
.login-form-group {
    margin-bottom: 20px;
}

.login-form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.login-submit-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

.login-message {
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 6px;
    display: none;
}

.login-message-success {
    background: var(--brand-primary-tint);
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary);
}

.login-message-error {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger-primary);
    border: 1px solid var(--danger-primary);
}

.login-form-group .login-input,
.login-input {
    width: 100%;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--surface-alt);
    color: var(--text-primary);
    font-size: 16px;
    box-sizing: border-box;
    font-family: inherit;
    transition: all 0.2s ease;
}

.login-form-group .login-input:focus,
.login-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    background: var(--surface-primary);
    box-shadow: 0 0 0 3px rgba(23, 162, 184, 0.15);
    color: var(--text-primary);
}

.login-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.login-input::-webkit-input-placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.login-input::-moz-placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.login-input:-ms-input-placeholder {
    color: var(--text-muted);
    opacity: 1;
}
