/* ==========================================================================
   HEa·Ven — Panel de gestión interno
   Sistema visual: identidad índigo "medianoche" + acento ámbar cálido.
   Tipografía:
     · Space Grotesk  → marca, titulares y números grandes
     · IBM Plex Sans  → texto de interfaz
     · IBM Plex Mono  → datos operativos (teléfonos, totales, folios, horas)
   Sin frameworks, como pide el MVP.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    /* Marca */
    --ink: #0F0F62;          /* índigo principal */
    --ink-700: #1E1E8C;      /* índigo más claro (hover) */
    --ink-900: #0A0A2E;      /* índigo profundo (fondos oscuros) */
    --amber: #E07B23;        /* ámbar (acento cálido) */
    --amber-300: #F2A341;

    /* Neutros */
    --bg: #ECEEF6;
    --surface: #ffffff;
    --surface-2: #F7F8FC;
    --border: #E1E4F0;
    --border-2: #EDEFF6;
    --text: #1B1C32;
    --text-muted: #62657E;
    --text-faint: #9A9DB4;

    /* Estados de orden */
    --st-pendiente:   #C0362C;
    --st-preparacion: #CF8A1A;
    --st-lista:       #2B6CB0;
    --st-entregada:   #2F855A;

    /* Tipografía */
    --font-ui:      "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: "Space Grotesk", "IBM Plex Sans", sans-serif;
    --font-mono:    "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(20,22,55,0.06), 0 1px 3px rgba(20,22,55,0.05);
    --shadow-md: 0 4px 18px rgba(20,22,55,0.09);
    --shadow-lg: 0 14px 44px rgba(10,12,45,0.18);

    --radius: 12px;
    --topbar-h: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-ui);
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
}

/* ==========================================================================
   Barra superior
   ========================================================================== */
.topbar {
    display: flex;
    align-items: center;
    gap: 26px;
    height: var(--topbar-h);
    padding: 0 22px;
    background: linear-gradient(180deg, #15156e 0%, var(--ink) 100%);
    color: #fff;
    box-shadow: inset 0 -1px 0 rgba(224,123,35,0.55), 0 1px 0 rgba(0,0,0,0.04);
    position: relative;
    z-index: 60;
}

/* Marca */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}
.brand-mark {
    width: 20px;
    height: 20px;
    color: var(--amber-300);
    flex-shrink: 0;
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.18rem;
    letter-spacing: 0.2px;
    line-height: 1;
}

/* Navegación */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.nav-link {
    color: rgba(255,255,255,0.66);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 8px;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-link[aria-current="page"] {
    color: #fff;
    background: rgba(255,255,255,0.10);
    box-shadow: inset 0 -2px 0 var(--amber-300);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.actualizacion {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: rgba(255,255,255,0.62);
    white-space: nowrap;
}
.logout {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.28);
    padding: 6px 12px;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.logout:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.5); }

@media (max-width: 768px) {
    :root { --topbar-h: 52px; }
    .topbar { gap: 14px; padding: 0 14px; }
    .brand-name { display: none; }
    .brand-mark { width: 22px; height: 22px; }
    .nav-link { font-size: 0.8rem; padding: 6px 10px; }
    .actualizacion { display: none; }
    .logout { font-size: 0.74rem; padding: 5px 9px; }
}

main { padding: 26px; }

@media (max-width: 768px) {
    main { padding: 16px; }
}

/* Encabezado de página (eyebrow + título) -------------------------------- */
.page-head { margin: 2px 0 22px; }
.page-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--amber);
    margin: 0 0 6px;
}
.page-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--text);
}

/* ==========================================================================
   Rejilla de órdenes
   ========================================================================== */
.grid-ordenes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
}

@media (max-width: 768px) {
    .grid-ordenes { grid-template-columns: 1fr; gap: 12px; }
}

.sin-ordenes {
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 56px;
}

/* ----------------------- Tarjeta de orden ----------------------- */
.orden {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    transition: box-shadow 0.18s, transform 0.18s;
}
.orden:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Color del borde y la etiqueta según el estado */
.estado-pendiente   { border-left-color: var(--st-pendiente); }
.estado-preparacion { border-left-color: var(--st-preparacion); }
.estado-lista       { border-left-color: var(--st-lista); }
.estado-entregada   { border-left-color: var(--st-entregada); opacity: 0.72; }

.orden-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.numero {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.badge {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.estado-pendiente   .badge { background: #FBEAE8; color: var(--st-pendiente);   border-color: #F3D2CE; }
.estado-preparacion .badge { background: #FBF1DC; color: #9A6608;               border-color: #F0E0BC; }
.estado-lista       .badge { background: #E7F0FA; color: var(--st-lista);       border-color: #CFE0F2; }
.estado-entregada   .badge { background: #E6F2EC; color: var(--st-entregada);   border-color: #CDE6D8; }

.items {
    list-style: none;
    padding: 12px 0;
    margin: 0 0 12px 0;
    border-top: 1px solid var(--border-2);
    border-bottom: 1px solid var(--border-2);
}
.items li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    font-size: 0.9rem;
}
.items .precio { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.84rem; }

/* Nota del cliente (pedido web): sola, debajo de los productos, sin precio. */
.items li.item-nota {
    display: block;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    padding-top: 8px;
    line-height: 1.4;
}
.items li.item-nota strong { color: var(--text); font-style: normal; }

/* Indicación especial de un producto (ej. "sin huevo"). Resaltada para que la
   cocina no la pase por alto: va debajo del producto, en rojo y en negrita. */
.items li.item-nota-cocina {
    display: block;
    color: #B42318;
    background: #FEF3F2;
    border-left: 3px solid #B42318;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 4px 8px;
    margin: 2px 0 4px 12px;
    border-radius: 4px;
}

.orden-datos {
    font-size: 0.88rem;
    line-height: 1.7;
    margin-bottom: 14px;
    color: var(--text-muted);
}
.orden-datos strong { color: var(--text); font-weight: 600; }

/* ----------------------- Botones de estado ----------------------- */
.acciones { display: flex; flex-wrap: wrap; gap: 6px; }
.form-estado { margin: 0; }
.btn-estado {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 11px;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.15s;
}
.btn-estado:hover { border-color: var(--ink); color: var(--ink); background: #F4F4FB; }

/* ----------------------- Botón eliminar / archivar orden ----------------------- */
.btn-eliminar {
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-faint);
    font-size: 1.05rem;
    line-height: 1;
    padding: 2px 7px;
    border-radius: 6px;
    margin-left: auto;
    transition: all 0.15s;
}
.btn-eliminar:hover { background: #FBEAE8; color: var(--st-pendiente); }

/* ==========================================================================
   Página de configuración
   ========================================================================== */
.config-main { padding: 26px 24px 64px; max-width: 900px; margin: 0 auto; }

@media (max-width: 768px) {
    .config-main { padding: 18px 16px 60px; }
}

/* Encabezado pegajoso con el botón de guardar siempre visible */
.config-cabecera {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(236,238,246,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px 0;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

@media (max-width: 768px) {
    .config-cabecera { flex-direction: column; align-items: stretch; padding: 12px 0; }
}
.config-cabecera-texto h2 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
}
.config-cabecera-texto p { margin: 3px 0 0; color: var(--text-muted); font-size: 0.85rem; }

.btn-guardar {
    cursor: pointer;
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px 22px;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(15,15,98,0.22);
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn-guardar:hover { background: var(--ink-700); box-shadow: 0 4px 16px rgba(15,15,98,0.3); }
.btn-guardar:active { transform: translateY(1px); }

.config-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px 26px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}
.config-section h3 {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.config-section > .hint { margin-top: 0; }

.campo-grupo { margin-bottom: 15px; }
.campo-grupo label, .campo-row label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.campo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 768px) {
    .campo-row { grid-template-columns: 1fr; }
}
.campo-config {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.campo-config::placeholder { color: var(--text-faint); }
.campo-config:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(15,15,98,0.10);
    background: var(--surface);
}
textarea.campo-config { resize: vertical; }

.hint { color: var(--text-muted); font-size: 0.82rem; margin: 4px 0 16px; line-height: 1.5; }

/* Horarios */
.horarios-grid { display: flex; flex-direction: column; gap: 10px; }
.horario-fila { display: flex; align-items: center; gap: 12px; }
.horario-dia {
    width: 92px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
    transition: color 0.2s;
}
.dia-cerrado { color: var(--text-faint); }
.horario-fila .campo-config { flex: 1; }
.campo-config:disabled { opacity: 0.45; cursor: not-allowed; background: #F1F2F7; }
.horario-badge-cerrado {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-faint);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    min-width: 54px;
}

/* Menú */
.menu-categoria {
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.categoria-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.categoria-titulo {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

.items-lista { padding: 4px 16px; }

.item-menu {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-2);
}
.items-lista .item-menu:last-child { border-bottom: none; }
.item-no-disponible { opacity: 0.5; }
.item-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.item-nombre { font-weight: 500; }
.item-desc { color: var(--text-muted); font-size: 0.82rem; }
.item-precio { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.moneda-simbolo { font-family: var(--font-mono); font-size: 0.92rem; color: var(--text-muted); font-weight: 500; }
.campo-xs { width: 88px; text-align: right; font-family: var(--font-mono); }
.campo-sm { min-width: 150px; }

/* Toggle switch (disponible / agotado, día abierto / cerrado) */
.toggle-wrap { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: #CBD0DE; border-radius: 24px; cursor: pointer;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
    transition: transform 0.2s;
}
.toggle-input:checked + .toggle-slider { background: var(--ink); }
.toggle-input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-input:focus-visible + .toggle-slider { box-shadow: 0 0 0 3px rgba(224,123,35,0.4); }

/* Estado del bot (pausar / reanudar) */
.bot-estado-section { border-left: 4px solid var(--ink); }
.bot-estado-fila { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.toggle-grande { width: 56px; height: 30px; }
.toggle-grande .toggle-slider { border-radius: 30px; }
.toggle-grande .toggle-slider::before { width: 24px; height: 24px; left: 3px; bottom: 3px; }
.toggle-grande .toggle-input:checked + .toggle-slider::before { transform: translateX(26px); }
.bot-estado-texto { font-weight: 600; font-size: 1.02rem; }
.estado-activo { color: var(--ink); }
.estado-pausa  { color: var(--amber); }

/* Botones auxiliares */
.btn-secundario {
    cursor: pointer;
    border: 1px solid var(--ink);
    background: var(--surface);
    color: var(--ink);
    border-radius: 9px;
    padding: 8px 14px;
    font-family: var(--font-ui);
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.btn-secundario:hover { background: var(--ink); color: #fff; }

.btn-mini {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 11px;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-mini:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-peligro { border-color: #E7B3AE; color: var(--st-pendiente); }
.btn-peligro:hover { background: #FBEAE8; border-color: var(--st-pendiente); }

.nuevo-item {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 4px 16px 14px;
    padding-top: 13px;
    border-top: 1px dashed var(--border);
}
.nueva-categoria { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* Toast de notificación */
.toast {
    position: fixed;
    top: 70px;
    right: 24px;
    padding: 13px 20px;
    border-radius: 11px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 999;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.22s ease-out;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.toast-exito { background: #E6F2EC; color: var(--st-entregada); border: 1px solid #BFE0CC; }
.toast-error { background: #FBEAE8; color: var(--st-pendiente); border: 1px solid #EFC4BF; }

/* ==========================================================================
   Página de historial
   ========================================================================== */
.historial-main { padding: 26px 24px 64px; max-width: 1120px; margin: 0 auto; }

@media (max-width: 768px) {
    .historial-main { padding: 18px 16px 56px; }
}

/* Filtros de día */
.hist-filtros { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.hist-btn-dia {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 7px 16px;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}
.hist-btn-dia:hover  { border-color: var(--ink); color: var(--ink); }
.hist-btn-dia.activo { background: var(--ink); color: #fff; border-color: var(--ink); }
.hist-fecha-input {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 14px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--surface);
    cursor: pointer;
}
.hist-fecha-input:focus { outline: none; border-color: var(--ink); }

/* Nombre + teléfono en historial */
.hist-nombre  { font-weight: 600; color: var(--text); font-size: 0.88rem; }
.hist-tel-sub { color: var(--text-faint); font-size: 0.78rem; font-family: var(--font-mono); }
.hist-nota    { color: var(--amber); font-size: 0.8rem; font-style: italic; }

.historial-cabecera {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.historial-cabecera h2 {
    margin: 0 0 3px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: -0.01em;
}
.historial-cabecera .hint { margin: 0; }

.historial-resumen { display: flex; gap: 14px; }
.resumen-card {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px 22px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    min-width: 116px;
}
.resumen-num {
    display: block;
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 600;
    color: var(--ink);
}
.resumen-label { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.historial-tabla-wrap {
    background: var(--surface);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
.historial-tabla { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.historial-tabla thead tr { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.historial-tabla th {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}
.historial-tabla td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-2);
    vertical-align: top;
}
.historial-tabla tbody tr:last-child td { border-bottom: none; }
.historial-tabla tbody tr:hover { background: var(--surface-2); }

.hist-numero { font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--ink); }
.hist-fecha  { white-space: nowrap; color: var(--text-muted); font-family: var(--font-mono); font-size: 0.8rem; }
.hist-items  { color: var(--text); max-width: 320px; }
.hist-total  { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.hist-tel    { color: var(--text-muted); font-size: 0.82rem; }
.col-num     { text-align: right; }

/* ==========================================================================
   Página de clientes
   ========================================================================== */
.cli-buscador { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.cli-input {
    flex: 1;
    min-width: 220px;
    max-width: 420px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 9px 18px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
}
.cli-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(15,15,98,0.08); }
.cli-resultado { font-size: 0.84rem; font-weight: 500; }
.cli-resultado.cli-ok { color: var(--st-entregada); }
.cli-resultado.cli-no { color: var(--st-pendiente); }

.cli-sin-nombre { color: var(--text-faint); font-style: italic; font-size: 0.85rem; }

.cli-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.cli-badge-cliente  { background: #E6F2EC; color: var(--st-entregada); border: 1px solid #BFE0CC; }
.cli-badge-contacto { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ==========================================================================
   Pantalla de login
   ========================================================================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 25% 30%, #16166f 0%, var(--ink-900) 62%);
    position: relative;
    overflow: hidden;
    padding: 24px;
}
/* Campo estelar tenue del fondo (decorativo) */
.login-body::before,
.login-body::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1.5px 1.5px at 70% 20%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1.5px 1.5px at 40% 70%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.5px 1.5px at 85% 60%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.5px 1.5px at 55% 45%, rgba(242,163,65,0.45), transparent);
    pointer-events: none;
}
.login-body::after { opacity: 0.5; transform: scale(1.4); }

.login-card {
    position: relative;
    z-index: 2;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 40px 34px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(91,91,230,0.12);
    width: 340px;
    max-width: 100%;
    text-align: center;
    color: #fff;
}
.login-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 22px;
    color: #fff;
}
.login-brand .brand-mark { width: 22px; height: 22px; color: var(--amber-300); }
.login-brand span {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: 0.2px;
}
.login-card h1 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.12rem;
    color: #fff;
}
.login-sub { color: rgba(255,255,255,0.55); font-size: 0.88rem; margin-bottom: 24px; line-height: 1.5; }
.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 1rem;
    font-family: var(--font-ui);
    background: rgba(255,255,255,0.06);
    color: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input::placeholder { color: rgba(255,255,255,0.4); }
.login-card input:focus {
    outline: none;
    border-color: var(--amber-300);
    box-shadow: 0 0 0 3px rgba(242,163,65,0.18);
}
.login-card button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--ink-700), #2a2ac4);
    color: #fff;
    border: 1px solid rgba(91,91,230,0.5);
    border-radius: 10px;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 4px 18px rgba(15,15,98,0.5);
}
.login-card button:hover { box-shadow: 0 6px 24px rgba(15,15,98,0.7); transform: translateY(-1px); }
.login-card button:active { transform: translateY(0); }
.login-error {
    background: rgba(192,54,44,0.18);
    color: #ffb4ad;
    border: 1px solid rgba(192,54,44,0.4);
    padding: 9px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 14px;
}

/* ==========================================================================
   Bandeja de chats (ver conversaciones e intervenir)
   ========================================================================== */
.chats-main {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 0;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
}

/* ----------------------- Lista de conversaciones ----------------------- */
.chats-lista {
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.chats-lista-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-2);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
}
.chats-actualizacion { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-faint); }

/* Pestañas Activos / Archivados */
.chats-tabs { display: flex; gap: 5px; }
.chats-tab {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 13px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.chats-tab:hover { background: var(--surface-2); }
.chats-tab-activo { background: var(--ink); color: #fff; border-color: var(--ink); }

.chat-item {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-2);
    cursor: pointer;
    transition: background 0.12s;
    border-left: 3px solid transparent;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item-activo { background: #F0F1FB; border-left-color: var(--ink); }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-item-tel { font-family: var(--font-mono); font-weight: 500; font-size: 0.86rem; color: var(--text); }
.chat-item-acciones { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-item-hora { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-faint); flex-shrink: 0; }
.chat-item-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 6px;
    color: var(--text-faint);
    transition: all 0.15s;
}
.chat-item-eliminar:hover { background: #FBEAE8; color: var(--st-pendiente); }
.chat-item-restaurar { color: var(--ink); }
.chat-item-restaurar:hover { background: #E9EAF8; }
.chat-item-preview {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sin-chats { text-align: center; color: var(--text-muted); padding: 34px 16px; font-size: 0.9rem; }

/* ----------------------- Hilo de conversación ----------------------- */
.chat-hilo { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.chat-vacio {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    font-size: 0.95rem;
    padding: 24px;
    text-align: center;
}
.chat-activo { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-hilo-cabecera {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-volver {
    display: none;     /* solo visible en móvil */
    border: none;
    background: transparent;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--ink);
    padding: 0 4px;
}
.chat-hilo-telefono { font-family: var(--font-mono); font-weight: 500; font-size: 0.92rem; }

.chat-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-burbuja {
    max-width: 70%;
    padding: 9px 13px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
}
.chat-burbuja-rol {
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
    opacity: 0.75;
}
.chat-burbuja-texto { font-size: 0.92rem; line-height: 1.45; white-space: pre-wrap; }
.chat-burbuja-hora { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-faint); text-align: right; margin-top: 4px; }

/* Cliente: burbuja blanca a la izquierda */
.msg-cliente { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; }
.msg-cliente .chat-burbuja-rol { color: var(--text-muted); }

/* Bot: burbuja índigo clara a la derecha */
.msg-bot { align-self: flex-end; background: #E7E8F7; border-bottom-right-radius: 4px; }
.msg-bot .chat-burbuja-rol { color: var(--ink); }

/* Dueño (manual): burbuja ámbar a la derecha */
.msg-dueno { align-self: flex-end; background: #FBEBD7; border-bottom-right-radius: 4px; }
.msg-dueno .chat-burbuja-rol { color: #9A5611; }

/* ----------------------- Caja para escribir ----------------------- */
.chat-form {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 0.92rem;
    font-family: inherit;
    line-height: 1.3;
    max-height: 120px;
    outline: none;
    background: var(--surface-2);
    transition: border-color 0.15s, background 0.15s;
}
.chat-input:focus { border-color: var(--ink); background: var(--surface); }
.chat-enviar {
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 22px;
    padding: 10px 20px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-enviar:hover { background: var(--ink-700); }
.chat-enviar:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----------------------- Chats en móvil ----------------------- */
@media (max-width: 768px) {
    .chats-main { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h)); }
    .chat-hilo { display: none; }
    .chats-main.ver-hilo .chats-lista { display: none; }
    .chats-main.ver-hilo .chat-hilo { display: flex; }
    .chat-volver { display: inline-block; }
    .chat-burbuja { max-width: 85%; }
}

/* ==========================================================================
   Página de conexión (vincular WhatsApp por QR)
   ========================================================================== */
.conexion-main { padding: 44px 20px; display: flex; justify-content: center; }
.conexion-card {
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    padding: 34px;
    max-width: 470px;
    width: 100%;
    text-align: center;
}
.conexion-card h2 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
}
.conexion-card .hint { margin: 0 0 24px; }

.conexion-estado {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    padding: 18px 20px;
    border-radius: 13px;
}
.conexion-estado.conectado { background: #E6F2EC; border: 1px solid #BFE0CC; }
.conexion-estado.espera { background: #FBF1DC; border: 1px solid #F0E0BC; }
.conexion-icono { display: inline-flex; flex-shrink: 0; color: var(--st-entregada); }
.conexion-titulo { font-weight: 600; font-size: 1rem; }
.conexion-sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.conexion-sub code {
    font-family: var(--font-mono);
    background: rgba(0,0,0,0.05);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.conexion-qr-wrap { text-align: center; }
.conexion-pasos {
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 20px;
}
.conexion-qr {
    width: 260px;
    height: 260px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    background: #fff;
}

/* Spinner de "esperando" */
.conexion-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #F0E0BC;
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: girar 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ==========================================================================
   Accesibilidad: respetar reducción de movimiento
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
