/* ============================================================
   Panel admin — estilos
   Layout: sidebar oscuro fijo + main blanco.
   ============================================================ */

body.admin {
    margin: 0;
    background: #fafafa;
    color: var(--color-dark);
    font-family: var(--font-sans);
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

/* -------------------- Sidebar -------------------- */
.admin-side {
    background: var(--color-dark);
    color: var(--color-white);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100dvh;
}
.admin-side__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-side__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-yellow);
    box-shadow: 0 0 0 2px rgba(238, 203, 59, 0.5);
}
.admin-side__name {
    font-weight: 700;
    font-size: 17px;
    line-height: 1.1;
}
.admin-side__suffix { color: var(--color-yellow); }
.admin-side__role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-yellow);
    margin-top: 3px;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}
.admin-nav__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.admin-nav__item .icon {
    flex: 0 0 auto;
    opacity: 0.85;
}
.admin-nav__item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-white);
}
.admin-nav__item:hover .icon { opacity: 1; }
.admin-nav__item.is-active {
    background: var(--color-yellow);
    color: var(--color-dark);
    font-weight: 700;
}
.admin-nav__item.is-active .icon { opacity: 1; }
.admin-nav__item.is-disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: not-allowed;
}
.admin-nav__item.is-disabled:hover {
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
}
.admin-nav__chip {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.55);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.admin-side__footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.admin-side__chat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--color-yellow);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 14px;
    border: 1.5px solid var(--color-yellow);
    border-radius: var(--radius-pill);
    transition: background 0.12s, color 0.12s;
    align-self: flex-start;
}
.admin-side__chat:hover {
    background: var(--color-yellow);
    color: var(--color-dark);
}

.admin-side__user {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-side__user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.admin-side__user-name {
    color: var(--color-white);
    font-weight: 700;
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}
.admin-side__user-email {
    color: rgba(255, 255, 255, 0.55);
    word-break: break-all;
    font-size: 11.5px;
}
.admin-side__logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.16);
    padding: 7px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.admin-side__logout:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-white);
    border-color: rgba(255, 255, 255, 0.45);
}

/* Role pill — visible junto al nombre del admin */
.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 7px;
    border-radius: var(--radius-pill);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex: 0 0 auto;
}
.role-pill--super_admin {
    background: linear-gradient(135deg, var(--color-yellow) 0%, #f5dc63 100%);
    color: var(--color-dark);
    box-shadow: 0 1px 3px rgba(238, 203, 59, 0.45);
}
.role-pill--admin {
    background: rgba(255, 255, 255, 0.14);
    color: var(--color-white);
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.role-pill--gerente {
    background: linear-gradient(135deg, #2f6fcf 0%, #4c87df 100%);
    color: var(--color-white);
    box-shadow: 0 1px 3px rgba(47, 111, 207, 0.45);
}

/* -------------------- Main -------------------- */
.admin-main {
    padding: 28px 32px 60px;
    min-width: 0;
    overflow-x: hidden;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-topbar__eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-gray-500);
    margin-bottom: 4px;
}
.admin-topbar__title {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.admin-topbar__meta {
    display: flex;
    gap: 8px;
    align-items: center;
}
.badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--color-dark);
    color: var(--color-yellow);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.badge--model {
    background: var(--color-yellow);
    color: var(--color-dark);
    text-transform: none;
}

/* -------------------- KPI cards -------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.kpi {
    background: var(--color-white);
    border: 1px solid rgba(23, 26, 28, 0.06);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(23, 26, 28, 0.04);
}
.kpi--accent { border-color: var(--color-yellow); }
.kpi--cost   { background: linear-gradient(135deg, #fffaea 0%, #ffffff 80%); border-color: rgba(238, 203, 59, 0.4); }
.kpi__label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-gray-500);
    font-weight: 600;
}
.kpi__value {
    margin-top: 4px;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.kpi__sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--color-gray-500);
}

/* -------------------- Cards (tablas/listas) -------------------- */
.admin-card {
    background: var(--color-white);
    border: 1px solid rgba(23, 26, 28, 0.06);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(23, 26, 28, 0.04);
}
.admin-card--soft { background: #fafaf8; }
.admin-card__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(23, 26, 28, 0.05);
    flex-wrap: wrap;
    gap: 8px;
}
.admin-card__head h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.admin-card__hint {
    font-size: 12px;
    color: var(--color-gray-500);
    font-style: italic;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.admin-table th, .admin-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(23, 26, 28, 0.05);
}
.admin-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-gray-500);
    font-weight: 600;
}
.admin-table .num   { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .muted { color: var(--color-gray-400); }

.admin-empty {
    color: var(--color-gray-500);
    font-style: italic;
    margin: 6px 0;
}

.admin-todo {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-todo li {
    padding: 10px 12px;
    background: var(--color-white);
    border: 1px dashed rgba(23, 26, 28, 0.15);
    border-radius: var(--radius);
    font-size: 14px;
}
.admin-todo em {
    color: var(--color-gray-400);
    font-style: normal;
    font-size: 12px;
}

/* -------------------- Login admin (botón Google) -------------------- */
.admin-login-card {
    max-width: 420px;
}
.admin-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--color-white);
    color: var(--color-dark);
    border: 1.5px solid rgba(23, 26, 28, 0.16);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.admin-google-btn:hover {
    border-color: var(--color-dark);
    box-shadow: 0 4px 12px rgba(23, 26, 28, 0.10);
}
.admin-google-btn:active { transform: translateY(1px); }

.admin-disabled-cta {
    background: #fff7e6;
    border: 1px solid #f0d398;
    color: #6c4f00;
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.5;
}
.admin-disabled-cta code {
    background: rgba(23, 26, 28, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
}

/* -------------------- Flash messages -------------------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.45;
}
.flash--ok  { background: #e7f7ec; border: 1px solid #b6e3c4; color: #1d6a3a; }
.flash--err { background: #fdecea; border: 1px solid #f4c7c3; color: #a23029; }

/* -------------------- Botones -------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
    text-decoration: none;
}
.btn--primary {
    background: var(--color-yellow);
    color: var(--color-dark);
}
.btn--primary:hover  { box-shadow: 0 4px 12px rgba(238, 203, 59, 0.4); }
.btn--primary:active { transform: translateY(1px); }
.btn--primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn--ghost {
    background: transparent;
    color: var(--color-gray-500);
    border-color: rgba(23, 26, 28, 0.16);
}
.btn--ghost:hover { color: var(--color-dark); border-color: var(--color-dark); }
.btn--block { width: 100%; margin-top: 10px; }

/* -------------------- Editor de personalidad -------------------- */
.pers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}
.pers-col {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}
.pers-help {
    margin: 0 0 12px;
    color: var(--color-gray-500);
    font-size: 13px;
    line-height: 1.5;
}
.pers-help-small {
    margin: 6px 0 0;
    color: var(--color-gray-500);
    font-size: 12px;
    line-height: 1.4;
}
.pers-help-small code,
.pers-help code {
    background: rgba(23, 26, 28, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.pers-textarea, .pers-input {
    width: 100%;
    appearance: none;
    border: 1.5px solid rgba(23, 26, 28, 0.10);
    border-radius: 14px;
    padding: 16px 18px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.65;
    color: var(--color-dark);
    background: #fbfbfa;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    resize: vertical;
    letter-spacing: -0.005em;
}
.pers-textarea:hover, .pers-input:hover {
    background: var(--color-white);
    border-color: rgba(23, 26, 28, 0.16);
}
.pers-textarea:focus, .pers-input:focus {
    outline: none;
    border-color: var(--color-dark);
    background: var(--color-white);
    box-shadow: 0 0 0 4px rgba(238, 203, 59, 0.25);
}
.pers-textarea--big {
    min-height: 340px;
    font-size: 14.5px;
}
.pers-textarea::placeholder, .pers-input::placeholder {
    color: var(--color-gray-400);
    font-style: italic;
}
.pers-input--narrow { max-width: 180px; }

/* Meta debajo del textarea (contador, etc.) */
.pers-meta {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    font-size: 12px;
    color: var(--color-gray-400);
    font-variant-numeric: tabular-nums;
}
.pers-meta strong { color: var(--color-gray-500); }

.pers-field {
    margin-top: 18px;
}
.pers-field:first-child { margin-top: 0; }
.pers-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-dark);
    margin-bottom: 8px;
}
/* Pill de valor (ej: "0.70" del slider). Solo si es hijo directo del label
   que es hijo directo de .pers-field, para no afectar a otros <strong> reutilizados. */
.pers-field > label > strong {
    color: var(--color-yellow);
    background: var(--color-dark);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* Slider amarillo */
.pers-range {
    width: 100%;
    appearance: none;
    background: transparent;
    margin: 10px 0 4px;
    height: 24px;
}
.pers-range::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(to right, #d9dadc 0%, var(--color-yellow) 100%);
    border-radius: var(--radius-pill);
}
.pers-range::-moz-range-track {
    height: 8px;
    background: linear-gradient(to right, #d9dadc 0%, var(--color-yellow) 100%);
    border-radius: var(--radius-pill);
}
.pers-range::-webkit-slider-thumb {
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-dark);
    border: 3px solid var(--color-yellow);
    margin-top: -7px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(23,26,28,0.3);
    transition: transform 0.1s;
}
.pers-range::-webkit-slider-thumb:hover { transform: scale(1.1); }
.pers-range::-webkit-slider-thumb:active { transform: scale(0.95); }
.pers-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-dark);
    border: 3px solid var(--color-yellow);
    cursor: pointer;
}
.pers-range__labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-gray-500);
    margin-top: 8px;
}
.pers-range__labels span { display: flex; align-items: center; gap: 4px; }

.pers-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

/* Preview */
.pers-preview { position: sticky; top: 20px; }
.pv-result {
    margin-top: 14px;
    border: 1px solid rgba(238, 203, 59, 0.5);
    background: #fffbea;
    border-radius: var(--radius);
    padding: 14px 16px;
}
.pv-result__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.pv-result__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-yellow);
}
.pv-result__name {
    font-size: 14px;
    font-weight: 700;
}
.pv-result__model {
    font-size: 11px;
    color: var(--color-gray-500);
    font-weight: 500;
    margin-left: 2px;
}
.pv-result__meta {
    font-size: 11px;
    color: var(--color-gray-500);
}
.pv-result__text {
    font-size: 14px;
    line-height: 1.55;
    color: var(--color-dark);
}
.pv-result__text > *:first-child { margin-top: 0; }
.pv-result__text > *:last-child  { margin-bottom: 0; }
.pv-result__text p  { margin: 0 0 8px; }
.pv-result__text strong { font-weight: 700; }
.pv-result__text ul, .pv-result__text ol { margin: 6px 0 10px; padding-left: 22px; }
.pv-result__text li { margin: 3px 0; }
.pv-result__text a {
    color: var(--color-dark);
    text-decoration: underline;
    text-decoration-color: var(--color-yellow);
    text-decoration-thickness: 2px;
    font-weight: 600;
}
.pv-result__text code {
    background: rgba(23, 26, 28, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
}
.pv-result__text blockquote {
    margin: 8px 0;
    padding: 4px 10px;
    border-left: 3px solid var(--color-yellow);
    background: rgba(238, 203, 59, 0.10);
    border-radius: 0 6px 6px 0;
}

/* El atributo hidden de HTML no gana frente a display:inline-flex. Forzamos. */
[hidden] { display: none !important; }

.pv-loading {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-gray-500);
    font-size: 13px;
}
.pv-loading .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-gray-400);
    animation: typing 1.2s infinite;
}
.pv-loading .dot:nth-child(2) { animation-delay: 0.15s; }
.pv-loading .dot:nth-child(3) { animation-delay: 0.30s; }

/* -------------------- Conocimiento (RAG) -------------------- */

/* Segmented control: tipo de entrada */
.seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 6px;
    background: #f3f3f4;
    border-radius: 14px;
    margin-bottom: 18px;
}
.seg__btn {
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--color-gray-500);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
    font-family: inherit;
}
.seg__btn:hover { background: rgba(255,255,255,0.6); color: var(--color-dark); }
.seg__btn.is-active {
    background: var(--color-white);
    color: var(--color-dark);
    border-color: var(--color-yellow);
    box-shadow: 0 2px 6px rgba(23, 26, 28, 0.06);
}
.seg__icon { font-size: 20px; }
.seg__text { font-weight: 700; font-size: 13px; }
.seg__hint { font-size: 11px; color: var(--color-gray-500); }
.seg__btn.is-active .seg__hint { color: #6c4f00; }

.seg-panel { animation: msgIn 0.18s ease-out; }

/* Pills de tipo en la tabla */
.tipo-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.tipo-pill--documento { background: #eaf3ff; color: #2363b8; border: 1px solid #c7dcfa; }
.tipo-pill--enlace    { background: #fffaea; color: #6c4f00; border: 1px solid #f0d398; }
.tipo-pill--nota      { background: #f0f7ec; color: #3a6a1d; border: 1px solid #cce3bc; }

.doc-link {
    color: var(--color-dark);
    text-decoration: none;
    border-bottom: 1px dotted var(--color-gray-400);
    font-size: 13px;
}
.doc-link:hover { color: #2363b8; border-bottom-color: #2363b8; }

/* ================== Etiquetas (locales / puestos) ================== */

/* Explainer top — locales vs puestos */
.tag-explain {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.tag-explain li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--color-white);
    border: 1px solid rgba(23, 26, 28, 0.06);
    border-radius: var(--radius-lg);
    font-size: 13.5px;
    line-height: 1.55;
}
.tag-explain__icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
}
.tag-explain__icon--local   { background: #fff7d6; color: #6c4f00; }
.tag-explain__icon--puesto  { background: #eef3ff; color: #2363b8; }

/* Tabla de tags — fila normal, inputs dentro de TD, alineación con cabeceras */
.tag-table thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-gray-500);
    font-weight: 600;
    padding: 0 8px 10px;
}
.tag-table thead th.actions { text-align: right; }

.tag-table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(23, 26, 28, 0.04);
    vertical-align: middle;
}
.tag-table tbody tr:last-child td { border-bottom: none; }
.tag-table tbody td.actions {
    text-align: right;
    white-space: nowrap;
    width: 90px;
}
.tag-table tbody td.actions .btn-icon + .btn-icon { margin-left: 4px; }

.tag-table input.pers-input {
    padding: 9px 12px;
    font-size: 13.5px;
    background: var(--color-white);
}

/* Anchos de columna para evitar saltos de tamaño */
.tag-table--local  thead th:nth-child(1),
.tag-table--local  tbody td:nth-child(1) { width: 42%; }
.tag-table--local  thead th:nth-child(2),
.tag-table--local  tbody td:nth-child(2) { width: 28%; }
.tag-table--local  thead th:nth-child(3),
.tag-table--local  tbody td:nth-child(3) { width: 130px; }

.tag-table--puesto thead th:nth-child(1),
.tag-table--puesto tbody td:nth-child(1) { width: 70%; }
.tag-table--puesto thead th:nth-child(2),
.tag-table--puesto tbody td:nth-child(2) { width: 130px; }

/* Variante compacta del switch para usar dentro de filas */
.switch--compact { gap: 8px; }
.switch--compact .switch__slider { width: 36px; height: 20px; }
.switch--compact .switch__slider::after {
    width: 16px; height: 16px; top: 2px; left: 2px;
}
.switch--compact input:checked + .switch__slider::after { transform: translateX(16px); }
.switch--compact .switch__text {
    font-size: 12.5px;
    color: var(--color-gray-500);
}
.switch--compact input:checked ~ .switch__text { color: var(--color-dark); }

/* Botones-icono (guardar / borrar) */
.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    background: transparent;
    color: var(--color-gray-500);
    border: 1.5px solid rgba(23, 26, 28, 0.12);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.05s;
}
.btn-icon:hover {
    background: var(--color-dark);
    color: var(--color-yellow);
    border-color: var(--color-dark);
}
.btn-icon:active { transform: scale(0.94); }
.btn-icon--danger:hover {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

/* Form de creación nueva etiqueta */
.tag-create {
    display: grid;
    grid-template-columns: 1.4fr 1fr auto;
    gap: 10px;
    margin-top: 12px;
    padding: 14px;
    background: #fafafa;
    border: 1px dashed rgba(23, 26, 28, 0.15);
    border-radius: var(--radius-lg);
    align-items: center;
}
.tag-create--no-city { grid-template-columns: 1fr auto; }
.tag-create input.pers-input {
    padding: 9px 12px;
    font-size: 13.5px;
    background: var(--color-white);
}

.upload-form { display: flex; flex-direction: column; gap: 14px; }
.upload-form__row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}
.upload-form__actions { display: flex; justify-content: flex-end; }

.upload-drop {
    position: relative;
    border: 2px dashed rgba(23, 26, 28, 0.18);
    border-radius: 14px;
    padding: 32px 20px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.05s;
    background: #fbfbfa;
    cursor: pointer;
}
.upload-drop:hover, .upload-drop.is-over {
    border-color: var(--color-yellow);
    background: #fffdf2;
}
.upload-drop.has-file {
    border-color: var(--color-yellow);
    background: #fffaea;
}
.upload-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.upload-drop__hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    color: var(--color-gray-500);
    font-size: 14px;
}
.upload-drop__hint strong { color: var(--color-dark); }
.upload-drop__hint small { font-size: 11px; color: var(--color-gray-400); }
.upload-drop__icon { font-size: 28px; }

/* Tabla de documentos */
.doc-table th, .doc-table td { vertical-align: middle; }
.doc-table .actions { text-align: right; white-space: nowrap; }
.doc-row--inactive td { opacity: 0.6; }

.doc-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
}
.doc-status--on  { background: #e7f7ec; color: #1d6a3a; }
.doc-status--off { background: #f3f3f4; color: #6b6f74; }

.doc-cat {
    display: inline-block;
    padding: 2px 10px;
    background: var(--color-dark);
    color: var(--color-yellow);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.inline-form { display: inline; }
.btn-mini {
    background: transparent;
    color: var(--color-gray-500);
    border: 1px solid rgba(23, 26, 28, 0.12);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    margin-left: 4px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-mini:hover { background: var(--color-dark); color: var(--color-yellow); border-color: var(--color-dark); }
.btn-mini--danger:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

.rag-explain ol {
    margin: 6px 0 12px;
    padding-left: 22px;
    line-height: 1.7;
    color: var(--color-dark);
}
.rag-explain li { margin-bottom: 4px; }

/* -------------------- Visor de conversaciones -------------------- */

.admin-back {
    color: var(--color-gray-500);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.admin-back:hover { color: var(--color-dark); }

.conv-filters {
    display: grid;
    grid-template-columns: 1.6fr 1.4fr 0.9fr 0.9fr auto;
    gap: 12px;
    align-items: end;
}
.conv-filters__field { display: flex; flex-direction: column; gap: 6px; }
.conv-filters__field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.conv-filters__field--narrow { max-width: 160px; }
.conv-filters__actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.conv-table th, .conv-table td { vertical-align: middle; }
.conv-table__dni {
    font-size: 11px;
    margin-top: 2px;
}
.conv-table .actions { width: 60px; text-align: right; }

.conv-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid rgba(23, 26, 28, 0.06);
}
.conv-pager__btn {
    padding: 6px 14px;
    color: var(--color-dark);
    text-decoration: none;
    border: 1.5px solid rgba(23, 26, 28, 0.16);
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
}
.conv-pager__btn:hover { background: var(--color-dark); color: var(--color-yellow); border-color: var(--color-dark); }
.conv-pager__btn[aria-disabled="true"] {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}
.conv-pager__info { font-size: 13px; color: var(--color-gray-500); }

/* Detalle de conversación */
.conv-detail__head {
    display: grid;
    grid-template-columns: 2fr 1.4fr 1fr;
    gap: 16px;
    padding: 18px 20px;
}
.conv-detail__col + .conv-detail__col { border-left: 1px solid rgba(23, 26, 28, 0.06); padding-left: 16px; }
.conv-detail__value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 2px;
    line-height: 1.2;
}

.conv-transcript {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.conv-transcript__day {
    text-align: center;
    margin: 6px 0 2px;
}
.conv-transcript__day span {
    display: inline-block;
    padding: 3px 12px;
    background: rgba(23, 26, 28, 0.07);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-500);
    letter-spacing: 0.04em;
}

.conv-msg {
    padding: 12px 14px;
    border-radius: 12px;
    max-width: 88%;
    box-shadow: 0 1px 2px rgba(23, 26, 28, 0.04);
}
.conv-msg--user {
    background: #fffaea;
    border: 1px solid rgba(238, 203, 59, 0.45);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.conv-msg--assistant {
    background: var(--color-white);
    border: 1px solid rgba(23, 26, 28, 0.08);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.conv-msg__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    gap: 10px;
}
.conv-msg__who { font-size: 12.5px; font-weight: 600; }
.conv-msg__time {
    font-size: 11px;
    color: var(--color-gray-400);
    font-variant-numeric: tabular-nums;
}
.conv-msg__model {
    font-size: 11px;
    color: var(--color-gray-500);
    font-weight: 500;
}
.conv-msg__body {
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.conv-msg__meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-gray-400);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ================== Switch elegante (reutilizable) ================== */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}
.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.switch__slider {
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    background: #d8d9dc;
    border-radius: 999px;
    position: relative;
    transition: background 0.18s ease;
}
.switch__slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(23, 26, 28, 0.20);
    transition: transform 0.18s ease;
}
.switch:hover .switch__slider { background: #cbccd0; }
.switch input:checked + .switch__slider {
    background: var(--color-yellow);
}
.switch input:checked + .switch__slider::after {
    transform: translateX(20px);
}
.switch input:focus-visible + .switch__slider {
    box-shadow: 0 0 0 4px rgba(238, 203, 59, 0.30);
}
.switch__text {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-dark);
}

/* ================== Empleados ================== */

.emp-filters {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}
.emp-filters__field { display: flex; flex-direction: column; gap: 6px; }
.emp-filters__field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.emp-filters__actions {
    display: flex; gap: 8px; align-items: flex-end;
}

/* Tabla empleados */
.emp-table td { vertical-align: middle; }
.emp-table .actions { text-align: right; white-space: nowrap; width: 90px; }

.emp-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}
.emp-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-yellow) 0%, #f5dc63 100%);
    color: var(--color-dark);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex: 0 0 auto;
    box-shadow: 0 1px 3px rgba(238, 203, 59, 0.4);
}
.emp-cell__body { min-width: 0; }
.emp-cell__name { font-weight: 600; font-size: 14px; }
.emp-cell__sub { font-size: 12px; margin-top: 2px; display: flex; gap: 6px; }

.emp-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 280px;
}
.emp-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px 3px 7px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
}
.emp-tag--local  { background: #fff7d6; color: #6c4f00; }
.emp-tag--puesto { background: #eef3ff; color: #2363b8; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
}
.status-pill--on      { background: #e7f7ec; color: #1d6a3a; }
.status-pill--off     { background: #f3f3f4; color: #6b6f74; }
.status-pill--blocked { background: #fdecea; color: #a23029; }

/* ================== Empleado edit form ================== */

.emp-form { display: flex; flex-direction: column; gap: 18px; }
.emp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}
/* Cuando hay un switch a la izquierda y un input a la derecha:
   el switch va más estrecho, el input ocupa más espacio. */
.emp-grid--switch-left {
    grid-template-columns: minmax(260px, auto) 1fr;
}

.emp-switch-field {
    padding: 14px 16px;
    background: #fafafa;
    border: 1px solid rgba(23, 26, 28, 0.06);
    border-radius: 12px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}
.emp-switch-field .pers-help-small { margin: 0; }

.emp-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid rgba(23, 26, 28, 0.06);
}

.emp-tags-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.emp-tags-col h3.emp-tags-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
}
.emp-tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
}
.emp-restr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

/* Checkbox elegante con caja */
.emp-tag-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1.5px solid rgba(23, 26, 28, 0.10);
    border-radius: 10px;
    cursor: pointer;
    background: var(--color-white);
    transition: border-color 0.12s, background 0.12s;
    user-select: none;
}
.emp-tag-check:hover { border-color: var(--color-dark); }
.emp-tag-check input { position: absolute; opacity: 0; pointer-events: none; }
.emp-tag-check__box {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid rgba(23, 26, 28, 0.25);
    background: var(--color-white);
    flex: 0 0 auto;
    position: relative;
    transition: border-color 0.12s, background 0.12s;
}
.emp-tag-check__box::after {
    content: '';
    position: absolute;
    top: 3px; left: 6px;
    width: 4px; height: 8px;
    border: solid var(--color-dark);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.12s;
}
.emp-tag-check input:checked + .emp-tag-check__box {
    background: var(--color-yellow);
    border-color: var(--color-yellow);
}
.emp-tag-check input:checked + .emp-tag-check__box::after {
    transform: rotate(45deg) scale(1);
}
.emp-tag-check input:checked ~ .emp-tag-check__text { color: var(--color-dark); font-weight: 600; }
.emp-tag-check__text {
    font-size: 13px;
    color: var(--color-gray-500);
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}
.emp-tag-check__text small {
    color: var(--color-gray-400);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Variante restricción: rojo cuando checked = restringido */
.emp-tag-check--restrict input:checked + .emp-tag-check__box {
    background: #c0392b;
    border-color: #c0392b;
}
.emp-tag-check--restrict input:checked + .emp-tag-check__box::after { border-color: #fff; }
.emp-tag-check--restrict input:checked ~ .emp-tag-check__text {
    color: #a23029;
}

/* Sección de admin (visible cuando se concede acceso) */
.emp-admin-fields { animation: msgIn 0.18s ease-out; }

/* Caja de "zona peligrosa" para resetear chat */
.emp-danger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 14px 16px;
    background: #fff7f5;
    border: 1px solid #f4c7c3;
    border-radius: 12px;
}
.emp-danger-row strong { color: #a23029; }
.btn--danger:hover {
    background: #c0392b !important;
    color: #fff !important;
    border-color: #c0392b !important;
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.35) !important;
}

/* ================== Banners (admin) ================== */
.banner-table .actions { white-space: nowrap; text-align: right; }
.banner-table__hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    margin-top: 2px;
}
.banner-table__sched {
    font-size: 12.5px;
    line-height: 1.5;
}

/* Status pill — extiende los existentes */
.status-pill--sched {
    background: #eaf3ff;
    color: #2363b8;
}
.status-pill--exp {
    background: #f3f3f4;
    color: #6b6f74;
}

/* Imagen actual del banner en edit */
.banner-current-image {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
    background: #fafafa;
    border: 1px solid rgba(23, 26, 28, 0.06);
    border-radius: 12px;
    margin-bottom: 12px;
}
.banner-current-image img {
    max-width: 180px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(23, 26, 28, 0.10);
}
.banner-remove-image {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-gray-500);
    cursor: pointer;
}
.banner-remove-image input { accent-color: #c0392b; }
.banner-upload-drop { padding: 22px 16px; }

/* ================== Métricas ================== */

/* Chart.js wrapper — altura fija para que no salte el layout */
.chart-wrap {
    position: relative;
    height: 260px;
    width: 100%;
}

/* Grid de 2 columnas para parejas de cards */
.metrics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

/* Heatmap horas del día (24 columnas) */
.heatmap {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 4px;
    align-items: end;
    height: 160px;
    margin-bottom: 12px;
}
.heatmap__cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    position: relative;
    gap: 4px;
}
.heatmap__hour {
    font-size: 9px;
    color: var(--color-gray-400);
    font-variant-numeric: tabular-nums;
    order: 3;
}
.heatmap__val {
    position: absolute;
    top: 0;
    font-size: 9px;
    color: var(--color-gray-500);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.15s;
}
.heatmap__cell:hover .heatmap__val { opacity: 1; }
.heatmap__bar {
    width: 100%;
    background: linear-gradient(180deg, var(--color-yellow) 0%, #d8b833 100%);
    border-radius: 4px 4px 1px 1px;
    height: calc(var(--pct, 0) * 100%);
    min-height: 2px;
    transition: filter 0.15s;
    order: 2;
}
.heatmap__cell:hover .heatmap__bar { filter: brightness(0.85); }

/* Rank list (barras horizontales) */
.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rank-list li {
    display: grid;
    grid-template-columns: minmax(120px, 1.4fr) 3fr 60px;
    gap: 12px;
    align-items: center;
}
.rank-list__name {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rank-list__name small {
    font-weight: 500;
    color: var(--color-gray-400);
    font-size: 11px;
}
.rank-list__bar {
    height: 10px;
    background: var(--color-gray-100);
    border-radius: var(--radius-pill);
    position: relative;
    overflow: hidden;
}
.rank-list__bar::after {
    content: '';
    position: absolute;
    inset: 0;
    width: calc(var(--pct, 0) * 100%);
    background: linear-gradient(90deg, var(--color-yellow) 0%, #d8b833 100%);
    border-radius: var(--radius-pill);
    transition: width 0.4s ease;
}
.rank-list__bar--local::after  { background: linear-gradient(90deg, #fff7d6 0%, var(--color-yellow) 100%); }
.rank-list__bar--puesto::after { background: linear-gradient(90deg, #c7dcfa 0%, #2363b8 100%); }
.rank-list__val {
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Cron status (dos columnas) */
.cron-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.cron-status__block {
    padding: 14px 16px;
    background: var(--color-white);
    border: 1px solid rgba(23, 26, 28, 0.06);
    border-radius: 12px;
}
.cron-status__value strong {
    display: block;
    font-size: 18px;
    margin: 4px 0 2px;
}

/* -------------------- Responsive -------------------- */
@media (max-width: 1080px) {
    .metrics-row { grid-template-columns: 1fr; }
    .cron-status { grid-template-columns: 1fr; }
    .heatmap { height: 120px; gap: 2px; }
    .heatmap__hour { font-size: 8px; }

    .pers-grid { grid-template-columns: 1fr; }
    .pers-preview { position: static; }
    .upload-form__row { grid-template-columns: 1fr; }
    .conv-filters { grid-template-columns: 1fr 1fr; }
    .conv-filters__actions { grid-column: 1 / -1; justify-content: flex-end; }
    .conv-detail__head { grid-template-columns: 1fr; }
    .conv-detail__col + .conv-detail__col { border-left: none; border-top: 1px solid rgba(23,26,28,0.06); padding-left: 0; padding-top: 14px; }
    .emp-filters { grid-template-columns: 1fr 1fr; }
    .emp-filters__actions { grid-column: 1 / -1; justify-content: flex-end; }
    .emp-grid, .emp-tags-section { grid-template-columns: 1fr; }
    .emp-tags { max-width: none; }
}

@media (max-width: 860px) {
    body.admin {
        grid-template-columns: 1fr;
    }
    .admin-side {
        position: static;
        height: auto;
        flex-direction: row;
        gap: 14px;
        overflow-x: auto;
        padding: 14px 16px;
    }
    .admin-side__brand { flex: 0 0 auto; }
    .admin-nav { flex-direction: row; flex: 1 1 auto; gap: 4px; }
    .admin-nav__item { white-space: nowrap; }
    .admin-side__footer { display: none; }
    .admin-main { padding: 16px; }
    .admin-topbar__title { font-size: 22px; }
}
