/* =====================================================================
   STREAMTECH MANTENIMIENTO · style.css  (v2 · contraste WCAG AA + multi-pantalla)

   PALETA (modo oscuro industrial, todo cumple AA ≥ 4.5:1 sobre --bg-0…--bg-4)
     --text    #f0fdf4   19,3:1 sobre --bg-0 · 12,8:1 sobre --bg-4
     --muted   #a7cbbb   11,4:1 sobre --bg-0 ·  7,6:1 sobre --bg-4
     --muted-2 #84a898    7,7:1 sobre --bg-0 ·  5,1:1 sobre --bg-4
   TIPOGRAFÍA: ningún texto por debajo de 11 px.
   PUNTOS DE CORTE
     ≤ 768 px         celular  → tablas como tarjetas, sidebar como cajón, modales tipo hoja
     769 – 1200 px    tablet / laptop → KPIs en 2 columnas, tablas con scroll horizontal nativo
     > 1200 px        escritorio → grilla completa, sidebar colapsable a íconos
   ===================================================================== */

:root {
    color-scheme: dark;

    /* Fondos */
    --bg-0: #030806; --bg-1: #07140e; --bg-2: #0b1c14; --bg-3: #10281d; --bg-4: #163527;
    /* Bordes: --border decora tarjetas; --border-input (≥ 3:1 sobre el fondo) delimita campos y botones */
    --border: #24483a; --border-soft: #183527; --border-input: #4b8f70;

    /* Acento esmeralda. --sky-2 / --blue son los extremos de los degradés de botón:
       texto blanco sobre ellos = 5,5:1 y 7,7:1 (AA). Los nombres se heredan del SCADA. */
    --sky: #10b981; --sky-2: #047857; --blue: #065f46;
    --accent-rgb: 16, 185, 129;

    /* Texto */
    --text: #f0fdf4; --muted: #a7cbbb; --muted-2: #84a898;
    --th: #6ee7b7;

    /* Semánticos (todos ≥ 4,9:1 sobre los fondos) */
    --ok: #22c55e; --warn: #f59e0b; --danger: #f43f5e; --danger-text: #fb7185; --violet: #a78bfa; --info: #38bdf8;

    --radius: 12px; --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .55);
    --font: 'Segoe UI', system-ui, -apple-system, Roboto, Tahoma, sans-serif;
    --tap: 44px;                                  /* área táctil mínima */
    --safe-b: env(safe-area-inset-bottom, 0px);   /* barra de gestos de iOS/Android */
    --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: radial-gradient(1200px 700px at 80% -10%, #0a2119 0%, var(--bg-0) 55%);
    color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.4; overflow: hidden;
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(var(--accent-rgb), .18);
}
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c6150; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3a7d67; }
* { scrollbar-width: thin; scrollbar-color: #2c6150 transparent; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
::selection { background: rgba(var(--accent-rgb), .35); color: #fff; }

/* ---------------------------------------------------------------- Login */
#login {
    position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 10000; padding: 16px;
    background: radial-gradient(900px 500px at 20% 0%, #0b2a20 0%, #030806 60%); overflow-y: auto;
}
#login::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(var(--accent-rgb), .06) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--accent-rgb), .06) 1px, transparent 1px);
    background-size: 42px 42px; mask-image: radial-gradient(700px 500px at 50% 40%, #000, transparent);
}
body.sin-sesion #login { display: flex; }   /* el login sólo aparece cuando /api/me confirmó que no hay sesión: sin parpadeo al recargar */
.login-card {
    position: relative; width: 100%; max-width: 400px; margin: auto;
    background: linear-gradient(180deg, rgba(16, 40, 29, .94), rgba(7, 20, 14, .97));
    border: 1px solid var(--border); border-radius: 18px; padding: 42px 38px;
    box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.login-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 6px; }
.login-logo, .brand-logo {
    display: grid; place-items: center; flex-shrink: 0;
    background: linear-gradient(135deg, var(--sky-2), var(--blue)); box-shadow: 0 6px 18px rgba(var(--accent-rgb), .35);
}
.login-logo { width: 46px; height: 46px; border-radius: 12px; }
.login-title { font-size: 19px; font-weight: 800; letter-spacing: .5px; line-height: 1.15; }
.login-title span { color: var(--sky); display: block; font-size: 15px; letter-spacing: 1.2px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; line-height: 1.5; }
#loginErr { color: var(--danger-text); font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }

/* ---------------------------------------------------------- Formularios */
.field { margin-bottom: 14px; min-width: 0; }
.field label, form label {
    display: block; font-size: 12px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
input, select, textarea {
    width: 100%; padding: 11px 13px; min-height: 42px; background: var(--bg-1); border: 1px solid var(--border-input); border-radius: 10px;
    color: var(--text); font-size: 14px; font-weight: 500; outline: none; transition: border-color .15s, box-shadow .15s; font-family: var(--font);
}
select { cursor: pointer; }
option { background: var(--bg-2); color: var(--text); }
textarea { resize: vertical; min-height: 68px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .25); }
input::placeholder, textarea::placeholder { color: var(--muted-2); opacity: 1; }
input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--sky); cursor: pointer; flex-shrink: 0; }
input[type="search"] { min-width: 200px; }
.chk { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; margin: 0; width: auto; min-height: 40px; }
.chk:hover { color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* -------------------------------------------------------------- Botones */
button { font-family: var(--font); }
.btn-primary {
    width: 100%; margin-top: 8px; padding: 13px; border: none; border-radius: 10px; cursor: pointer;
    font-weight: 800; font-size: 14px; letter-spacing: .4px; color: #fff; min-height: var(--tap);
    background: linear-gradient(135deg, var(--sky-2), var(--blue)); transition: .18s; box-shadow: 0 8px 20px rgba(var(--accent-rgb), .25);
    border: 1px solid rgba(var(--accent-rgb), .55);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.btn-primary:disabled, .btn-danger:disabled, .btn-neutral:disabled { opacity: .6; cursor: wait; transform: none; }
.btn-inline { width: auto; margin-top: 0; padding: 10px 18px; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-neutral {
    background: var(--bg-3); color: var(--text); border: 1px solid var(--border-input); padding: 10px 16px; min-height: 42px;
    border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 700; transition: .15s;
}
.btn-neutral:hover:not(:disabled) { border-color: var(--sky); color: var(--sky); }
.btn-danger {
    background: rgba(244, 63, 94, .14); color: var(--danger-text); border: 1px solid rgba(244, 63, 94, .55);
    padding: 10px 16px; min-height: 42px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 700; transition: .15s;
}
.btn-danger:hover:not(:disabled) { background: rgba(244, 63, 94, .26); }
.btn-icon {
    min-width: 40px; height: 40px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: 10px; cursor: pointer;
    background: var(--bg-3); color: var(--text); border: 1px solid var(--border-input); font-size: 16px; font-weight: 800; transition: .15s;
}
.btn-icon:hover:not(:disabled) { border-color: var(--sky); color: var(--sky); }
.btn-icon:disabled { opacity: .45; cursor: not-allowed; }
.btn-icon.b-cam { background: rgba(var(--accent-rgb), .18); border-color: rgba(var(--accent-rgb), .7); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* -------------------------------------------------------------- Layout */
#app { display: none; height: 100vh; height: 100dvh; flex-direction: column; }
body.autenticado #app { display: flex; }
.app-shell { display: flex; flex: 1; min-height: 0; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.sidebar {
    width: 244px; flex-shrink: 0; display: flex; flex-direction: column;
    background: linear-gradient(180deg, #08160f, #040b08); border-right: 1px solid var(--border);
    transition: width .2s ease;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 16px 16px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .4px; line-height: 1.15; overflow: hidden; white-space: nowrap; min-width: 0; }
.brand-name small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .9px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.btn-sidebar-toggle {
    flex-shrink: 0; margin-left: auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .05); border: 1px solid var(--border-input); color: var(--muted); cursor: pointer; transition: .15s;
}
.btn-sidebar-toggle:hover { color: var(--text); background: rgba(255, 255, 255, .1); }
.btn-sidebar-toggle svg { width: 16px; height: 16px; transition: transform .2s ease; }
.sidebar.collapsed .btn-sidebar-toggle svg { transform: rotate(180deg); }

.side-nav { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.nav-group-label {
    font-size: 11.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--th);
    padding: 16px 13px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item {
    position: relative; display: flex; align-items: center; gap: 11px; padding: 10px 13px; min-height: 42px; border-radius: 10px; cursor: pointer;
    color: var(--muted); font-size: 14px; font-weight: 600; border: 1px solid transparent; transition: .15s; user-select: none;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.nav-item.active {
    color: #fff; background: linear-gradient(90deg, rgba(var(--accent-rgb), .26), rgba(4, 120, 87, .12));
    border-color: rgba(var(--accent-rgb), .5); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .1);
}
.nav-item.active svg { color: var(--sky); }
.nav-item-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
    flex-shrink: 0; min-width: 22px; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; line-height: 18px; font-weight: 800; text-align: center;
    background: rgba(var(--accent-rgb), .22); color: #6ee7b7; font-variant-numeric: tabular-nums;
}
.nav-badge:empty { display: none; }
.nav-badge-warn { background: rgba(245, 158, 11, .22); color: #fbbf24; }

.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.sys-status {
    display: flex; align-items: center; gap: 9px; background: rgba(var(--accent-rgb), .1);
    border: 1px solid rgba(var(--accent-rgb), .4); border-radius: 10px; padding: 10px 12px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sky); animation: pulse 2s infinite; flex-shrink: 0; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .5); } 70% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); } 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); } }
.sys-status b { font-size: 13px; }
.sys-status small { display: block; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Sidebar colapsada a íconos (escritorio y tablet) */
.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .brand { padding: 18px 0 16px; justify-content: center; flex-direction: column; gap: 10px; }
.sidebar.collapsed .brand-name { display: none; }
.sidebar.collapsed .btn-sidebar-toggle { margin-left: 0; }
.sidebar.collapsed .side-nav { padding: 8px 10px; }
.sidebar.collapsed .nav-group-label { height: 1px; padding: 0; margin: 10px 6px; background: var(--border); font-size: 0; overflow: hidden; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px 0; gap: 0; }
.sidebar.collapsed .nav-item-txt { display: none; }
.sidebar.collapsed .nav-badge { position: absolute; top: 1px; right: 1px; min-width: 18px; padding: 0 4px; line-height: 16px; font-size: 11px; }
.sidebar.collapsed .side-foot { padding: 14px 10px; }
.sidebar.collapsed .sys-status { justify-content: center; padding: 10px 0; gap: 0; }
.sidebar.collapsed .sys-status > div { display: none; }

/* Topbar */
.topbar {
    height: 62px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 0 20px; background: rgba(4, 11, 8, .88); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px);
}
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crumb { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb small { display: block; font-size: 11.5px; color: var(--th); font-weight: 700; letter-spacing: .6px; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.clock {
    background: var(--bg-2); border: 1px solid var(--border-input); padding: 7px 13px; border-radius: 9px;
    font-size: 13px; font-weight: 700; color: #a7f3d0; font-variant-numeric: tabular-nums;
}
.user-chip { display: flex; align-items: center; gap: 9px; background: var(--bg-3); border: 1px solid var(--border-input); padding: 6px 13px 6px 7px; border-radius: 30px; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex-shrink: 0;
    background: linear-gradient(135deg, #047857, #6d28d9);
}
.user-chip .u-name { font-size: 13px; font-weight: 700; line-height: 1.1; }
.user-chip .u-role { font-size: 11.5px; color: var(--muted); }
.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: 6px; background: rgba(244, 63, 94, .14); color: var(--danger-text);
    border: 1px solid rgba(244, 63, 94, .55); padding: 8px 14px; min-height: 40px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; transition: .15s;
}
.btn-logout:hover { background: rgba(244, 63, 94, .26); }
.btn-menu-movil {
    display: none; width: var(--tap); height: var(--tap); border-radius: 10px; place-items: center; cursor: pointer; flex-shrink: 0;
    background: var(--bg-3); border: 1px solid var(--border-input); color: var(--text);
}

.content { flex: 1; overflow-y: auto; padding: 22px 24px calc(32px + var(--safe-b)); min-height: 0; overscroll-behavior: contain; }
main { display: none; }
main.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dash-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.dash-header h2 { font-size: 21px; font-weight: 800; letter-spacing: .2px; }
.dash-header p { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.45; }
.dash-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.last-update { font-size: 12.5px; color: var(--muted); }
.last-update span { font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------------------------------------------------- Tarjetas y KPIs */
.card {
    background: linear-gradient(180deg, rgba(16, 40, 29, .62), rgba(11, 28, 20, .78)); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .32); min-width: 0;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi-grid.kpi-6 { grid-template-columns: repeat(6, 1fr); }
.kpi-grid.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.kpi {
    position: relative; background: linear-gradient(180deg, rgba(16, 40, 29, .68), rgba(8, 22, 15, .82));
    border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; overflow: hidden; min-width: 0;
}
.kpi[data-ir] { cursor: pointer; transition: .15s; }
.kpi[data-ir]:hover { border-color: var(--ac, var(--sky)); transform: translateY(-2px); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ac, var(--sky)); }
.kpi .k-ico {
    position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--ac, var(--sky)) 16%, transparent); color: var(--ac, var(--sky));
}
.kpi .k-ico svg { width: 18px; height: 18px; }
.kpi .k-lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; padding-right: 40px; }
.kpi .k-val { font-size: 27px; font-weight: 800; margin: 7px 0 3px; color: var(--ac, var(--sky)); font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .k-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* Trabajos por ubicación (tablero) */
.ubi-row {
    display: grid; grid-template-columns: minmax(120px, 1.1fr) 2fr auto; align-items: center; gap: 14px;
    padding: 11px 10px; min-height: 48px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: .12s;
}
.ubi-row + .ubi-row { border-top: 1px solid var(--border-soft); }
.ubi-row:hover { background: rgba(var(--accent-rgb), .08); border-color: rgba(var(--accent-rgb), .3); }
.ubi-nombre { font-size: 14px; font-weight: 700; }
.ubi-bar { display: flex; height: 9px; border-radius: 6px; overflow: hidden; background: var(--bg-1); border: 1px solid var(--border); }
.ubi-bar i { display: block; height: 100%; }
.s-pend { background: var(--warn); } .s-curso { background: var(--sky); } .s-fin { background: var(--ok); opacity: .6; }
.ubi-nums { display: flex; gap: 6px; font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ubi-nums span { min-width: 28px; text-align: center; padding: 2px 6px; border-radius: 6px; background: var(--bg-1); border: 1px solid var(--border-soft); }
.c-pend { color: #fbbf24; } .c-curso { color: #34d399; } .c-fin { color: #4ade80; }

.stock-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 8px; min-height: 52px; border-bottom: 1px solid var(--border-soft); cursor: pointer; font-size: 14px; border-radius: 8px; }
.stock-item:last-child { border-bottom: none; }
.stock-item:hover { background: rgba(var(--accent-rgb), .08); }
.stock-item b { font-variant-numeric: tabular-nums; }
.stock-item small { display: block; color: var(--muted); font-size: 12px; }

.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.empty.ok { color: #34d399; }

/* --------------------------------------------------------- Toolbar / seg */
.toolbar { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1; max-width: 340px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border-input); border-radius: 10px; padding: 4px; gap: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
    border: none; background: transparent; color: var(--muted); padding: 8px 15px; border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 700; transition: .15s; white-space: nowrap; min-height: 36px;
}
.seg button:hover:not(.active) { color: var(--text); background: rgba(255, 255, 255, .05); }
.seg button.active { background: linear-gradient(135deg, var(--sky-2), var(--blue)); color: #fff; box-shadow: 0 4px 14px rgba(var(--accent-rgb), .3); }
#elecEstacion { margin-bottom: 14px; }

/* ---------------------------------------------------------------- Tablas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
th { background: rgba(16, 40, 29, .95); color: var(--th); font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; font-weight: 800; white-space: nowrap; }
tbody tr { transition: .12s; }
tbody tr:hover { background: rgba(var(--accent-rgb), .07); }
tr.fila-click { cursor: pointer; }
td small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
td small.solo-m { display: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ta-c, th.ta-c { text-align: center; }
.t-titulo { font-weight: 700; font-size: 14px; }
.tbl-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.tbl-title h4 { font-size: 12.5px; color: var(--th); text-transform: uppercase; letter-spacing: .6px; font-weight: 800; }
.tbl-link { font-size: 12.5px; color: var(--muted); cursor: pointer; font-weight: 700; padding: 6px 4px; }
.tbl-link:hover { color: var(--sky); }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pager:empty { display: none; }
.btn-page {
    background: var(--bg-3); color: var(--text); border: 1px solid var(--border-input); padding: 8px 14px; min-height: 38px;
    border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 700; transition: .15s;
}
.btn-page:hover:not(:disabled) { border-color: var(--sky); color: var(--sky); }
.btn-page:disabled { opacity: .4; cursor: not-allowed; }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 800; letter-spacing: .3px; line-height: 1.4;
    border: 1px solid transparent; white-space: nowrap;
}
.est-pendiente { color: #fbbf24; background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .5); }
.est-en_curso { color: #34d399; background: rgba(var(--accent-rgb), .16); border-color: rgba(var(--accent-rgb), .55); }
.est-finalizado { color: #4ade80; background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .45); }
.prio-baja { color: var(--muted); background: rgba(167, 203, 187, .1); border-color: rgba(167, 203, 187, .4); }
.prio-media { color: #7dd3fc; background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .45); }
.prio-alta { color: #fbbf24; background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .5); }
.prio-critica { color: #fff; background: rgba(244, 63, 94, .42); border-color: rgba(244, 63, 94, .8); }
.stk-ok { color: #4ade80; background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .45); }
.stk-bajo { color: #fbbf24; background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .55); }
.stk-cero { color: var(--danger-text); background: rgba(244, 63, 94, .16); border-color: rgba(244, 63, 94, .55); }
.mov-ingreso { color: #4ade80; } .mov-egreso { color: var(--danger-text); } .mov-ajuste { color: #7dd3fc; }
.foto-n { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; font-size: 13px; }
tr.stock-bajo td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.stock-cero td:first-child { box-shadow: inset 4px 0 0 var(--danger); }

/* --------------------------------------------------------------- Diálogos */
dialog.dlg {
    border: 1px solid var(--border-input); background: var(--bg-2); color: var(--text); border-radius: 14px; padding: 0; margin: auto;
    width: min(560px, 94vw); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); box-shadow: var(--shadow); overflow: hidden;
}
dialog.dlg[open] { display: flex; flex-direction: column; animation: fade .2s ease; }
dialog.dlg > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
dialog.dlg-ancho { width: min(780px, 96vw); }
dialog.dlg-chico { width: min(420px, 94vw); }
dialog::backdrop { background: rgba(1, 6, 4, .78); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, #103024, #0b1c14); }
.dlg-head h3 { font-size: 16px; font-weight: 800; overflow-wrap: anywhere; }
.dlg-x { width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--border-input); background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.dlg-x:hover { color: var(--text); border-color: var(--sky); }
.dlg-body { padding: 16px 18px; overflow-y: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }
.dlg-sub { font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--th); margin: 20px 0 10px; font-weight: 800; }
.dlg-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg-1); flex-wrap: wrap; }
.spacer { flex: 1; }
.dlg-err { color: var(--danger-text); font-size: 13px; padding: 0 18px 10px; }
.dlg-err:empty { display: none; }
.mov-info { font-size: 14px; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }
.mov-info b { color: var(--text); }

.det-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; margin-bottom: 16px; }
.det-meta .m { min-width: 0; }
.det-meta .m.full { grid-column: 1 / -1; }
.det-meta .m span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.det-meta .m div { font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.det-meta .m small { font-size: 12px; }
#detEstado { margin-bottom: 4px; }
.lista-simple { list-style: none; font-size: 13.5px; }
.lista-simple li { padding: 9px 2px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lista-simple li small { color: var(--muted); font-size: 12px; }
#btnDetDescontar { margin-top: 10px; }

/* Fotos de taller */
.foto-acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.foto-item {
    position: relative; aspect-ratio: 1; padding: 0; border-radius: 10px; overflow: hidden; cursor: pointer;
    background: var(--bg-1); border: 1px solid var(--border-input); transition: .15s;
}
.foto-item:hover { border-color: var(--sky); transform: translateY(-2px); }
.foto-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-item span { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 6px 4px; font-size: 11px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0, 0, 0, .85)); }
.foto-vacia { grid-column: 1 / -1; color: var(--muted); font-size: 13.5px; padding: 8px 0; }

/* Visor nativo de fotos */
dialog#visorOverlay {
    width: 100%; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 20px; border: 0; color: var(--text);
    background: rgba(1, 6, 4, .94); overflow: hidden;
}
dialog#visorOverlay[open] { display: flex; align-items: center; justify-content: center; animation: fade .2s ease; }
dialog#visorOverlay::backdrop { background: transparent; }
.visor-card { position: relative; max-width: 860px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.visor-card img { width: 100%; max-height: 72vh; max-height: 72dvh; object-fit: contain; border-radius: 10px; border: 1px solid var(--border-input); background: #000; touch-action: pan-y; }
.visor-meta { text-align: center; font-size: 13px; color: var(--muted); line-height: 1.5; }
.visor-meta b { color: var(--text); }
.visor-cerrar {
    position: absolute; top: -8px; right: -8px; z-index: 3; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    background: rgba(11, 28, 20, .95); border: 1px solid var(--border-input); color: var(--text); font-size: 16px;
}
.visor-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 48px; height: 48px; padding: 0; border-radius: 50%;
    background: rgba(11, 28, 20, .85); border: 1px solid var(--border-input); color: var(--text); font-size: 26px; line-height: 1;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .15s;
}
.visor-nav:hover:not(:disabled) { background: rgba(var(--accent-rgb), .3); border-color: var(--sky); color: #fff; }
.visor-nav:disabled { opacity: .3; cursor: not-allowed; }
.visor-nav.izq { left: 18px; } .visor-nav.der { right: 18px; }

/* ---------------------------------------------------- Análisis eléctrico */
.mqtt-badge { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border-input); padding: 7px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.mqtt-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.mqtt-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.alert-strip { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.alert-strip:empty { display: none; }
.alert-item { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 700; background: rgba(244, 63, 94, .14); border: 1px solid rgba(244, 63, 94, .55); color: #fecdd3; }
.alert-item.warn { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .5); color: #fde68a; }
.chart-title { font-size: 12.5px; font-weight: 800; color: var(--th); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px; }
.chart-box { position: relative; height: 240px; }
.chart-box .empty { position: absolute; inset: 0; display: grid; place-items: center; }

/* ------------------------------------------------------ Avisos y toasts */
#sessionBanner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 40000; padding: 10px 14px; text-align: center; font-size: 13px; font-weight: 700; background: #78350f; color: #fef3c7; }
#sessionBanner.show { display: block; }
#toastWrap { position: fixed; inset: auto 16px 16px auto; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: inherit; width: min(380px, calc(100vw - 32px)); flex-direction: column; gap: 8px; }
#toastWrap:popover-open, #toastWrap:not([popover]) { display: flex; }
.toast {
    padding: 12px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1.4; box-shadow: var(--shadow); color: var(--text);
    background: var(--bg-3); border: 1px solid var(--border-input); border-left: 5px solid var(--sky); animation: fade .2s ease;
}
.toast.error { border-left-color: var(--danger); } .toast.warn { border-left-color: var(--warn); } .toast.info { border-left-color: var(--info); }

.sidebar-backdrop { display: none; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

/* ---------- Tablets y laptops chicas (769 – 1200 px) ---------- */
@media (max-width: 1200px) {
    .kpi-grid, .kpi-grid.kpi-6, .kpi-grid.kpi-5 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .content { padding: 18px 18px calc(28px + var(--safe-b)); }
    .table-wrap > table { min-width: 680px; }
    .table-wrap > table.t-cards { min-width: 0; }
    .table-wrap { border-radius: 8px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar:not(.collapsed) { width: 232px; }
    .clock { display: none; }
}

/* ---------- Celulares (≤ 768 px) ---------- */
@media (max-width: 768px) {
    body { font-size: 15px; }
    .btn-menu-movil { display: grid; }

    .sidebar, .sidebar.collapsed {
        position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 30000;
        padding-bottom: var(--safe-b); padding-top: var(--safe-t);
        transform: translateX(-102%); visibility: hidden; box-shadow: none;
        transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s, box-shadow .28s;
    }
    body.menu-abierto .sidebar { transform: translateX(0); visibility: visible; box-shadow: var(--shadow); transition-delay: 0s; }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 29000; background: rgba(1, 6, 4, .68); backdrop-filter: blur(2px);
        opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .28s ease, visibility 0s linear .28s;
    }
    body.menu-abierto .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
    body.menu-abierto .content { overflow: hidden; }

    .sidebar.collapsed .brand { flex-direction: row; justify-content: flex-start; padding: 18px 16px 16px; gap: 11px; }
    .sidebar.collapsed .brand-name { display: block; }
    .sidebar.collapsed .nav-group-label { height: auto; padding: 16px 13px 6px; margin: 0; background: none; font-size: 11.5px; overflow: hidden; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 12px 13px; gap: 11px; }
    .sidebar.collapsed .nav-item-txt { display: block; }
    .sidebar.collapsed .nav-badge { position: static; min-width: 22px; padding: 1px 7px; line-height: 18px; font-size: 11.5px; }
    .sidebar.collapsed .sys-status { justify-content: flex-start; padding: 10px 12px; gap: 9px; }
    .sidebar.collapsed .sys-status > div { display: block; }
    .btn-sidebar-toggle { display: none; }
    .nav-item { min-height: 48px; font-size: 15px; }

    .topbar { padding: 0 12px; height: 58px; }
    .clock, .user-chip .u-role, .user-chip .u-name { display: none; }
    .user-chip { padding: 5px; }
    .btn-logout { min-height: var(--tap); padding: 8px 14px; }
    .crumb small { display: none; }
    .crumb { font-size: 16px; }
    .content { padding: 14px 12px calc(28px + var(--safe-b)); }
    .dash-header { align-items: flex-start; }
    .dash-header h2 { font-size: 20px; }

    .kpi-grid, .kpi-grid.kpi-6, .kpi-grid.kpi-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi { padding: 13px 14px; } .kpi .k-val { font-size: 23px; } .kpi .k-ico { display: none; } .kpi .k-lbl { padding-right: 0; }
    .card { padding: 14px; }
    .ubi-row { grid-template-columns: 1fr auto; }
    .ubi-bar { grid-column: 1 / -1; order: 3; }

    input, select, textarea { min-height: var(--tap); font-size: 16px; }
    input[type="checkbox"] { width: 24px; height: 24px; }
    .chk { min-height: var(--tap); }
    .btn-icon { min-width: var(--tap); height: var(--tap); }
    .btn-neutral, .btn-danger, .btn-inline, .btn-page { min-height: var(--tap); }
    .seg button { min-height: var(--tap); padding: 8px 16px; }
    .dlg-x { width: var(--tap); height: var(--tap); }
    .stock-item { min-height: 56px; }
    .tbl-link { padding: 12px 6px; }
    .visor-nav { width: var(--tap); height: var(--tap); font-size: 22px; } .visor-nav.izq { left: 6px; } .visor-nav.der { right: 6px; }
    .visor-cerrar { width: var(--tap); height: var(--tap); top: -4px; right: -4px; }
    .toolbar { gap: 10px; }
    .toolbar input[type="search"] { max-width: none; min-width: 0; width: 100%; flex-basis: 100%; }
    .login-card { padding: 30px 22px; }

    .hide-m { display: none; }
    .table-wrap > table { min-width: 0; }
    th, td { padding: 10px 9px; }
    table.t-cards thead { display: none; }
    table.t-cards, table.t-cards tbody { display: block; }
    table.t-cards tr {
        display: grid; gap: 8px 10px; align-items: center; margin-bottom: 10px; padding: 12px;
        background: rgba(7, 20, 14, .6); border: 1px solid var(--border); border-radius: 12px;
    }
    table.t-cards tr:hover { background: rgba(var(--accent-rgb), .07); }
    table.t-cards td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
    table.t-cards td.hide-m, table.t-cards td[data-a="id"] { display: none; }
    table.t-cards .row-actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
    td[data-a="tit"] { grid-area: tit; } td[data-a="prio"] { grid-area: prio; } td[data-a="est"] { grid-area: est; }
    td[data-a="foto"] { grid-area: foto; } td[data-a="acc"] { grid-area: acc; justify-self: end; }
    td[data-a="nom"] { grid-area: nom; } td[data-a="stk"] { grid-area: stk; }
    td[data-a="u"] { grid-area: u; } td[data-a="n"] { grid-area: n; } td[data-a="r"] { grid-area: r; } td[data-a="e"] { grid-area: e; }
    td small.solo-m { display: inline; }
    .t-ubi tr { grid-template-columns: auto auto 1fr auto; grid-template-areas: "tit tit tit acc" "prio est foto acc"; }
    .t-stock tr { grid-template-columns: 1fr auto; grid-template-areas: "nom est" "stk stk" "acc acc"; }
    .t-stock td[data-a="acc"] { justify-self: start; }
    .t-users tr { grid-template-columns: 1fr auto; grid-template-areas: "u acc" "n acc" "r e"; }
    .t-users select { width: 100%; }
    tr.stock-bajo, tr.stock-cero { border-left-width: 4px; }
    tr.stock-bajo { border-left-color: var(--warn); } tr.stock-cero { border-left-color: var(--danger); }
    tr.stock-bajo td:first-child, tr.stock-cero td:first-child { box-shadow: none; }

    .form-grid { grid-template-columns: 1fr; }
    .det-meta { grid-template-columns: 1fr 1fr; }
    dialog.dlg, dialog.dlg-chico, dialog.dlg-ancho {
        width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; border-bottom: 0;
        max-height: calc(100vh - 8px - var(--safe-t)); max-height: calc(100dvh - 8px - var(--safe-t));
    }
    dialog.dlg-ancho { height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
    .dlg-head { padding: 12px 14px 12px 16px; }
    .dlg-body { padding: 14px 16px; }
    .dlg-foot { padding: 12px 16px calc(12px + var(--safe-b)); }
    .dlg-foot .btn-neutral, .dlg-foot .btn-danger, .dlg-foot .btn-primary { flex: 1 1 auto; }
    .dlg-err { padding: 0 16px 10px; }
    dialog#visorOverlay { padding: 12px 8px calc(12px + var(--safe-b)); }
    #toastWrap { inset: auto 12px calc(12px + var(--safe-b)) 12px; width: auto; }
}

@media (max-width: 380px) {
    .kpi-grid, .kpi-grid.kpi-6, .kpi-grid.kpi-5 { grid-template-columns: 1fr; }
    .det-meta { grid-template-columns: 1fr; }
}

@media (hover: none) {
    .kpi[data-ir]:hover, .foto-item:hover, .btn-primary:hover:not(:disabled) { transform: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }eral táctil: se desliza con transform y oscurece el resto con un backdrop semitransparente */
    .sidebar, .sidebar.collapsed {
        position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 30000;
        padding-bottom: var(--safe-b); padding-top: var(--safe-t);
        transform: translateX(-102%); visibility: hidden; box-shadow: none;
        transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s, box-shadow .28s;
    }
    body.menu-abierto .sidebar { transform: translateX(0); visibility: visible; box-shadow: var(--shadow); transition-delay: 0s; }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 29000; background: rgba(1, 6, 4, .68); backdrop-filter: blur(2px);
        opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .28s ease, visibility 0s linear .28s;
    }
    body.menu-abierto .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
    body.menu-abierto .content { overflow: hidden; }

    /* En el cajón siempre se ve la versión completa (ignora el modo íconos) */
    .sidebar.collapsed .brand { flex-direction: row; justify-content: flex-start; padding: 18px 16px 16px; gap: 11px; }
    .sidebar.collapsed .brand-name { display: block; }
    .sidebar.collapsed .nav-group-label { height: auto; padding: 16px 13px 6px; margin: 0; background: none; font-size: 11.5px; overflow: hidden; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 12px 13px; gap: 11px; }
    .sidebar.collapsed .nav-item-txt { display: block; }
    .sidebar.collapsed .nav-badge { position: static; min-width: 22px; padding: 1px 7px; line-height: 18px; font-size: 11.5px; }
    .sidebar.collapsed .sys-status { justify-content: flex-start; padding: 10px 12px; gap: 9px; }
    .sidebar.collapsed .sys-status > div { display: block; }
    .btn-sidebar-toggle { display: none; }
    .nav-item { min-height: 48px; font-size: 15px; }

    .topbar { padding: 0 12px; height: 58px; }
    .clock, .user-chip .u-role, .user-chip .u-name { display: none; }
    .user-chip { padding: 5px; }
    .btn-logout { min-height: var(--tap); padding: 8px 14px; }
    .crumb small { display: none; }
    .crumb { font-size: 16px; }
    .content { padding: 14px 12px calc(28px + var(--safe-b)); }
    .dash-header { align-items: flex-start; }
    .dash-header h2 { font-size: 20px; }

    .kpi-grid, .kpi-grid.kpi-6, .kpi-grid.kpi-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi { padding: 13px 14px; } .kpi .k-val { font-size: 23px; } .kpi .k-ico { display: none; } .kpi .k-lbl { padding-right: 0; }
    .card { padding: 14px; }
    .ubi-row { grid-template-columns: 1fr auto; }
    .ubi-bar { grid-column: 1 / -1; order: 3; }

    /* Controles con área táctil mínima de 44×44 px y 16 px de fuente (evita el zoom automático de iOS) */
    input, select, textarea { min-height: var(--tap); font-size: 16px; }
    input[type="checkbox"] { width: 24px; height: 24px; }
    .chk { min-height: var(--tap); }
    .btn-icon { min-width: var(--tap); height: var(--tap); }
    .btn-neutral, .btn-danger, .btn-inline, .btn-page { min-height: var(--tap); }
    .seg button { min-height: var(--tap); padding: 8px 16px; }
    .dlg-x { width: var(--tap); height: var(--tap); }
    .stock-item { min-height: 56px; }
    .tbl-link { padding: 12px 6px; }
    .visor-nav { width: var(--tap); height: var(--tap); font-size: 22px; } .visor-nav.izq { left: 6px; } .visor-nav.der { right: 6px; }
    .visor-cerrar { width: var(--tap); height: var(--tap); top: -4px; right: -4px; }
    .toolbar { gap: 10px; }
    .toolbar input[type="search"] { max-width: none; min-width: 0; width: 100%; flex-basis: 100%; }
    .login-card { padding: 30px 22px; }

    /* Tablas → tarjetas verticales compactas: sin scroll horizontal, con el botón 📷 siempre a la vista */
    .hide-m { display: none; }
    .table-wrap > table { min-width: 0; }
    th, td { padding: 10px 9px; }
    table.t-cards thead { display: none; }
    table.t-cards, table.t-cards tbody { display: block; }
    table.t-cards tr {
        display: grid; gap: 8px 10px; align-items: center; margin-bottom: 10px; padding: 12px;
        background: rgba(7, 20, 14, .6); border: 1px solid var(--border); border-radius: 12px;
    }
    table.t-cards tr:hover { background: rgba(var(--accent-rgb), .07); }
    table.t-cards td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
    table.t-cards td.hide-m, table.t-cards td[data-a="id"] { display: none; }
    table.t-cards .row-actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
    td[data-a="tit"] { grid-area: tit; } td[data-a="prio"] { grid-area: prio; } td[data-a="est"] { grid-area: est; }
    td[data-a="foto"] { grid-area: foto; } td[data-a="acc"] { grid-area: acc; justify-self: end; }
    td[data-a="nom"] { grid-area: nom; } td[data-a="stk"] { grid-area: stk; }
    td[data-a="u"] { grid-area: u; } td[data-a="n"] { grid-area: n; } td[data-a="r"] { grid-area: r; } td[data-a="e"] { grid-area: e; }
    td small.solo-m { display: inline; }
    .t-ubi tr { grid-template-columns: auto auto 1fr auto; grid-template-areas: "tit tit tit acc" "prio est foto acc"; }
    .t-stock tr { grid-template-columns: 1fr auto; grid-template-areas: "nom est" "stk stk" "acc acc"; }
    .t-stock td[data-a="acc"] { justify-self: start; }
    .t-users tr { grid-template-columns: 1fr auto; grid-template-areas: "u acc" "n acc" "r e"; }
    .t-users select { width: 100%; }
    tr.stock-bajo, tr.stock-cero { border-left-width: 4px; }
    tr.stock-bajo { border-left-color: var(--warn); } tr.stock-cero { border-left-color: var(--danger); }
    tr.stock-bajo td:first-child, tr.stock-cero td:first-child { box-shadow: none; }

    /* Modales: hojas inferiores que respetan 100dvh (no quedan tapadas por las barras de Chrome/Safari) */
    .form-grid { grid-template-columns: 1fr; }
    .det-meta { grid-template-columns: 1fr 1fr; }
    dialog.dlg, dialog.dlg-chico, dialog.dlg-ancho {
        width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; border-bottom: 0;
        max-height: calc(100vh - 8px - var(--safe-t)); max-height: calc(100dvh - 8px - var(--safe-t));
    }
    dialog.dlg-ancho { height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
    .dlg-head { padding: 12px 14px 12px 16px; }
    .dlg-body { padding: 14px 16px; }
    .dlg-foot { padding: 12px 16px calc(12px + var(--safe-b)); }
    .dlg-foot .btn-neutral, .dlg-foot .btn-danger, .dlg-foot .btn-primary { flex: 1 1 auto; }
    .dlg-err { padding: 0 16px 10px; }
    dialog#visorOverlay { padding: 12px 8px calc(12px + var(--safe-b)); }
    #toastWrap { inset: auto 12px calc(12px + var(--safe-b)) 12px; width: auto; }
}

/* Celulares muy angostos */
@media (max-width: 380px) {
    .kpi-grid, .kpi-grid.kpi-6, .kpi-grid.kpi-5 { grid-template-columns: 1fr; }
    .det-meta { grid-template-columns: 1fr; }
}

/* Sin hover real (pantallas táctiles): se evitan los "saltos" de las tarjetas al tocar */
@media (hover: none) {
    .kpi[data-ir]:hover, .foto-item:hover, .btn-primary:hover:not(:disabled) { transform: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
