﻿:root {
    --bg: #fff7ed;
    --surface: #ffffff;
    --border: #f0e2d2;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #ea580c;
    --primary-dark: #c2410c;
    --success: #16a34a;
    --error: #dc2626;
    --radius: 14px;
    --shadow: 0 4px 24px rgba(124, 45, 18, .07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: Segoe UI, system-ui, sans-serif;
    color: var(--text);
    line-height: 1.5;
    background:
        radial-gradient(ellipse 60% 50% at 8% 0%, rgba(251, 146, 60, .16), transparent),
        radial-gradient(ellipse 50% 45% at 95% 100%, rgba(234, 88, 12, .10), transparent),
        linear-gradient(135deg, #fff7ed, #fffbf5 55%, #fef3e2);
    background-attachment: fixed;
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

.logo { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; display: inline-flex; align-items: center; gap: .65rem; min-width: 0; }
.logo-img { height: 36px; width: auto; max-width: 120px; object-fit: contain; flex-shrink: 0; }
.logo-icon { font-size: 1.35rem; line-height: 1; flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.logo-app { font-size: .95rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.logo-empresa { font-size: .78rem; font-weight: 600; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.logo-empresa--muted { color: var(--muted); font-weight: 500; }
.header-brand { display: flex; align-items: center; gap: .75rem; min-width: 0; flex: 0 1 auto; }
.header-empresa-select { flex-shrink: 0; }
.empresa-select {
    max-width: 220px;
    padding: .35rem .55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: .82rem;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.badge-activa { display: inline-block; margin-left: .45rem; padding: .1rem .45rem; border-radius: 999px; background: #dcfce7; color: #166534; font-size: .72rem; font-weight: 600; vertical-align: middle; }
.link-abrir { margin-left: .45rem; font-size: .82rem; font-weight: 600; }

.empresa-logo-section { margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.empresa-logo-section h2 { font-size: 1rem; margin-bottom: .35rem; }
.empresa-logo-box { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.empresa-logo-preview, .empresa-logo-inline { max-height: 72px; max-width: 180px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; padding: .35rem; background: #fff; }
.empresa-logo-placeholder { width: 120px; height: 72px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); font-size: .85rem; }
.empresa-brand-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.empresa-form-row { flex-direction: column; align-items: stretch !important; gap: .5rem; }
.empresa-form-edit { margin-left: 1.75rem; font-size: .85rem; color: var(--muted); }
.empresa-section { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.empresa-section h2 { font-size: 1rem; margin-bottom: .75rem; color: var(--primary); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-4 { grid-template-columns: 1fr; } }

.empresa-encabezado {
    margin-bottom: 1.25rem;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    overflow: hidden;
    background: #fffbf5;
}
.empresa-encabezado__titulo {
    background: linear-gradient(90deg, #ea580c, #c2410c);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .55rem .85rem;
}
.empresa-encabezado__tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: .84rem;
}
.empresa-encabezado__tabla th,
.empresa-encabezado__tabla td {
    border: 1px solid #ffedd5;
    padding: .45rem .65rem;
    vertical-align: top;
}
.empresa-encabezado__tabla th {
    width: 18%;
    background: #fff7ed;
    color: #475569;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
}
.empresa-encabezado__tabla td { color: #0f172a; }
@media (max-width: 640px) {
    .empresa-encabezado__tabla,
    .empresa-encabezado__tabla tbody,
    .empresa-encabezado__tabla tr,
    .empresa-encabezado__tabla th,
    .empresa-encabezado__tabla td { display: block; width: 100%; }
    .empresa-encabezado__tabla tr { margin-bottom: .5rem; border-bottom: 1px solid #ffedd5; }
}

.welcome-logo { width: 72px; height: 72px; border-radius: 18px; background: rgba(255,255,255,.85); border: 1px solid rgba(234, 88, 12, .25); box-shadow: 0 4px 14px rgba(124, 45, 18, .12); display: flex; align-items: center; justify-content: center; padding: .35rem; flex-shrink: 0; }
.welcome-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.form-public-brand { text-align: center; margin-bottom: 1rem; }
.form-public-logo { max-height: 80px; max-width: 220px; object-fit: contain; }

.header {
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(234, 88, 12, .14);
    box-shadow: 0 2px 12px rgba(124, 45, 18, .06);
    position: sticky; top: 0; z-index: 10;
}
.logo-badge {
    width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
    background: linear-gradient(160deg, #fdba74, #fed7aa 60%, #ffedd5);
    border: 1px solid rgba(234, 88, 12, .25);
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(124, 45, 18, .12);
}
.logo-badge svg { width: 20px; height: 20px; color: #ea580c; }
.bandera-co--sm { width: 27px; height: 19px; border-radius: 4px; }
.header .container { max-width: 1400px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; flex-wrap: wrap; padding: .45rem 0; column-gap: 1.25rem; row-gap: .3rem; }
.nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-left: auto; row-gap: .3rem; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav .btn { white-space: nowrap; }
.nav a:hover { color: var(--primary); }
.nav-toggle, .nav-toggle-btn { display: none; }

/* Menú colapsable en pantallas pequeñas (celular y tablet vertical) */
@media (max-width: 900px) {
    .header-inner { height: auto; min-height: 60px; padding: .5rem 0; flex-wrap: wrap; gap: .5rem; }
    .header-brand { flex: 1 1 100%; order: 1; flex-wrap: wrap; }
    .empresa-select { max-width: 100%; width: 100%; margin-top: .35rem; }
    .nav-toggle-btn { order: 2; margin-left: auto; }
    .nav-toggle { order: 3; }
    .nav { order: 4; width: 100%; }
    .logo-app, .logo-empresa { max-width: 160px; }
    .nav-toggle-btn {
        display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 8px;
        font-size: 1.25rem; cursor: pointer; background: var(--surface); color: var(--text);
        user-select: none;
    }
    .nav {
        display: none;
        position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: .25rem;
        background: var(--surface); border-bottom: 1px solid var(--border);
        padding: .5rem 1rem 1rem;
        box-shadow: 0 12px 24px rgba(15, 23, 42, .12);
    }
    .nav-toggle:checked ~ .nav { display: flex; }
    .nav-toggle:checked + .nav-toggle-btn { background: #fff7ed; border-color: var(--primary); color: var(--primary); }
    .nav a { padding: .7rem .6rem; border-radius: 8px; }
    .nav a:hover, .nav a:active { background: #fef3e2; }
    .nav .btn { justify-content: center; margin-top: .25rem; }
    .nav-user { align-items: flex-start; padding: .6rem .6rem 0; border-top: 1px solid var(--border); margin-top: .25rem; }
}
.main { padding: 2rem 1rem; min-height: calc(100vh - 120px); }
.footer { text-align: center; padding: 1rem; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--border); }

.hero { text-align: center; padding: 2rem 1rem 3rem; }
.hero h1 { font-size: 2rem; margin-bottom: .5rem; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 1.5rem; }

/* Bienvenida */
.welcome-banner {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    margin-bottom: 2rem;
    background: linear-gradient(160deg, #fdba74, #fed7aa 48%, #ffedd5);
    color: #7c2d12;
    box-shadow: 0 24px 64px rgba(124, 45, 18, .16);
}
.welcome-banner--fresh {
    animation: welcomeIn .6s ease-out;
}
@keyframes welcomeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.welcome-banner__pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle 130px at 92% -8%, rgba(255, 255, 255, .38) 99%, transparent 100%),
        radial-gradient(circle 100px at -2% 108%, rgba(255, 255, 255, .38) 99%, transparent 100%);
}
.welcome-banner__inner {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.5rem;
    align-items: center;
    padding: 2rem 2.25rem;
}
@media (max-width: 768px) {
    .welcome-banner__inner { grid-template-columns: 1fr; text-align: center; }
    .welcome-aside { justify-self: center; }
    .welcome-meta { justify-content: center; }
}
.welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: .05em;
    color: #ea580c;
    background: rgba(255, 255, 255, .85);
    border: 1px solid rgba(234, 88, 12, .25);
    box-shadow: 0 4px 14px rgba(124, 45, 18, .12);
    flex-shrink: 0;
}
.welcome-greeting {
    font-size: .95rem;
    color: #9a3412;
    margin-bottom: .25rem;
    font-weight: 500;
    letter-spacing: .02em;
}
.welcome-name {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: .85rem;
    letter-spacing: -.02em;
}
.welcome-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .85rem;
}
.welcome-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .85rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    color: #9a3412;
    background: rgba(255, 255, 255, .65);
    border: 1px solid rgba(234, 88, 12, .22);
}
.welcome-chip--role { background: rgba(255, 255, 255, .45); }
.welcome-icon { width: 15px; height: 15px; flex-shrink: 0; color: #ea580c; }
.welcome-sub {
    font-size: .92rem;
    color: #9a3412;
    max-width: 520px;
    line-height: 1.55;
}
.welcome-aside {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-end;
}
@media (max-width: 768px) { .welcome-aside { align-items: center; text-align: center; } }
.welcome-date {
    font-size: .82rem;
    color: #9a3412;
    font-weight: 500;
    line-height: 1.4;
    max-width: 160px;
}
.welcome-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .75rem 1.25rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .75);
    border: 1px solid rgba(234, 88, 12, .22);
    box-shadow: 0 4px 14px rgba(124, 45, 18, .1);
    min-width: 90px;
}
.welcome-stat__num {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    color: #ea580c;
}
.welcome-stat__label {
    font-size: .72rem;
    color: #9a3412;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: .25rem;
}
.section-heading { margin-bottom: 1.25rem; }
.section-heading h2 { font-size: 1.15rem; margin-bottom: .25rem; color: #7c2d12; }
.main > .page-header h1, .main h1 { color: #7c2d12; }
.section-heading p { font-size: .9rem; }

.formularios-rol-lista { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.formularios-todos-toggle { margin-bottom: 0; font-weight: 600; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: .55rem 1rem; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; text-decoration: none; font-size: .9rem; transition: .15s; }
.btn-primary { background: #f97316; color: #fff; box-shadow: 0 2px 10px rgba(249, 115, 22, .28); }
.btn-primary:hover { background: #ea580c; }
.btn-secondary { background: #ffedd5; color: #9a3412; }
.btn-secondary:hover { background: #fed7aa; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--primary); border-color: #fdba74; background: #fff7ed; }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.panel-header h2 { margin: 0; }

label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .75rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=tel], select, textarea {
    width: 100%; margin-top: .35rem; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #fb923c; box-shadow: 0 0 0 3px rgba(251, 146, 60, .18); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; position: relative; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(124, 45, 18, .12); }
.card h3 { color: #7c2d12; }
.card h3 { margin-bottom: .35rem; }
.card-meta { display: flex; gap: 1rem; color: var(--muted); font-size: .85rem; margin: .75rem 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.card-badge { position: absolute; top: 1rem; right: 1rem; }

.badge, .card-badge { font-size: .75rem; padding: .2rem .5rem; border-radius: 999px; font-weight: 600; text-transform: capitalize; }
.badge-borrador, .badge-borrador { background: #fef3c7; color: #92400e; }
.badge-publicado { background: #dcfce7; color: #166534; }
.badge-archivado { background: #fef3e2; color: #475569; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #fef3e2; font-size: .85rem; }
.table .actions a { margin-right: .75rem; color: var(--primary); text-decoration: none; font-size: .875rem; }
.table .actions a.danger { color: var(--error); }
.text-center { text-align: center; }
.muted { color: var(--muted); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #fff7ed; color: #9a3412; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 3rem; color: var(--muted); }

/* Constructor de campos */
.add-field-bar { display: flex; gap: .5rem; align-items: center; }
.campos-container { display: flex; flex-direction: column; gap: .75rem; min-height: 80px; }
.campos-container.drag-active .builder-sortable:not(.is-dragging) { transition: transform .15s ease; }
body.builder-dragging { cursor: grabbing; user-select: none; }
body.builder-dragging .drag-handle { cursor: grabbing; }
.seccion-item { border: 2px solid var(--primary); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: .75rem; background: #fff7ed; position: relative; }
.seccion-item-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.seccion-badge { font-size: .78rem; font-weight: 700; color: #9a3412; text-transform: uppercase; letter-spacing: .04em; flex: 1; }
.seccion-item label { margin-bottom: .65rem; display: block; }

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    cursor: grab;
    font-size: .95rem;
    line-height: 1;
    flex-shrink: 0;
    touch-action: none;
    user-select: none;
}
.drag-handle:hover { background: #fef3e2; color: var(--primary); border-color: #fdba74; }
.drag-handle:active { cursor: grabbing; }

.builder-sortable.is-dragging {
    opacity: .75;
    transform: scale(1.01);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .15);
    z-index: 2;
    pointer-events: none;
}
.builder-sortable.is-drag-over {
    box-shadow: 0 0 0 2px rgba(234, 88, 12, .35);
}
.builder-sortable.drop-before::before,
.builder-sortable.drop-after::after {
    content: '';
    position: absolute;
    left: .75rem;
    right: .75rem;
    height: 3px;
    background: var(--primary);
    border-radius: 999px;
    pointer-events: none;
}
.builder-sortable.drop-before::before { top: -2px; }
.builder-sortable.drop-after::after { bottom: -2px; }

.builder-drop-end {
    min-height: 44px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: .82rem;
    background: #fffaf3;
    transition: border-color .15s, background .15s;
}
.builder-drop-end.is-drag-over {
    border-color: var(--primary);
    background: #fff7ed;
    color: #9a3412;
}
.campos-container.drag-active .builder-drop-end { border-style: solid; }

.form-section { margin: 1.75rem 0 1rem; padding: 1rem 0 .25rem; border-top: 3px solid var(--primary); }
.form-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.form-section-title { font-size: 1.35rem; color: #7c2d12; margin-bottom: .35rem; }

.catalogo-import {
    margin: .75rem 0 1rem;
    padding: .85rem 1rem;
    background: #fff7ed;
    border: 1px dashed #fdba74;
    border-radius: 8px;
}
.catalogo-info {
    margin: .5rem 0 1rem;
    padding: .65rem .85rem;
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.select-busqueda { position: relative; }
.select-busqueda-wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.select-busqueda--open .select-busqueda-wrap {
    border-color: var(--primary, #ea580c);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, .15);
}
.select-busqueda-input {
    flex: 1;
    border: none;
    box-shadow: none;
    min-width: 0;
}
.select-busqueda-input:focus { outline: none; box-shadow: none; }
.select-busqueda-toggle {
    border: none;
    background: #fffaf3;
    color: #475569;
    padding: 0 .85rem;
    cursor: pointer;
    border-left: 1px solid var(--border, #d1d5db);
}
.select-busqueda-toggle:hover { background: #fff7ed; color: var(--primary, #ea580c); }
.select-busqueda-results {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    margin: .25rem 0 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.select-busqueda-results li {
    padding: .55rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid #fef3e2;
}
.select-busqueda-results li:hover,
.select-busqueda-results li:focus,
.select-busqueda-results li.is-active {
    background: #fff7ed;
    outline: none;
}
.select-busqueda-empty {
    color: var(--muted, #64748b);
    cursor: default;
}
.form-section-desc { color: var(--muted); font-size: .92rem; margin-bottom: .5rem; }

.campo-item { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; background: #fffdf9; position: relative; }
.campo-item-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.campo-item-header-main { display: flex; align-items: center; gap: .5rem; flex: 1; flex-wrap: wrap; }
.campo-grid-top { margin-bottom: .75rem; }
.campo-tipo-badge { font-size: .75rem; background: #ffedd5; color: #9a3412; padding: .15rem .5rem; border-radius: 4px; font-weight: 600; }
.campo-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .75rem; }
.campo-grid label { margin: 0; font-size: .82rem; }
.campo-opciones { margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.opcion-row { display: grid; grid-template-columns: 60px 1fr 1fr auto; gap: .5rem; margin-bottom: .5rem; align-items: end; }
.opcion-row-abc .opcion-letra { font-weight: 700; text-align: center; background: #fff7ed; border-radius: 6px; padding: .55rem; }
.campo-actions { display: flex; gap: .35rem; }
.campo-actions button { background: none; border: 1px solid var(--border); border-radius: 6px; padding: .25rem .5rem; cursor: pointer; font-size: .8rem; }
.campo-actions button:hover { background: #fee2e2; border-color: #fca5a5; }
.campo-actions button[data-action="duplicate"]:hover { background: #ffedd5; border-color: #fdba74; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .75rem; }
.form-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }

/* Formulario publico */
.form-public { max-width: 720px; margin: 0 auto; }
.form-public-header { margin-bottom: 1.5rem; text-align: center; }

/* Wizard paso a paso al llenar formulario */
.form-wizard-form { overflow: hidden; }
.form-wizard { display: flex; flex-direction: column; gap: 1.25rem; }
.form-wizard-progress { margin-bottom: .25rem; }
.form-wizard-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: .85rem;
}
.form-wizard-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ea580c, #f97316);
    border-radius: 999px;
    transition: width .25s ease;
}
.form-wizard-steps-list {
    list-style: none;
    display: flex;
    justify-content: space-between;
    gap: .35rem;
    padding: 0;
    margin: 0;
}
.form-wizard-step-dot {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}
.form-wizard-step-dot span {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .82rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #64748b;
    border: 2px solid #e2e8f0;
    transition: background .2s, color .2s, border-color .2s;
}
.form-wizard-step-dot.is-active span {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, .2);
}
.form-wizard-step-dot.is-done span {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}
.form-wizard-step-dot.is-clickable { cursor: pointer; }
.form-wizard-step-dot.is-clickable:hover span { border-color: var(--primary); }

.form-wizard-step-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
}
.form-wizard-step-count {
    font-size: .82rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .35rem;
}
.form-wizard-step-title {
    font-size: 1.35rem;
    color: #7c2d12;
    margin-bottom: .35rem;
}
.form-wizard-step-desc {
    color: var(--muted);
    font-size: .92rem;
    margin: 0;
}
.form-wizard-step-body { min-height: 120px; }
.form-wizard-empty {
    text-align: center;
    padding: 2rem 1rem;
    background: #fffaf3;
    border-radius: 8px;
    border: 1px dashed var(--border);
}
.form-wizard-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    margin-top: .5rem;
    border-top: 1px solid var(--border);
}
.form-wizard-nav [data-wizard-submit] { margin-left: auto; }

.field { margin-bottom: 1.25rem; }
.field-help { display: block; color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.field-help-tz { font-style: italic; }
.field-separator { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.field-figure { margin: 0 0 1rem; }
.field-image { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }
.field-image--block { display: block; margin: 0 auto; max-height: 420px; object-fit: contain; }
.field-caption { text-align: center; color: var(--muted); font-size: .88rem; margin-top: .5rem; }
.field-image-placeholder { text-align: center; padding: 2rem; background: #fffaf3; border: 1px dashed var(--border); border-radius: 8px; }
.field-file { margin-top: .35rem; }
.respuesta-imagen { max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--border); display: block; margin-bottom: .35rem; }

.campo-imagen-block { margin-top: .75rem; padding: .75rem; border: 1px dashed var(--border); border-radius: 8px; background: #fff; }
.campo-imagen-preview { display: block; max-width: 100%; max-height: 200px; margin: .75rem 0; border-radius: 8px; border: 1px solid var(--border); object-fit: contain; }
.campo-imagen-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.campo-imagen-actions label.btn input { display: none; }
.campo-archivo-config { margin-top: .75rem; }
.campo-firma-config {
    margin: .75rem 0;
    padding: .85rem 1rem;
    background: #fffaf3;
    border: 1px dashed var(--border);
    border-radius: 8px;
}
.campo-firma-config .hint { margin: .35rem 0 .65rem; }

.field-title { font-size: 1.2rem; margin: 1rem 0 .5rem; border-bottom: 2px solid var(--primary); padding-bottom: .25rem; }
.field-paragraph { color: var(--muted); }
.field-separator { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
legend { font-weight: 600; padding: 0 .25rem; }
.inline-option { display: inline-flex; align-items: center; gap: .35rem; margin-right: 1rem; margin-bottom: .35rem; font-weight: 400; }

.abc-options { display: flex; flex-direction: column; gap: .5rem; }
.abc-option { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.abc-option:has(input:checked) { border-color: var(--primary); background: #fff7ed; }
.abc-letter { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; background: var(--primary); color: #fff; border-radius: 50%; font-weight: 700; font-size: .85rem; }
.abc-text { flex: 1; }

.table-respuestas td:first-child { width: 35%; font-weight: 500; }

/* Censo */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 768px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.stat-num { display: block; font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .82rem; color: var(--muted); }
.censo-filtros h2 { margin-bottom: 1rem; }
.filtro-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .filtro-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .filtro-row { grid-template-columns: 1fr; } }
.censo-resumen { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .75rem 1rem; background: #fff7ed; border-radius: 8px; }

/* Constructor: obligatorio y censo */
.campo-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .campo-grid-4 { grid-template-columns: 1fr 1fr; } }
.badge-required { font-size: .72rem; background: #fee2e2; color: #991b1b; padding: .15rem .5rem; border-radius: 4px; font-weight: 600; }
.badge-optional { font-size: .72rem; background: #fef3e2; color: #64748b; padding: .15rem .5rem; border-radius: 4px; font-weight: 600; }
.toggle-obligatorio { display: flex; flex-direction: column; gap: .35rem; }
.toggle-obligatorio input[type=checkbox] { width: auto; margin-top: .35rem; }
.field-required label >:first-child,
.field-required legend { color: #9a3412; }
.field-required label::after, .field-required legend::after { content: none; }
.badge-completado { background: #dcfce7; color: #166534; }
.badge-anulado { background: #fee2e2; color: #991b1b; }

/* Login */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(ellipse 60% 50% at 8% 0%, rgba(251, 146, 60, .16), transparent),
        radial-gradient(ellipse 50% 45% at 95% 100%, rgba(234, 88, 12, .10), transparent),
        linear-gradient(135deg, #fff7ed, #fffbf5 55%, #fef3e2);
    padding: 1.5rem;
}
.auth-container { width: 100%; max-width: 900px; padding: 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.auth-card h1 { text-align: center; margin-bottom: .25rem; }
.auth-card .muted { text-align: center; margin-bottom: 1.5rem; }
.auth-form label { margin-bottom: 1rem; }

/* Login con panel de marca */
.auth-card--split {
    display: flex; align-items: stretch; padding: 0; border: none; overflow: hidden;
    border-radius: 18px; box-shadow: 0 24px 64px rgba(15, 23, 42, .18);
}
.auth-card--split h1 { text-align: left; }
.auth-brand {
    flex: 1 1 45%; min-width: 0; position: relative; overflow: hidden;
    background: linear-gradient(160deg, #fdba74, #fed7aa 48%, #ffedd5);
    color: #7c2d12; padding: 2.75rem 2.5rem;
    display: flex; flex-direction: column; justify-content: center; gap: .9rem;
}
.auth-brand::before, .auth-brand::after {
    content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .38); pointer-events: none;
}
.auth-brand::before { width: 260px; height: 260px; top: -90px; right: -80px; }
.auth-brand::after { width: 200px; height: 200px; bottom: -70px; left: -60px; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand__logo {
    width: 62px; height: 62px; border-radius: 16px;
    background: rgba(255, 255, 255, .85); border: 1px solid rgba(234, 88, 12, .25);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(124, 45, 18, .12);
}
.auth-brand__logo svg { width: 32px; height: 32px; color: #ea580c; }
.auth-brand__logo img { max-width: 46px; max-height: 46px; object-fit: contain; }
.auth-brand__title { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.auth-brand__name { font-size: 1.65rem; font-weight: 800; line-height: 1.2; letter-spacing: .2px; color: #7c2d12; }
.auth-brand__tagline { color: #9a3412; font-size: .95rem; line-height: 1.5; }
.auth-brand__features { list-style: none; margin-top: .6rem; display: flex; flex-direction: column; gap: .6rem; }
.auth-brand__features li { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: #7c2d12; }
.auth-brand__features svg { width: 17px; height: 17px; flex-shrink: 0; color: #ea580c; }

/* Bandera de Colombia (CSS puro) */
.bandera-co {
    display: inline-flex; flex-direction: column; width: 36px; height: 25px;
    border-radius: 5px; overflow: hidden; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(124, 45, 18, .25); border: 1px solid rgba(255, 255, 255, .6);
}
.bandera-co i { display: block; }
.bandera-co i:nth-child(1) { flex: 2; background: #fcd116; }
.bandera-co i:nth-child(2) { flex: 1; background: #003893; }
.bandera-co i:nth-child(3) { flex: 1; background: #ce1126; }
.auth-panel {
    flex: 1 1 55%; min-width: 0; background: var(--surface);
    padding: 2.75rem 2.5rem; display: flex; flex-direction: column; justify-content: center;
}
.auth-panel h1 { font-size: 1.45rem; margin-bottom: .3rem; }
.auth-panel__sub { color: var(--muted); font-size: .92rem; margin-bottom: 1.6rem; line-height: 1.5; }
.auth-panel__sub strong { color: #ea580c; }
.auth-panel .btn-primary { background: #f97316; border-color: #f97316; }
.auth-panel .btn-primary:hover { background: #ea580c; border-color: #ea580c; }
.auth-panel .auth-form input:focus { border-color: #fb923c; outline-color: #fb923c; box-shadow: 0 0 0 3px rgba(251, 146, 60, .18); }
.auth-panel .auth-form label { font-weight: 600; font-size: .88rem; }
.auth-panel .auth-form input { margin-top: .3rem; }
.auth-footer { margin-top: 1.6rem; text-align: center; font-size: .78rem; color: var(--muted); }

@media (max-width: 760px) {
    .auth-container { padding: .25rem; }
    .auth-card--split { flex-direction: column; border-radius: 14px; }
    .auth-brand { padding: 1.9rem 1.5rem; gap: .7rem; }
    .auth-brand__name { font-size: 1.35rem; }
    .auth-brand__features { display: none; }
    .auth-panel { padding: 1.9rem 1.5rem; }
}
.btn-block { width: 100%; }
.auth-hint { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); }
.auth-hint p { margin: .25rem 0; }
.nav-user { font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; max-width: 200px; min-width: 0; }
.nav-user__name { font-weight: 600; color: var(--text); }
.nav-user__name, .nav-user__company, .nav-user__role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; display: block; }
.nav-user__company, .nav-user__role { color: #94a3b8; font-size: .75rem; }
.nav-user small { color: #94a3b8; }
.checkbox-list { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0; }
.checkbox-item { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.checkbox-item:has(input:checked) { border-color: var(--primary); background: #fff7ed; }
.checkbox-item input { margin-top: .2rem; width: auto; }
.checkbox-item span { display: flex; flex-direction: column; }
.inline-check { display: flex; align-items: center; gap: .5rem; }
.inline-check input { width: auto; }

/* Permisos por rol */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; background: #fffdf9; }
.perm-group h3 { font-size: .95rem; margin-bottom: .75rem; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: .35rem; }
.perm-item { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .5rem; font-weight: 400; cursor: pointer; }
.perm-item input { width: auto; margin-top: .2rem; }
.perm-item span { display: flex; flex-direction: column; font-size: .85rem; }
.perm-item strong { font-size: .88rem; }

/* ============================================================
   Ajustes para celular y tablet
   La app se usa principalmente en pantallas táctiles: objetivos
   de toque de al menos 44px y cuadrículas que colapsan.
   ============================================================ */

input[type=checkbox], input[type=radio] { accent-color: var(--primary); }

/* Dispositivos táctiles (celular y tablet, sin importar el ancho) */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
    input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
    input[type=time], input[type=datetime-local], input[type=tel], select, textarea {
        min-height: 44px; padding: .65rem .75rem;
    }
    input[type=checkbox], input[type=radio] { width: 1.25rem; height: 1.25rem; }
    .table .actions a { display: inline-block; padding: .5rem .35rem; margin-right: .35rem; }
    .campo-actions button { min-width: 42px; min-height: 40px; }
    .abc-option, .checkbox-item { min-height: 48px; }
}

/* Tablet horizontal táctil: el menú sigue en fila, dar más área de toque */
@media (pointer: coarse) and (min-width: 901px) {
    .nav a { padding: .6rem .35rem; }
}

/* Tablet vertical */
@media (max-width: 900px) {
    .campo-grid { grid-template-columns: 1fr 1fr; }
    .nav-user { align-items: flex-start; }
    .welcome-banner__inner { padding: 1.5rem 1.5rem; }
}

/* Celular */
@media (max-width: 640px) {
    .main { padding: 1.25rem .75rem; }
    .panel, .card { padding: 1rem; }
    .hero { padding: 1.25rem .5rem 2rem; }
    .hero h1 { font-size: 1.5rem; }

    .page-header { flex-direction: column; align-items: stretch; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1; }

    .welcome-banner__inner { padding: 1.25rem 1rem; gap: 1rem; }
    .welcome-avatar { width: 56px; height: 56px; font-size: 1.2rem; }

    .campo-grid, .campo-grid-4 { grid-template-columns: 1fr; }
    .opcion-row { grid-template-columns: 1fr 1fr auto; }
    .opcion-row-abc { grid-template-columns: 44px 1fr auto; }
    .add-field-bar { flex-wrap: wrap; }
    .add-field-bar select { flex: 1 1 100%; }

    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }

    .form-wizard-nav { flex-direction: column; }
    .form-wizard-nav .btn { width: 100%; }
    .form-wizard-nav [data-wizard-submit] { margin-left: 0; }
    .form-wizard-step-dot span { width: 28px; height: 28px; font-size: .75rem; }

    .stats-grid { gap: .6rem; }
    .censo-resumen { gap: .5rem 1rem; padding: .6rem .75rem; }

    .table th, .table td { padding: .6rem .65rem; font-size: .85rem; white-space: nowrap; }

    .auth-card { padding: 1.5rem 1.25rem; }
}

/* Campo firma (pad de dibujo) */
.firma-campo { display: block; }
.firma-campo--adjunta {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}
.respuesta-firma-adjunta { margin-top: .75rem; }
.firma-label { display: block; font-weight: 500; margin-bottom: .35rem; }
.firma-pad {
    position: relative; border: 1px dashed var(--border); border-radius: 8px;
    background: #fff; overflow: hidden; min-height: 180px;
}
.firma-canvas {
    display: block; width: 100%; height: 180px; cursor: crosshair;
    touch-action: none; position: relative; z-index: 1; background: #fff;
}
.firma-placeholder {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: .9rem; pointer-events: none;
}
.firma-actions { margin-top: .4rem; }
.firma-error .firma-pad { border-color: #dc2626; }
.respuesta-firma { max-width: 260px; max-height: 110px; border-bottom: 1px solid var(--border); }

