:root {
    --primary: #e67e22;
    --primary-dark: #d35400;
    --primary-light: #f39c12;
    --secondary: #27ae60;
    --bg: #fdf6e3;
    --surface: #ffffff;
    --surface-alt: #faf2e0;
    --border: #e8ddc3;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --success: #27ae60;
    --error: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.app-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.app-header h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.8rem;
}

.subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.card-body {
    padding: 1.5rem;
}

.card-body.collapsed {
    display: none;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Step descriptions */
.step-description {
    margin: 0 0 1rem 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Forms */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

select,
textarea,
input[type=text] {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    color: var(--text);
}

select:focus,
textarea:focus,
input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.15);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.button-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-alt);
}

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.pending {
    background: #ecf0f1;
    color: var(--text-muted);
}

.badge.running {
    background: #fff3cd;
    color: #856404;
    animation: pulse 1.5s ease-in-out infinite;
}

.badge.done {
    background: #d4edda;
    color: #155724;
}

.badge.error {
    background: #f8d7da;
    color: #721c24;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Pipeline Steps */
.pipeline-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-alt);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.step-number {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.step-info {
    flex: 1;
    min-width: 0;
}

.step-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

/* Artifacts */
.artifacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.artifact-card {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.artifact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.artifact-header h3 {
    margin: 0;
    font-size: 1rem;
}

/* Submissions / recipes lists */
.submissions-list,
.recipes-list {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-alt);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.submissions-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.submission-item,
.recipe-item {
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.submission-item a,
.recipe-item a {
    color: var(--primary-dark);
    text-decoration: none;
}

.submission-item a:hover,
.recipe-item a:hover {
    text-decoration: underline;
}

/* Markdown preview */
.markdown-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    margin-top: 0.5rem;
}

.markdown-preview pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 0.75rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.markdown-preview code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.85em;
}

/* Session links */
.session-link-container {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.session-link-container a {
    color: var(--info);
    margin-right: 0.75rem;
    text-decoration: none;
}

.session-link-container a:hover {
    text-decoration: underline;
}

.session-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.session-row:last-child {
    border-bottom: none;
}

.session-target {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Activity Log */
.activity-log {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
    min-height: 100px;
}

.activity-log .log-entry {
    padding: 0.15rem 0;
}

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

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

.activity-log .log-warning {
    color: #fcd34d;
}

.activity-log .log-info {
    color: #93c5fd;
}

/* Status messages */
.status-message {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    padding: 0.3rem 0;
    min-height: 1.2em;
}

.status-message.success {
    color: var(--success);
}

.status-message.error {
    color: var(--error);
}

.status-message.info {
    color: var(--info);
}

.status-message.warning {
    color: var(--warning);
}

/* Toasts */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    color: white;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: slideIn 0.2s ease-out;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--error);
}

.toast-warning {
    background: var(--warning);
}

.toast-info {
    background: var(--info);
}

@keyframes slideIn {
    from {
        transform: translateX(20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}
/* Modal */
.modal-overlay {
     position: fixed;
     inset: 0;
     background: rgba(0, 0, 0, 0.6);
     z-index: 2000;
     display: flex;
     align-items: center;
     justify-content: center;
     padding: 1rem;
     animation: fadeIn 0.15s ease-out;
}
.modal-content {
     background: var(--surface);
     border-radius: var(--radius);
     box-shadow: var(--shadow-lg);
     width: 100%;
     max-width: 960px;
     max-height: 90vh;
     display: flex;
     flex-direction: column;
     overflow: hidden;
}
.modal-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     padding: 1rem 1.5rem;
     background: var(--surface-alt);
     border-bottom: 1px solid var(--border);
}
.modal-header h2 {
     margin: 0;
     font-size: 1.15rem;
}
.modal-body {
     padding: 1.5rem 2rem;
     overflow-y: auto;
     flex: 1;
     font-size: 1rem;
     line-height: 1.6;
}
.modal-body h1,
.modal-body h2,
.modal-body h3 {
     margin-top: 1rem;
}
.modal-body pre {
     background: #2c3e50;
     color: #ecf0f1;
     padding: 0.75rem;
     border-radius: 4px;
     overflow-x: auto;
     font-size: 0.9rem;
}
.modal-body code {
     background: rgba(0, 0, 0, 0.05);
     padding: 0.1rem 0.3rem;
     border-radius: 3px;
     font-size: 0.9em;
}
@keyframes fadeIn {
     from { opacity: 0; }
     to { opacity: 1; }
}


/* Utility */
.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .app-header {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1.4rem;
    }

    .container {
        padding: 0 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .pipeline-steps {
        grid-template-columns: 1fr;
    }

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