:root {
    --bg-color: #05060d;
    --card-bg: rgba(12, 16, 32, 0.88);
    --section-bg: rgba(8, 12, 24, 0.92);
    --card-border: rgba(0, 240, 255, 0.18);
    --text-main: #e8f4ff;
    --text-muted: #7a8fa8;
    --primary: #00e5ff;
    --primary-hover: #00b8d4;
    --primary-gradient: linear-gradient(135deg, #00e5ff 0%, #a855f7 55%, #ff2da8 100%);
    --success: #00ff9d;
    --error: #ff4d6d;
    --warning: #fbbf24;
    --radius: 14px;
    --shadow: 0 0 40px rgba(0, 229, 255, 0.08), 0 20px 50px rgba(0, 0, 0, 0.55);
    /* Dashboard surfaces (dark defaults) */
    --surface-elevated: rgba(10, 16, 28, 0.55);
    --surface-muted: rgba(10, 16, 28, 0.45);
    --surface-subtle: rgba(10, 16, 28, 0.4);
    --surface-input: #0a101c;
    --surface-input-hover: #111827;
    --surface-pill: #070b14;
    --surface-active-text: #041018;
    --surface-overlay: rgba(8, 12, 24, 0.98);
    --surface-border-subtle: rgba(255, 255, 255, 0.07);
    --surface-border-faint: rgba(255, 255, 255, 0.06);
    --surface-border-light: rgba(255, 255, 255, 0.08);
    --surface-border-medium: rgba(255, 255, 255, 0.1);
    --surface-hover: rgba(255, 255, 255, 0.03);
    --surface-hover-strong: rgba(255, 255, 255, 0.06);
    --surface-dashed-bg: rgba(0, 0, 0, 0.15);
    --surface-row-hover: rgba(255, 255, 255, 0.03);
    --chart-tick: #8fa3bf;
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-bar-bg: rgba(56, 189, 248, 0.65);
    --chart-bar-border: rgba(56, 189, 248, 1);
    --chart-bar-fill: rgba(56, 189, 248, 0.12);
    --chart-line: rgba(16, 185, 129, 0.85);
    --chart-line-fill: rgba(16, 185, 129, 0.12);
    --chart-line-point: rgba(16, 185, 129, 1);
    --chart-line-point-dim: rgba(16, 185, 129, 0.35);
    --chart-line-point-border-dim: rgba(16, 185, 129, 0.45);
    --chart-focus-tick: #38bdf8;
    --chart-focus-tick-muted: #6b8299;
    --person-publicador: #d5e4f7;
    --person-siervo: #ff7a45;
    --person-anciano: #ffc933;
    --person-sup: #2dd4bf;
    --person-sup-bg: rgba(45, 212, 191, 0.18);
    --person-sup-border: rgba(45, 212, 191, 0.4);
    --person-aux: #99f6e4;
    --person-aux-bg: rgba(153, 246, 228, 0.14);
    --person-aux-border: rgba(153, 246, 228, 0.38);
    /* Motion: overlays & view changes (not data re-renders) */
    --motion-fast: 150ms;
    --motion-panel: 240ms;
    --motion-view: 320ms;
    --motion-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --motion-duration: var(--motion-panel);
    /* Dashboard heading hierarchy (sections → subsections → panels) */
    --heading-section-color: var(--text-main);
    --heading-section-size: 0.85rem;
    --heading-section-weight: 700;
    --heading-section-tracking: 0.06em;
    --heading-section-transform: uppercase;
    --heading-subsection-color: var(--text-main);
    --heading-subsection-size: 0.82rem;
    --heading-subsection-weight: 600;
    --heading-subsection-tracking: 0.04em;
    --heading-subsection-transform: uppercase;
    --heading-panel-color: var(--text-muted);
    --heading-panel-size: 0.72rem;
    --heading-panel-weight: 600;
    --heading-panel-tracking: 0.06em;
    --heading-panel-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --motion-fast: 0.01ms;
        --motion-panel: 0.01ms;
        --motion-view: 0.01ms;
    }
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.5rem 1rem 2rem;
}

.container {
    width: 100%;
    max-width: 680px;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.app-header .header-nav {
    margin-left: auto;
}

.logo-icon {
    font-size: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 0.55rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.nav-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 8px;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(56, 189, 248, 0.1);
}

.main-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.form-section {
    background: var(--section-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.section-head .section-title {
    margin: 0;
}

.section-icon {
    font-size: 1.1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(56, 189, 248, 0.12);
    border-radius: 8px;
    flex-shrink: 0;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.section-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--primary);
    margin: 0.35rem 0 0;
}

.toggle-row {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--card-border);
}

.switch-label {
    font-size: 0.875rem;
    color: var(--text-main);
    line-height: 1.3;
}

.folder-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.folder-list {
    list-style: none;
    min-height: 4.5rem;
    max-height: 8rem;
    overflow-y: auto;
    background: #0a101c;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.35rem;
}

.folder-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    gap: 0.5rem;
}

.folder-list li:hover {
    background: rgba(255, 255, 255, 0.04);
}

.folder-list li.selected {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.folder-name {
    font-weight: 500;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.folder-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.folder-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.origin-actions-row {
    flex-direction: row;
    flex-wrap: wrap;
}

.origin-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: start;
}

.origin-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.75rem;
}

.compact-grid .span-2 {
    grid-column: span 2;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.field-block label,
.option-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.option-block {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.6rem 0.65rem;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background-color: #0a101c;
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
}

textarea {
    min-height: 4.5rem;
    line-height: 1.4;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

.input-with-button {
    display: flex;
    gap: 0.4rem;
}

.input-with-button input {
    flex: 1;
    min-width: 0;
}

.input-with-button .btn-browse {
    flex-shrink: 0;
    min-width: 5.75rem;
    padding: 0.6rem 0.85rem;
}

.btn-secondary,
.btn-ghost {
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    font-family: inherit;
}

.btn-secondary {
    background-color: #243044;
    color: var(--text-main);
    border: 1px solid #3a506e;
    padding: 0.55rem 0.75rem;
}

.btn-secondary:hover {
    background-color: #2f3f58;
    border-color: #4a6280;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 0.55rem 0.65rem;
}

.btn-ghost:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.btn-compact {
    padding: 0.55rem 0.7rem;
}

.pill-group {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.pill-group-vertical {
    flex-direction: column;
}

.pill-option {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.pill-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pill-option span {
    display: inline-block;
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: #0a101c;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.pill-option:hover span {
    border-color: #4a6280;
    color: var(--text-main);
}

.pill-option input:checked + span {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.pill-radio span {
    border-radius: 8px;
    width: 100%;
}

.inline-switch {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    margin: 0;
    width: 100%;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

.inline-switch input {
    display: none;
}

.mini-slider {
    width: 36px;
    height: 20px;
    background-color: #334155;
    border-radius: 20px;
    position: relative;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

.mini-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #fff;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.inline-switch input:checked + .mini-slider {
    background-color: var(--primary);
}

.inline-switch input:checked + .mini-slider::before {
    transform: translateX(16px);
}

.form-actions {
    margin-top: 0.85rem;
}

.dashboard-action-row {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--card-border);
}

.btn-dashboard-link {
    display: inline-flex;
    text-decoration: none;
    width: 100%;
    justify-content: center;
}

.btn-primary {
    width: 100%;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    padding: 0.8rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.28);
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(14, 165, 233, 0.38);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.results-container {
    margin-top: 1rem;
    border-top: 1px solid var(--card-border);
    padding-top: 1rem;
}

.results-header h2 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.processing { background-color: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-indicator.success { background-color: var(--success); box-shadow: 0 0 6px var(--success); }
.status-indicator.error { background-color: var(--error); box-shadow: 0 0 6px var(--error); }

.status-box {
    background-color: #0a101c;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.875rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

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

.output-details {
    margin-top: 0.85rem;
}

.metric-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(14, 165, 233, 0.08) 100%);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    margin-bottom: 0.85rem;
}

.metric-number {
    display: block;
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--success);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.details-list h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.65rem;
    margin-bottom: 0.3rem;
}

.path-display {
    background-color: #0a101c;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--primary);
    word-break: break-all;
}

.files-list {
    list-style: none;
}

.files-list li {
    background-color: #0a101c;
    border: 1px solid var(--card-border);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.3rem;
    font-family: 'Consolas', monospace;
    font-size: 0.78rem;
    color: #cbd5e1;
}

.results-by-folder {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--card-border);
}

.folder-result-item {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
}

.folder-result-item.error {
    color: var(--error);
}

.hidden {
    display: none !important;
}

@media (max-width: 560px) {
    .origin-panel {
        grid-template-columns: 1fr;
    }

    .origin-actions {
        flex-direction: row;
    }

    .compact-grid,
    .options-grid {
        grid-template-columns: 1fr;
    }

    .compact-grid .span-2 {
        grid-column: span 1;
    }
}
