/* ==========================================================================
   Sistema de Consulta de Listas Negras — Base Stylesheet
   Stack: Plain CSS, no frameworks
   ========================================================================== */

/* ── CSS Custom Properties ─────────────────────────────────────────────────── */
:root {
    /* Brand */
    --color-primary:       #1e3a5f;
    --color-primary-dark:  #152c47;
    --color-primary-light: #2d5986;

    /* Accent */
    --color-accent:      #c0392b;

    /* Neutrals */
    --color-bg:          #f0f4f8;
    --color-surface:     #ffffff;
    --color-border:      #d1d8e0;
    --color-text:        #1a2332;
    --color-text-muted:  #6b7c93;

    /* Semantic */
    --color-success:     #059669;
    --color-error:       #dc2626;
    --color-warning:     #d97706;
    --color-info:        #2563eb;

    /* UI */
    --radius:    6px;
    --radius-lg: 10px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);

    /* Typography */
    --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

    /* Transition */
    --transition: 0.15s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a           { color: var(--color-primary); text-decoration: none; }
a:hover     { text-decoration: underline; }
img, svg    { display: block; max-width: 100%; }
button      { font-family: var(--font); }

/* ── Site Header ────────────────────────────────────────────────────────────── */
.site-header {
    background: var(--color-primary);
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow-md);
}

/* ── Fila 1: datos notaría + navegación ────── */
.site-header__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    height: 52px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

/* ── Fila 2: título del sistema + logo ─────── */
.site-header__brandbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .5rem 1.5rem;
    background: var(--color-primary-dark);
}

.site-header__title {
    font-size: .875rem;
    font-weight: 500;
    color: rgba(255,255,255,.82);
    letter-spacing: .015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

/* Brand-bar clickable title link */
.site-header__brand-link {
    font-size: .875rem;
    font-weight: 500;
    color: rgba(255,255,255,.82);
    letter-spacing: .015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--transition);
}
.site-header__brand-link:hover,
.site-header__brand-link:focus-visible {
    color: #fff;
    text-decoration: none;
}
.site-header__brand-link:focus-visible {
    outline: 2px solid rgba(255,255,255,.6);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Brand-bar logo link wrapper */
.site-header__logo-link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
    text-decoration: none;
    cursor: pointer;
    border-radius: var(--radius);
    transition: opacity var(--transition);
}
.site-header__logo-link:hover,
.site-header__logo-link:focus-visible { opacity: .82; }
.site-header__logo-link:focus-visible {
    outline: 2px solid rgba(255,255,255,.6);
    outline-offset: 3px;
}

.site-header__logo {
    height: 38px;
    width: auto;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

/* ── Datos de la notaría ─────────────────────── */
.notary-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
    line-height: 1.25;
}
.notary-info__name {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .07em;
    color: #fff;
    text-transform: uppercase;
}
.notary-info__location {
    font-size: .67rem;
    color: rgba(255,255,255,.62);
    letter-spacing: .05em;
    text-transform: uppercase;
}

/* ── Navegación principal ────────────────────── */
.main-nav {
    display: flex;
    align-items: center;
    gap: .15rem;
    flex-shrink: 0;
}

.main-nav__link {
    color: rgba(255,255,255,.82);
    padding: .375rem .7rem;
    border-radius: var(--radius);
    font-size: .875rem;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.main-nav__link:hover  { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.main-nav__link:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: 2px; }

.main-nav__sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,.2);
    margin: 0 .4rem;
    flex-shrink: 0;
}

.main-nav__user {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .82rem;
    color: rgba(255,255,255,.72);
    white-space: nowrap;
    flex-shrink: 0;
}

.main-nav__logout {
    flex-shrink: 0;
}

/* ── Botón hamburger (solo visible en móvil) ─── */
.site-header__toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 26px;
    height: 19px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.site-header__toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: #fff;
    border-radius: 2px;
    transition: transform var(--transition), opacity var(--transition);
}
/* Animación X al abrir */
.site-header__toggle--open span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.site-header__toggle--open span:nth-child(2) { opacity: 0; }
.site-header__toggle--open span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

/* ── Main content ───────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), transform .1s;
    white-space: nowrap;
}
.btn:active       { transform: scale(.98); }
.btn:focus-visible{ outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn--primary  { background: var(--color-primary);  color: #fff; }
.btn--primary:hover  { background: var(--color-primary-light); color: #fff; text-decoration: none; }

.btn--secondary { background: #e5eaf0; color: var(--color-text); }
.btn--secondary:hover { background: #d2dbe5; text-decoration: none; }

.btn--danger   { background: var(--color-error); color: #fff; }
.btn--danger:hover { background: #b91c1c; text-decoration: none; }

.btn--ghost    { background: transparent; color: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.3); }
.btn--ghost:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }

.btn--full { width: 100%; }
.btn--sm   { padding: .3rem .75rem; font-size: .8rem; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 1rem; }

.form__group { display: flex; flex-direction: column; gap: .35rem; }

.form__label { font-size: .875rem; font-weight: 500; color: var(--color-text); }

.form__input,
.form__select,
.form__textarea {
    width: 100%;
    padding: .6rem .875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form__input:focus,
.form__select:focus,
.form__textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,.15);
}
.form__textarea { resize: vertical; min-height: 100px; }
.form__hint     { font-size: .8rem; color: var(--color-text-muted); }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    border-left: 4px solid transparent;
}
.alert--error   { background: #fef2f2; color: #991b1b; border-left-color: var(--color-error); }
.alert--success { background: #f0fdf4; color: #14532d; border-left-color: var(--color-success); }
.alert--warning { background: #fffbeb; color: #78350f; border-left-color: var(--color-warning); }
.alert--info    { background: #eff6ff; color: #1e40af; border-left-color: var(--color-info); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.badge--admin    { background: #dbeafe; color: #1e40af; }
.badge--operator { background: #dcfce7; color: #166534; }

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.page-header__title { font-size: 1.5rem; font-weight: 700; color: var(--color-text); }
.page-header__sub   { font-size: .875rem; color: var(--color-text-muted); margin-top: .15rem; }

/* ── Dashboard cards ────────────────────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1.25rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}
.card--link { text-decoration: none; color: inherit; cursor: pointer; }
.card--link:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }

.card__icon { color: var(--color-primary); }
.card__title { font-size: 1.05rem; font-weight: 600; color: var(--color-text); }
.card__desc  { font-size: .875rem; color: var(--color-text-muted); flex: 1; }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: 85vh;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-card__header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
.login-card__logo        { margin-bottom: .25rem; }
.login-card__logo-img    { max-width: 220px; width: 100%; height: auto; display: block; margin: 0 auto; }
.login-card__title       { font-size: 1rem; font-weight: 600; color: var(--color-primary); line-height: 1.4; }
.login-card__subtitle    { font-size: .875rem; color: var(--color-text-muted); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--color-border); }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th {
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 600;
    text-align: left;
    padding: .75rem 1rem;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}
td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--color-bg); }

/* ── Search module ──────────────────────────────────────────────────────────── */
.search-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-sm);
}

.search-form { display: flex; flex-direction: column; gap: 1.25rem; }

.search-form__row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}
.search-form__input-wrap { flex: 1; display: flex; flex-direction: column; gap: .375rem; }
.search-form__input-wrap label { font-size: .875rem; font-weight: 600; color: var(--color-text); }

.form__input--lg {
    font-size: 1rem;
    padding: .65rem 1rem;
    border-radius: var(--radius);
    border: 1.5px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color .15s;
    width: 100%;
}
.form__input--lg:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.12);
}

.btn--search {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: .65rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.btn--search:hover { background: var(--color-primary-dark); }

/* Source filter checkboxes */
.source-filters { display: flex; flex-direction: column; gap: .625rem; }

.source-filters__legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.source-filters__legend span {
    font-size: .875rem;
    font-weight: 600;
    color: var(--color-text);
}
.source-filters__actions { display: flex; gap: .5rem; }

.source-filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .5rem;
}

.source-filter {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: .45rem .75rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.source-filter input[type="checkbox"] { accent-color: var(--color-primary); width: 1rem; height: 1rem; cursor: pointer; }
.source-filter:hover { border-color: var(--color-primary); background: var(--color-surface); }
.source-filter input[type="checkbox"]:checked + .source-filter__label { color: var(--color-primary); font-weight: 600; }

.source-filter__label { font-size: .875rem; color: var(--color-text); }

/* ── Last-update dates (inside source-filters fieldset) ──────────────────────── */
.source-update-info {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}
.source-update-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    margin: 0 0 .6rem;
}
.source-update-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: .5rem;
}
.source-update-card {
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: .55rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.source-update-name {
    font-weight: 700;
    color: var(--color-primary);
    font-size: .8rem;
}
.source-update-date {
    color: var(--color-text-muted);
    font-size: .78rem;
}
.source-update-date--none {
    font-style: italic;
    opacity: .8;
}
@media (max-width: 640px) {
    .source-update-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: .4rem;
    }
    .source-update-card {
        padding: .5rem .6rem;
    }
    .source-update-name,
    .source-update-date {
        font-size: .75rem;
    }
}
@media (max-width: 360px) {
    .source-update-grid {
        grid-template-columns: 1fr;
    }
}

.btn--ghost-dark {
    background: transparent;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: .75rem;
    font-weight: 600;
    padding: .3rem .75rem;
    transition: border-color .15s, color .15s;
}
.btn--ghost-dark:hover { border-color: var(--color-primary); color: var(--color-primary); }

.btn--xs { font-size: .75rem; padding: .3rem .75rem; }

/* Results */
.results-section { margin-top: 1rem; }

.results-header {
    display: flex;
    align-items: baseline;
    gap: .625rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.results-header__title { font-size: 1rem; font-weight: 700; color: var(--color-text); }
.results-header__query {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    font-style: italic;
    word-break: break-all;
}

.badge--results {
    display: inline-flex;
    align-items: center;
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    padding: .15rem .6rem;
    margin-left: .25rem;
    vertical-align: middle;
}

.result__name  { font-weight: 600; color: var(--color-text); }
.result__date  { white-space: nowrap; }

/* Source badges per list */
.source-badge {
    display: inline-block;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .65rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #fff;
}
.source-badge--sat     { background: #1e40af; }
.source-badge--ofac    { background: #9a3412; }
.source-badge--anexo_a { background: #065f46; }
.source-badge--anexo_b { background: #4d7c0f; }
.source-badge--anexo_c { background: #6b21a8; }
.source-badge--anexo_d { background: #0e7490; }

/* Empty state */
.results-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 1.5rem 1rem;
    color: var(--color-text-muted);
    text-align: center;
}
.results-empty svg { opacity: .35; }
.results-empty__title { font-size: 1.05rem; font-weight: 700; color: var(--color-text); margin: 0; }
.results-empty__sub   { font-size: .875rem; color: var(--color-text-muted); margin: 0; max-width: 320px; }

/* Error alert inside search */
.alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: .875rem;
    font-weight: 500;
}

/* ── Error pages ────────────────────────────────────────────────────────────── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 1rem;
    text-align: center;
}
.error-page__code { font-size: 5rem; font-weight: 800; color: var(--color-primary); line-height: 1; }
.error-page__msg  { font-size: 1.1rem; color: var(--color-text-muted); max-width: 360px; }

/* ── User management module ─────────────────────────────────────────────────── */

/* Status badges */
.badge--active   { background: #dcfce7; color: #166534; }
.badge--inactive { background: #fee2e2; color: #991b1b; }

/* Table helpers */
.table-empty { text-align: center; color: var(--color-text-muted); padding: 2.5rem 1rem; font-size: .9rem; }
.td-bold     { font-weight: 600; }
.td-date     { white-space: nowrap; color: var(--color-text-muted); font-size: .825rem; }
.text-muted  { color: var(--color-text-muted); }

/* Action cell: edit + delete side by side */
.table-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* Form card (create / edit screens) */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-sm);
}

/* Form sections with a subtle top divider */
.form-section {
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.form-section:first-child { border-top: none; padding-top: 0; }

.form-section__title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}
.form-section__optional {
    font-weight: 400;
    font-size: .8rem;
    color: var(--color-text-muted);
}

/* Two-column grid for form fields on wider screens */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 1.5rem;
}

/* Validation error state on a form group */
.form__group--error .form__input,
.form__group--error .form__select {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}
.form__error {
    font-size: .8rem;
    color: var(--color-error);
    margin-top: .15rem;
}

/* Required asterisk */
.required { color: var(--color-error); font-weight: 700; }

/* Form action bar (cancel + submit) */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    margin-top: .5rem;
}

/* ── Form Row (legacy row layout) ───────────────────────────────────────────── */
.form-rows { display: flex; flex-direction: column; gap: .875rem; }

.form-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: start;
    column-gap: 1.25rem;
}
.form-row--error .form__input,
.form-row--error .form__select { border-color: var(--color-danger); }

.form-row__label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-text);
    text-align: right;
    padding-top: .575rem; /* visually align with input height */
    line-height: 1.4;
}

.form-row__field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.form-row__check {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding-top: .5rem;
    cursor: pointer;
}
.form-row__check input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
}
.form-row__check-label {
    font-size: .9rem;
    color: var(--color-text);
}

/* ── Logo preview ────────────────────────────────────────────────────────────── */
.logo-preview {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
}
.logo-preview__img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #f8f9fa;
    padding: 4px;
    flex-shrink: 0;
}
.logo-preview__label {
    font-size: .8rem;
    color: var(--color-text-muted, #6c757d);
}

/* ── Logo current block (edit view) ─────────────────────────────────────────── */
.logo-current {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
}

/* Wrapper button around the thumbnail */
.logo-current__thumb-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius);
    flex-shrink: 0;
    line-height: 0;
}
.logo-current__thumb-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Hover effect on clickable thumbnail */
.logo-preview__img--clickable {
    cursor: pointer;
    transition: opacity var(--transition);
}
.logo-current__thumb-btn:hover .logo-preview__img--clickable,
.logo-current__thumb-btn:focus-visible .logo-preview__img--clickable {
    opacity: .75;
}

/* Info column (label + trash button) */
.logo-current__info {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

/* Pending removal: grey-out the thumbnail */
.logo-current--pending-removal .logo-preview__img {
    opacity: .3;
    filter: grayscale(100%);
    transition: opacity .2s, filter .2s;
}

/* ── Removal notice / undo ───────────────────────────────────────────────────── */
.logo-removal-notice {
    align-items: center;
    gap: .6rem;
    margin-bottom: .5rem;
    padding: .45rem .75rem;
    background: #fff8e1;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    font-size: .85rem;
    color: #78350f;
    flex-wrap: wrap;
}
.logo-removal-notice__text {
    flex: 1;
    min-width: 0;
}

/* Undo button */
.logo-undo-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .65rem;
    border-radius: var(--radius);
    font-size: .8rem;
    font-family: var(--font);
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
}
.logo-undo-btn:hover { background: #dbeafe; border-color: #60a5fa; }
.logo-undo-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}
.logo-undo-btn svg { width: 13px; height: 13px; }

/* ── Logo modal overlay ──────────────────────────────────────────────────────── */
.logo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.logo-modal__content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 1rem 1rem;
    max-width: min(90vw, 600px);
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-modal__close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius);
    padding: .3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
}
.logo-modal__close:hover { color: var(--color-text); background: var(--color-bg); }
.logo-modal__close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}
.logo-modal__close svg { width: 20px; height: 20px; }

.logo-modal__img {
    max-width: 100%;
    max-height: calc(90vh - 5rem);
    object-fit: contain;
    border-radius: var(--radius);
    display: block;
}

@media (max-width: 480px) {
    .logo-modal__content { padding: 2.25rem .75rem .75rem; }
}

/* ── Icon Buttons ────────────────────────────────────────────────────────────── */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn-icon:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-icon[disabled]     { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-icon svg           { width: 18px; height: 18px; pointer-events: none; }

.btn-icon--edit  { color: #1e40af; }
.btn-icon--edit:hover  { background: #dbeafe; }
.btn-icon--delete { color: #dc2626; }
.btn-icon--delete:hover { background: #fee2e2; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* ── Responsive: site-header ─── */
    .site-header__toggle { display: flex; }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-primary-dark);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: .5rem 1rem .75rem;
        box-shadow: 0 4px 10px rgba(0,0,0,.22);
        z-index: 10;
    }
    .main-nav--open { display: flex; }

    .main-nav__link  { width: 100%; padding: .6rem .5rem; }
    .main-nav__sep   { width: 100%; height: 1px; margin: .35rem 0; }
    .main-nav__user  { padding: .35rem .5rem; width: 100%; }
    .main-nav__logout { width: 100%; }
    .main-nav__logout .btn { width: 100%; justify-content: center; }

    .site-header__title,
    .site-header__brand-link {
        font-size: .78rem;
        white-space: normal;
    }
    .site-header__logo { height: 28px; }

    .main-content { padding: 1.25rem 1rem; }
    .page-header  { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .login-card   { padding: 1.75rem 1.25rem; }
    .cards-grid   { grid-template-columns: 1fr; }

    .search-card  { padding: 1.25rem 1rem; }
    .search-form__row { flex-direction: column; align-items: stretch; }
    .btn--search  { width: 100%; }
    .source-filters__grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

    .form-card  { padding: 1.25rem 1rem; }
    .form-grid  { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .btn { width: 100%; justify-content: center; }

    /* Legacy row layout on mobile */
    .form-row { grid-template-columns: 1fr; }
    .form-row__label { text-align: left; padding-top: 0; }
}

@media (max-width: 480px) {
    .error-page__code { font-size: 4rem; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Import module
───────────────────────────────────────────────────────────────────────────── */

/* ── Import result summary card ─── */
.import-result {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.import-result__header {
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: 1rem;
    font-weight: 600;
    color: #166534;
    margin-bottom: 1rem;
}
.import-result__header svg { flex-shrink: 0; color: #16a34a; }

/* Stats grid */
.import-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: .75rem;
}

.import-stat {
    background: #fff;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: .65rem .85rem;
}
.import-stat--success { border-color: #4ade80; background: #f0fdf4; }
.import-stat--warning { border-color: #fde68a; background: #fffbeb; }

.import-stat__label {
    display: block;
    font-size: .75rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-bottom: .2rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.import-stat__value {
    display: block;
    font-size: .95rem;
    font-weight: 600;
    color: var(--color-text);
    word-break: break-word;
}
.import-stat__value--num {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-primary);
}
.import-stat--warning .import-stat__value--num { color: #b45309; }

.import-result__note {
    font-size: .82rem;
    color: #166534;
    margin: .35rem 0 0;
}
.import-result__note--replace {
    color: var(--color-text-muted);
    font-style: italic;
}

/* ── Import file rules info box ─── */
.import-file-rules {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    margin-top: .35rem;
    font-size: .82rem;
    color: var(--color-text-muted);
}
.import-file-rules__title {
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 .3rem;
}
.import-file-rules__list {
    margin: 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Taxpayer status badges (SAT results)
───────────────────────────────────────────────────────────────────────────── */
.taxpayer-badge {
    display: inline-block;
    border-radius: var(--radius);
    font-size: .72rem;
    font-weight: 700;
    padding: .2rem .6rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #fff;
    background: #6b7280; /* default / unknown */
    white-space: nowrap;
}

/* DEFINITIVO — dark red (real confirmed evader) */
.taxpayer-badge--definitivo        { background: #991b1b; }
/* PRESUNTO — amber/orange (suspected) */
.taxpayer-badge--presunto          { background: #b45309; }
/* DESVIRTUADO — gray-blue (disproved) */
.taxpayer-badge--desvirtuado       { background: #475569; }
/* SENTENCIA FAVORABLE — green */
.taxpayer-badge--sentencia-favorable { background: #15803d; }

/* ── Search results: RFC column ─── */
.result__rfc { white-space: nowrap; }

/* ── Responsive: import stats grid on small screens ─── */
@media (max-width: 600px) {
    .import-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
    .import-stats { grid-template-columns: 1fr; }
}

/* ── Responsive: search results table (5 cols) ─── */
@media (max-width: 768px) {
    /* Hide RFC and status on small screens — they appear in SAT results only */
    .result__rfc { display: none; }
    th:nth-child(3),
    th:nth-child(4),
    td:nth-child(3),
    td:nth-child(4) { display: none; }
}

/* ── Certificate section (shown below 0-result message) ─────────────────────── */
.cert-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    margin-top: .75rem;
    padding: .75rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
}

.cert-section__hint {
    margin: 0;
    font-size: .9rem;
    color: var(--text-muted);
}

.btn--cert {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

/* ── Certificate confirmation dialog ────────────────────────────────────────── */
.cert-dialog {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    padding: 0;
    max-width: 480px;
    width: 90%;
    /* Center in viewport across all browsers when opened with showModal() */
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
}

.cert-dialog::backdrop {
    background: rgba(0, 0, 0, .45);
}

.cert-dialog__body {
    padding: 2rem 2rem 1.5rem;
}

.cert-dialog__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem;
}

.cert-dialog__text {
    margin: 0 0 .4rem;
    font-size: .95rem;
    color: var(--text-secondary);
}

.cert-dialog__entity {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-alt, #f1f5f9);
    border-radius: var(--radius);
    padding: .4rem .75rem;
    margin: 0 0 .75rem;
    word-break: break-word;
}

.cert-dialog__note {
    font-size: .82rem;
    color: var(--text-muted);
    margin: 0 0 .75rem;
}

/* ── User form: constancia configuration section title ───────────────────── */
.form-row--section-title {
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    margin-top: .5rem;
    align-items: center;
}

.form-row__section-label {
    font-weight: 600;
    font-size: .95rem;
    color: var(--color-text);
    grid-column: 1 / -1;
}

/* ── Certificate dialog ──────────────────────────────────────────────────── */
.cert-dialog__actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
}
        flex-direction: column-reverse;
    }
    .cert-dialog__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── Responsive: users table → card layout on mobile ──────────────────────── */
@media (max-width: 768px) {
    .users-table thead { display: none; }

    .users-table,
    .users-table tbody,
    .users-table tr,
    .users-table td { display: block; width: 100%; box-sizing: border-box; }

    .users-table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        margin-bottom: 1rem;
        padding: .75rem 1rem .6rem;
        box-shadow: 0 1px 4px rgba(0,0,0,.06);
    }

    .users-table td {
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: .3rem 0;
        border: none;
        font-size: .92rem;
        color: var(--text-primary);
        min-height: 1.9rem;
        word-break: break-word;
    }

    .users-table td::before {
        content: attr(data-label);
        font-size: .78rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--text-muted);
        min-width: 78px;
        flex-shrink: 0;
    }

    .users-table td[data-label="Acciones"] {
        border-top: 1px solid var(--border);
        margin-top: .45rem;
        padding-top: .6rem;
        justify-content: flex-end;
    }
    .users-table td[data-label="Acciones"]::before { display: none; }

    .users-table .table-actions {
        justify-content: flex-end;
        gap: .75rem;
    }

    /* Empty-state row */
    .users-table td.table-empty {
        justify-content: center;
        text-align: center;
        padding: 1rem 0;
    }
    .users-table td.table-empty::before { display: none; }
}

