/*
    Panel de gestión

    Diseño "tipo app": fondo gris suave, tarjetas blancas redondeadas con relieve leve, íconos con
    color en cada sección y estado. En celular y tablet (hasta 1100 px) el menú es una barra abajo
    que se desliza de costado, las ventanas suben como hojas y las tablas se muestran como tarjetas
    (admin.js anota en cada celda su columna). Ahí la página no se desliza de costado y nada flota
    sobre el contenido: la ayuda está en la cabecera y la acción de cada pantalla, bajo el título.

    Dos temas, claro y oscuro: todo color sale de las variables de abajo. No escribir colores
    sueltos en las reglas; si falta uno, se suma como variable en los dos temas.
    --brand y --brand-contrast llegan desde la configuración de la tienda (tema_head.php).
*/

:root {
    --brand: #111111;
    --brand-contrast: #ffffff;

    --fondo: #f3f3f6;               /* la página */
    --superficie: #ffffff;          /* tarjetas, menú, campos, barras y lo que flota */
    --relleno: #eeedf2;             /* rellenos suaves: ítem activo, botones secundarios, hover */
    --linea: #e9e8ee;
    --linea-fuerte: #d3d2da;        /* bordes de campos */
    --texto: #17171c;
    --texto-suave: #5d5d68;
    --texto-tenue: #9d9da8;         /* íconos apagados, guiones, textos de ejemplo */

    --ok: #17603a;        --ok-fondo: #dff3e6;
    --aviso: #7a4b00;     --aviso-fondo: #fff1cc;
    --error: #a3271a;     --error-fondo: #ffe3e0;
    --azul: #1e46a8;      --azul-fondo: #e3ecff;
    --violeta: #5b2fb0;   --violeta-fondo: #eee6ff;
    --turquesa: #0c6b62;  --turquesa-fondo: #ddf4f1;
    --punto: #c8321f;               /* globos de pendientes y acciones de borrar (texto blanco encima) */
    /* Gráficos: más vivos que los de texto, porque rellenan superficies */
    --g-verde: #2fa36b;   --g-rojo: #e5584f;   --g-azul: #4c7df0;   --g-violeta: #8f67e8;
    --g-turquesa: #23b3a4; --g-ambar: #eaa92a; --g-gris: #b9b8c4;
    --whatsapp: #0e7a6d;

    --relieve: 0 1px 2px rgba(20, 20, 40, 0.05), 0 10px 24px rgba(20, 20, 40, 0.06);
    --relieve-bajo: 0 1px 2px rgba(20, 20, 40, 0.07);
    --sombra: 0 18px 44px rgba(20, 20, 40, 0.16), 0 2px 6px rgba(20, 20, 40, 0.06);
    --sombra-barra: 0 -6px 24px rgba(20, 20, 40, 0.09);
    --velo: rgba(20, 20, 28, 0.45);         /* detrás de los modales y las hojas */
    --anillo: rgba(23, 23, 28, 0.09);       /* foco de los campos */
    --borde-muestra: rgba(0, 0, 0, 0.18);   /* contorno de las muestras de color */

    --sidebar-width: 248px;
    --header-height: 64px;
    --alto-barra: 64px;             /* barra de navegación del celular */
    --radius: 14px;
    --radius-tarjeta: 20px;
    --suave: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Tema oscuro. :root[...] para ganarle al color de marca que escribe tema_head.php */
:root[data-tema="oscuro"] {
    color-scheme: dark;
    --brand: var(--brand-oscuro, #f2f2f4);
    --brand-contrast: var(--brand-oscuro-contraste, #121216);

    --fondo: #121216;
    --superficie: #1d1d23;
    --relleno: #2a2a32;
    --linea: #2c2c34;
    --linea-fuerte: #3f3f4a;
    --texto: #f2f2f4;
    --texto-suave: #a6a6b0;
    --texto-tenue: #6e6e79;

    --ok: #8fdcb0;        --ok-fondo: rgba(116, 207, 155, 0.16);
    --aviso: #ebc377;     --aviso-fondo: rgba(227, 180, 88, 0.16);
    --error: #f4a199;     --error-fondo: rgba(240, 120, 108, 0.17);
    --azul: #9dbcf8;      --azul-fondo: rgba(142, 182, 247, 0.16);
    --violeta: #c3adf5;   --violeta-fondo: rgba(185, 162, 240, 0.17);
    --turquesa: #86d6cd;  --turquesa-fondo: rgba(127, 208, 198, 0.16);
    --whatsapp: #62d1bf;
    --g-verde: #5fd39a;   --g-rojo: #f2857c;   --g-azul: #86a9fb;   --g-violeta: #b79df5;
    --g-turquesa: #5fd6c9; --g-ambar: #f0c35f; --g-gris: #5c5c68;

    --relieve: 0 1px 2px rgba(0, 0, 0, 0.3);
    --relieve-bajo: 0 1px 2px rgba(0, 0, 0, 0.3);
    --sombra: 0 20px 48px rgba(0, 0, 0, 0.6);
    --sombra-barra: 0 -6px 24px rgba(0, 0, 0, 0.35);
    --velo: rgba(0, 0, 0, 0.62);
    --anillo: rgba(255, 255, 255, 0.12);
    --borde-muestra: rgba(255, 255, 255, 0.28);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9375rem;
    background: var(--fondo);
    color: var(--texto);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--texto); outline-offset: 2px; }

/* Al cambiar de tema los colores pasan de uno a otro en vez de saltar (la clase la pone admin.js un instante) */
:root.cambiando-tema *, :root.cambiando-tema *::before, :root.cambiando-tema *::after { transition: background-color 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s !important; }

/* --- Menú lateral (solo en escritorio; en celular y tablet el menú es la barra de abajo) --- */
aside.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--superficie);
    box-shadow: var(--relieve-bajo);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 1000;
}

.sidebar-header { display: flex; align-items: center; height: var(--header-height); padding: 0 18px; flex-shrink: 0; }
.sidebar-logo-link { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
/* El ícono va sobre una placa blanca: en el tema oscuro los logos negros no se verían */
.sidebar-logo-link img { width: 36px; height: 36px; object-fit: contain; border-radius: 12px; background: #fff; box-shadow: var(--relieve-bajo); flex-shrink: 0; }
.sidebar-logo-link strong { font-size: 1rem; font-weight: 700; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logo-link small { display: block; font-size: 0.75rem; color: var(--texto-suave); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 6px 12px 16px; overflow-y: auto; scrollbar-width: thin; overscroll-behavior: contain; }

.nav-label { padding: 16px 10px 6px; font-size: 0.75rem; font-weight: 600; color: var(--texto-suave); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--texto-suave);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
/* Cada sección lleva su ícono en una placa de color */
.nav-item i { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--relleno); color: var(--texto-suave); font-size: 0.85rem; flex-shrink: 0; transition: background 0.15s, color 0.15s; }
.nav-item:hover { color: var(--texto); background: var(--relleno); }
.nav-item.active { color: var(--texto); background: var(--relleno); font-weight: 700; }
.nav-item.active i { background: var(--brand); color: var(--brand-contrast); }

.tinte-ambar i, .stat-icono.tinte-ambar { background: var(--aviso-fondo); color: var(--aviso); }
.tinte-azul i, .stat-icono.tinte-azul { background: var(--azul-fondo); color: var(--azul); }
.tinte-violeta i, .stat-icono.tinte-violeta { background: var(--violeta-fondo); color: var(--violeta); }
.tinte-turquesa i, .stat-icono.tinte-turquesa { background: var(--turquesa-fondo); color: var(--turquesa); }
.tinte-verde i, .stat-icono.tinte-verde { background: var(--ok-fondo); color: var(--ok); }
.tinte-rojo i, .stat-icono.tinte-rojo { background: var(--error-fondo); color: var(--error); }

.sidebar-footer { padding: 8px 12px 12px; border-top: 1px solid var(--linea); }

.nav-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 20px; background: var(--punto); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1.6; text-align: center; }

.tabbar, .top-marca, .asistente-cabecera { display: none; }

/* --- Contenido --- */
main.main-content { flex: 1; min-width: 0; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }

header.top-header {
    height: var(--header-height);
    flex-shrink: 0;
    background: var(--fondo);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 900;
}
.top-header .spacer { flex: 1; }
.top-header .btn-icon, .campana-btn { width: 44px; height: 44px; border-radius: var(--radius); background: var(--superficie); box-shadow: var(--relieve-bajo); color: var(--texto); font-size: 1rem; }
.top-header .btn-outline { min-height: 44px; background: var(--superficie); box-shadow: var(--relieve-bajo); }

/* Campanita de avisos */
.campana { position: relative; }
.campana-btn { position: relative; border: 0; cursor: pointer; transition: transform 0.12s; }
.campana-btn:active { transform: scale(0.94); }
.campana-num { position: absolute; top: 5px; right: 5px; min-width: 17px; padding: 0 4px; border-radius: 20px; background: var(--punto); color: #fff; font-size: 0.66rem; font-weight: 700; line-height: 1.55; }
.campana-panel { position: absolute; right: 0; top: 52px; width: min(340px, calc(100vw - 28px)); background: var(--superficie); border-radius: var(--radius-tarjeta); box-shadow: var(--sombra); overflow: hidden; z-index: 950; }
.campana-cabeza { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--linea); }
.campana-leer { min-height: 32px; border: 0; background: none; color: var(--texto-suave); font: inherit; font-size: 0.8rem; text-decoration: underline; cursor: pointer; }
.campana-panel ul { list-style: none; max-height: 360px; overflow-y: auto; }
.campana-panel li { padding: 12px 16px; border-bottom: 1px solid var(--linea); }
.campana-panel li:last-child { border-bottom: 0; }
.campana-panel li a { display: block; font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.campana-panel li a:hover { text-decoration: underline; }
.campana-panel li small { color: var(--texto-suave); font-size: 0.75rem; }
.campana-vacia { color: var(--texto-suave); font-size: 0.9rem; }

.user-info { margin-left: 6px; text-align: right; line-height: 1.2; }
.user-name { font-weight: 700; font-size: 0.86rem; }
.user-role { font-size: 0.74rem; color: var(--texto-suave); }

.content-wrapper { padding: 16px 32px 64px; width: 100%; max-width: 1280px; }

.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.page-title p { margin-top: 4px; color: var(--texto-suave); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-title .btn-outline { background: var(--superficie); box-shadow: var(--relieve-bajo); }

/* --- Tarjetas --- */
.card { margin-bottom: 16px; padding: 22px; border-radius: var(--radius-tarjeta); background: var(--superficie); box-shadow: var(--relieve); }
.card h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 4px; }
.card-sub { color: var(--texto-suave); font-size: 0.88rem; margin-bottom: 18px; }
.card-table { padding: 6px 22px 12px; }
.card-nota { margin: 12px 0 6px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { display: block; padding: 16px 18px 18px; border-radius: var(--radius-tarjeta); background: var(--superficie); box-shadow: var(--relieve); text-decoration: none; transition: transform 0.2s var(--suave), box-shadow 0.2s; }
.stat-card:active { transform: scale(0.97); }
.stat-icono { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px; border-radius: 13px; background: var(--relleno); color: var(--texto-suave); font-size: 1rem; }
.stat-card .stat-num { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card .stat-label { color: var(--texto-suave); font-size: 0.85rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 13px;
    border: 0;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s, background 0.15s, color 0.15s, transform 0.12s;
}
.btn:active, .btn-icon:active { transform: scale(0.96); }
.btn i { font-size: 0.9em; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { filter: brightness(1.25); }
:root[data-tema="oscuro"] .btn-primary:hover { filter: brightness(0.9); }
.btn-dark { background: var(--texto); color: var(--fondo); }
.btn-outline { background: var(--relleno); color: var(--texto); }
.btn-outline:hover { filter: brightness(0.96); }
:root[data-tema="oscuro"] .btn-outline:hover { filter: brightness(1.15); }
.btn-danger { background: var(--punto); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 12px; border-radius: 12px; font-size: 0.8125rem; }

.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 12px;
    border: 0;
    background: var(--relleno);
    color: var(--texto-suave);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s, background 0.15s, transform 0.12s;
}
.btn-icon:hover { color: var(--texto); }
.btn-icon.is-on { color: var(--aviso); background: var(--aviso-fondo); }
.btn-icon.danger:hover { color: var(--error); background: var(--error-fondo); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* --- Formularios --- */
.form-group { margin-bottom: 16px; }
.form-group label, .field-label { display: block; font-size: 0.84rem; font-weight: 600; margin-bottom: 6px; color: var(--texto); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.help { font-size: 0.8125rem; color: var(--texto-suave); margin-top: 6px; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="date"], select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 14px;
    border-radius: 13px;
    border: 1px solid var(--linea-fuerte);
    background: var(--superficie);
    color: var(--texto);
    font: inherit;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
::placeholder { color: var(--texto-tenue); opacity: 1; }
textarea { resize: vertical; min-height: 96px; }
textarea.texto-largo { min-height: 300px; line-height: 1.5; }
.help code { padding: 1px 5px; border-radius: 4px; background: var(--relleno); font-size: 0.85em; }
input:focus, select:focus, textarea:focus { border-color: var(--texto); box-shadow: 0 0 0 3px var(--anillo); }
input[type="color"] { width: 56px; height: 42px; padding: 2px; border: 1px solid var(--linea-fuerte); border-radius: 13px; background: var(--superficie); cursor: pointer; }
input[type="file"] { font: inherit; font-size: 0.86rem; max-width: 100%; color: var(--texto-suave); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin-bottom: 10px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--brand); flex-shrink: 0; }
/* Dentro de un grupo de formulario la casilla sigue siendo una fila, no un rótulo en negrita */
.form-group label.check { display: flex; font-weight: 400; }
.check small { display: block; color: var(--texto-suave); font-size: 0.8125rem; }

/* Los filtros van sueltos sobre el fondo: sin borde, con relieve */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="search"], .filters select { border-color: transparent; box-shadow: var(--relieve-bajo); }
.filters input[type="search"]:focus, .filters select:focus { border-color: var(--texto); box-shadow: 0 0 0 3px var(--anillo); }
.filters input[type="search"] { flex: 1; min-width: 180px; }
.filters select { width: auto; min-width: 160px; }
.filters .btn-outline { background: var(--superficie); box-shadow: var(--relieve-bajo); }

.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.inline-form input[type="text"] { flex: 1; min-width: 0; }

/* --- Tablas --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; padding: 12px 14px; font-size: 0.78rem; font-weight: 600; color: var(--texto-suave); border-bottom: 1px solid var(--linea); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td small { color: var(--texto-suave); }
td a { text-decoration-color: var(--linea-fuerte); text-underline-offset: 3px; }
td a:hover { text-decoration-color: currentColor; }
.td-right, .th-right { text-align: right; }
.empty { text-align: center; padding: 48px 20px !important; color: var(--texto-suave); }
.empty i { font-size: 1.6rem; display: block; margin-bottom: 10px; color: var(--texto-tenue); }

.thumb { width: 52px; height: 65px; border-radius: 12px; object-fit: cover; background: var(--relleno); display: block; }
.thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--texto-tenue); }

/* --- Etiquetas de estado y avisos --- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.badge-success { background: var(--ok-fondo); color: var(--ok); }
.badge-warning { background: var(--aviso-fondo); color: var(--aviso); }
.badge-danger { background: var(--error-fondo); color: var(--error); }
.badge-muted { background: var(--relleno); color: var(--texto-suave); }

.alert { padding: 13px 16px; border-radius: 16px; margin-bottom: 16px; font-size: 0.9rem; font-weight: 500; display: flex; gap: 10px; align-items: flex-start; }
.alert > i { margin-top: 3px; }
.alert-success { background: var(--ok-fondo); color: var(--ok); }
.alert-error { background: var(--error-fondo); color: var(--error); }
.alert-warning { background: var(--aviso-fondo); color: var(--aviso); }

/* Los logos se muestran sobre blanco también en el tema oscuro: suelen ser negros */
.logo-preview { max-height: 80px; border-radius: 12px; padding: 6px; background: #fff; box-shadow: var(--relieve-bajo); margin-bottom: 10px; }

.color-dot { display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--borde-muestra); vertical-align: -3px; margin-right: 6px; }

.checklist { list-style: none; }
.checklist li { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--linea); }
.checklist li:last-child { border-bottom: none; }
.checklist i { font-size: 1.05rem; color: var(--texto-tenue); }
.checklist li.done i { color: var(--ok); }
.checklist li.done span { color: var(--texto-suave); text-decoration: line-through; }
.checklist a { margin-left: auto; padding: 7px 14px; border-radius: 12px; background: var(--relleno); font-size: 0.8125rem; font-weight: 700; text-decoration: none; white-space: nowrap; }

/* --- Fotos del producto --- */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.foto-item { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--relleno); }
.foto-item img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; }
.foto-item.quitar img { opacity: 0.25; }
.foto-item .foto-bar { display: flex; justify-content: space-between; padding: 5px; gap: 4px; }
.foto-item .foto-bar button { flex: 1; height: 36px; border: 0; border-radius: 10px; background: var(--superficie); cursor: pointer; color: var(--texto-suave); font-size: 0.8rem; }
.foto-item .foto-bar button:hover { color: var(--texto); }
.foto-item .foto-tag { position: absolute; top: 6px; left: 6px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 0.68rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; display: none; }
.foto-item:first-child .foto-tag { display: block; }
.foto-item.nueva { outline: 2px dashed var(--linea-fuerte); outline-offset: -2px; }

/* --- Matriz de variantes (color x talle) --- */
.matriz th, .matriz td { padding: 9px 10px; text-align: center; }
.matriz th:first-child, .matriz td:first-child { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--superficie); }
.matriz input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); cursor: pointer; }
.matriz .fila-todos { min-height: 32px; font: inherit; font-size: 0.75rem; color: var(--texto-suave); background: none; border: none; cursor: pointer; text-decoration: underline; }

/* --- Stock --- */
.stock-num { font-size: 1.1rem; }
.stock-grid td { vertical-align: top; }
.stock-grid input[type="number"] { width: 72px; padding: 7px 6px; text-align: center; }
.stock-actual { display: block; font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.stock-actual.cero { color: var(--error); }
.stock-na { color: var(--texto-tenue); }

/* Selector de una opción entre varias (tipo de movimiento) */
.segmented { display: inline-flex; flex-wrap: wrap; padding: 4px; border-radius: var(--radius); background: var(--relleno); margin-bottom: 8px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: 10px; font-weight: 600; font-size: 0.875rem; color: var(--texto-suave); transition: background 0.15s, color 0.15s; }
.segmented input:checked + span { background: var(--brand); color: var(--brand-contrast); }
.segmented input:focus-visible + span { outline: 2px solid var(--texto); outline-offset: 1px; }
.segmented + .help { margin: 0 0 14px; }

/* --- Pedidos --- */
.estado-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.estado-tabs a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 12px; background: var(--superficie); box-shadow: var(--relieve-bajo); font-size: 0.8125rem; font-weight: 600; text-decoration: none; color: var(--texto-suave); transition: background 0.15s, color 0.15s, transform 0.12s; }
.estado-tabs a:hover { color: var(--texto); }
.estado-tabs a:active { transform: scale(0.96); }
.estado-tabs a.active { background: var(--brand); color: var(--brand-contrast); }
.estado-tabs a span { margin-left: 6px; padding: 0 6px; border-radius: 20px; background: var(--relleno); font-size: 0.72rem; }
.estado-tabs a.active span { background: rgba(127, 127, 127, 0.4); }

/* Cada estado del pedido lleva su color y su ícono */
[class*="badge-pedido-"]::before, tr[data-estado]::before { font-family: "Font Awesome 6 Free"; font-weight: 900; }
[class*="badge-pedido-"]::before { font-size: 0.9em; }
.badge-pedido-nuevo, tr[data-estado="nuevo"]::before { background: var(--aviso-fondo); color: var(--aviso); }
.badge-pedido-nuevo::before, tr[data-estado="nuevo"]::before { content: "\f017"; }
.badge-pedido-en_deposito, tr[data-estado="en_deposito"]::before { background: var(--azul-fondo); color: var(--azul); }
.badge-pedido-en_deposito::before, tr[data-estado="en_deposito"]::before { content: "\f00c"; }
.badge-pedido-empaquetado, tr[data-estado="empaquetado"]::before { background: var(--violeta-fondo); color: var(--violeta); }
.badge-pedido-empaquetado::before, tr[data-estado="empaquetado"]::before { content: "\f49e"; }
.badge-pedido-en_viaje, tr[data-estado="en_viaje"]::before { background: var(--turquesa-fondo); color: var(--turquesa); }
.badge-pedido-en_viaje::before, tr[data-estado="en_viaje"]::before { content: "\f0d1"; }
.badge-pedido-entregado, tr[data-estado="entregado"]::before { background: var(--ok-fondo); color: var(--ok); }
.badge-pedido-entregado::before, tr[data-estado="entregado"]::before { content: "\f058"; }
.badge-pedido-conforme, tr[data-estado="conforme"]::before { background: var(--ok); color: var(--superficie); }
.badge-pedido-conforme::before, tr[data-estado="conforme"]::before { content: "\f560"; }
.badge-pedido-cancelado, tr[data-estado="cancelado"]::before { background: var(--error-fondo); color: var(--error); }
.badge-pedido-cancelado::before, tr[data-estado="cancelado"]::before { content: "\f00d"; }
tr[data-estado]::before { display: none; }                      /* la insignia del estado se ve solo en las tarjetas del celular */
.page-title h1 .badge { vertical-align: middle; margin-left: 8px; padding: 5px 12px; border-radius: 12px; letter-spacing: 0; }

/* Recorrido del pedido: una secuencia real, por eso va numerada */
.pasos { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 20px; list-style: none; counter-reset: paso; }
.pasos li { counter-increment: paso; display: inline-flex; align-items: center; min-height: 34px; padding: 0 13px; border-radius: 12px; background: var(--relleno); font-size: 0.84rem; font-weight: 600; color: var(--texto-suave); }
.pasos li::before { content: counter(paso) ". "; white-space: pre; }
.pasos li.hecho { color: var(--texto); }
.pasos li.actual { background: var(--brand); color: var(--brand-contrast); font-weight: 700; }

/* Resumen de importes de un pedido */
.importes div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--linea); }
.importes dt { color: var(--texto-suave); }
.importes dd { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.importes .importes-total { border-bottom: 0; font-size: 1.25rem; }
.importes .importes-total dt { color: var(--texto); font-weight: 700; }
.importes .importes-total dd { font-weight: 700; }
.importes .importes-interno { border-bottom: 0; padding: 3px 0; font-size: 0.86rem; }
.importes .importes-interno:first-of-type { margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--linea-fuerte); }

.estado-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.estado-form select { width: auto; min-width: 200px; }
.estado-form input[type="text"] { flex: 1; min-width: 200px; }
.estado-form .check { flex-basis: 100%; margin: 6px 0 0; }
.input-mini { width: 78px !important; padding: 6px 8px !important; text-align: right; }
.input-precio { width: 116px !important; }
.card-pie { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; padding: 16px 0 6px; }
.pack-colores, .pack-talles { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.pack-colores label, .pack-talles label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }

/* Control de armado */
td.armado { min-width: 250px; }
td.armado .btn { margin: 6px 0 2px; }
.armado-falta { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin: 0 8px; font-size: 0.875rem; font-weight: 600; cursor: pointer; }
.armado-falta input { width: 20px; height: 20px; accent-color: var(--punto); }
input.armado-nota { width: 150px; min-height: 40px; padding: 6px 10px; font-size: 0.86rem; }
tr.fila-falta td { background: var(--error-fondo); }
tr.fila-falta td:first-child { box-shadow: inset 3px 0 0 var(--error); padding-left: 12px; }

/* Contador con menos y más (admin.js lo arma alrededor del campo de prendas armadas) */
.contador { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius); background: var(--relleno); vertical-align: middle; }
.contador button { width: 36px; height: 36px; border: 0; border-radius: 11px; background: none; color: var(--texto); font: inherit; font-size: 1.15rem; font-weight: 600; line-height: 1; cursor: pointer; transition: transform 0.12s; }
.contador button:last-child { background: var(--superficie); box-shadow: var(--relieve-bajo); }
.contador button:active { transform: scale(0.9); }
.contador input.input-mini { width: 46px !important; min-height: 36px; padding: 0 !important; border: 0; background: none; box-shadow: none; text-align: center; font-weight: 700; -moz-appearance: textfield; appearance: textfield; }
.contador input::-webkit-outer-spin-button, .contador input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.mt { margin-top: 16px; }
.input-corto { max-width: 140px; }
.nowrap { white-space: nowrap; }
.wa-link { color: var(--whatsapp); font-weight: 700; text-decoration: none; white-space: nowrap; }
.wa-link:hover { text-decoration: underline; }
.notas { white-space: pre-line; }

.form-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--fondo); padding: 14px 0; }

/* --- Modales (en celular suben desde abajo como una hoja) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--velo);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 9995;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.active { visibility: visible; opacity: 1; }
.confirmation-overlay { z-index: 10000; }

.modal-content { background: var(--superficie); padding: 26px; border-radius: 24px; box-shadow: var(--sombra); width: 100%; max-width: 480px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; transform: translateY(-10px); transition: transform 0.3s var(--suave); }
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-content.modal-ancho { max-width: 680px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-close { width: 44px; height: 44px; margin: -8px -10px -8px 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--texto-suave); background: none; border: none; border-radius: 12px; }
.modal-footer { margin-top: 22px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

.confirm-box { max-width: 360px; text-align: center; }
.confirm-box .confirm-icon { font-size: 2rem; margin-bottom: 12px; color: var(--aviso); }
.confirm-box h3 { margin-bottom: 8px; }
.confirm-box p { color: var(--texto-suave); font-size: 0.92rem; margin-bottom: 22px; }
.confirm-box .confirm-actions { display: flex; gap: 8px; }
.confirm-box .confirm-actions .btn { flex: 1; min-height: 48px; }

/* --- Login / instalación --- */
body.auth-body { align-items: center; justify-content: center; overflow-y: auto; padding: 20px; height: auto; min-height: 100vh; min-height: 100dvh; }
.auth-card { width: 100%; max-width: 390px; background: var(--superficie); border-radius: 28px; box-shadow: var(--relieve); padding: 38px 30px; }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo img { max-width: 120px; max-height: 84px; border-radius: 20px; background: #fff; padding: 6px; box-shadow: var(--relieve-bajo); }
.auth-logo .auth-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-card h1 { font-size: 0.95rem; font-weight: 500; text-align: center; color: var(--texto-suave); margin-bottom: 26px; }
.auth-card input[type="text"], .auth-card input[type="password"] { min-height: 50px; font-size: 1rem; }
.auth-card .btn { width: 100%; min-height: 52px; margin-top: 8px; border-radius: 16px; background: var(--brand); color: var(--brand-contrast); font-size: 0.95rem; }
.auth-error { background: var(--error-fondo); color: var(--error); padding: 12px; border-radius: var(--radius); margin-bottom: 20px; font-size: 0.88rem; font-weight: 500; text-align: center; }
/* Segundo paso del ingreso: el código de la app */
.auth-texto { margin-bottom: 18px; font-size: 0.9rem; text-align: center; color: var(--texto-suave); }
.auth-card #codigo { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }
.auth-volver { margin-top: 14px; text-align: center; }
.enlace-boton { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--texto-suave); font: inherit; font-size: 0.88rem; text-decoration: underline; cursor: pointer; }

/* Seguridad: pasos para activar la verificación en dos pasos */
.pasos-activar { display: grid; gap: 22px; margin: 6px 0 0; padding-left: 22px; }
.pasos-activar li > strong { display: block; margin-bottom: 4px; }
.pasos-activar li > span { display: block; font-size: 0.875rem; color: var(--texto-suave); }
.pasos-activar .form-group { max-width: 240px; margin-top: 10px; }
.pasos-activar input[name="codigo"] { font-size: 1.2rem; letter-spacing: 0.25em; }
/* El QR va siempre negro sobre blanco (lo dibuja qr.js), también en el tema oscuro: así lo leen las apps */
.qr-caja { width: 200px; max-width: 100%; margin: 12px 0; border-radius: 14px; overflow: hidden; box-shadow: var(--relieve-bajo); }
.qr-caja svg { display: block; width: 100%; height: auto; }
.clave-totp { display: inline-block; margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--relleno); font-size: 0.95rem; letter-spacing: 0.06em; overflow-wrap: anywhere; user-select: all; }

/* --- Tema: botón de la cabecera --- */
.tema-btn .fa-sun { display: none; }
:root[data-tema="oscuro"] .tema-btn .fa-sun { display: inline; }
:root[data-tema="oscuro"] .tema-btn .fa-moon { display: none; }

/* --- Asistente de ayuda: en escritorio, burbuja abajo a la derecha; en celular y tablet, botón en la cabecera. Con forma de chat. --- */
.asistente { position: fixed; right: 24px; bottom: 24px; z-index: 9980; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none; }
.asistente > * { pointer-events: auto; }
.asistente-boton { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 18px; background: var(--superficie); color: var(--texto); box-shadow: var(--sombra); font: inherit; font-size: 0.875rem; font-weight: 700; cursor: pointer; transition: transform 0.12s; }
.asistente-boton:active { transform: scale(0.95); }
.asistente.abierto .asistente-boton { display: none; }

.asistente-panel { display: flex; flex-direction: column; width: min(370px, calc(100vw - 28px)); max-height: min(580px, calc(100vh - 110px)); max-height: min(580px, calc(100dvh - 110px)); border-radius: 24px; background: var(--superficie); box-shadow: var(--sombra); overflow: hidden; }
.asistente-panel[hidden] { display: none; }
.asistente-cabeza { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--linea); }
.asistente-cabeza .btn-icon { width: 44px; height: 44px; }
.asistente-chat { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.asistente-msj { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 0.9rem; line-height: 1.45; }
.asistente-msj.bot { align-self: flex-start; background: var(--relleno); border-bottom-left-radius: 4px; }
.asistente-msj.yo { align-self: flex-end; background: var(--brand); color: var(--brand-contrast); border-bottom-right-radius: 4px; }
.asistente-opciones { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.asistente-opcion { min-height: 40px; padding: 8px 14px; border: 1px solid var(--linea-fuerte); border-radius: 14px; background: none; color: var(--texto); font: inherit; font-size: 0.875rem; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.asistente-opcion:hover { background: var(--relleno); }
.asistente-escribir { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-top: 1px solid var(--linea); }
.asistente-escribir input { flex: 1; min-width: 0; }
.asistente-escribir .btn-icon { width: 44px; height: 44px; }
.asistente-micro[hidden] { display: none; }
.asistente-micro.escuchando { color: var(--error); background: var(--error-fondo); animation: escuchando 1.2s ease-in-out infinite; }
@keyframes escuchando { 50% { box-shadow: 0 0 0 5px var(--error-fondo); } }
.asistente-pie { margin: 0; padding: 9px 18px 12px; font-size: 0.84rem; color: var(--texto-suave); }

/* Resaltado: el aro deja a la vista la parte de la que se habla y apaga el resto; el globo lleva el texto del paso */
.foco { position: fixed; inset: 0; z-index: 9985; pointer-events: none; }
.foco[hidden] { display: none; }
.foco-aro { position: fixed; border-radius: 16px; outline: 2px solid var(--texto); box-shadow: 0 0 0 9999px var(--velo); transition: top 0.25s, left 0.25s, width 0.25s, height 0.25s; }
.foco.sin-ancla .foco-aro { top: 50%; left: 50%; width: 0; height: 0; outline: 0; }
.foco-globo { position: fixed; top: 0; left: 0; width: min(340px, calc(100vw - 24px)); padding: 16px 16px 12px; border-radius: 20px; background: var(--superficie); box-shadow: var(--sombra); pointer-events: auto; }
.foco.sin-ancla .foco-globo { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.foco-texto { font-size: 0.92rem; line-height: 1.5; }
.foco-pie { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.foco-cuenta { margin-right: auto; font-size: 0.8rem; color: var(--texto-suave); font-variant-numeric: tabular-nums; }

/* Con "Mostrar el nombre de los botones" tildado en la ayuda, los botones de solo ícono dicen qué hacen */
body.guia .btn-icon[title] { width: auto; padding: 0 12px; gap: 6px; }
/* Con nombre ocupan más: bajan de renglón en vez de ensanchar la tabla */
body.guia .row-actions { flex-wrap: wrap; max-width: 340px; margin-left: auto; }
body.guia .btn-icon[title]::after { content: attr(title); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }

/* --- Finanzas: números clave, saldos y movimientos --- */
.seccion-cabeza { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 12px; }
.seccion-cabeza h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.seccion-cabeza a { font-size: 0.8125rem; font-weight: 700; }
.card-titulo { margin: 12px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 16px 18px; border-radius: var(--radius-tarjeta); background: var(--superficie); box-shadow: var(--relieve); overflow: hidden; }
.kpi-rotulo { display: flex; align-items: center; gap: 10px; color: var(--texto-suave); font-size: 0.8125rem; font-weight: 600; }
.kpi-rotulo .stat-icono { display: grid; place-items: center; width: 32px; height: 32px; margin: 0; border-radius: 10px; font-size: 0.85rem; flex-shrink: 0; }
.kpi-valor { margin-top: 10px; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-nota { min-height: 1.3em; font-size: 0.78rem; color: var(--texto-suave); }
.kpi .grafico { height: 38px; margin: 10px -18px -16px; }
.variacion { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 8px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.variacion.bien { background: var(--ok-fondo); color: var(--ok); }
.variacion.mal { background: var(--error-fondo); color: var(--error); }

.saldos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.saldo { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 14px 16px; border-radius: 18px; background: var(--superficie); box-shadow: var(--relieve-bajo); }
.card .saldo { background: var(--relleno); box-shadow: none; }
.saldo > i { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--relleno); color: var(--texto-suave); flex-shrink: 0; }
.card .saldo > i { background: var(--superficie); }
.saldo span { display: block; font-size: 0.78rem; color: var(--texto-suave); }
.saldo strong { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.saldo.total, .card .saldo.total { background: var(--brand); color: var(--brand-contrast); }
.saldo.total span { color: inherit; opacity: 0.75; }
.saldo.total > i, .card .saldo.total > i { background: rgba(127, 127, 127, 0.3); color: inherit; }

.importe-ingreso { color: var(--ok); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.importe-egreso { color: var(--error); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.anulado td { opacity: 0.6; }
tr.anulado .importe-ingreso, tr.anulado .importe-egreso { text-decoration: line-through; }
.cobro-ok { color: var(--ok); font-weight: 600; }
.cobro-falta { color: var(--aviso); font-weight: 600; }

.rango { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; font-size: 0.8125rem; color: var(--texto-suave); }
.rango label { font-weight: 600; }
.rango input[type="date"] { width: auto; min-width: 0; border-color: transparent; box-shadow: var(--relieve-bajo); }
.rango .btn { background: var(--superficie); box-shadow: var(--relieve-bajo); }

/* --- Gráficos (los dibuja graficos.js). Cada color es una clase que define --g. --- */
.g-verde { --g: var(--g-verde); }      .g-rojo { --g: var(--g-rojo); }        .g-azul { --g: var(--g-azul); }
.g-violeta { --g: var(--g-violeta); }  .g-turquesa { --g: var(--g-turquesa); } .g-ambar { --g: var(--g-ambar); }
.g-gris { --g: var(--g-gris); }        .g-marca { --g: var(--brand); }
.grafico { position: relative; min-width: 0; }
.g-vacio { padding: 26px 8px; text-align: center; color: var(--texto-suave); font-size: 0.875rem; }
.g-punto { display: inline-block; width: 10px; height: 10px; border-radius: 4px; background: var(--g); flex-shrink: 0; }

/* Columnas, línea y área */
.g-lienzo { position: relative; height: 230px; margin-top: 22px; }
.g-bajo .g-lienzo { height: 170px; }
.g-rejilla span { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--linea); }
.g-rejilla span.g-cero { border-top: 1px solid var(--linea-fuerte); }
.g-rejilla i { position: absolute; left: 0; bottom: 2px; font-style: normal; font-size: 0.6875rem; color: var(--texto-suave); font-variant-numeric: tabular-nums; white-space: nowrap; }
.g-zona { position: absolute; inset: 0 0 0 52px; }
.g-grupos { position: absolute; inset: 0; display: grid; touch-action: pan-y; }
.g-grupo { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; justify-items: center; gap: 2px; min-width: 0; padding: 0 14%; border: 0; border-radius: 8px; background: none; cursor: pointer; transition: background 0.15s; }
.g-grupo.activo { background: var(--relleno); }
.g-grupo:focus-visible { outline-offset: -2px; }
.g-barra { position: relative; width: 100%; max-width: 30px; border-radius: 5px 5px 0 0; background: var(--g); transform: scaleY(0); transform-origin: bottom; transition: transform 0.8s var(--suave) calc(var(--i, 0) * 35ms); }
.grafico.visible .g-barra { transform: scaleY(1); }
.g-linea { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; clip-path: inset(-12px 100% -12px -12px); transition: clip-path 1.2s ease 0.25s; }
.grafico.visible .g-linea { clip-path: inset(-12px -12px -12px -12px); }
.g-trazo { fill: none; stroke: var(--g); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.g-area { fill: var(--g); stroke: none; opacity: 0.16; }
.g-nudo { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 2.5px solid var(--g); border-radius: 50%; background: var(--superficie); pointer-events: none; transform: scale(0); transition: transform 0.3s var(--suave) calc(0.5s + var(--i, 0) * 60ms); }
.grafico.visible .g-nudo { transform: scale(1); }
.g-globo { position: absolute; top: 0; z-index: 2; min-width: 150px; padding: 10px 12px; border-radius: 14px; background: var(--texto); color: var(--fondo); box-shadow: var(--sombra); font-size: 0.78rem; pointer-events: none; transform: translateX(-50%); }
.g-globo strong { display: block; margin-bottom: 4px; }
.g-globo-fila { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.g-globo-fila b { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }
.g-pie { display: grid; margin: 6px 0 0 52px; }
.g-pie span { display: flex; justify-content: center; min-width: 0; font-size: 0.6875rem; color: var(--texto-suave); white-space: nowrap; }
.g-pie-denso span:last-child { justify-content: flex-end; }           /* con muchas etiquetas, la última no se sale del borde */
.g-leyenda { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 0.8125rem; color: var(--texto-suave); }
.g-leyenda span { display: inline-flex; align-items: center; gap: 7px; }

/* Dona */
.g-dona { display: flex; align-items: center; flex-wrap: wrap; gap: 18px 24px; }
.g-anillo { position: relative; width: 156px; height: 156px; margin: 0 auto; flex-shrink: 0; }
.g-anillo svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.g-arco-fondo { fill: none; stroke: var(--relleno); stroke-width: 5.5; }
.g-arco { fill: none; stroke: var(--g); stroke-width: 5.5; stroke-dasharray: 0 100; transition: stroke-dasharray 0.9s var(--suave) calc(var(--i, 0) * 90ms); }
.grafico.visible .g-arco { stroke-dasharray: var(--pct) 100; }
.g-centro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.g-centro strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.g-centro span { font-size: 0.72rem; color: var(--texto-suave); }
.g-partes { flex: 1 1 210px; display: grid; gap: 9px; min-width: 0; list-style: none; }
.g-partes li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; font-size: 0.875rem; }
.g-partes span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-partes b { font-variant-numeric: tabular-nums; }
.g-partes em { min-width: 34px; font-style: normal; font-size: 0.78rem; color: var(--texto-suave); text-align: right; }

/* Barras acostadas */
.g-filas { display: grid; gap: 13px; list-style: none; }
.g-fila { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 5px 12px; font-size: 0.875rem; }
.g-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.g-nombre small { margin-left: 6px; font-weight: 500; color: var(--texto-suave); }
.g-valor { font-variant-numeric: tabular-nums; }
.g-pista { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: var(--relleno); overflow: hidden; }
.g-relleno { display: block; height: 100%; border-radius: 5px; background: var(--g); transform: scaleX(0); transform-origin: left; transition: transform 0.8s var(--suave) calc(var(--i, 0) * 70ms); }
.grafico.visible .g-relleno { transform: scaleX(1); }

/* Chispa: la tendencia al pie de un número */
.g-chispa { display: block; width: 100%; height: 100%; clip-path: inset(0 100% 0 0); transition: clip-path 1s ease 0.2s; }
.grafico.visible .g-chispa { clip-path: inset(0 0 0 0); }
.g-chispa .g-trazo { stroke-width: 2; }
.g-chispa .g-area { opacity: 0.13; }

/* Con mouse, las tarjetas que llevan a otro lado se levantan apenas */
@media (hover: hover) {
    a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sombra); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==============================================================================================
   Celular y tablet angosta: barra de navegación abajo, tablas como tarjetas, acción principal a
   mano y ventanas como hojas. Nada se desliza de costado.
   ============================================================================================== */
@media (max-width: 1100px) {
    .user-info, .top-header .solo-ancho { display: none; }

    /* Cabecera: la marca a la izquierda, tema y avisos a la derecha. Se va con el contenido al bajar. */
    header.top-header { position: relative; padding: 0 16px; gap: 8px; }
    .top-marca { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; text-decoration: none; font-size: 0.9375rem; }
    .top-marca img { width: 36px; height: 36px; border-radius: 12px; background: #fff; box-shadow: var(--relieve-bajo); object-fit: contain; flex-shrink: 0; }
    .top-marca span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
    .top-marca small { font-size: inherit; font-weight: 500; color: var(--texto-suave); }
    /* El asistente de ayuda va junto a los avisos, con su nombre y el color de la marca para que no pase por un ícono más */
    .asistente-cabecera { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; min-height: 44px; padding: 0 14px; border: 0; border-radius: var(--radius); background: var(--brand); color: var(--brand-contrast); box-shadow: var(--relieve-bajo); font: inherit; font-size: 0.875rem; font-weight: 700; cursor: pointer; transition: transform 0.12s; }
    .asistente-cabecera:active { transform: scale(0.95); }
    .asistente-cabecera i { font-size: 1rem; }
    .campana { position: static; }
    .campana-panel { top: calc(100% + 4px); left: 12px; right: 12px; width: auto; }

    .content-wrapper { padding: 8px 16px calc(var(--alto-barra) + 28px); }
    .page-title { position: relative; align-items: flex-start; margin-bottom: 16px; }
    .page-title > div:first-child { flex: 1 1 100%; min-width: 0; }
    .page-title h1 { font-size: 1.75rem; overflow-wrap: anywhere; }
    .page-title p { font-size: 0.875rem; }
    .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
    .card { padding: 18px 16px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi { padding: 14px; }
    .kpi .grafico { margin: 8px -14px -14px; }
    .kpi-valor { font-size: clamp(1.05rem, 5.4vw, 1.25rem); }
    .saldos { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
    .saldo { padding: 12px; gap: 10px; }
    .saldo > i { width: 34px; height: 34px; }
    .saldo strong { font-size: 0.9375rem; }
    .g-lienzo { height: 200px; }
    .g-bajo .g-lienzo { height: 150px; }
    .g-zona { left: 44px; }
    .g-pie { margin-left: 44px; }
    .g-grupo { padding: 0 8%; gap: 1px; }
    .rango label { flex-basis: 100%; }
    .rango input[type="date"] { flex: 1 1 0; }
    .card-titulo { margin: 0 2px 4px; font-size: 1.05rem; }
    .stat-card { padding: 14px 14px 16px; }

    /* Barra de navegación: todas las secciones en una tira que se desliza de costado.
       Las flechas de las puntas avisan que hay más y también la corren (las muestra admin.js). */
    aside.sidebar { display: none; }
    .tabbar { position: fixed; inset: auto 0 0 0; z-index: 950; display: block; height: var(--alto-barra); background: var(--superficie); border-radius: 20px 20px 0 0; box-shadow: var(--sombra-barra); overflow: hidden; }
    .tabbar-pista { position: relative; display: flex; gap: 2px; height: 100%; padding: 4px 6px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; }
    .tabbar-pista::-webkit-scrollbar { display: none; }
    .tab-form { display: flex; flex: 0 0 auto; }
    .tab { position: relative; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 72px; height: 56px; padding: 0 10px; border: 0; border-radius: 16px; background: none; color: var(--texto-suave); font: inherit; font-size: 0.6875rem; font-weight: 600; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background 0.2s, color 0.2s, transform 0.12s; }
    .tab i { font-size: 1.15rem; }
    .tab:active { transform: scale(0.94); }
    .tab.activa { background: var(--relleno); color: var(--texto); font-weight: 700; }
    .tab .nav-badge { position: absolute; top: 2px; left: 50%; margin-left: 6px; }
    .tabbar-flecha { position: absolute; top: 0; z-index: 1; display: flex; align-items: center; width: 52px; height: 100%; border: 0; color: var(--brand-contrast); font-size: 0.75rem; cursor: pointer; }
    .tabbar-flecha.der { right: 0; justify-content: flex-end; padding-right: 8px; background: linear-gradient(to right, transparent, var(--superficie) 60%); }
    .tabbar-flecha.izq { left: 0; padding-left: 8px; background: linear-gradient(to left, transparent, var(--superficie) 60%); }
    .tabbar-flecha i { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); box-shadow: var(--relieve-bajo); }
    .tabbar-flecha.der i { animation: asomar 1.1s ease-in-out 0.6s 2; }                  /* al entrar, la flecha se asoma dos veces */
    @keyframes asomar { 50% { transform: translateX(-5px); } }

    /* Volver: una flecha arriba a la izquierda, junto al título */
    .page-title.con-volver > div:first-child { min-height: 44px; padding-left: 56px; }
    .page-title.con-volver h1 { font-size: 1.4rem; line-height: 1.25; }
    .btn.btn-volver { position: absolute; top: 0; left: 0; width: 44px; min-height: 44px; padding: 0; gap: 0; border-radius: var(--radius); font-size: 0; }
    .btn.btn-volver i { font-size: 1rem; }

    /* La acción de la pantalla ("Nuevo...") va debajo del título, a lo ancho: nada flota sobre el contenido.
       Si hay varias acciones, son una fila de botones grandes con su ícono arriba. */
    .page-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; width: 100%; }
    .page-actions:empty { display: none; }
    .page-actions .btn:not(.btn-volver) { flex-direction: column; gap: 6px; min-height: 68px; padding: 10px 6px; border-radius: 18px; font-size: 0.75rem; line-height: 1.2; text-align: center; }
    .page-actions .btn:not(.btn-volver) i { font-size: 1.15rem; }
    .page-title > .btn:not(.btn-volver) { width: 100%; min-height: 48px; }
    .page-title > .btn-primary:not(.btn-volver) { min-height: 52px; border-radius: 16px; font-size: 0.9375rem; }

    .btn { min-height: 44px; }
    .btn-sm { min-height: 44px; padding: 8px 14px; }
    .btn-icon { width: 44px; height: 44px; border-radius: 14px; font-size: 0.95rem; }
    input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="date"], select, textarea { min-height: 48px; border-radius: 14px; font-size: 1rem; }
    input[type="color"] { height: 48px; }
    .check { min-height: 44px; align-items: center; }
    .check input { width: 22px; height: 22px; margin-top: 0; }
    .segmented { display: flex; }
    .segmented label { flex: 1; }
    .segmented span { justify-content: center; width: 100%; min-height: 44px; padding: 6px 8px; }
    .checklist a { padding: 12px 14px; }
    .fotos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .foto-item .foto-bar { flex-wrap: wrap; padding: 3px; gap: 1px; }           /* en las pantallas más angostas el tercer botón baja de renglón */
    .foto-item .foto-bar button { flex: 1 1 44px; min-width: 44px; height: 44px; }
    .inline-form input[type="text"] { flex: 1 1 140px; }
    .inline-form .btn { min-width: 48px; min-height: 48px; }
    .modal-footer .btn { flex: 1 1 auto; min-height: 48px; }

    /* Filtros: el buscador y su botón arriba; los desplegables debajo, a lo ancho */
    .filters input[type="search"] { flex: 1 0 calc(100% - 64px); min-width: 0; border-radius: 16px; }
    .filters select { order: 2; flex: 1 1 140px; min-width: 0; width: auto; border-radius: 16px; }
    .filters .btn { min-height: 48px; border-radius: 16px; }
    .filters button.btn { min-width: 48px; padding: 0 14px; }
    .filters a.btn { order: 3; }
    .estado-tabs a { min-height: 40px; }

    /* Recorrido del pedido: una barra de tramos (hechos, el actual, los que faltan) y debajo el nombre del paso actual */
    .pasos { flex-wrap: nowrap; margin: 16px 0 18px; }
    .pasos li { position: relative; flex: 1; display: flex; min-width: 0; min-height: 0; padding: 14px 0 0; border-radius: 0; background: none; font-size: 0; white-space: nowrap; }
    .pasos li:nth-child(n+4) { justify-content: flex-end; }                  /* en la segunda mitad el nombre se apoya a la derecha */
    .pasos li::before { content: none; }
    .pasos li::after { content: ''; position: absolute; inset: 0 0 auto 0; height: 6px; border-radius: 3px; background: var(--relleno); }
    .pasos li.hecho::after { background: var(--texto-tenue); }
    .pasos li.actual { background: none; color: var(--texto); font-size: 0.8125rem; }
    .pasos li.actual::before { content: "Paso " counter(paso) ": "; font-weight: 500; color: var(--texto-suave); }
    .pasos li.actual::after { background: var(--brand); }
    .estado-form select, .estado-form input[type="text"] { flex: 1 1 100%; width: 100%; min-width: 0; }
    .estado-form .btn { flex: 1 1 100%; min-height: 48px; }
    .estado-form .btn-primary { min-height: 52px; border-radius: 16px; font-size: 0.9375rem; }

    /* --- Tablas como tarjetas: un renglón, una tarjeta; cada dato con el nombre de su columna --- */
    .table-wrap.en-tarjetas { overflow: visible; }
    .card.card-table { padding: 0; background: none; box-shadow: none; }
    .tabla-tarjetas, .tabla-tarjetas tbody { display: block; }
    .tabla-tarjetas thead { display: none; }
    .tabla-tarjetas tr { display: grid; grid-template-columns: minmax(0, 1fr) fit-content(46%); column-gap: 12px; align-items: start; margin-bottom: 12px; padding: 14px 16px; border-radius: var(--radius-tarjeta); background: var(--superficie); box-shadow: var(--relieve); }
    .tabla-tarjetas td { grid-column: 1 / -1; display: flow-root; min-width: 0; padding: 5px 0; border: 0; background: none; text-align: right; white-space: normal; overflow-wrap: anywhere; }
    .tabla-tarjetas td[data-rotulo]::before { content: attr(data-rotulo); float: left; margin-right: 16px; color: var(--texto-suave); font-size: 0.8125rem; font-weight: 500; line-height: 1.40625rem; }
    .tabla-tarjetas td.vacia { display: none; }
    /* El dato que nombra la tarjeta, y arriba a la derecha su estado */
    .tabla-tarjetas td.celda-titulo { grid-column: 1; grid-row: 1; padding-top: 0; font-size: 1rem; font-weight: 700; text-align: left; }
    .tabla-tarjetas td.celda-titulo small { font-weight: 500; }
    .tabla-tarjetas td.celda-titulo a { text-decoration: none; }
    .tabla-tarjetas td.celda-estado { grid-column: 2; grid-row: 1; padding-top: 0; }
    .tabla-tarjetas td.celda-titulo::before, .tabla-tarjetas td.celda-estado::before, .tabla-tarjetas td.celda-acciones::before, .tabla-tarjetas td.celda-foto::before { content: none; }
    /* Textos largos y celdas con varios campos: el rótulo arriba y el contenido debajo, a lo ancho */
    .tabla-tarjetas td.celda-larga, .tabla-tarjetas td.celda-campos { text-align: left; }
    .tabla-tarjetas td.celda-larga::before, .tabla-tarjetas td.celda-campos::before { float: none; display: block; margin: 0 0 4px; }
    .tabla-tarjetas td.celda-acciones { margin-top: 8px; padding: 12px 0 0; border-top: 1px solid var(--linea); }
    .tabla-tarjetas .row-actions, body.guia .tabla-tarjetas .row-actions { flex-wrap: wrap; max-width: none; }
    .tabla-tarjetas tr.fila-suelta { display: block; }
    .tabla-tarjetas td.empty { text-align: center; padding: 28px 12px !important; }
    .tabla-tarjetas tr.fila-falta { box-shadow: var(--relieve), inset 0 0 0 2px var(--error); }
    .tabla-tarjetas tr.fila-falta td { background: none; box-shadow: none; padding-left: 0; }

    /* Listas con foto (productos, stock): la foto a la izquierda y los datos al lado */
    .tabla-tarjetas[data-vista="fotos"] tr { grid-template-columns: 64px minmax(0, 1fr) fit-content(48%); column-gap: 14px; }
    .tabla-tarjetas[data-vista="fotos"] td { grid-column: 2 / -1; }
    .tabla-tarjetas[data-vista="fotos"] td.celda-foto { grid-column: 1; grid-row: 1 / span 3; padding: 0; }
    .tabla-tarjetas[data-vista="fotos"] .thumb { width: 64px; height: 80px; border-radius: 14px; }
    .tabla-tarjetas[data-vista="fotos"] td.celda-titulo { grid-column: 2 / -1; grid-row: 1; }
    .tabla-tarjetas[data-vista="fotos"] td[data-col="categoria"], .tabla-tarjetas[data-vista="fotos"] td[data-col="venta"] { grid-row: 2; padding: 2px 0; font-size: 0.8125rem; color: var(--texto-suave); }
    .tabla-tarjetas[data-vista="fotos"] td[data-col="categoria"] { grid-column: 2; text-align: left; }
    .tabla-tarjetas[data-vista="fotos"] td[data-col="venta"] { grid-column: 3; }
    .tabla-tarjetas[data-vista="fotos"] td[data-col="precio"], .tabla-tarjetas[data-vista="fotos"] td[data-col="stock"] { grid-column: 2; grid-row: 3; font-size: 1rem; font-weight: 700; text-align: left; }
    .tabla-tarjetas[data-vista="fotos"] td[data-col="stock"]::before { float: none; margin-right: 6px; }
    .tabla-tarjetas[data-vista="fotos"] td.celda-estado { grid-column: 3; grid-row: 3; padding-top: 5px; align-self: center; }
    .tabla-tarjetas[data-vista="fotos"] td[data-col="categoria"]::before, .tabla-tarjetas[data-vista="fotos"] td[data-col="venta"]::before, .tabla-tarjetas[data-vista="fotos"] td[data-col="precio"]::before { content: none; }
    .tabla-tarjetas[data-vista="fotos"] td.celda-acciones { grid-column: 1 / -1; }

    /* Bandeja de pedidos: la insignia del estado, la clienta, el importe; toda la tarjeta abre el pedido */
    .tabla-tarjetas[data-vista="pedidos"] tr { grid-template-columns: 44px minmax(0, 1fr) auto; cursor: pointer; transition: transform 0.12s; }
    .tabla-tarjetas[data-vista="pedidos"] tr[data-estado]:active { transform: scale(0.985); }
    .tabla-tarjetas[data-vista="pedidos"] tr[data-estado]::before { grid-area: 1 / 1 / 3 / 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-size: 1.05rem; }
    .tabla-tarjetas[data-vista="pedidos"] td { padding: 0; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-rotulo]::before { content: none; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="cliente"] { grid-area: 1 / 2 / 2 / 3; font-size: 1rem; font-weight: 700; line-height: 1.3; text-align: left; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="cliente"] small { font-size: 0.8125rem; font-weight: 500; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="importe"] { grid-area: 1 / 3 / 2 / 4; font-size: 1rem; font-weight: 700; line-height: 1.3; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="importe"] small { font-size: 0.75rem; font-weight: 500; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="pedido"], .tabla-tarjetas[data-vista="pedidos"] td[data-col="prendas"] { font-size: 0.8125rem; font-weight: 500; color: var(--texto-suave); }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="pedido"] { grid-area: 2 / 2 / 3 / 4; margin-top: 2px; text-align: left; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="pedido"] a { text-decoration: none; color: var(--texto); }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="pedido"] br, .tabla-tarjetas[data-vista="pedidos"] td[data-col="estado"] br { display: none; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="pedido"] small::before { content: " · "; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="prendas"] { grid-area: 3 / 3 / 4 / 4; align-self: center; margin-top: 12px; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="prendas"]::after { content: " prendas"; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="estado"] { grid-area: 3 / 1 / 4 / 3; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; text-align: left; }
    .tabla-tarjetas[data-vista="pedidos"] td[data-col="estado"] small { font-size: 0.8125rem; }
    .tabla-tarjetas[data-vista="pedidos"] td.celda-acciones { display: none; }
    .tabla-tarjetas[data-vista="pedidos"] td.empty { padding: 28px 12px !important; }

    /* Renglones de un pedido: prenda e importe arriba; debajo, color y talle; después lo que se carga */
    .tabla-tarjetas[data-vista="renglones"] tr { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 6px; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="articulo"] { grid-area: 1 / 1 / 2 / 3; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="importe"] { grid-area: 1 / 3 / 2 / 4; padding: 0 0 5px 10px; font-size: 1rem; font-weight: 700; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="color"], .tabla-tarjetas[data-vista="renglones"] td[data-col="talle"] { grid-row: 2; padding: 0 0 6px; font-size: 0.8125rem; color: var(--texto-suave); text-align: left; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="color"] { grid-column: 1; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="talle"] { grid-column: 2 / -1; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="importe"]::before, .tabla-tarjetas[data-vista="renglones"] td[data-col="color"]::before { content: none; }
    .tabla-tarjetas[data-vista="renglones"] td[data-col="talle"]::before { content: "· talle "; float: none; margin: 0; font-size: inherit; line-height: inherit; white-space: pre; }
    .tabla-tarjetas[data-vista="renglones"] td.celda-acciones { margin-top: 0; padding-top: 4px; border-top: 0; }
    .tabla-tarjetas td.armado.celda-campos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
    .tabla-tarjetas td.armado.celda-campos::before { flex: 1 1 100%; margin: 0; }
    .tabla-tarjetas td.armado .btn { flex: 1 1 100%; margin: 4px 0 0; }
    .tabla-tarjetas td.armado small { margin-left: 6px; }
    .tabla-tarjetas .armado-falta { min-height: 44px; margin: 0 4px; }
    .tabla-tarjetas input.armado-nota { flex: 1 1 150px; width: auto; min-height: 44px; }
    .contador button { width: 44px; height: 44px; }
    .contador input.input-mini { min-height: 44px; }

    /* Las listas sin encabezado siguen siendo tablas: con menos aire a los costados entran en las pantallas más angostas */
    table:not(.tabla-tarjetas):not(.tabla-bloques) td:not(:first-child) { padding-left: 8px; }
    table:not(.tabla-tarjetas):not(.tabla-bloques) td:not(:last-child) { padding-right: 4px; }

    /* Caja: el concepto y el importe arriba; debajo, la fecha, el medio y quién lo anotó */
    .tabla-tarjetas[data-vista="caja"] tr { grid-template-columns: auto auto minmax(0, 1fr) auto; column-gap: 6px; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="concepto"] { grid-area: 1 / 1 / 2 / 4; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="importe"] { grid-area: 1 / 4 / 2 / 5; padding: 0 0 5px 10px; font-size: 1rem; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="fecha"], .tabla-tarjetas[data-vista="caja"] td[data-col="medio"], .tabla-tarjetas[data-vista="caja"] td[data-col="quien"] { grid-row: 2; align-self: center; padding: 0; font-size: 0.8125rem; color: var(--texto-suave); text-align: left; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="fecha"] { grid-column: 1; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="medio"] { grid-column: 2; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="quien"] { grid-column: 3; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="importe"]::before, .tabla-tarjetas[data-vista="caja"] td[data-col="fecha"]::before { content: none; }
    .tabla-tarjetas[data-vista="caja"] td[data-col="medio"]::before, .tabla-tarjetas[data-vista="caja"] td[data-col="quien"]::before { content: "· "; float: none; margin: 0; font-size: inherit; line-height: inherit; white-space: pre; }
    .tabla-tarjetas[data-vista="caja"] td.celda-acciones { grid-area: 2 / 4 / 3 / 5; margin: 0; padding: 0; border: 0; }
    .tabla-tarjetas[data-vista="caja"] tr.anulado td { opacity: 0.6; }

    /* Una tabla dentro de una tarjeta común: renglones separados por una línea, sin tarjeta dentro de tarjeta */
    .card:not(.card-table) .tabla-tarjetas tr { margin: 0; padding: 12px 0; border-radius: 0; background: none; box-shadow: none; border-bottom: 1px solid var(--linea); }
    .card:not(.card-table) .tabla-tarjetas tr:last-child { border-bottom: 0; }
    .card:not(.card-table) .tabla-tarjetas td.celda-acciones { margin-top: 0; padding-top: 4px; border-top: 0; }

    /* Lo que guarda una lista o un formulario largo queda a mano, sobre la barra */
    .card-nota { margin: 0 2px 12px; }
    .form-footer, .card-table .card-pie { position: sticky; bottom: calc(var(--alto-barra) + 10px); z-index: 930; flex-wrap: nowrap; gap: 10px; margin-top: 4px; padding: 10px; border-radius: 22px; background: var(--superficie); box-shadow: var(--sombra); }
    .form-footer .btn, .card-table .card-pie .btn { flex: 1 1 auto; min-height: 52px; border-radius: 14px; }
    .form-footer .btn-primary, .card-table .card-pie .btn-primary { flex-grow: 3; font-size: 0.9375rem; }

    /* Grillas color x talle: un bloque por color, con los talles bajando de renglón */
    .tabla-bloques, .tabla-bloques tbody { display: block; }
    .tabla-bloques thead { display: none; }
    .tabla-bloques tr { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 8px; padding: 14px 0; border-bottom: 1px solid var(--linea); }
    .tabla-bloques tr:last-child { border-bottom: 0; }
    .tabla-bloques td, .tabla-bloques td:first-child { position: static; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; padding: 0; border: 0; background: none; }
    .tabla-bloques td[data-rotulo]::before { content: attr(data-rotulo); font-size: 0.75rem; font-weight: 600; color: var(--texto-suave); }
    .tabla-bloques td:first-child { flex: 1 1 100%; flex-direction: row; gap: 0; font-weight: 700; }
    .tabla-bloques td.vacia { display: none; }
    .tabla-bloques .stock-actual { margin: 0; }
    .matriz input[type="checkbox"] { width: 28px; height: 28px; margin: 8px; }
    .matriz .fila-todos { min-height: 44px; padding: 0 8px; font-size: 0.8125rem; }
    .stock-grid input[type="number"] { width: 64px; min-height: 44px; }

    /* Ventanas emergentes: una hoja que sube desde abajo */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-content, .modal-content.modal-ancho { max-width: none; max-height: 92vh; max-height: 92dvh; padding: 22px 18px 18px; border-radius: 24px 24px 0 0; transform: translateY(100%); }
    .confirmation-overlay { align-items: center; padding: 16px; }
    .confirmation-overlay .modal-content { max-width: 360px; padding: 26px 22px; border-radius: 24px; transform: none; }

    /* La charla del asistente se abre abajo, sobre la barra; el botón que la abre está en la cabecera */
    .asistente { left: 16px; right: 16px; bottom: calc(var(--alto-barra) + 12px); align-items: flex-start; }
    .asistente-boton { display: none; }
    .asistente-panel { width: 100%; max-height: calc(100vh - var(--alto-barra) - 110px); max-height: calc(100dvh - var(--alto-barra) - 110px); }
    /* El globo del resaltado va fijo sobre la barra y lo resaltado queda arriba */
    .foco-globo { top: auto !important; left: 12px !important; right: 12px; bottom: calc(var(--alto-barra) + 12px); width: auto; transform: none !important; }
}

/* Tablet: con más ancho, las tarjetas van de a dos y las ventanas vuelven al centro */
@media (min-width: 700px) and (max-width: 1100px) {
    .content-wrapper { padding-left: 24px; padding-right: 24px; }
    .card.card-table .tabla-tarjetas tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
    .card.card-table .tabla-tarjetas tr { margin-bottom: 0; }
    .card.card-table .tabla-tarjetas tr.fila-suelta { grid-column: 1 / -1; }
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .saldos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .tab { min-width: 84px; }
    .modal-overlay { align-items: center; padding: 16px; }
    .modal-content, .modal-content.modal-ancho { max-width: 560px; border-radius: 24px; padding: 26px; transform: translateY(12px); }
    .modal-content.modal-ancho { max-width: 680px; }
    .asistente { align-items: flex-end; }
    .asistente-panel { width: min(370px, 100%); }
    .page-title > div:first-child { flex: 1 1 0; }
    .page-title > .btn:not(.btn-volver) { width: auto; }
    .foco-globo { left: auto !important; right: 24px; width: 360px; }
}

/* Celulares: en la cabecera queda solo el nombre del comercio, para que entre el botón de ayuda */
@media (max-width: 430px) {
    .top-marca small { display: none; }
}
@media (max-width: 380px) {
    header.top-header { gap: 6px; }
    .top-marca { gap: 8px; }
    .asistente-cabecera { padding: 0 10px; }
}
@media (max-width: 350px) {
    header.top-header { padding: 0 12px; }
}
