:root {
    --bg: #f1f5f9;
    --ink: #0e1e3d;
    --muted: #495057;
    --accent: #008bda;
    --accent-2: #d42c7f;
    --paper: #ffffff;
    --line: #d0e4f5;
    --ok: #008bda;
    --err: #d42c7f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", sans-serif;
    background: radial-gradient(circle at 10% -10%, #d0e4f5 0%, transparent 45%), var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(50px);
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
}

.bg-orb-a {
    width: 360px;
    height: 360px;
    background: #008bda;
    top: -120px;
    right: -80px;
}

.bg-orb-b {
    width: 280px;
    height: 280px;
    background: #d42c7f;
    bottom: -90px;
    left: -90px;
}

.shell-header,
.shell-main {
    position: relative;
}

.shell-header {
    z-index: 200;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: blur(8px);
}

.brand {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--ink);
    padding: 0.4rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 8px;
}

nav a:hover {
    border-color: var(--line);
    background: #ffffffaa;
}

/* ── Nav dropdown ───────────────────────────────── */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    display: inline-block;
    cursor: pointer;
    color: var(--ink);
    padding: 0.4rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 8px;
    user-select: none;
    font-size: inherit;
    font-family: inherit;
    white-space: nowrap;
}

.nav-dropdown-toggle:hover,
.nav-dropdown:focus-within .nav-dropdown-toggle {
    border-color: var(--line);
    background: #ffffffaa;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 170px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 24px #00000014;
    z-index: 100;
    padding: 0.4rem;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: flex;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.45rem 0.75rem;
    border-radius: 7px;
    border: 1px solid transparent;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-dropdown-menu a:hover {
    background: #f0f7ff;
    border-color: var(--line);
}
/* ────────────────────────────────────────────────── */

.inline-form {
    margin: 0;
}

.nav-logout {
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffffaa;
    color: var(--ink);
}

.nav-logout:hover {
    background: #fff;
}

.shell-main {
    max-width: 1000px;
    margin: 1.4rem auto;
    padding: 0 1rem 2rem;
}

.hero h1,
.panel h1,
.panel h2,
.card h2 {
    margin: 0 0 0.4rem;
    font-family: "Space Grotesk", sans-serif;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-weight: 600;
}

.subtitle {
    color: var(--muted);
    max-width: 60ch;
}

.grid-cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 1.2rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.kpi-card {
    background: linear-gradient(135deg, #ffffff, #f3f9ff);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.9rem;
}

.kpi-card h2 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--muted);
}

.kpi-value {
    margin: 0.35rem 0 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
}

.risk-bars {
    display: grid;
    gap: 0.65rem;
}

.risk-row {
    display: grid;
    grid-template-columns: 90px 1fr 42px;
    align-items: center;
    gap: 0.6rem;
}

.risk-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: #ebe7dc;
    overflow: hidden;
}

.risk-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #008bda, #d42c7f);
    transition: width 260ms ease;
}

.nom-stack {
    display: grid;
    gap: 0.9rem;
}

.nom-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 0.9rem;
}

.nom-card h3 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
}

.nom-card p {
    margin: 0.25rem 0 0.8rem;
    color: var(--muted);
}

.nom-questions {
    display: grid;
    gap: 0.55rem;
}

.nom-question label {
    display: grid;
    grid-template-columns: 1fr 90px;
    align-items: center;
    gap: 0.6rem;
    background: #faf8f2;
    border: 1px solid #e7e0d0;
    padding: 0.55rem;
    border-radius: 8px;
}

.card,
.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 20px #1f29330d;
}

.card {
    text-decoration: none;
    color: inherit;
    padding: 1rem;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px #1f29331a;
}

.panel {
    margin-top: 1rem;
    padding: 1rem;
}

.report-layout {
    display: grid;
    grid-template-columns: minmax(320px, 1.2fr) minmax(260px, 0.8fr);
    gap: 1rem;
    margin: 1rem 0 1.2rem;
}

.report-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.95rem;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.report-box h3 {
    margin: 0 0 0.4rem;
    font-family: "Space Grotesk", sans-serif;
}

.report-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
}

.report-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.report-field-wide {
    grid-column: 1 / -1;
}

.report-field small {
    color: var(--muted);
}

.report-actions,
.download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.report-box-downloads {
    background: linear-gradient(180deg, #f3f9ff, #ffffff);
}

.download-actions {
    flex-direction: column;
    align-items: stretch;
}

.download-link {
    display: block;
    text-align: center;
    padding: 0.75rem 0.9rem;
}

.download-link.is-loading {
    background: linear-gradient(90deg, #0c7bc0, #2a9de0);
    box-shadow: 0 0 0 3px #008bda22;
}

.download-link.is-loading::after {
    content: " Preparando...";
    font-weight: 700;
}

.auth-shell {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(460px, 100%);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 20px #1f29330d;
    padding: 1.2rem;
}

.auth-form {
    display: grid;
    gap: 0.8rem;
}

.password-field {
    position: relative;
    width: 100%;
}

.password-field input {
    width: 100%;
    padding-right: 2.6rem;
}

.password-toggle {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.password-toggle:hover {
    color: var(--ink);
    background: #eef4fb;
    border-color: var(--line);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.93rem;
}

label.full {
    grid-column: 1 / -1;
}

.checkbox-inline {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.35rem;
}

.checkbox-inline input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

input,
textarea,
select,
button {
    font: inherit;
}

input,
textarea,
select {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0.55rem 0.65rem;
}

.html-editor-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.html-code-editor {
    min-height: 280px;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.4;
    tab-size: 2;
    resize: vertical;
}

.nom035-correo-preview {
    margin-top: 0.65rem;
    width: 100%;
    min-height: 340px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

button,
.button-link {
    display: inline-block;
    border: 0;
    border-radius: 9px;
    padding: 0.5rem 0.8rem;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font-size: 0.85rem;
    line-height: 1.2;
}

.td-action {
    white-space: nowrap;
    width: 1%;
    padding-right: 0.75rem;
}

.td-action > * + * {
    margin-left: 0.4rem;
}

.correo-select-row,
#correo-select-all {
    width: 1rem;
    height: 1rem;
}

.nom035-folio-select-row,
#nom035-folios-select-all {
    width: 1rem;
    height: 1rem;
}

.empresa-logo-thumb {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 0.25rem;
}

button.secondary {
    background: var(--accent-2);
    color: #1f2933;
}

button.danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

button.danger:hover:not(:disabled) {
    background: #fecaca;
}

.msg {
    min-height: 1.2rem;
    margin: 0.7rem 0 0;
    color: var(--muted);
}

.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

.table-wrap {
    overflow-x: auto;
    cursor: grab;
    scroll-behavior: smooth;
}
.table-wrap.is-dragging {
    cursor: grabbing;
    user-select: none;
}
.table-wrap::-webkit-scrollbar {
    height: 8px;
}
.table-wrap::-webkit-scrollbar-track {
    background: var(--line, #e5e7eb);
    border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-thumb {
    background: #a0aec0;
    border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 0.55rem;
    font-size: 0.93rem;
}

.reveal {
    animation: rise 420ms ease both;
}

.reveal-delay {
    animation: rise 620ms ease both;
}

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

@media (max-width: 760px) {
    .shell-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }

    nav {
        width: 100%;
        justify-content: space-between;
    }

    .report-layout {
        grid-template-columns: 1fr;
    }
}

/* ── Reporte Avance ─────────────────────────────── */
.avance-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: flex-end;
    margin-top: 1rem;
}

.avance-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.93rem;
    min-width: 220px;
    flex: 1 1 220px;
}

.avance-filter-actions {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
}

.avance-kpis {
    margin-top: 1rem;
}

.kpi-card.kpi-ok {
    background: linear-gradient(135deg, #edfbf2, #f3fff8);
    border-color: #b3e8cc;
}

.kpi-card.kpi-ok .kpi-value { color: #1a7a4a; }

.kpi-card.kpi-partial {
    background: linear-gradient(135deg, #eef4ff, #f5f8ff);
    border-color: #9dbcf5;
}

.kpi-card.kpi-partial .kpi-value { color: #1a4a9a; }

.kpi-card.kpi-pending {
    background: linear-gradient(135deg, #fff7e6, #fffbf2);
    border-color: #f5d98a;
}

.kpi-card.kpi-pending .kpi-value { color: #8a5a00; }

.avance-chart-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
}

.avance-chart-canvas-wrap {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
}

.avance-chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1 1 180px;
}

.avance-legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.avance-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.avance-legend-label {
    flex: 1;
    font-size: 0.92rem;
    font-weight: 600;
}

.avance-legend-val {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
}

.avance-legend-val small {
    font-weight: 400;
    color: var(--muted);
}

.avance-tabs {
    display: flex;
    gap: 0.4rem;
    border-bottom: 2px solid var(--line);
    padding-bottom: 0;
    margin-bottom: 0;
}

.avance-tab {
    background: transparent;
    color: var(--muted);
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    padding: 0.55rem 0.9rem;
    font-weight: 600;
    margin-bottom: -2px;
    cursor: pointer;
}

.avance-tab:hover {
    color: var(--ink);
    background: #f5f9ff;
}

.avance-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

.avance-badge {
    display: inline-block;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-ok {
    background: #eaf8f0;
    color: #1a7a4a;
    border: 1px solid #b3e8cc;
}

.badge-partial {
    background: #eef4ff;
    color: #1a4a9a;
    border: 1px solid #9dbcf5;
}

.badge-pending {
    background: #fff7e6;
    color: #8a5a00;
    border: 1px solid #f5d98a;
}
/* ────────────────────────────────────────────────── */
