:root {
    --primary-color: #0B6B3A;
    --secondary-color: #094d2a;
    --text-color: #1a1a1a;
    --background-color: #f5f5f5;
    --component-background: #ffffff;
    --header-text-color: #666666;
    --button-background: var(--primary-color);
    --button-hover-background: var(--secondary-color);
    --button-text-color: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --corrective-color: #DC2626;
    --preventive-color: #097045;
    --border-color: #eeeeee;
    --shimmer-base: #eeeeee;
    --shimmer-highlight: #f7f7f7;
    --corrective-tint: #dc26261a;
    --corrective-border: #dc262640;
    --preventive-tint: #0970451a;
    --preventive-border: #09704540;
    --dashed-border: #d4d4d4;
    --secondary-button-background: #f3f3f3;
    --progress-track: #e5e5e5;
    --pending-text: #a3a3a3;
    --warning-color: #B45309;
    --warning-tint: #d977061a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Open Sans", sans-serif;
}

html, body {
    min-height: 100%;
    width: 100%;
    font-size: 16px;
    padding: 8px;
    background: var(--background-color);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* Diseño de componentes */

/* Vistas */
.upload-view,
.processing-view {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 0;
}

.upload-view[hidden],
.processing-view[hidden] {
    display: none;
}

.view-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.view-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-color);
}

.view-header p {
    max-width: 640px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--header-text-color);
}

.card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 24px;
    border-radius: 12px;
    background: var(--component-background);
    box-shadow: 0 2px 4px var(--shadow-color);
}

/* Botones */
.btn-primary,
.btn-secondary,
.dropzone__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: 10px;
    font: inherit;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.btn-primary {
    padding: 14px 28px;
    background: var(--button-background);
    color: var(--button-text-color);
    font-size: 1rem;
    font-weight: 700;
}

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

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

.btn-secondary,
.dropzone__button {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: var(--secondary-button-background);
    color: var(--text-color);
    font-size: 0.85rem;
}

.btn-secondary:hover,
.dropzone__button:hover {
    border-color: var(--primary-color);
}

.btn-compact {
    padding: 10px 18px;
    font-size: 0.9rem;
}

/* Empresa */
.client-form__header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.client-form__header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
}

.client-form__header p {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--header-text-color);
}

.client-form__tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background: var(--secondary-button-background);
}

.client-form__tabs button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--header-text-color);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.client-form__tabs button[aria-selected="true"] {
    background: var(--component-background);
    color: var(--primary-color);
    font-weight: 700;
    box-shadow: 0 1px 2px var(--shadow-color);
}

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

.client-form__panel[hidden] {
    display: none;
}

.client-form__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 240px;
    min-width: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
}

.field abbr {
    color: var(--corrective-color);
    text-decoration: none;
}

.field input {
    padding: 10px 12px;
    border: 1px solid var(--dashed-border);
    border-radius: 8px;
    font: inherit;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text-color);
}

.field input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--preventive-tint);
}

.client-form__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.client-form__status {
    font-size: 0.8rem;
    color: var(--header-text-color);
}

.client-form__status:empty {
    display: none;
}

.client-form__status[data-tone="success"] { color: var(--preventive-color); }
.client-form__status[data-tone="error"] { color: var(--corrective-color); }

/* Upload */
.dropzones {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1 1 320px;
    min-width: 0;
    padding: 28px 24px;
    border: 2px dashed var(--dashed-border);
    border-radius: 12px;
    background: var(--component-background);
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
}

.dropzone--active {
    border-color: var(--primary-color);
    background: var(--preventive-tint);
}

.dropzone__icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 1.3rem;
}

.dropzone--pdf .dropzone__icon { color: var(--corrective-color); background: var(--corrective-tint); border-color: var(--corrective-border); }
.dropzone--csv .dropzone__icon { color: var(--preventive-color); background: var(--preventive-tint); border-color: var(--preventive-border); }

.dropzone__caption {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.dropzone--pdf .dropzone__caption { color: var(--corrective-color); }
.dropzone--csv .dropzone__caption { color: var(--preventive-color); }

.dropzone__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
}

.dropzone__description {
    max-width: 320px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--header-text-color);
}

.dropzone__button {
    margin-top: 8px;
}

.dropzone__error {
    font-size: 0.8rem;
    color: var(--corrective-color);
}

.dropzone__error:empty {
    display: none;
}

.dropzone__files {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    list-style: none;
}

.dropzone__file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    text-align: left;
    color: var(--text-color);
}

.dropzone__file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropzone__file-size {
    color: var(--header-text-color);
    white-space: nowrap;
}

.dropzone__file button {
    border: none;
    background: transparent;
    color: var(--header-text-color);
    cursor: pointer;
}

.dropzone__file button:hover {
    color: var(--corrective-color);
}

.upload-view__actions {
    display: flex;
    justify-content: center;
}

/* Processing */
.processing-progress__row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-color);
}

.processing-progress__row i {
    color: var(--primary-color);
}

.processing-progress__row strong {
    color: var(--primary-color);
}

.processing-progress__status {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.processing-progress__countdown {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
    color: var(--header-text-color);
}

.processing-progress__countdown[hidden] {
    display: none;
}

.progress-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--progress-track);
    overflow: hidden;
}

.progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-color);
    transition: width 0.4s ease;
}

.processing-stages h2 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--header-text-color);
}

.stage-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    list-style: none;
}

.stage {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1 1 300px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
}

.stage--done {
    border-color: var(--border-color);
}

.stage--active {
    border-color: var(--preventive-border);
    background: var(--preventive-tint);
}

.stage__icon {
    flex: 0 0 18px;
    color: var(--primary-color);
}

.stage__number {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 18px;
    height: 18px;
    border: 1px solid var(--pending-text);
    border-radius: 50%;
    font-size: 0.65rem;
    color: var(--pending-text);
}

.stage__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.stage__text strong {
    font-size: 0.85rem;
    color: var(--text-color);
}

.stage__text span {
    font-size: 0.75rem;
    color: var(--header-text-color);
}

.stage--pending .stage__text strong,
.stage--pending .stage__text span {
    color: var(--pending-text);
}

/* Distintivo de paso */
.step-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 6px 14px;
    border: 1px solid var(--preventive-border);
    border-radius: 999px;
    background: var(--preventive-tint);
    color: var(--preventive-color);
    font-size: 0.75rem;
    font-weight: 700;
}

.step-badge--uppercase {
    text-transform: uppercase;
}

/* Toast */
.toast-region {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
}

.toast {
    --toast-accent: var(--primary-color);
    --toast-tint: var(--preventive-tint);
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--toast-accent);
    border-radius: 12px;
    background: var(--component-background);
    box-shadow: 0 8px 24px var(--shadow-color);
    animation: toast-in 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) both;
}

.toast--success { --toast-accent: var(--preventive-color); --toast-tint: var(--preventive-tint); }
.toast--warning { --toast-accent: var(--warning-color); --toast-tint: var(--warning-tint); }
.toast--error { --toast-accent: var(--corrective-color); --toast-tint: var(--corrective-tint); }

.toast--leaving {
    animation: toast-out 0.25s ease-in both;
}

.toast__icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex: 0 0 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--toast-tint);
    color: var(--toast-accent);
    font-size: 0.95rem;
}

.toast__message {
    flex: 1;
    align-self: center;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-color);
}

.toast__close {
    flex: 0 0 auto;
    padding: 2px 4px;
    border: none;
    background: transparent;
    color: var(--header-text-color);
    cursor: pointer;
}

.toast__close:hover {
    color: var(--text-color);
}

.toast__timer {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--toast-accent);
    opacity: 0.35;
    transform-origin: left;
    animation: toast-timer var(--toast-duration) linear both;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(24px); }
}

@keyframes toast-timer {
    to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast--leaving {
        animation-duration: 0.01ms;
    }
}

/* Leyenda de subsistemas */
.subsystem-legend {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 0 16px;
    border-top: 1px solid var(--dashed-border);
}

.subsystem-legend h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    color: var(--header-text-color);
}

.subsystem-legend__list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    list-style: none;
}

.subsystem-legend__item {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--component-background);
    box-shadow: 0 1px 2px var(--shadow-color);
    font-family: ui-monospace, "Consolas", monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-color);
}
