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

:root {
    --ink: #0a0a0f;
    --paper: #fafaf8;
    --accent: #3d5afe;
    --accent-hover: #304ffe;
    --accent-glow: rgba(61, 90, 254, 0.12);
    --accent-light: rgba(61, 90, 254, 0.06);
    --dim: #6b6b7b;
    --border: #e2e2e6;
    --surface: #f2f2f0;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.15;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: white;
    color: var(--ink);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface); }

.btn-ghost {
    background: transparent;
    color: var(--dim);
    border-color: transparent;
}
.btn-ghost:hover { color: var(--ink); background: var(--surface); }

.btn-danger {
    background: white;
    color: var(--error);
    border-color: var(--border);
}
.btn-danger:hover { background: var(--error-bg); border-color: var(--error); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.92rem;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink);
    transition: border-color 0.15s ease;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    padding: 24px;
}
.auth-container {
    width: 100%;
    max-width: 400px;
}
.auth-logo {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-decoration: none;
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo span { color: var(--accent); }
.auth-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}
.auth-card h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}
.auth-subtitle {
    font-size: 0.88rem;
    color: var(--dim);
    margin-bottom: 24px;
}
.auth-error {
    font-size: 0.85rem;
    color: var(--error);
    margin-bottom: 12px;
    min-height: 20px;
}
.auth-toggle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--dim);
    margin-top: 20px;
}
.auth-toggle a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.auth-toggle a:hover { text-decoration: underline; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
    min-height: 100vh;
}
.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.app-nav-left { display: flex; align-items: center; gap: 32px; }
.app-nav-right { display: flex; align-items: center; gap: 16px; }
.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-decoration: none;
}
.logo span { color: var(--accent); }
.user-email {
    font-size: 0.82rem;
    color: var(--dim);
}

.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 1.6rem;
    letter-spacing: -0.02em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}
.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.stat-card .stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ink);
}

/* ============================================================
   PROCESS LIST
   ============================================================ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.process-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.process-row {
    display: grid;
    grid-template-columns: 1fr 120px 100px 140px 100px;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    color: inherit;
}
.process-row:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.process-name {
    font-weight: 500;
    font-size: 0.92rem;
}
.process-desc {
    font-size: 0.8rem;
    color: var(--dim);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.process-meta {
    font-size: 0.8rem;
    color: var(--dim);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 100px;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-draft { background: var(--surface); color: var(--dim); }
.badge-paused { background: var(--warning-bg); color: var(--warning); }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-failed { background: var(--error-bg); color: var(--error); }
.badge-running { background: var(--accent-glow); color: var(--accent); }
.badge-skipped { background: var(--surface); color: var(--dim); }
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: white;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.6;
}
.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.empty-state p {
    font-size: 0.9rem;
    color: var(--dim);
    max-width: 400px;
    margin: 0 auto 24px;
}

/* ============================================================
   NEW PROCESS BUILDER
   ============================================================ */
.builder-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
}
.builder-card h2 {
    font-size: 1.2rem;
    margin-bottom: 4px;
}
.builder-card .subtitle {
    font-size: 0.88rem;
    color: var(--dim);
    margin-bottom: 24px;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.suggestion-chip {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--dim);
    cursor: pointer;
    transition: all 0.15s ease;
}
.suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* Parsed Steps Preview */
.parsed-preview {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.parsed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.parsed-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}
.parsed-info {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.parsed-info-item {
    font-size: 0.82rem;
    color: var(--dim);
}
.parsed-info-item strong {
    color: var(--ink);
}

.step-pipeline {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 24px;
}
.step-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    position: relative;
}
.step-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    border-radius: 50%;
}
.step-content {
    flex: 1;
}
.step-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.step-description {
    font-size: 0.82rem;
    color: var(--dim);
    line-height: 1.5;
}
.step-action-tag {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 6px;
    display: inline-block;
}

.step-connector {
    width: 2px;
    height: 12px;
    background: var(--border);
    margin-left: 33px;
}

.parsed-actions {
    display: flex;
    gap: 12px;
}

/* ============================================================
   PROCESS DETAIL
   ============================================================ */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}
.detail-header h1 {
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}
.detail-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--dim);
}
.detail-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.detail-section {
    margin-bottom: 32px;
}
.detail-section h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.detail-description {
    font-size: 0.92rem;
    color: var(--dim);
    line-height: 1.7;
    background: var(--surface);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
}

/* Run History */
.run-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.run-row {
    display: grid;
    grid-template-columns: 80px 120px 1fr 120px;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}
.run-row:hover { border-color: var(--accent); }
.run-id {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--dim);
}
.run-time {
    font-size: 0.82rem;
    color: var(--dim);
}

/* Run Detail Modal */
.run-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    backdrop-filter: blur(2px);
}
.run-detail-modal {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.run-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}
.run-modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.run-step-result {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.run-step-result:has(.run-step-status.completed) {
    border-color: rgba(22, 163, 74, 0.2);
    background: rgba(240, 253, 244, 0.5);
}
.run-step-result:has(.run-step-status.failed) {
    border-color: rgba(220, 38, 38, 0.2);
    background: rgba(254, 242, 242, 0.5);
}
.run-step-result:has(.run-step-status.running) {
    border-color: var(--accent);
    background: var(--accent-light);
}
.run-step-status {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 1px;
}
.run-step-status.completed { background: var(--success-bg); color: var(--success); }
.run-step-status.failed { background: var(--error-bg); color: var(--error); }
.run-step-status.skipped { background: var(--surface); color: var(--dim); border: 1px solid var(--border); }
.run-step-status.running { background: var(--accent-glow); color: var(--accent); }
.run-step-status.pending { background: var(--surface); color: var(--dim); border: 1px solid var(--border); }
.step-pending-dot {
    width: 6px;
    height: 6px;
    background: var(--border);
    border-radius: 50%;
    display: block;
}
.run-step-info { flex: 1; min-width: 0; }
.step-row-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.run-step-info .step-label { font-size: 0.88rem; font-weight: 600; }
.run-step-output {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.75rem;
    color: var(--dim);
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 6px;
    border: 1px solid var(--border);
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Live Output Data */
.run-step-output-live {
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}
.output-fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.output-field {
    display: flex;
    gap: 8px;
    font-size: 0.78rem;
    line-height: 1.5;
    align-items: baseline;
}
.output-key {
    font-weight: 600;
    color: var(--dim);
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 0;
}
.output-key::after { content: ':'; }
.output-val {
    color: var(--ink);
    word-break: break-word;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.75rem;
}
.output-preview {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--dim);
    font-style: italic;
    border-left: 2px solid var(--border);
    padding-left: 8px;
    line-height: 1.5;
}

/* ============================================================
   LOADING & ANIMATIONS
   ============================================================ */
.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-bar {
    height: 3px;
    background: var(--accent-glow);
    position: relative;
    border-radius: 2px;
    overflow: hidden;
    margin: 16px 0;
}
.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: var(--accent);
    animation: loadbar 1s ease-in-out infinite;
}
@keyframes loadbar {
    0% { left: -50%; }
    100% { left: 100%; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   BACK LINK
   ============================================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--dim);
    text-decoration: none;
    margin-bottom: 20px;
    cursor: pointer;
}
.back-link:hover { color: var(--accent); }

/* ============================================================
   WORKFLOW DIAGRAM
   ============================================================ */
.wf-view-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.wf-tab {
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dim);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: 'DM Sans', sans-serif;
    transition: color 0.15s ease;
}
.wf-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.wf-tab:hover:not(.active) { color: var(--ink); }

.wf-diagram-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.wf-svg-container {
    padding: 20px 10px;
    background: var(--surface);
    cursor: grab;
    overflow: hidden;
    position: relative;
    min-height: 180px;
}
.wf-svg-container:active { cursor: grabbing; }
.wf-svg-container svg { display: block; width: 100%; touch-action: none; }

.wf-legend {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    background: white;
}
.wf-legend-item {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 100px;
    letter-spacing: 0.03em;
}
.wf-legend-trigger  { background: #eff6ff; color: #3d5afe; border: 1px solid rgba(61,90,254,0.25); }
.wf-legend-action   { background: #f0fdf4; color: #16a34a; border: 1px solid rgba(22,163,74,0.25); }
.wf-legend-condition{ background: #fffbeb; color: #d97706; border: 1px solid rgba(217,119,6,0.25); }
.wf-legend-output   { background: #faf5ff; color: #7c3aed; border: 1px solid rgba(124,58,237,0.25); }

.wf-hint {
    text-align: center;
    font-size: 0.71rem;
    color: var(--dim);
    padding: 5px;
    background: white;
    opacity: 0.65;
    border-top: 1px solid var(--border);
}

/* Running node pulse animation */
@keyframes wf-pulse {
    0%, 100% { stroke-width: 1.5; opacity: 1; }
    50%       { stroke-width: 3;   opacity: 0.75; }
}
.wf-running .wf-node-rect {
    animation: wf-pulse 1s ease-in-out infinite;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .process-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .detail-header {
        flex-direction: column;
        gap: 16px;
    }
    .run-row {
        grid-template-columns: 1fr 1fr;
    }
    .app-nav {
        flex-direction: column;
        gap: 12px;
    }
    .parsed-actions {
        flex-direction: column;
    }
}

/* ============================================================
   ANALYTICS
   ============================================================ */

/* Nav links */
.app-nav-links {
    display: flex;
    gap: 4px;
}
.nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dim);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    border: 1px solid transparent;
}
.nav-link:hover { color: var(--ink); background: var(--surface); }
.nav-link.active {
    color: var(--accent);
    background: var(--accent-light);
    border-color: var(--accent-glow);
}

/* Filters */
.analytics-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-select {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.15s;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

/* Stat cards with icons */
.analytics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card-highlight {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 24px;
}
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.stat-icon-blue   { background: rgba(61, 90, 254, 0.1);  color: var(--accent); }
.stat-icon-green  { background: rgba(22, 163, 74, 0.1);  color: var(--success); }
.stat-icon-purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.stat-icon-orange { background: rgba(249, 115, 22, 0.1); color: #f97316; }
.stat-sub {
    font-size: 0.75rem;
    color: var(--dim);
    margin-top: 3px;
}

/* Charts */
.analytics-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}
.chart-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.chart-card-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
}
.chart-legend {
    font-size: 0.75rem;
    color: var(--dim);
    display: flex;
    align-items: center;
    gap: 10px;
}
.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.legend-dot-blue  { background: var(--accent); }
.legend-dot-green { background: var(--success); }
.chart-container {
    height: 220px;
    position: relative;
}

/* Analytics section */
.analytics-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h2 {
    font-size: 1rem;
}
.section-count {
    font-size: 0.8rem;
    color: var(--dim);
}

/* Run history table */
.run-history-table {
    overflow-x: auto;
}
.rht-header {
    display: grid;
    grid-template-columns: 180px 1fr 100px 90px 70px 90px;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.rht-row {
    display: grid;
    grid-template-columns: 180px 1fr 100px 90px 70px 90px;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.83rem;
    align-items: center;
    transition: background 0.1s;
}
.rht-row:last-child { border-bottom: none; }
.rht-row:hover { background: var(--surface); border-radius: var(--radius-sm); }
.rht-time { color: var(--dim); font-size: 0.78rem; }
.rht-process { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rht-num { color: var(--ink); font-variant-numeric: tabular-nums; }
.rht-saved { color: var(--success); font-weight: 600; }
.dim { color: var(--dim); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.page-info { font-size: 0.82rem; color: var(--dim); }

@media (max-width: 768px) {
    .analytics-charts {
        grid-template-columns: 1fr;
    }
    .rht-header, .rht-row {
        grid-template-columns: 1fr 1fr 80px;
    }
    .rht-header > :nth-child(n+4),
    .rht-row > :nth-child(n+4) {
        display: none;
    }
    .analytics-stats {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================
   INTEGRATIONS PAGE
   ============================================================ */

.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.integration-card {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: box-shadow 0.2s ease;
}

.integration-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
}

.integration-card--connected {
    border-color: rgba(22,163,74,0.35);
    background: linear-gradient(135deg, white 80%, rgba(22,163,74,0.03));
}

.integration-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.integration-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.integration-icon--google { background: #f8f9fa; border: 1px solid #e8eaed; }
.integration-icon--slack  { background: #f8f9fa; border: 1px solid #e8eaed; }

.integration-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

.integration-subtitle {
    font-size: 0.8rem;
    color: var(--dim);
    margin-top: 2px;
}

.integration-status-badge {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
}

.integration-status-badge--connected {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(22,163,74,0.25);
}

.integration-status-badge--disconnected {
    background: var(--surface);
    color: var(--dim);
    border: 1px solid var(--border);
}

.integration-capabilities {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--radius-sm);
}

.capability-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.83rem;
    color: var(--dim);
}

.capability-icon {
    font-size: 0.85rem;
    margin-top: 1px;
    flex-shrink: 0;
}

.capability-item code {
    font-size: 0.78rem;
    background: white;
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'DM Mono', 'Fira Code', monospace;
    color: var(--accent);
}

.integration-info {
    margin-bottom: 12px;
}

.integration-config {
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

.integration-config label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--dim);
    margin-bottom: 6px;
}

.integration-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.integrations-hint-box {
    margin-top: 28px;
    padding: 20px 24px;
    background: var(--accent-light);
    border: 1px solid rgba(61,90,254,0.12);
    border-radius: var(--radius);
}

.integrations-hint-box h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ink);
}

.integrations-hint-box p {
    font-size: 0.84rem;
    color: var(--dim);
    line-height: 1.5;
}

.integrations-hint-box ul {
    margin: 8px 0 0 18px;
    font-size: 0.84rem;
    color: var(--dim);
    line-height: 1.7;
}

.integrations-hint-box code {
    font-size: 0.78rem;
    background: white;
    border: 1px solid rgba(61,90,254,0.15);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--accent);
}

@media (max-width: 768px) {
    .integrations-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   USAGE BAR
   ============================================================ */
.usage-bar-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}
.usage-bar-card--warn {
    background: var(--warning-bg);
    border-color: rgba(217,119,6,0.3);
}
.usage-bar-card--pro {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: rgba(61,90,254,0.04);
    border-color: rgba(61,90,254,0.15);
}
.usage-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}
.usage-bar-label {
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
}
.usage-upgrade-link {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.usage-upgrade-link:hover { text-decoration: underline; }
.usage-bar-track {
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}
.usage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.4s ease;
}
.usage-bar-fill--warn { background: var(--warning); }
.usage-bar-hint {
    font-size: 0.75rem;
    color: var(--dim);
}
.usage-plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--dim);
}
.usage-plan-badge--pro {
    background: rgba(61,90,254,0.08);
    border-color: rgba(61,90,254,0.25);
    color: var(--accent);
}

/* ============================================================
   PRICING PAGE
   ============================================================ */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 680px;
    margin: 0 auto;
}
.pricing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    position: relative;
}
.pricing-card--featured {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 4px 32px rgba(61,90,254,0.1);
}
.pricing-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 14px;
    border-radius: 99px;
}
.pricing-tier {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.pricing-price {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}
.pricing-period {
    font-size: 1rem;
    color: var(--dim);
    font-weight: 400;
}
.pricing-desc {
    color: var(--dim);
    font-size: 0.85rem;
    margin-bottom: 20px;
}
.pricing-features {
    list-style: none;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.875rem;
}
.pricing-features li { color: var(--ink); }
.pricing-feature-dim { color: var(--dim) !important; }
.pricing-cta { margin-top: auto; }

/* ============================================================
   TEAM PAGE
   ============================================================ */
.team-org-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.team-org-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.team-org-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.team-org-plan {
    display: flex;
    align-items: center;
    gap: 8px;
}
.team-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.team-section h2 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dim);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.team-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 99px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--dim);
    font-weight: 600;
}
.invite-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.invite-form input[type="email"] {
    flex: 1;
    min-width: 180px;
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--ink);
}
.invite-link-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}
.team-members-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.team-member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.team-member-row:last-child { border-bottom: none; }
.team-member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    border: 1px solid rgba(61,90,254,0.15);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.team-member-info {
    flex: 1;
    min-width: 0;
}
.team-member-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.team-member-email {
    font-size: 0.78rem;
    color: var(--dim);
}
.team-role-badge {
    display: inline-flex;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.team-role-badge--admin {
    background: rgba(61,90,254,0.08);
    border: 1px solid rgba(61,90,254,0.2);
    color: var(--accent);
}
.team-role-badge--member {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--dim);
}
.team-member-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
@media (max-width: 600px) {
    .invite-form { flex-direction: column; }
    .team-member-actions { flex-direction: column; }
    .pricing-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   TEMPLATES MARKETPLACE
   ============================================================ */

/* Hero */
.tpl-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    background: linear-gradient(135deg, var(--accent-light) 0%, #f5f3ff 100%);
    border: 1.5px solid rgba(61, 90, 254, 0.15);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 28px;
}
.tpl-hero-content { flex: 1; }
.tpl-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    background: white;
    border: 1px solid rgba(61, 90, 254, 0.2);
    border-radius: 20px;
    padding: 4px 12px;
    margin-bottom: 12px;
}
.tpl-hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 8px;
    line-height: 1.2;
}
.tpl-hero-subtitle {
    color: var(--dim);
    font-size: 0.92rem;
    max-width: 480px;
    line-height: 1.6;
    margin-bottom: 16px;
}
.tpl-hero-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.83rem;
    color: var(--dim);
    font-weight: 500;
}
.tpl-hero-dot { color: var(--border); }

/* Controls bar */
.tpl-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* Category pills */
.templates-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.tpl-cat-btn {
    padding: 6px 15px;
    border-radius: 99px;
    border: 1.5px solid var(--border);
    background: var(--paper);
    color: var(--dim);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'DM Sans', sans-serif;
    white-space: nowrap;
}
.tpl-cat-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.tpl-cat-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Search */
.tpl-search-wrap {
    position: relative;
    flex-shrink: 0;
}
.tpl-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dim);
    pointer-events: none;
}
.tpl-search-input {
    padding: 7px 14px 7px 32px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    background: white;
    color: var(--ink);
    width: 220px;
    transition: border-color 0.15s;
}
.tpl-search-input:focus { outline: none; border-color: var(--accent); }
.tpl-search-input::placeholder { color: var(--dim); }

/* Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Card */
.tpl-card {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
    position: relative;
    cursor: pointer;
}
.tpl-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 24px rgba(61, 90, 254, 0.1);
    transform: translateY(-2px);
}

.tpl-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.tpl-icon { font-size: 1.75rem; line-height: 1; }

.tpl-badge-featured {
    font-size: 0.7rem;
    font-weight: 600;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
}

.tpl-cat-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 99px;
    padding: 3px 10px;
    white-space: nowrap;
}

.tpl-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    line-height: 1.3;
}

.tpl-desc {
    font-size: 0.84rem;
    color: var(--dim);
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Step preview mini-flow */
.tpl-step-preview {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
}
.tpl-step-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1.5px solid;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.tpl-step-arrow {
    font-size: 0.62rem;
    color: var(--dim);
    flex-shrink: 0;
}
.tpl-step-more {
    font-size: 0.72rem;
    color: var(--dim);
    font-weight: 600;
    padding: 0 4px;
}

/* Meta row */
.tpl-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.tpl-meta-item {
    font-size: 0.77rem;
    color: var(--dim);
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}
.tpl-meta-item svg { flex-shrink: 0; opacity: 0.6; }

/* Card footer */
.tpl-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 4px;
    border-top: 1px solid var(--surface);
}

.tpl-integrations { display: flex; gap: 5px; flex-wrap: wrap; }

.tpl-integration-tag {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--dim);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 4px;
}

/* Empty state */
.tpl-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 64px 24px;
    color: var(--dim);
}

/* Modal */
.tpl-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

.tpl-modal {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 580px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.18);
    animation: slideUp 0.2s ease;
    position: relative;
}
.tpl-modal-detail { max-width: 660px; }

.tpl-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--dim);
    transition: all 0.15s;
}
.tpl-modal-close:hover { background: var(--error-bg); color: var(--error); }

/* Detail modal parts */
.tpl-detail-hero {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-right: 44px;
}
.tpl-detail-icon { font-size: 2.4rem; flex-shrink: 0; line-height: 1; margin-top: 2px; }
.tpl-detail-title { font-size: 1.35rem; font-weight: 700; color: var(--ink); margin: 6px 0 6px; line-height: 1.25; }
.tpl-detail-desc { font-size: 0.87rem; color: var(--dim); line-height: 1.55; margin: 0; }

.tpl-detail-stats {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}
.tpl-detail-stat {
    flex: 1;
    text-align: center;
    padding: 14px 12px;
    border-right: 1px solid var(--border);
}
.tpl-detail-stat:last-child { border-right: none; }
.tpl-detail-stat-val {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}
.tpl-detail-stat-label { font-size: 0.73rem; color: var(--dim); margin-top: 3px; }

.tpl-detail-section { margin-bottom: 20px; }
.tpl-detail-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.tpl-detail-steps { display: flex; flex-direction: column; }
.tpl-detail-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 11px 0;
    border-bottom: 1px solid var(--surface);
}
.tpl-detail-step:last-child { border-bottom: none; }

.tpl-detail-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.tpl-detail-step-body { flex: 1; }
.tpl-detail-step-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}
.tpl-detail-step-icon { font-size: 0.85rem; }
.tpl-detail-step-label { font-size: 0.86rem; font-weight: 600; color: var(--ink); }
.tpl-detail-step-desc { font-size: 0.81rem; color: var(--dim); line-height: 1.5; }

.step-action-tag {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--dim);
    background: var(--surface);
    border-radius: 4px;
    padding: 1px 6px;
    text-transform: capitalize;
    letter-spacing: 0.01em;
}

.tpl-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

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

@media (max-width: 900px) {
    .tpl-hero { flex-direction: column; gap: 16px; }
    .tpl-hero-title { font-size: 1.45rem; }
}
@media (max-width: 700px) {
    .templates-grid { grid-template-columns: 1fr; }
    .tpl-controls { flex-direction: column; align-items: flex-start; }
    .tpl-search-input { width: 100%; }
    .tpl-modal-actions { flex-direction: column; }
}

/* ============================================================
   DASHBOARD v2 — ONBOARDING + LAYOUT POLISH
   ============================================================ */

/* Page header actions */
.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Dashboard 2-column body */
.dashboard-body {
    display: grid;
    grid-template-columns: 1fr 296px;
    gap: 24px;
    align-items: flex-start;
}
.dashboard-main { min-width: 0; }
.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Section header spacing in sidebar */
.dashboard-sidebar .section-header { margin-bottom: 10px; }

/* Recent Activity */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.activity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    color: inherit;
}
.activity-row:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.activity-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-completed { background: var(--success); }
.status-failed { background: var(--error); }
.status-running { background: var(--accent); animation: pulse-dot 1.2s ease-in-out infinite; }
.status-pending { background: var(--border); }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.activity-info { flex: 1; min-width: 0; }
.activity-name {
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.activity-meta {
    font-size: 0.74rem;
    color: var(--dim);
    margin-top: 1px;
}
.activity-empty {
    font-size: 0.82rem;
    color: var(--dim);
    padding: 20px 14px;
    text-align: center;
    background: white;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}
.badge-sm {
    font-size: 0.68rem !important;
    padding: 2px 7px !important;
    flex-shrink: 0;
}

/* Getting Started Checklist */
.checklist-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.checklist-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
}
.checklist-progress-text {
    font-size: 0.73rem;
    color: var(--dim);
    margin-top: 2px;
}
.checklist-dismiss-btn {
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.1s;
    line-height: 1;
}
.checklist-dismiss-btn:hover { background: var(--surface); color: var(--ink); }
.checklist-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 12px;
    overflow: hidden;
}
.checklist-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #7c6dff);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.checklist-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.82rem;
    color: var(--dim);
    padding: 6px 4px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.checklist-item:not(.done)[data-clickable="true"]:hover {
    color: var(--accent);
    background: var(--accent-light);
    cursor: pointer;
}
.checklist-item.done { color: var(--ink); }
.checklist-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    flex-shrink: 0;
    background: white;
    color: transparent;
    transition: all 0.2s;
}
.checklist-item.done .checklist-check {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.checklist-arrow {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.15s;
}
.checklist-item:not(.done)[data-clickable="true"]:hover .checklist-arrow { opacity: 1; }

/* Enhanced Empty State */
.empty-state-big {
    text-align: center;
    padding: 64px 32px 52px;
    background: white;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state-icon-big {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
    line-height: 1;
}
.empty-state-big h3 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 12px;
}
.empty-state-big p {
    font-size: 0.9rem;
    color: var(--dim);
    max-width: 380px;
    margin: 0 auto 28px;
    line-height: 1.7;
}
.empty-ctas {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Welcome Modal */
.welcome-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}
.welcome-modal {
    background: white;
    border-radius: 18px;
    padding: 40px 36px 32px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.2);
    position: relative;
    animation: slideUp 0.25s ease;
}
.welcome-dismiss {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--dim);
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.1s;
    line-height: 1;
}
.welcome-dismiss:hover { background: var(--surface); }
.welcome-header {
    text-align: center;
    margin-bottom: 28px;
}
.welcome-logo { font-size: 2.5rem; margin-bottom: 16px; display: block; }
.welcome-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.welcome-header p { font-size: 0.88rem; color: var(--dim); }
.welcome-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.welcome-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--paper);
}
.welcome-option:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.welcome-option-icon { font-size: 1.75rem; margin-bottom: 8px; }
.welcome-option-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
    line-height: 1.3;
}
.welcome-option-desc {
    font-size: 0.73rem;
    color: var(--dim);
    line-height: 1.4;
}

/* Stat card hover enhancement */
.stat-card { transition: box-shadow 0.15s ease, transform 0.15s ease; }
.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 900px) {
    .dashboard-body { grid-template-columns: 1fr; }
    .dashboard-sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}
@media (max-width: 640px) {
    .dashboard-sidebar { grid-template-columns: 1fr; }
    .welcome-options { grid-template-columns: 1fr; }
    .empty-ctas { flex-direction: column; align-items: center; }
    .page-actions .btn-secondary { display: none; }
}
