/* =========================================================
   SGA · GRUPO JERÓNIMO — CAPA iOS
   Se carga DESPUÉS de theme.css. Cambia forma, tipografía, densidad,
   translucidez y controles al estilo iOS / iPadOS.
   ⛔ NO cambia la paleta: todos los colores salen de los tokens --gj-* de
   theme.css. Los "rellenos" grises translúcidos de iOS se obtienen mezclando
   los grises de la propia paleta (color-mix), no con colores nuevos.
   Tras cualquier cambio aquí: subir CACHE_VERSION en service-worker.js.
   ========================================================= */

:root {
    /* Fuente del sistema: en iPhone/iPad/Mac sale SF Pro; en Windows y Android,
       Inter (la más parecida a SF), y si no carga, la del sistema. */
    --gj-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI Variable Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --gj-font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI Variable Display', 'Segoe UI', Roboto, sans-serif;
    --gj-font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;

    /* Escala tipográfica de iOS (Dynamic Type). En escritorio va un punto más
       compacta, como iPadOS/macOS; en el móvil, la de iPhone (ver @media). */
    --fs-largetitle: 30px;
    --fs-title1:     26px;
    --fs-title2:     21px;
    --fs-title3:     18px;
    --fs-headline:   15px;
    --fs-body:       15px;
    --fs-callout:    14.5px;
    --fs-subhead:    14px;
    --fs-footnote:   13px;
    --fs-caption:    12px;
    --fs-caption2:   11px;

    /* Radios de iOS: tarjetas agrupadas 12, controles 10, hojas 14 */
    --gj-r-xs:  7px;
    --gj-r-sm:  10px;
    --gj-r:     12px;
    --gj-r-lg:  12px;
    --gj-r-xl:  16px;
    --gj-r-2xl: 22px;

    /* iOS es plano: casi sin sombras */
    --gj-shadow-xs:   none;
    --gj-shadow-sm:   none;
    --gj-shadow-card: none;
    --gj-shadow-card-hover: none;
    --gj-shadow-md:   0 8px 24px rgba(17,24,39,0.10);
    --gj-shadow-lg:   0 12px 32px rgba(17,24,39,0.14);
    --gj-shadow-focus: 0 0 0 3px var(--gj-primary-ring);

    /* Rellenos y separadores tipo iOS, sacados de los grises de la paleta */
    --ios-fill:        color-mix(in srgb, var(--gj-zinc-500) 12%, transparent);
    --ios-fill-strong: color-mix(in srgb, var(--gj-zinc-500) 20%, transparent);
    --ios-separator:   color-mix(in srgb, var(--gj-zinc-500) 26%, transparent);
    --ios-bar:         color-mix(in srgb, var(--gj-card) 78%, transparent);
    --ios-bar-blur:    saturate(180%) blur(20px);

    /* Fondo "agrupado" de iOS: el gris claro de la paleta, con tarjetas blancas encima */
    --gj-bg: var(--gj-zinc-100);

    /* iOS rellena plano: los degradados de marca pasan a su mismo color, sin degradar */
    --gj-primary-grad: var(--gj-primary);
    --gj-accent-grad:  var(--gj-accent);
    --gj-info-grad:    var(--gj-info);

    /* Curvas de animación de iOS */
    --ios-spring: cubic-bezier(0.32, 0.72, 0, 1);
    --gj-t-fast: 160ms var(--ios-spring);
    --gj-t:      300ms var(--ios-spring);

    --ios-tabbar-h: 0px;
}
:root[data-theme="dark"] {
    --gj-bg: var(--gj-zinc-950);
    --ios-fill:        color-mix(in srgb, var(--gj-zinc-400) 18%, transparent);
    --ios-fill-strong: color-mix(in srgb, var(--gj-zinc-400) 26%, transparent);
    --ios-separator:   color-mix(in srgb, var(--gj-zinc-400) 24%, transparent);
}

@media (max-width: 768px) {
    :root {
        --fs-largetitle: 32px;
        --fs-title1:     27px;
        --fs-title2:     22px;
        --fs-title3:     20px;
        --fs-headline:   17px;
        --fs-body:       17px;
        --fs-callout:    16px;
        --fs-subhead:    15px;
        --fs-footnote:   13px;
        --fs-caption:    12px;
        --fs-caption2:   11px;
        --ios-tabbar-h:  calc(50px + env(safe-area-inset-bottom));
    }
}

/* ---------- Base ---------- */
html, body {
    font-size: var(--fs-body);
    line-height: 1.38;
    letter-spacing: -0.012em;
    font-feature-settings: normal;
}
body { background-image: none; background-color: var(--gj-bg); }
h1 { font-size: var(--fs-largetitle); font-weight: 700; letter-spacing: -0.022em; }
h2 { font-size: var(--fs-title3); font-weight: 600; letter-spacing: -0.018em; }
h3 { font-size: var(--fs-headline); font-weight: 600; letter-spacing: -0.012em; }
p  { font-size: var(--fs-body); }
/* Blazor pone el foco en el <h1> al cambiar de pantalla (accesibilidad): sin marco visible */
h1:focus, h1:focus-visible, [tabindex="-1"]:focus { outline: none; }
a  { color: var(--gj-primary-600); }
::selection { background: var(--gj-primary-200); color: inherit; }
* { -webkit-tap-highlight-color: transparent; }

/* ---------- Iconos (sprite Ionicons, componente <Icono>) ---------- */
.ico {
    width: 1.15em; height: 1.15em;
    flex-shrink: 0;
    vertical-align: -0.2em;
    fill: currentColor;
    stroke: currentColor;
    overflow: visible;
}
.ico-texto { font-size: 1em; }

/* Códigos (ubicaciones, artículos, unidades): legibles, no grises y diminutos */
.code-mono {
    color: inherit;
    opacity: 1;
    font-size: 0.94em;
    font-weight: 500;
    letter-spacing: 0;
}

/* Ubicación fijada al contar en inventario */
.inv-ubicacion-fijada {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    border-radius: var(--gj-r-pill);
    background: color-mix(in srgb, var(--gj-primary) 16%, transparent);
    color: var(--gj-primary-700);
    font-family: var(--gj-font-mono);
    font-size: var(--fs-headline);
    font-weight: 600;
}
:root[data-theme="dark"] .inv-ubicacion-fijada { color: var(--gj-primary-300); }

/* Pie del menú lateral */
.app-sidebar .sidebar-footer { color: var(--gj-fg-muted); }

/* En pantallas medias la miga de pan no cabe junto a los botones de la cabecera */
@media (max-width: 1180px) {
    .app-header .crumbs { display: none; }
}
.ico-punto {
    display: inline-block;
    width: 0.62em; height: 0.62em;
    border-radius: 50%;
    vertical-align: 0.05em;
    flex-shrink: 0;
}
.ico-punto.punto-ok      { background: var(--gj-success); }
.ico-punto.punto-aviso   { background: var(--gj-warning); }
.ico-punto.punto-naranja { background: var(--gj-accent); }
.ico-punto.punto-error   { background: var(--gj-danger); }
.ico-punto.punto-gris    { background: var(--gj-zinc-400); }

/* ---------- Barra superior: translúcida como la de iOS ---------- */
.app-header {
    background: var(--ios-bar);
    backdrop-filter: var(--ios-bar-blur);
    -webkit-backdrop-filter: var(--ios-bar-blur);
    border-bottom: 0.5px solid var(--ios-separator);
    padding: 0 20px;
}
:root[data-theme="dark"] .app-header { background: var(--ios-bar); }
.app-header .crumbs { font-size: var(--fs-subhead); font-weight: 600; color: var(--gj-fg); }
.app-header .user-zone { font-size: var(--fs-footnote); gap: 10px; }
.app-header .user-avatar { width: 32px; height: 32px; box-shadow: none; background: var(--gj-primary); font-size: var(--fs-caption); }
.menu-toggle, .theme-toggle-btn, .header-search-btn {
    border: none !important;
    background: var(--ios-fill) !important;
    box-shadow: none !important;
    border-radius: var(--gj-r-pill) !important;
    color: var(--gj-fg) !important;
    min-height: 34px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.menu-toggle, .theme-toggle-btn { width: 34px; padding: 0 !important; }
.header-search-btn { padding: 0 12px !important; font-size: var(--fs-subhead) !important; color: var(--gj-fg-muted) !important; }
.header-search-btn kbd { background: transparent; border: none; color: var(--gj-fg-soft); font-size: var(--fs-caption2); }

.user-bloque { display: flex; align-items: center; gap: 10px; }
.user-datos { text-align: right; line-height: 1.2; }
.user-nombre { font-weight: 600; font-size: var(--fs-footnote); color: var(--gj-fg); }
.user-roles { font-size: var(--fs-caption2); color: var(--gj-fg-muted); }
.app-header .user-avatar { text-decoration: none; color: #fff; }

/* ---------- Barra lateral: la de iPadOS ---------- */
.app-sidebar {
    background: var(--gj-bg);
    border-right: 0.5px solid var(--ios-separator);
}
.app-sidebar .brand { border-bottom: none; padding: 0 20px; }
.app-sidebar nav { padding: 6px 10px 14px; }
.nav-section-toggle {
    text-transform: none;
    letter-spacing: -0.01em;
    font-size: var(--fs-headline);
    font-weight: 700;
    color: var(--gj-fg);
    padding: 16px 10px 6px;
    margin-top: 4px;
}
.nav-section-toggle:hover { color: var(--gj-fg); }
.nav-section-toggle .nav-chevron { order: 2; margin-left: auto; color: var(--gj-primary-600); font-size: 13px; }
.nav-section-toggle.open .nav-chevron { transform: rotate(90deg); color: var(--gj-primary-600); }
.nav-group { border-left: none; margin-left: 0; padding-left: 0; gap: 2px; animation: none; }
.nav-group .nav-item { padding-left: 10px; }
.app-sidebar .nav-item {
    font-size: var(--fs-body);
    font-weight: 400;
    padding: 7px 10px;
    border-radius: var(--gj-r-sm);
    color: var(--gj-fg);
    gap: 10px;
    min-height: 36px;
}
.app-sidebar .nav-item > span:first-child,
.app-sidebar .nav-item > .ico:first-child { width: 22px; font-size: 18px; color: var(--gj-primary-600); opacity: 1; }
.app-sidebar .nav-item > .ico:first-child { width: 21px; height: 21px; }
.app-sidebar .nav-item:hover { background: var(--ios-fill); color: var(--gj-fg); }
/* Fila seleccionada como en iPadOS: relleno del color de marca y texto blanco */
.app-sidebar .nav-item.active { background: var(--gj-primary); color: #fff; font-weight: 600; }
.app-sidebar .nav-item.active > span:first-child,
.app-sidebar .nav-item.active > .ico:first-child { color: #fff; }
.app-sidebar .sidebar-footer { background: transparent; border-top: 0.5px solid var(--ios-separator); font-size: var(--fs-caption2); }

.app-content { padding: 18px 28px 60px; }

/* ---------- Cabecera de página: título grande de iOS ---------- */
.page-header {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 6px 2px 4px;
    margin-bottom: 18px;
    gap: 14px;
    overflow: visible;
}
.page-header::before { content: none; }
.page-header h1 { font-size: var(--fs-largetitle); font-weight: 700; letter-spacing: -0.024em; }
.page-header .ph-sub { font-size: var(--fs-subhead); color: var(--gj-fg-muted); margin-top: 2px; }
.page-header .ph-icon,
.page-header.accent .ph-icon, .page-header.info .ph-icon,
.page-header.purple .ph-icon, .page-header.warning .ph-icon {
    width: 44px; height: 44px;
    border-radius: 11px;            /* esquina de icono de app */
    box-shadow: none;
    font-size: 22px;
}
.page-header .ph-icon .ico { width: 24px; height: 24px; vertical-align: 0; }

/* ---------- Tarjetas: "inset grouped" ---------- */
.gj-card, .gj-kpi-card, .gj-table-wrap {
    border: none;
    border-radius: var(--gj-r-lg);
    box-shadow: none;
}
.gj-card { padding: 16px 18px; }
.gj-card:hover, .gj-kpi-card:hover { box-shadow: none; border-color: transparent; transform: none; }
.gj-kpi-card::after { content: none; }
.gj-kpi-card { padding: 16px 18px; }
.gj-kpi-card .kpi-icon { border-radius: 9px; box-shadow: none; width: 36px; height: 36px; font-size: 18px; margin-bottom: 10px; }
.gj-kpi-card .kpi-label, .gj-kpi .kpi-label {
    text-transform: none; letter-spacing: -0.005em;
    font-size: var(--fs-footnote); font-weight: 500; color: var(--gj-fg-muted);
}
.gj-kpi-card .kpi-value, .gj-kpi .kpi-value { font-size: var(--fs-title1); letter-spacing: -0.02em; }
.gj-kpi-card .kpi-sub, .gj-kpi .kpi-sub { font-size: var(--fs-caption); }

/* Rótulos de sección encima de un grupo (como "AJUSTES GENERALES" en iOS) */
.field-label, label.field-label {
    font-size: var(--fs-footnote);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--gj-fg-muted);
    margin: 0 0 6px 4px;
}

/* ---------- Botones ---------- */
.gj-btn {
    height: 36px;
    padding: 0 16px;
    border-radius: var(--gj-r-sm);
    font-size: var(--fs-subhead);
    font-weight: 600;
    letter-spacing: -0.01em;
    gap: 6px;
    border: none;
    box-shadow: none;
    transition: opacity 120ms ease, background-color var(--gj-t-fast), transform 120ms ease;
}
.gj-btn:hover:not(:disabled) { transform: none; }
.gj-btn:active:not(:disabled) { opacity: 0.62; transform: scale(0.98); }
.gj-btn:disabled { opacity: 0.35; }
.gj-btn .ico { width: 1.15em; height: 1.15em; }

/* Relleno sólido (botón "filled" de iOS) */
.gj-btn-primary, .gj-btn-primary:hover:not(:disabled) { background: var(--gj-primary); color: #fff; box-shadow: none; }
.gj-btn-accent,  .gj-btn-accent:hover:not(:disabled)  { background: var(--gj-accent);  color: #fff; box-shadow: none; }
.gj-btn-danger,  .gj-btn-danger:hover:not(:disabled)  { background: var(--gj-danger);  color: #fff; box-shadow: none; }
/* Gris (botón "gray" de iOS) */
.gj-btn-ghost { background: var(--ios-fill); color: var(--gj-fg); border: none; box-shadow: none; }
.gj-btn-ghost:hover:not(:disabled) { background: var(--ios-fill-strong); border-color: transparent; box-shadow: none; }
/* Teñido (botón "tinted" de iOS) */
.gj-btn-soft { background: color-mix(in srgb, var(--gj-primary) 16%, transparent); color: var(--gj-primary-700); border: none; }
.gj-btn-soft:hover:not(:disabled) { background: color-mix(in srgb, var(--gj-primary) 24%, transparent); }
:root[data-theme="dark"] .gj-btn-soft { color: var(--gj-primary-300); }

.gj-btn-lg { height: 50px; padding: 0 22px; font-size: var(--fs-headline); border-radius: var(--gj-r); }
.gj-btn-sm { height: 30px; padding: 0 12px; font-size: var(--fs-footnote); border-radius: var(--gj-r-pill); }
.gj-btn-xs { height: 24px; padding: 0 9px;  font-size: var(--fs-caption);  border-radius: var(--gj-r-pill); }
/* Botón solo con icono */
.gj-btn.gj-btn-icono, .gj-btn-sm.gj-btn-icono { width: 30px; padding: 0; }

/* ---------- Campos ---------- */
.gj-input, select.gj-input, textarea.gj-input {
    height: 38px;
    padding: 0 12px;
    font-size: var(--fs-body);
    background-color: var(--ios-fill);
    border: none;
    border-radius: var(--gj-r-sm);
    box-shadow: none;
}
textarea.gj-input { padding: 10px 12px; height: auto; }
.gj-input:hover:not(:focus):not(:disabled) { border-color: transparent; }
.gj-input:focus { background-color: var(--gj-card); box-shadow: 0 0 0 2px var(--gj-primary); }
:root[data-theme="dark"] .gj-input:focus { background-color: var(--ios-fill-strong); }
.gj-input:disabled { background-color: var(--ios-fill); opacity: 0.6; }
.gj-input::placeholder { color: var(--gj-fg-soft); }
/* Desplegable con el doble chevron de iOS */
select.gj-input {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='14' viewBox='0 0 12 14'%3e%3cpath fill='none' stroke='%236B7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3 5l3-3 3 3M3 9l3 3 3-3'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 12px 14px;
    padding-right: 34px;
}
/* Modo oscuro: theme.css pone "background:" (abreviado) a todos los campos con más
   especificidad, lo que borraba el chevron y el relleno iOS. */
:root[data-theme="dark"] .gj-input,
:root[data-theme="dark"] select.gj-input,
:root[data-theme="dark"] textarea.gj-input {
    background-color: var(--ios-fill);
    border-color: transparent;
}
:root[data-theme="dark"] select.gj-input {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='14' viewBox='0 0 12 14'%3e%3cpath fill='none' stroke='%2398A0AC' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M3 5l3-3 3 3M3 9l3 3 3-3'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 12px 14px;
}
.gj-input-barcode {
    height: 56px;
    font-size: var(--fs-title3);
    border-radius: var(--gj-r);
    border: none;
    background: var(--gj-card);
    box-shadow: inset 0 0 0 1px var(--ios-separator);
}
.gj-input-barcode:focus { box-shadow: 0 0 0 2px var(--gj-primary); }
.gj-input-barcode::placeholder { font-size: var(--fs-subhead); }

/* Casillas normales con el color de marca */
input[type="checkbox"], input[type="radio"] { accent-color: var(--gj-primary); width: 18px; height: 18px; }

/* Interruptor de iOS: <input type="checkbox" class="ios-switch"> */
input[type="checkbox"].ios-switch {
    -webkit-appearance: none; appearance: none;
    width: 51px; height: 31px;
    border-radius: 999px;
    background: var(--ios-fill-strong);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 220ms var(--ios-spring);
    margin: 0;
}
input[type="checkbox"].ios-switch::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 27px; height: 27px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 1px 1px rgba(0,0,0,0.16);
    transition: transform 260ms var(--ios-spring);
}
input[type="checkbox"].ios-switch:checked { background: var(--gj-success); }
input[type="checkbox"].ios-switch:checked::after { transform: translateX(20px); }
input[type="checkbox"].ios-switch:disabled { opacity: 0.4; cursor: not-allowed; }
input[type="checkbox"].ios-switch:focus-visible { outline: none; box-shadow: var(--gj-shadow-focus); }

/* Control segmentado de iOS:
   <div class="ios-segmented"><button class="on">A</button><button>B</button></div> */
.ios-segmented {
    display: inline-flex;
    background: var(--ios-fill);
    border-radius: 9px;
    padding: 2px;
    gap: 2px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.ios-segmented::-webkit-scrollbar { display: none; }
.ios-segmented > button, .ios-segmented > a {
    flex: 1 0 auto;
    border: none;
    background: transparent;
    color: var(--gj-fg);
    font: inherit;
    font-size: var(--fs-footnote);
    font-weight: 500;
    padding: 5px 14px;
    min-height: 28px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    transition: background-color 200ms var(--ios-spring);
}
.ios-segmented > .on {
    background: var(--gj-card);
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 3px 1px rgba(0,0,0,0.04);
}
:root[data-theme="dark"] .ios-segmented > .on { background: var(--gj-zinc-600); }

/* Filtros con rótulo + segmentado */
.filter-group { gap: 8px; min-width: 0; }
.filter-label {
    font-size: var(--fs-footnote);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--gj-fg-muted);
    white-space: nowrap;
}

/* ---------- Etiquetas: cápsulas de iOS ---------- */
.gj-tag {
    border: none;
    border-radius: var(--gj-r-pill);
    font-size: var(--fs-caption);
    font-weight: 600;
    letter-spacing: -0.005em;
    padding: 2px 9px;
}
.gj-tag .ico { width: 1.1em; height: 1.1em; }

/* ---------- Tablas: como una lista de iOS ---------- */
.gj-table { font-size: var(--fs-subhead); }
.gj-table th, .gj-table td { padding: 11px 14px; border-bottom: 0.5px solid var(--ios-separator); }
.gj-table thead th {
    background: var(--gj-card);
    color: var(--gj-fg-muted);
    font-size: var(--fs-caption);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 0.5px solid var(--ios-separator);
}
.gj-table tbody tr, .gj-table tbody tr:nth-child(even) { background: var(--gj-card); }
.gj-table tbody tr:hover { background: var(--ios-fill); box-shadow: none; }
.gj-table.dense th, .gj-table.dense td { padding: 8px 12px; font-size: var(--fs-footnote); }
:root[data-theme="dark"] .gj-table tbody tr:nth-child(even) { background: var(--gj-card); }

/* ---------- Ventanas: hoja de iOS ---------- */
.gj-modal-backdrop {
    background: rgba(0,0,0,0.32);
    animation: ios-fade 220ms ease both;
}
.gj-modal {
    background: var(--gj-card);
    border-radius: 14px;
    box-shadow: var(--gj-shadow-lg);
    overflow: hidden;
    animation: ios-pop 320ms var(--ios-spring) both;
}
.gj-modal-head { border-bottom: 0.5px solid var(--ios-separator); padding: 12px 16px; position: relative; }
.gj-modal-head h2 { font-size: var(--fs-headline); font-weight: 600; }
.gj-modal-close {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--ios-fill); color: var(--gj-fg-muted);
    font-size: 15px; display: inline-flex; align-items: center; justify-content: center;
}
.gj-modal-close:hover { background: var(--ios-fill-strong); }
.gj-modal-body { padding: 16px; }
.gj-modal-actions { border-top: 0.5px solid var(--ios-separator); padding: 12px 16px; }
@keyframes ios-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ios-pop  { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes ios-sheet { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- Estados vacíos / carga / avisos ---------- */
.gj-empty { color: var(--gj-fg-muted); font-size: var(--fs-subhead); }
.gj-empty .empty-icon { font-size: 44px; color: var(--gj-zinc-400); opacity: 1; }
.gj-empty .empty-icon .ico { width: 48px; height: 48px; }
.gj-error, .gj-success, .gj-warning-banner { border-radius: var(--gj-r-sm); font-size: var(--fs-subhead); }

/* ---------- Barra de pestañas (solo móvil) ---------- */
.ios-tabbar { display: none; }

/* ========================== MÓVIL ========================== */
@media (max-width: 768px) {
    .app-content { padding: 10px 16px calc(var(--ios-tabbar-h) + 28px); }
    .app-header { padding: 0 12px; }

    .page-header { padding: 4px 0 2px; margin-bottom: 14px; }
    .page-header .ph-icon { display: none; }
    .page-header h1 { font-size: var(--fs-title1); }
    /* La explicación bajo el título, a 2 líneas: lo importante es llegar a la tarea */
    .page-header .ph-sub {
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
        font-size: var(--fs-footnote);
    }

    /* Filas de botones/controles en línea: que salten de línea en vez de salirse */
    .app-content [style*="display:flex"], .app-content [style*="display: flex"] { flex-wrap: wrap; }
    .app-content .ios-segmented { flex-wrap: nowrap; }

    /* Líneas de una solicitud de repuesto: filas apiladas, el "sale de" a todo lo ancho */
    table.tabla-lineas { min-width: 0 !important; }
    .tabla-lineas thead { display: none; }
    .tabla-lineas tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 0.5px solid var(--ios-separator); }
    .tabla-lineas td { border: none !important; padding: 0 !important; }
    .tabla-lineas td:nth-child(3) { grid-column: 1 / -1; }
    .tabla-lineas td:nth-child(3) select { width: 100%; }

    /* Asistente más discreto en el móvil */
    .chat-fab { width: 46px !important; height: 46px !important; right: 12px !important; }

    .gj-btn { height: 44px; font-size: var(--fs-headline); }
    .gj-btn-sm { height: 34px; font-size: var(--fs-subhead); }
    .gj-btn-lg { height: 52px; }
    .gj-input, select.gj-input { height: 44px; }

    .gj-card, .gj-kpi-card { padding: 14px 16px; }

    /* Filtros: rótulo arriba y segmentado a todo lo ancho, deslizable */
    .filter-group { flex-direction: column; align-items: stretch; width: 100%; }
    .ios-segmented { display: flex; width: 100%; }
    .ios-segmented > button, .ios-segmented > a { min-height: 32px; font-size: var(--fs-subhead); }

    /* La ventana pasa a ser una hoja que sube desde abajo */
    .gj-modal-backdrop { align-items: flex-end; padding: 0; }
    .gj-modal {
        max-width: none !important;
        width: 100% !important;
        max-height: 92vh;
        border-radius: 14px 14px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        animation: ios-sheet 380ms var(--ios-spring) both;
    }
    .gj-modal-head::before {        /* asa de arrastre */
        content: '';
        position: absolute; top: 5px; left: 50%;
        width: 36px; height: 5px; margin-left: -18px;
        border-radius: 3px;
        background: var(--ios-fill-strong);
    }
    .gj-modal-head { padding-top: 18px; }
    .gj-modal-actions { flex-direction: column-reverse; }
    .gj-modal-actions .gj-btn { width: 100%; }

    /* Barra de pestañas inferior translúcida */
    .ios-tabbar {
        display: flex;
        position: fixed; left: 0; right: 0; bottom: 0;
        height: var(--ios-tabbar-h);
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--ios-bar);
        backdrop-filter: var(--ios-bar-blur);
        -webkit-backdrop-filter: var(--ios-bar-blur);
        border-top: 0.5px solid var(--ios-separator);
        z-index: 900;
    }
    .ios-tabbar > a, .ios-tabbar > button {
        flex: 1;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px;
        padding-top: 6px;
        border: none; background: none; font: inherit;
        font-size: 10px; font-weight: 500; letter-spacing: 0.01em;
        color: var(--gj-zinc-400);
        text-decoration: none;
        position: relative;
        cursor: pointer;
    }
    .ios-tabbar .ico { width: 26px; height: 26px; }
    .ios-tabbar > a, .ios-tabbar > button { color: var(--gj-zinc-500); }
    .ios-tabbar > .active { color: var(--gj-primary-600); }
    .ios-tabbar .tab-badge {
        position: absolute; top: 2px; left: calc(50% + 6px);
        min-width: 17px; height: 17px; padding: 0 5px;
        border-radius: 999px;
        background: var(--gj-danger); color: #fff;
        font-size: 11px; font-weight: 600; line-height: 17px; text-align: center;
    }
    /* Con la barra de pestañas el menú lateral se abre desde "Más" */
    .menu-toggle { display: none !important; }
    .app-sidebar { bottom: var(--ios-tabbar-h); box-shadow: var(--gj-shadow-lg); background: var(--gj-card); }
    .user-datos { display: none; }
    .app-header .crumbs { font-size: var(--fs-headline); }
    /* El botón del asistente y su panel, por encima de la barra de pestañas */
    .chat-fab { bottom: calc(var(--ios-tabbar-h) + 14px) !important; }
    .chat-panel { bottom: calc(var(--ios-tabbar-h) + 72px) !important; height: calc(100vh - var(--ios-tabbar-h) - 140px) !important; }
}
