html, body { overflow-x: hidden; }
img, svg { max-width: 100%; }

.sede-stepper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 2rem;
    counter-reset: step;
    position: relative;
}

.sede-stepper__item {
    flex: 1 1 0;
    position: relative;
    text-align: center;
    padding: 0 0.5rem;
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 600;
}

.sede-stepper__item::before {
    counter-increment: step;
    content: counter(step);
    display: block;
    width: 2.25rem;
    height: 2.25rem;
    line-height: 2.25rem;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
    background: #ffffff;
    border: 2px solid #dee2e6;
    color: #6c757d;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.sede-stepper__item:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 1.125rem;
    left: 50%;
    right: -50%;
    height: 2px;
    background: #dee2e6;
    z-index: -1;
}

.sede-stepper__item--done::before {
    background: var(--primary, #005eb5);
    border-color: var(--primary, #005eb5);
    color: #fff;
}

.sede-stepper__item--done:not(:last-child)::after {
    background: var(--primary, #005eb5);
}

.sede-stepper__item--active {
    color: var(--primary, #005eb5);
}

.sede-stepper__item--active::before {
    background: var(--primary, #005eb5);
    border-color: var(--primary, #005eb5);
    color: #fff;
}

.step-section {
    display: none;
}

.step-section.active {
    display: block;
}

.sede-auth-title {
    color: var(--azul-oscuro, #001f53);
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
}

.sede-auth-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 0 0 1rem;
}

.sede-auth-tile {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.875rem;
    padding: 1.125rem 1rem;
    min-height: 96px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    color: var(--azul-oscuro, #001f53);
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sede-auth-tile:hover {
    border-color: var(--primary, #005eb5);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 94, 181, 0.18);
    background: var(--azul-blanco, #f1f8fe);
}

.sede-auth-tile:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem #ffcd00;
}

.sede-auth-tile[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.sede-auth-tile__icon {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    color: var(--primary, #005eb5);
}

.sede-auth-tile--clave .sede-auth-tile__icon {
    color: var(--clave, #f60);
}

.sede-auth-tile__label {
    flex: 1 1 auto;
    font-size: 1rem;
    line-height: 1.25;
}

.sede-auth-help {
    color: #6c757d;
    margin: 0.25rem 0 1.25rem;
}

.sede-auth-help a {
    color: var(--primary, #005eb5);
    text-decoration: underline;
}

.sede-auth-explain {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    margin-top: 1.5rem;
}

.sede-auth-explain__col p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #333;
}

.sede-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid rgba(0, 94, 181, 0.2);
    border-top-color: var(--primary, #005eb5);
    border-radius: 50%;
    animation: sede-spin 0.9s linear infinite;
    vertical-align: middle;
}

.sede-spinner--inline {
    margin-right: 0.5rem;
}

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

.sede-alert-danger {
    display: flex;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    border: 1px solid var(--rojo, #da291c);
    border-left: 4px solid var(--rojo, #da291c);
    background: #fdecea;
    color: #7a1711;
    border-radius: 0.25rem;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.sede-alert-danger__icon {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.5rem;
    margin-top: 0.1rem;
    color: var(--rojo, #da291c);
}

.sede-form {
    margin-top: 1rem;
}

.sede-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 575px) {
    .sede-form__row {
        grid-template-columns: 1fr;
    }
}

.sede-form__group {
    margin-bottom: 0.75rem;
}

.sede-form__group--full {
    grid-column: 1 / -1;
}

.sede-form__label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #333;
    font-size: 0.95rem;
}

.sede-form__label .sede-form__required {
    color: var(--rojo, #da291c);
    margin-left: 0.15rem;
}

.sede-form__help {
    display: block;
    font-size: 0.825rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.sede-form__error {
    display: none;
    font-size: 0.85rem;
    color: var(--rojo, #da291c);
    margin-top: 0.25rem;
    font-weight: 600;
}

.sede-form__group--invalid .sede-form__error {
    display: block;
}

.sede-form__group--invalid .form-control {
    border-color: var(--rojo, #da291c);
}

.sede-wizard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e9ecef;
}

.sede-wizard-actions .btn {
    min-width: 8rem;
}

@media (max-width: 575px) {
    .sede-wizard-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .sede-wizard-actions .btn {
        min-width: 0;
        flex: 1 1 45%;
        padding: 0.55rem 0.75rem;
        font-size: 0.95rem;
    }
}

.sede-step-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.sede-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    line-height: 1.2;
}

.sede-badge--muted {
    background: #e9ecef;
    color: #495057;
}

.sede-upload-card {
    margin: 1.25rem 0;
}

.sede-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 2px dashed var(--primary, #005eb5);
    border-radius: 0.5rem;
    padding: 2.25rem 1.25rem 2rem;
    text-align: center;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    color: #333;
    margin: 0;
}

.sede-upload-zone:hover,
.sede-upload-zone--drag {
    background: var(--azul-blanco, #f1f8fe);
    border-color: var(--dark-primary, #003669);
}

.sede-upload-zone:focus-within {
    outline: none;
    box-shadow: 0 0 0 0.2rem #ffcd00;
}

.sede-upload-zone input[type="file"] {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.sede-upload-zone__icon {
    width: 2.75rem;
    height: 2.75rem;
    color: var(--primary, #005eb5);
    margin-bottom: 0.25rem;
}

.sede-upload-zone__primary {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--azul-oscuro, #001f53);
}

.sede-upload-zone__or {
    margin: 0.1rem 0;
    font-size: 0.85rem;
    color: #6c757d;
}

.sede-upload-zone__btn {
    pointer-events: none;
    padding: 0.45rem 1.25rem;
    font-weight: 700;
    margin: 0.25rem 0 0.75rem;
}

.sede-upload-zone__hint {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: center;
}

.sede-upload-zone__formats {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.sede-format-chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.12rem 0.5rem;
    border-radius: 0.25rem;
    background: var(--azul-blanco, #f1f8fe);
    border: 1px solid #c1e0fb;
    color: var(--primary, #005eb5);
}

.sede-upload-errors {
    margin: 0 0 0.75rem;
}

.sede-upload-errors:empty {
    display: none;
}

.sede-upload-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--rojo, #da291c);
    border-left: 4px solid var(--rojo, #da291c);
    background: #fdecea;
    color: #7a1711;
    border-radius: 0.25rem;
    font-size: 0.9rem;
    margin-top: 0.4rem;
}

.sede-upload-error__icon {
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    color: var(--rojo, #da291c);
    margin-top: 0.15rem;
}

.sede-upload-error__body { flex: 1 1 auto; }

.sede-file-panel {
    margin-top: 0.25rem;
}

.sede-file-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.35rem 0 0.5rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 0.5rem;
}

.sede-file-panel__title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--azul-oscuro, #001f53);
}

.sede-file-panel__summary {
    font-size: 0.82rem;
    color: #6c757d;
    font-variant-numeric: tabular-nums;
}

.sede-file-panel--empty { display: none; }

.sede-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sede-file-list__item {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    background: #fff;
    font-size: 0.92rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.sede-file-list__item:hover {
    background: #fafbfc;
    border-color: #dee2e6;
}

.sede-file-list__type {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    background: var(--azul-blanco, #f1f8fe);
    color: var(--primary, #005eb5);
}

.sede-file-list__type svg { width: 1.25rem; height: 1.25rem; }

.sede-file-list__name {
    min-width: 0;
    font-weight: 600;
    color: #212529;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

.sede-file-list__size {
    color: #6c757d;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sede-file-list__status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--verde, #080);
    padding: 0.15rem 0.45rem;
    border-radius: 0.25rem;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    white-space: nowrap;
}

.sede-file-list__status svg { width: 0.85rem; height: 0.85rem; }

.sede-file-list__remove {
    background: transparent;
    border: 1px solid transparent;
    color: var(--rojo, #da291c);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sede-file-list__remove:hover {
    background: #fdecea;
    border-color: #f8c7c2;
}

.sede-file-list__remove:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem #ffcd00;
}

.sede-confirm-card {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin: 1.5rem 0 0.5rem;
    padding: 1rem 1.1rem;
    background: var(--azul-blanco, #f1f8fe);
    border: 1px solid #c1e0fb;
    border-radius: 0.375rem;
}

.sede-confirm-card__row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    cursor: pointer;
    color: #212529;
}

.sede-confirm-card__row input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    accent-color: var(--primary, #005eb5);
}

.sede-confirm-card__row input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem #ffcd00;
}

@media (max-width: 575px) {
    .sede-confirm-card {
        padding: 0.85rem 0.9rem;
        gap: 0.75rem;
    }
    .sede-confirm-card__row { font-size: 0.9rem; }
}

.sede-receipt {
    background: #fff;
    border: 1px solid #dee2e6;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    padding: 1.5rem;
    border-radius: 0.25rem;
    margin: 1.5rem 0;
}

.sede-receipt__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary, #005eb5);
    margin-bottom: 1.25rem;
}

.sede-receipt__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: var(--primary, #005eb5);
    font-size: 1rem;
}

.sede-receipt__title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--azul-oscuro, #001f53);
    margin: 0 0 1rem;
}

.sede-receipt__rows {
    margin-bottom: 1.25rem;
}

.sede-receipt__row {
    display: flex;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

.sede-receipt__label {
    flex: 0 0 40%;
    max-width: 40%;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    padding-right: 0.75rem;
}

.sede-receipt__value {
    flex: 1 1 60%;
    max-width: 60%;
    font-size: 0.95rem;
    word-break: break-word;
}

@media (max-width: 575px) {
    .sede-receipt__label,
    .sede-receipt__value {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.sede-receipt__detail {
    margin: 1rem 0 1.25rem;
    padding: 0.85rem 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.25rem;
}

.sede-receipt__detail-title {
    font-weight: 600;
    color: #333;
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.sede-receipt__detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sede-receipt__detail-list li {
    padding: 0.25rem 0;
    font-size: 0.9rem;
    color: #333;
}

.sede-receipt__detail-list li::before {
    content: "• ";
    color: var(--primary, #005eb5);
    font-weight: 700;
}

.sede-receipt__csv {
    margin: 1.25rem 0;
    padding: 1rem;
    background: var(--azul-blanco, #f1f8fe);
    border: 1px solid var(--primary, #005eb5);
    border-radius: 0.25rem;
}

.sede-receipt__csv-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    margin: 0 0 0.3rem;
}

.sede-receipt__csv-value {
    font-family: Consolas, "Courier New", monospace;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--azul-oscuro, #001f53);
    word-break: break-all;
}

.sede-receipt__footer {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    margin-top: 1rem;
}

.sede-receipt__actions {
    margin-top: 1.25rem;
}

.aeat-brand { line-height: 1; min-width: 0; }
.aeat-brand:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem #ffcd00;
}

.aeat-brand-logo {
    background-image: url(../images/gobierno-espana.png);
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 378.85% 737.10%;
    width: 227px;
    height: 62px;
    display: block;
    color: transparent;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 19.2px;
    position: relative;
    text-align: left;
    overflow: hidden;
    text-indent: -9999px;
    flex: 0 0 auto;
}

.aeat-brand-wordmark {
    display: block;
    height: 42px;
    width: auto;
    max-width: 100%;
    flex: 0 1 auto;
}

@media (max-width: 575px) {
    .aeat-brand-logo {
        width: 117px;
        height: 32px;
    }
    .aeat-brand-wordmark { height: 26px; }
}

@media (max-width: 374px) {
    .aeat-brand-wordmark { display: none; }
}

footer.bg-primary .container {
    font-size: 0.85rem;
    line-height: 1.4;
}
footer.bg-primary p.small,
footer.bg-primary .small {
    font-size: 0.78rem;
}

html, body { height: 100%; }
body { margin: 0; }
#body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
#body > main { flex: 1 0 auto; }
#body > footer { flex: 0 0 auto; margin-top: auto; }

#page-intro h1 { font-size: 1.8rem; }
#page-intro h2 { font-size: 1.3rem; }
#page-intro p  { line-height: 1.5; }

.sede-alert-info {
    background: var(--azul-blanco, #f1f8fe);
    border-left: 4px solid var(--primary, #005eb5);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    color: var(--text, #212529);
    font-size: 0.95rem;
}

.sede-asset-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.sede-asset-card {
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
}
.sede-asset-card--invalid {
    border-color: var(--rojo, #da291c);
}
.sede-asset-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f1f1;
}
.sede-asset-card__num { font-weight: 700; color: var(--primary, #005eb5); }
.sede-asset-card__remove {
    background: transparent; border: 0; font-size: 1.25rem; line-height: 1;
    color: var(--rojo, #da291c); cursor: pointer; padding: 0 0.5rem;
}
.sede-asset-card__remove:focus { box-shadow: 0 0 0 0.2rem #ffcd00; outline: 0; }

.sede-asset-card__remove {
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
}

@media (max-width: 575px) {
    .sede-stepper {
        margin: 1rem 0 1.5rem;
    }
    .sede-stepper__item {
        font-size: 0.72rem;
        padding: 0 0.15rem;
        line-height: 1.15;
    }
    .sede-stepper__item::before {
        width: 1.75rem;
        height: 1.75rem;
        line-height: 1.75rem;
        font-size: 0.85rem;
        margin-bottom: 0.35rem;
    }
    .sede-stepper__item:not(:last-child)::after {
        top: 0.875rem;
    }

    .sede-auth-tiles {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .sede-auth-tile {
        min-height: 72px;
        padding: 0.875rem 0.875rem;
    }
    .sede-auth-tile__icon {
        width: 1.5rem;
        height: 1.5rem;
    }
    .sede-auth-tile__label {
        font-size: 0.95rem;
    }
    .sede-auth-explain {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.875rem;
    }

    #page-intro h1 { font-size: 1.45rem; }
    #page-intro h2 { font-size: 1.15rem; }
    #page-intro p  { font-size: 0.95rem; }
    #page-intro .btn { width: 100%; }
    #page-intro .bg-light-blue { padding: 0.875rem; }

    .sede-asset-card { padding: 0.875rem; }
    .sede-asset-card__header { margin-bottom: 0.5rem; }
    #btn-add-asset { width: 100%; }

    .sede-upload-zone {
        padding: 1.75rem 1rem 1.5rem;
    }
    .sede-upload-zone__primary { font-size: 0.95rem; }
    .sede-upload-zone__btn { padding: 0.5rem 1rem; width: 100%; max-width: 20rem; }
    .sede-upload-zone__hint { font-size: 0.8rem; }
    .sede-upload-zone__formats { justify-content: center; }

    .sede-file-list__item {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "type  name    remove"
            "type  meta    remove";
        gap: 0.4rem 0.75rem;
    }
    .sede-file-list__type { grid-area: type; }
    .sede-file-list__name { grid-area: name; }
    .sede-file-list__remove { grid-area: remove; align-self: start; }

    .sede-file-list__size,
    .sede-file-list__status {
        grid-area: meta;
        display: inline-flex;
    }
    .sede-file-list__status {
        margin-left: 0.5rem;
    }

    .sede-receipt { padding: 1rem; }
    .sede-receipt__head { gap: 0.5rem; padding-bottom: 0.75rem; margin-bottom: 1rem; }
    .sede-receipt__brand { font-size: 0.9rem; }
    .sede-receipt__title { font-size: 1.1rem; }
    .sede-receipt__csv-value { font-size: 1.1rem; letter-spacing: 0.06em; }
    .sede-receipt__actions .btn { width: 100%; }
}

@media print {
    header, nav, footer, #page-intro, .sede-stepper, .sede-wizard-actions,
    #step-1, #step-2, #step-3 { display: none !important; }
    #wizard, #step-4, .sede-receipt { display: block !important; }
    .sede-receipt {
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    body { background: #fff !important; }
}
