:root {
    --bg: #0f1116;
    --panel: rgba(255, 255, 255, 0.04);
    --panel-soft: rgba(255, 255, 255, 0.08);
    --text: #f5f7fb;
    --muted: #a6b0c3;
    --accent: #5de3b3;
    --accent-strong: #00c896;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    --card-radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 20% 20%, rgba(93, 227, 179, 0.12), transparent 25%),
                radial-gradient(circle at 80% 0%, rgba(0, 200, 150, 0.14), transparent 22%),
                var(--bg);
    min-height: 100vh;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 56px 24px 80px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
}

.header__brand {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.header__logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    margin-top: 4px;
}

.page__footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: auto;
    padding-top: 32px;
}

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

h1 {
    margin: 6px 0 8px;
    font-size: 2.2rem;
    letter-spacing: -0.02em;
}

h2 {
    margin: 0;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
}

.lede {
    margin: 0;
    color: var(--muted);
    max-width: 640px;
}

.eyebrow {
    margin: 0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--muted);
}

.badge {
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
}

.help-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.95rem;
}

.help-button:hover {
    background: var(--panel-soft);
    color: var(--accent);
    border-color: var(--accent);
}

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

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 22px 22px 26px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(4px);
}

.card--light {
    background: var(--panel-soft);
}

.card__header {
    margin-bottom: 12px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.label {
    color: var(--muted);
    font-size: 0.95rem;
}

.input-shell {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.input-shell:focus-within {
    border-color: rgba(93, 227, 179, 0.6);
    box-shadow: 0 0 0 6px rgba(93, 227, 179, 0.08);
}

textarea {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 160px;
    font-family: inherit;
    outline: none;
}

textarea::placeholder {
    color: var(--muted);
}

.button {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(120deg, var(--accent-strong), var(--accent));
    color: #0c0e12;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 12px 30px rgba(0, 200, 150, 0.28);
}

.button:hover {
    transform: translateY(-1px) scale(1.01);
}

.button:active {
    transform: translateY(0);
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.list__title {
    margin: 0 0 4px;
    font-weight: 700;
}

.list__desc {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.step__number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #0c0e12;
    font-weight: 700;
    border-radius: 50%;
    font-size: 0.9rem;
}

.step__content {
    flex: 1;
}

.step__title {
    margin: 0 0 4px;
    font-weight: 700;
    font-size: 1.05rem;
}

.step__desc {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.step__preview {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    overflow-x: auto;
    max-height: 220px;
    overflow-y: auto;
}

.step__preview code {
    background: transparent;
    color: inherit;
    display: block;
    white-space: pre;
    line-height: 1.4;
}

.step__preview pre {
    margin: 0;
    padding: 0;
}

.step__preview--table {
    padding: 0;
    overflow: hidden;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.preview-table thead {
    background: rgba(93, 227, 179, 0.1);
}

.preview-table th {
    padding: 8px 10px;
    text-align: left;
    color: var(--accent);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.preview-table td {
    padding: 8px 10px;
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.preview-table tbody tr:last-child td {
    border-bottom: none;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal--open {
    display: flex;
}

.modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.modal__content {
    position: relative;
    z-index: 1001;
    margin: auto;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.modal__header h2 {
    margin: 0;
}

.modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal__close:hover {
    background: var(--panel);
    color: var(--text);
}

.modal__body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Progress Area */
.progress__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--muted);
    text-align: center;
}

/* Pipeline Steps */
.pipeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.step-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.step-header:hover {
    background: var(--panel-soft);
}

.step-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.step-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.step-description {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.step-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.step-details {
    padding: 0 20px 20px;
    border-top: 1px solid var(--border);
}

.step-content {
    padding-top: 16px;
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-section p {
    margin: 8px 0;
    color: var(--text);
    line-height: 1.6;
}

.detail-section ul {
    margin: 8px 0;
    padding-left: 20px;
    color: var(--text);
}

.detail-section ul li {
    margin: 4px 0;
}

.detail-section pre {
    margin: 8px 0;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}

.detail-section code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent);
}

/* Spinner */
.spinner {
    animation: spin 1s linear infinite;
}

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

/* Error State */
.step-error {
    padding-top: 16px;
}

.error-message {
    margin: 0 0 12px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
}

.retry-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-button:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

/* Quota Exceeded Error */
.quota-error {
    padding: 40px 20px;
    background: var(--panel);
    border-radius: 12px;
    margin-top: 20px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Download Button */
.download-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    margin-top: 16px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.download-button:hover {
    background: var(--accent-strong);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(93, 227, 179, 0.3);
}

/* Dataset Preview Table */
.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
}

.dataset-preview {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.dataset-preview thead {
    background: rgba(0, 0, 0, 0.3);
}

.dataset-preview th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 2px solid var(--border);
}

.dataset-preview td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.dataset-preview tbody tr:hover {
    background: var(--panel);
}

.preview-note {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 640px) {
    .page__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .button {
        width: 100%;
        justify-content: center;
    }

    .step-header-left {
        gap: 12px;
    }

    .step-title {
        font-size: 1rem;
    }

    .step-description {
        font-size: 0.85rem;
    }
}
