/*
 * Panel MDM — una superficie tranquila donde lo único con color vivo es el estado «en línea».
 * Marca: verde #41695B, menta #00E192, beige #E4E1D9, naranja #F18A00, gris #505050, rojo #CC1111.
 * Fuente del sistema: la CSP solo permite fuentes del propio servidor y así funciona igual sin red.
 */
:root {
  --bg:#f3f5f3; --surface:#fff; --sunken:#eef1ee; --hover:#f6f8f6;
  --line:#e1e6e2; --line-strong:#cbd3ce;
  --ink:#18241f; --fg:#3b4742; --muted:#66716c;
  --brand:#41695b; --brand-hover:#355749; --brand-tint:#e7f0eb; --on-brand:#fff;
  --live:#00e192; --live-ink:#00794f;
  --warn:#f18a00; --warn-ink:#9a5800; --warn-tint:#fdf1e0;
  --err:#c41212; --err-tint:#fbeaea;
  --violet:#6a5bc4; --violet-tint:#efedfa;
  --r-sm:8px; --r:12px; --r-lg:16px;
  --page:1240px; --gutter:32px;
  --font:system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --chev:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2366716c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  --lens:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2366716c' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='m10.5 10.5 3 3'/%3E%3C/svg%3E");
  color-scheme:light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#121815; --surface:#1a221e; --sunken:#151c19; --hover:#1f2824;
    --line:#29332e; --line-strong:#3a4741;
    --ink:#eef2ef; --fg:#c9d1cd; --muted:#929e98;
    --brand:#7fb5a1; --brand-hover:#97c7b5; --brand-tint:#1f2e28; --on-brand:#0e1b16;
    --live-ink:#3ff0ae;
    --warn-ink:#f5a84a; --warn-tint:#33281a;
    --err:#ff7a7a; --err-tint:#3a1e1e;
    --violet:#b3a9f0; --violet-tint:#29253f;
    color-scheme:dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing:border-box; }
[hidden] { display:none !important; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; font:15px/1.5 var(--font); background:var(--bg); color:var(--fg); -webkit-font-smoothing:antialiased; font-variant-numeric:tabular-nums; }
h1, h2, h3 { color:var(--ink); font-weight:600; letter-spacing:-.01em; line-height:1.25; }
h2 { font-size:24px; margin:0; }
h3 { font-size:15px; margin:28px 0 8px; }
b { color:var(--ink); font-weight:600; }
a { color:var(--brand); text-underline-offset:2px; }
code { font:12.5px var(--mono); background:var(--sunken); padding:1px 6px; border-radius:6px; }
pre { font:12.5px/1.6 var(--mono); background:var(--sunken); padding:14px 16px; border-radius:var(--r-sm); overflow:auto; white-space:pre-wrap; word-break:break-all; }
:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.muted { color:var(--muted); font-size:13px; font-weight:400; }
.error { color:var(--err); min-height:1.4em; font-size:13.5px; margin:8px 0; }
.error:empty { min-height:0; margin:0; }

/* ---------- Botones ---------- */
button { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:36px; padding:0 14px; white-space:nowrap;
  font:inherit; font-size:14px; font-weight:500; line-height:1; cursor:pointer;
  background:var(--brand); color:var(--on-brand); border:1px solid transparent; border-radius:var(--r-sm);
  transition:background-color .15s, border-color .15s, color .15s; }
button:hover { background:var(--brand-hover); }
button.secondary { background:var(--surface); color:var(--ink); border-color:var(--line-strong); }
button.secondary:hover { background:var(--hover); border-color:var(--muted); }
button.ghost { background:transparent; color:var(--fg); }
button.ghost:hover { background:var(--sunken); color:var(--ink); }
button.danger { background:var(--err-tint); color:var(--err); }
button.danger:hover { background:var(--err); color:#fff; }
button:disabled { opacity:.45; cursor:not-allowed; }
button.danger:disabled:hover { background:var(--err-tint); color:var(--err); }
button.ghost:disabled:hover { background:transparent; color:var(--fg); }
button.secondary:disabled:hover { background:var(--surface); border-color:var(--line-strong); }
button:not(.secondary, .ghost, .danger):disabled:hover { background:var(--brand); }
.btn-row { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }

/* ---------- Campos ---------- */
input, select, textarea { min-height:36px; padding:7px 12px; font:inherit; font-size:14px; color:var(--ink);
  background:var(--surface); border:1px solid var(--line-strong); border-radius:var(--r-sm); }
input:hover, select:hover, textarea:hover { border-color:var(--muted); }
input:focus, select:focus, textarea:focus { outline:3px solid color-mix(in srgb, var(--brand) 22%, transparent); outline-offset:0; border-color:var(--brand); }
input::placeholder, textarea::placeholder { color:var(--muted); }
select { appearance:none; padding-right:32px; background:var(--surface) var(--chev) no-repeat right 11px center; text-overflow:ellipsis; cursor:pointer; }
input[type=search] { padding-left:36px; background:var(--surface) var(--lens) no-repeat 12px center; }
input[type=checkbox], input[type=radio] { accent-color:var(--brand); width:16px; height:16px; min-height:0; padding:0; margin:0; flex:none; cursor:pointer; }
input[type=file] { min-height:0; padding:0; border:0; background:none; font-size:14px; max-width:100%; }
input[type=file]::file-selector-button { font:inherit; font-size:14px; font-weight:500; margin-right:12px; padding:8px 14px; color:var(--on-brand); background:var(--brand); border:0; border-radius:var(--r-sm); cursor:pointer; }
textarea { width:100%; line-height:1.5; resize:vertical; }
.full { width:100%; }

/* ---------- Inicio de sesión ---------- */
#login { display:grid; place-items:center; min-height:100vh; min-height:100dvh; padding:16px; }
#login form { width:min(360px, 100%); display:grid; gap:14px; padding:36px 32px 28px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); }
#login h1 { margin:0; font-size:22px; display:flex; align-items:center; gap:10px; }
#login h1::before, header h1::before { content:""; width:10px; height:10px; border-radius:50%; background:var(--live); box-shadow:0 0 0 4px color-mix(in srgb, var(--live) 25%, transparent); }
#login h1 + .muted { margin:-8px 0 8px; }
#login label { display:grid; gap:6px; font-size:13.5px; font-weight:500; color:var(--ink); }
#login button { min-height:40px; margin-top:6px; }
#login .error:empty { display:none; }
.login-version { margin:2px 0 0; text-align:center; font:11px/1.4 var(--mono); color:var(--muted); }
.login-version:empty { display:none; }

/* ---------- Barra superior ---------- */
#app { min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; }
header { position:sticky; top:0; z-index:30; display:flex; align-items:center; gap:8px 28px; min-height:60px;
  padding:0 max(var(--gutter), calc((100% - var(--page)) / 2 + var(--gutter)));
  background:color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter:saturate(1.4) blur(10px); border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:baseline; gap:10px; min-width:0; }
header h1 { margin:0; font-size:17px; display:flex; align-items:center; gap:10px; align-self:center; }
.badge { font-size:12.5px; color:var(--muted); white-space:nowrap; }
header nav { display:flex; gap:4px; align-self:stretch; flex:1; min-width:0; }
header nav button.tab { position:relative; min-height:0; height:100%; padding:0 10px; border:0; border-radius:0; background:transparent; color:var(--muted); font-weight:500; }
header nav button.tab:hover { background:transparent; color:var(--ink); }
header nav button.tab.active { color:var(--ink); }
header nav button.tab.active::after { content:""; position:absolute; left:10px; right:10px; bottom:-1px; height:2px; border-radius:2px 2px 0 0; background:var(--brand); }
.header-actions { display:flex; gap:6px; margin-left:auto; }

/* ---------- Páginas ---------- */
#app > section { width:100%; max-width:var(--page); margin:0 auto; padding:36px var(--gutter) 48px; }
.web-version { margin-top:auto; width:100%; max-width:var(--page); margin-left:auto; margin-right:auto;
  padding:10px var(--gutter) 16px; display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:6px 12px;
  border-top:1px solid var(--line); font:11.5px/1.4 var(--mono); color:var(--muted); }
.web-version:empty { display:none; }
.web-version.stale { color:var(--warn-ink); }
.web-version button { min-height:24px; padding:0 8px; font:11.5px var(--font); }
.page-head { display:flex; align-items:center; justify-content:space-between; gap:12px 16px; flex-wrap:wrap; margin-bottom:8px; }
.page-intro { max-width:72ch; margin:0 0 24px; font-size:14px; line-height:1.6; }
.section-title { display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; font-size:18px; margin:48px 0 14px; }
.section-title .muted { font-size:13px; }
.empty { margin:16px 0; padding:40px 20px; text-align:center; color:var(--muted); font-size:14px; border:1px dashed var(--line-strong); border-radius:var(--r); }
.load-more { display:flex; justify-content:center; margin:16px 0 0; }
.toolbar { margin-bottom:16px; }

/* ---------- Tablas ---------- */
.table-scroll { max-width:100%; min-width:0; overflow-x:auto; border:1px solid var(--line); border-radius:var(--r); background:var(--surface); }
#app .table-scroll > table { min-width:760px; }
table { width:100%; border-collapse:collapse; background:var(--surface); }
:not(.table-scroll) > table:not(.kv) { border:1px solid var(--line); border-radius:var(--r); border-collapse:separate; border-spacing:0; overflow:hidden; }
th, td { padding:12px 16px; text-align:left; vertical-align:middle; border-bottom:1px solid var(--line); }
th { font-size:12.5px; font-weight:500; color:var(--muted); background:var(--sunken); white-space:nowrap; }
td { font-size:14px; color:var(--fg); }
tbody tr:last-child td { border-bottom:0; }
tbody tr:hover td { background:var(--hover); }
td > b { display:block; }
td > b + .pill { margin-top:6px; }
td > button { min-height:32px; padding:0 12px; font-size:13.5px; margin:2px 0; }
td:last-child:has(> button) { white-space:nowrap; }
td .chips { display:flex; flex-wrap:wrap; gap:4px; }
td .chips .pill { max-width:230px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
td .pill.group { max-width:150px; }
/* Tabla de APKs: «Acciones» siempre a la vista aunque haya que desplazarse */
#view-apks .table-scroll > table { min-width:900px; }
#view-apks th { white-space:normal; }
#view-apks td:first-child { overflow-wrap:break-word; max-width:260px; }
#view-apks th:last-child, #view-apks td:last-child { position:sticky; right:0; box-shadow:-1px 0 0 var(--line); }
#view-apks td:last-child { background:var(--surface); }
#view-apks tbody tr:hover td:last-child { background:var(--hover); }
/* Tabla clave/valor del detalle (sin cabecera ni borde exterior) */
table.kv td { padding:9px 0; border-bottom:1px solid var(--line); }
table.kv td:first-child { color:var(--muted); font-size:13.5px; padding-right:16px; width:38%; }
table.kv tr:hover td { background:transparent; }

/* ---------- Etiquetas de estado ---------- */
.dot { display:inline-block; flex:none; width:8px; height:8px; border-radius:50%; background:var(--line-strong); margin-right:8px; }
.dot.on { background:var(--live); box-shadow:0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.pill { display:inline-block; max-width:100%; padding:2px 9px; margin:2px 4px 2px 0; font-size:12px; font-weight:500; line-height:1.6;
  border-radius:999px; background:var(--sunken); color:var(--fg); vertical-align:middle; }
.pill.ok { background:var(--brand-tint); color:var(--brand); }
.pill.bad { background:var(--err-tint); color:var(--err); }
.pill.warn, .pill.pending { background:var(--warn-tint); color:var(--warn-ink); }
.pill.group { background:var(--brand-tint); color:var(--brand); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:bottom; }
.pill.profile { background:var(--violet-tint); color:var(--violet); }
.pill.system { margin-left:6px; background:var(--warn-tint); color:var(--warn-ink); cursor:help; }
.chips:empty { display:none; }

/* ---------- Flota: titular con un punto por equipo ---------- */

/* Búsqueda, vistas y filtros */
.fleet-bar { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px 16px; align-items:center; margin-bottom:20px; }
#fleet-search { width:100%; }
.seg { display:inline-flex; padding:3px; gap:2px; background:var(--sunken); border:1px solid var(--line); border-radius:10px; }
.seg button { min-height:30px; padding:0 12px; border:0; border-radius:7px; background:transparent; color:var(--muted); font-size:13.5px; }
.seg button:hover { background:transparent; color:var(--ink); }
.seg button[aria-pressed=true] { background:var(--surface); color:var(--ink); box-shadow:0 1px 2px rgba(20,30,25,.12); }
.fleet-filters { grid-column:1 / -1; display:flex; flex-wrap:wrap; align-items:center; gap:10px 16px; min-width:0; }
.fleet-filters > .muted:last-child { margin-left:auto; white-space:nowrap; }
.sel { display:inline-flex; align-items:center; gap:8px; min-width:0; font-size:13px; color:var(--muted); }
.sel select { max-width:230px; min-height:34px; }

/* Vista Tarjetas: cada equipo es un teléfono cuya pantalla se llena con su batería */
.fleet { display:grid; gap:16px; grid-template-columns:repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.unit { min-width:0; display:grid; grid-template-columns:auto minmax(0,1fr); grid-template-rows:1fr auto; gap:4px 20px; align-items:start; padding:20px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); }
.unit.off { background:transparent; border-style:dashed; border-color:var(--line-strong); }
.unit-body { min-width:0; }
.unit-body h3 { margin:0; font-size:17px; letter-spacing:-.01em; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
.unit.off .unit-body h3 { color:var(--fg); }
.unit .meta { margin:2px 0 8px; color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
.unit .seen { margin:0; display:flex; align-items:center; font-size:13.5px; color:var(--fg); }
.unit .chips { margin-top:8px; }
.phone { position:relative; width:44px; height:78px; padding:3px; display:grid; overflow:hidden; background:var(--bg); border:2px solid var(--ink); border-radius:11px; }
.phone::before { content:""; position:absolute; top:5px; left:50%; z-index:2; width:12px; height:3px; margin-left:-6px; border-radius:2px; background:var(--ink); }
.phone i { position:absolute; left:0; right:0; bottom:0; height:var(--lvl); background:var(--line-strong); }
.unit.on .phone i { background:var(--live); }
.unit.on .phone.charging i { background:repeating-linear-gradient(135deg, var(--live) 0 7px, color-mix(in srgb, var(--live) 65%, #fff) 7px 14px); }
.phone span { position:relative; z-index:1; align-self:end; justify-self:center; margin-bottom:5px; font-size:12px; font-weight:600; color:var(--ink); }
.unit.off .phone { border-color:var(--muted); }
.unit.off .phone::before { background:var(--muted); }
/* La fila del contenido se estira (1fr): el botón queda al fondo y alineado entre tarjetas de distinta altura */
.unit-actions { grid-column:1 / -1; align-self:end; display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; padding-top:14px; border-top:1px solid var(--line); }
.unit-actions > button { flex:1 1 auto; }
.unit.on .unit-actions > button:first-child { background:var(--brand); color:var(--on-brand); border-color:transparent; }
.unit.on .unit-actions > button:first-child:hover { background:var(--brand-hover); }

/* Batería en barra (mosaico y lista) */
.batt { position:relative; display:grid; height:18px; min-width:64px; overflow:hidden; background:var(--bg); border:1px solid var(--line-strong); border-radius:5px; }
.batt i { position:absolute; left:0; top:0; bottom:0; width:var(--lvl); background:var(--line-strong); }
.on .batt i { background:color-mix(in srgb, var(--live) 70%, var(--surface)); }
.on .batt.charging i { background:repeating-linear-gradient(135deg, var(--live) 0 7px, color-mix(in srgb, var(--live) 65%, #fff) 7px 14px); }
.batt span { position:relative; z-index:1; align-self:center; justify-self:center; font-size:11.5px; font-weight:600; color:var(--ink); }

/* Vista Mosaico */
.fleet-tiles { grid-template-columns:repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap:12px; }
.tile { min-width:0; display:grid; grid-template-columns:minmax(0,1fr); gap:6px; align-content:start; padding:14px 14px 16px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); cursor:pointer; transition:border-color .15s; }
.tile:hover { border-color:var(--muted); }
.tile.off { background:transparent; border-style:dashed; border-color:var(--line-strong); }
.tile-top { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.tile .seen { display:flex; align-items:center; min-width:0; font-size:12.5px; color:var(--fg); }
.tile h3 { margin:2px 0 0; font-size:15px; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
.tile.off h3 { color:var(--fg); }
.tile .meta { margin:0; color:var(--muted); font-size:12.5px; overflow-wrap:anywhere; }
.tile .chips { min-width:0; }
.tile .more summary { min-height:28px; padding:0 10px; font-size:13px; }
.tile .menu { min-width:170px; }

/* Vista Lista */
.fleet-list { display:flex; flex-direction:column; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.row { display:grid; grid-template-columns:auto minmax(160px,2fr) minmax(110px,1fr) 80px minmax(0,1.2fr) auto; gap:6px 16px; align-items:center; padding:10px 16px; border-bottom:1px solid var(--line); }
.row:last-child { border-bottom:0; }
.row:hover { background:var(--hover); }
.row:first-child { border-radius:var(--r) var(--r) 0 0; } .row:last-child { border-radius:0 0 var(--r) var(--r); }
.row .dot { margin-right:0; }
.row-name { min-width:0; display:grid; }
.row-name b { font-weight:600; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
.row.off .row-name b { color:var(--fg); }
.row .meta { color:var(--muted); font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row-seen { font-size:13.5px; color:var(--fg); }
.row-actions { display:flex; gap:8px; align-items:center; justify-content:flex-end; }
.row .row-actions button, .row .more summary { min-height:32px; padding:0 12px; font-size:13.5px; }

/* Menú «Más» */
.more { position:relative; }
.more summary { list-style:none; display:inline-flex; align-items:center; min-height:36px; padding:0 14px; cursor:pointer; user-select:none;
  font-size:14px; font-weight:500; color:var(--ink); background:var(--surface); border:1px solid var(--line-strong); border-radius:var(--r-sm); }
.more summary::-webkit-details-marker { display:none; }
.more summary::after { content:""; width:12px; height:12px; margin-left:6px; margin-right:-4px; background:var(--chev) no-repeat center; }
.more summary:hover, .more[open] summary { background:var(--hover); border-color:var(--muted); }
.more .menu { position:absolute; right:0; top:calc(100% + 6px); z-index:20; min-width:200px; max-width:calc(100vw - 32px); padding:6px; display:grid; gap:1px;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r); box-shadow:0 12px 32px rgba(15,25,20,.16); }
.more .menu button { justify-content:flex-start; min-height:34px; border:0; background:transparent; color:var(--ink); font-weight:400; border-radius:6px; }
.more .menu button:hover { background:var(--sunken); }
.more .menu button:disabled:hover { background:transparent; }
.more .menu button.danger { color:var(--err); }
.more .menu button.danger:hover { background:var(--err-tint); color:var(--err); }

/* Paginación */
.fleet-pager { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:10px; margin:20px 0 4px; }

/* Mapa del detalle */
#det-map { height:280px; margin-top:10px; border:1px solid var(--line); border-radius:var(--r); z-index:0; }
#det-loc-info { font-weight:400; }
.leaflet-container { font:13px/1.45 var(--font); }

/* ---------- Actividad ---------- */
.activity { list-style:none; margin:0; padding:0; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.act { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:12px; align-items:start; padding:12px 16px; border-bottom:1px solid var(--line); font-size:14px; }
.act:last-child { border-bottom:0; }
.act > div { min-width:0; overflow-wrap:anywhere; }
.act > .muted { white-space:nowrap; }
.act-dot { width:8px; height:8px; margin-top:6px; border-radius:50%; background:var(--line-strong); }
.act.done .act-dot { background:var(--live); }
.act.sent .act-dot { background:var(--warn); }
.act.failed .act-dot { background:var(--err); }
.det-activity { max-height:260px; overflow-y:auto; }

/* ---------- APKs ---------- */
.mdm-update { display:grid; gap:6px; margin-bottom:16px; padding:16px 18px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.mdm-update p { margin:0; }
.mdm-update .btn-row { margin:6px 0 0; }
.mdm-update-head { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:4px 12px; }
.muted.small { font-size:12px; }
.upload-panel { display:grid; gap:12px; margin-bottom:16px; }
.drop { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:10px 14px; padding:28px 20px; text-align:center;
  color:var(--muted); font-size:14px; background:var(--surface); border:1.5px dashed var(--line-strong); border-radius:var(--r); transition:border-color .15s, background-color .15s; }
.drop.over { border-color:var(--brand); background:var(--brand-tint); color:var(--brand); }
.assign { padding:14px 16px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.assign:empty { display:none; }
.assign-label { display:block; font-size:13.5px; }
.assign-label ~ .assign-label { margin-top:14px; }
.assign-chips { display:flex; flex-wrap:wrap; gap:6px; max-height:136px; overflow:auto; margin-top:8px; }
.upload-log { list-style:none; margin:0 0 16px; padding:0; font-size:13.5px; display:grid; gap:6px; }
.upload-log:empty { display:none; }
.upload-log li { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.upload-log .ok { color:var(--live-ink); }
.upload-log .fail { color:var(--err); }
.upload-log button { min-height:30px; font-size:13px; }

/* Chips seleccionables (grupos y perfiles) */
.chip { display:inline-flex; align-items:center; gap:7px; max-width:100%; padding:5px 12px; cursor:pointer; user-select:none;
  font-size:13.5px; color:var(--ink); background:var(--surface); border:1px solid var(--line-strong); border-radius:999px; }
.chip:hover { border-color:var(--muted); }
.chip span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chip small { color:var(--muted); }
.chip:has(input:checked) { background:var(--brand-tint); border-color:var(--brand); color:var(--brand); }
.chip.profile:has(input:checked) { background:var(--violet-tint); border-color:var(--violet); color:var(--violet); }

/* ---------- Diálogos ---------- */
dialog { width:min(760px, calc(100vw - 32px)); max-height:min(90vh, 960px); padding:0 24px; overflow:auto; overscroll-behavior:contain;
  color:var(--fg); background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:0 24px 64px rgba(10,20,15,.28); }
dialog::backdrop { background:rgba(15,22,19,.45); backdrop-filter:blur(2px); }
dialog:not(:has(> form)) { padding-bottom:24px; } /* los formularios terminan en su pie fijo */
#group-dialog, #apk-dialog { width:min(880px, calc(100vw - 32px)); }
/* Enrolar: ancho y alto casi de pantalla completa para el panel de instalación por USB (equipo + terminal) */
#enroll-dialog { width:min(1400px, calc(100vw - 32px)); max-height:calc(100vh - 32px); max-height:calc(100dvh - 32px); }
#enroll-qr { max-width:760px; }
/* Detalle del equipo: más ancho, alto fijo (no salta al cambiar de pestaña); cabecera, estado y pestañas quedan fijos
   y solo se desplaza el contenido de la pestaña. */
#det-dialog { width:min(1100px, calc(100vw - 32px)); height:min(860px, calc(100vh - 32px)); height:min(860px, calc(100dvh - 32px)); padding-bottom:0; }
#det-dialog[open] { display:flex; flex-direction:column; overflow:hidden; }
#det-dialog > .remote-head { margin-bottom:8px; }
#det-dialog > #det-state { margin:0 0 4px; }
.det-tabs { flex:none; align-self:flex-start; margin:4px 0 8px; }
.det-tabs .tab-n { min-width:18px; padding:0 6px; border-radius:999px; font-size:11.5px; line-height:18px; color:var(--muted); background:var(--sunken); }
.det-tabs .tab-n:empty { display:none; }
.det-tabs button.tab.active .tab-n { color:var(--ink); background:var(--brand-tint); }
#det-dialog > #det-error { flex:none; }
.det-body { flex:1; min-height:0; overflow:auto; overscroll-behavior:contain; margin:0 -24px; padding:0 24px 24px; border-top:1px solid var(--line); }
#det-dialog .det-panel > h3:first-child { margin:16px 0 10px; padding-top:0; border-top:0; }
#det-dialog #det-map { height:clamp(260px, calc(100dvh - 400px), 560px); }
#det-dialog .det-activity { max-height:none; overflow:visible; }
#det-p-info table.kv { max-width:760px; }
/* Acciones del equipo: grupos en tarjetas que se reparten en columnas según el ancho del diálogo */
.det-actions { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:14px; }
.det-act-group { min-width:0; padding:14px 16px 16px; background:var(--sunken); border:1px solid var(--line); border-radius:var(--r); }
.det-act-group h4 { margin:0 0 10px; font-size:14px; font-weight:600; color:var(--ink); }
.det-act-group h4 .muted { font-weight:400; }
.det-act-group > p.muted { margin:-4px 0 10px; }
.det-act-buttons { display:flex; flex-wrap:wrap; gap:8px; }
.det-act-wide { grid-column:1 / -1; }
/* Tarjetas y filas de la flota: un clic abre el detalle (con todas las acciones) */
.unit, .row { cursor:pointer; }
.unit { transition:border-color .15s; }
.unit:hover { border-color:var(--line-strong); }
#remote-dialog { width:auto; max-width:calc(100vw - 32px); }
dialog p { margin:8px 0; }
dialog h3 { margin:28px 0 8px; }
/* Cabecera fija: el título y «Cerrar» siempre a la vista al desplazarse */
.remote-head { position:sticky; top:0; z-index:5; display:flex; align-items:center; gap:12px; margin:0 -24px 12px; padding:18px 24px 14px;
  background:var(--surface); border-bottom:1px solid var(--line); }
.remote-head b { flex:1; min-width:0; font-size:17px; overflow-wrap:anywhere; }
.remote-head h2 { margin:0; }
/* Pie fijo con las acciones del formulario */
.dialog-actions { position:sticky; bottom:0; z-index:5; display:flex; flex-wrap:wrap; gap:8px; margin:16px -24px 0; padding:14px 24px 18px;
  background:var(--surface); border-top:1px solid var(--line); }
.dialog-actions > .ghost:last-child { margin-left:auto; }
/* Secciones del detalle y de seguridad separadas por una línea */
#sec-dialog h3, #det-dialog h3 { margin:28px 0 8px; padding-top:20px; border-top:1px solid var(--line); }
#sec-dialog .remote-head + .muted + h3, #det-dialog .remote-head + .muted + h3 { border-top:0; padding-top:0; margin-top:16px; }
#sec-dialog h3.zone-danger { color:var(--err); }
.subtabs { display:inline-flex; padding:3px; gap:2px; margin:4px 0 12px; background:var(--sunken); border:1px solid var(--line); border-radius:10px; max-width:100%; overflow-x:auto; }
.subtabs button.tab { min-height:32px; padding:0 14px; border:0; border-radius:7px; background:transparent; color:var(--muted); font-size:13.5px; }
.subtabs button.tab:hover { background:transparent; color:var(--ink); }
.subtabs button.tab.active { background:var(--surface); color:var(--ink); box-shadow:0 1px 2px rgba(20,30,25,.12); }
#qr-img { display:block; width:320px; max-width:100%; margin:8px 0; padding:10px; background:#fff; border:1px solid var(--line); border-radius:var(--r); }

/* Filas de campos: se reparten el ancho y bajan de línea si no caben */
.dev-row { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:4px 0; }
.dev-row > input:not([type=checkbox]), .dev-row > select { flex:1 1 180px; min-width:0; }
.dev-row > .grow { flex:3 1 260px; }
.dev-row > .muted { margin-left:auto; }
.dev-row.check { flex-wrap:nowrap; align-items:flex-start; gap:10px; font-size:14px; color:var(--fg); cursor:pointer; }
.dev-row.check > span { min-width:0; }
.dev-row.check input { margin-top:3px; }
.dev-row.check + .dev-row.check { padding-top:0; }

/* Formularios de los diálogos */
#profile-form, #group-form, #kiosk-form { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; } /* minmax(0,1fr): sin esto la columna no encoge por debajo del contenido más ancho */
#profile-form > label:not(.check), #group-form > label:not(.check), #kiosk-form > label:not(.check) { display:grid; gap:6px; font-size:13.5px; font-weight:500; color:var(--ink); }
#profile-form > label input, #group-form > label input:not([type=checkbox]), #kiosk-form > label input:not([type=checkbox]) { width:100%; }
#profile-form h3, #group-form h3 { margin:18px 0 0; }
#profile-form > p, #group-form > p, #kiosk-form > p { margin:0; }
#profile-form .assign-chips { max-height:180px; }
#group-effective { display:flex; flex-wrap:wrap; gap:4px; min-width:0; }
#group-effective .pill, #profile-groups .chip { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#group-app-add, #profile-app-add { min-width:0; max-width:100%; }
#group-devices-search { width:100%; }
#group-devices { max-height:240px; overflow:auto; padding:4px 12px; border:1px solid var(--line); border-radius:var(--r-sm); }
#group-devices .dev-row { padding:6px 0; border-bottom:1px solid var(--line); font-size:14px; }
#group-devices .dev-row:last-child { border-bottom:0; }
#group-status-box { min-width:0; max-width:100%; }
#group-status td { overflow-wrap:anywhere; }
dialog .table-scroll td > select { width:100%; min-width:180px; }

/* Reglas del grupo */
.presets { display:flex; flex-wrap:wrap; align-items:center; gap:8px; font-size:13.5px; color:var(--muted); }
.presets button { min-height:32px; font-size:13.5px; }
#group-rules { padding:0 16px; border:1px solid var(--line); border-radius:var(--r); }
.rule-group { margin:0 -16px; padding:10px 16px; font-size:12.5px; font-weight:600; color:var(--muted); background:var(--sunken); border-bottom:1px solid var(--line); }
.rule-group:first-child { border-radius:var(--r) var(--r) 0 0; }
.rule { display:grid; grid-template-columns:auto 1fr; gap:2px 12px; padding:10px 0; border-bottom:1px solid var(--line); }
.rule:last-child, .rule:has(+ .rule-group) { border-bottom:0; }
.rule input { margin-top:3px; }
.rule label { color:var(--ink); font-size:14px; cursor:pointer; }
.rule .desc { grid-column:2; color:var(--muted); font-size:12.5px; }
.rule .warn { grid-column:2; color:var(--warn-ink); font-size:12.5px; }

/* Control remoto */
.remote-body { display:flex; gap:20px; align-items:flex-start; }
.remote-side { display:grid; gap:8px; width:256px; }
.remote-opts { display:grid; gap:6px; padding:8px 10px; background:var(--sunken); border:1px solid var(--line); border-radius:var(--r-sm); }
.remote-opts label { display:grid; gap:3px; font-size:12px; color:var(--muted); }
.remote-opts label:has(> input[type=range]) { grid-template-columns:1fr auto; align-items:center; }
.remote-opts input[type=range] { grid-column:1 / -1; width:100%; margin:2px 0 0; }
.remote-opts select { min-height:30px; padding:4px 26px 4px 8px; font-size:12.5px; }
.remote-opts-row { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.remote-opts label.check { display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--fg); padding:2px 0 0; }
#remote-stats:empty { display:none; }
.remote-keys { display:grid; grid-template-columns:repeat(auto-fit, minmax(0,1fr)); gap:6px; }
.remote-keys button { padding:0 8px; }
#remote-stage { display:flex; }
#remote-stage.paused canvas, #remote-stage.paused video { opacity:.45; filter:grayscale(.4); transition:opacity .15s; }
#remote-canvas, #remote-video { max-height:75vh; max-width:70vw; background:#0d1210; border-radius:var(--r); touch-action:none; cursor:crosshair; }
#remote-video[hidden], #remote-canvas[hidden] { display:none; }

/* Avisos flotantes de las órdenes */
.toasts { position:fixed; right:16px; bottom:16px; z-index:100; display:grid; gap:8px; width:min(380px, calc(100vw - 32px)); pointer-events:none; }
.toast { pointer-events:auto; display:flex; align-items:flex-start; gap:10px; padding:12px 12px 12px 14px; font-size:13.5px; line-height:1.45; color:var(--ink);
  background:var(--surface); border:1px solid var(--line-strong); border-left:4px solid var(--muted); border-radius:var(--r-sm); box-shadow:0 10px 28px rgba(15,25,20,.22); }
.toast.ok { border-left-color:var(--live); }
.toast.error { border-left-color:var(--err); }
.toast-text { flex:1; min-width:0; overflow-wrap:anywhere; }
.toast-x { min-height:0; padding:0 4px; font-size:18px; color:var(--muted); background:transparent; border:0; }
.toast-x:hover { background:transparent; color:var(--ink); }

/* ---------- Anchos medios: la lista pasa a dos líneas ---------- */
@media (max-width:1180px) {
  .row { grid-template-columns:auto minmax(0,1fr) auto; }
  .row-seen, .row .chips { grid-column:2 / -1; }
  .row .batt { grid-column:3; grid-row:1; }
  .row .row-actions { grid-column:1 / -1; justify-content:flex-start; flex-wrap:wrap; }
}

/* ---------- Tablet: la navegación baja a su propia fila ---------- */
@media (max-width:960px) {
  :root { --gutter:20px; }
  header { flex-wrap:wrap; padding-top:10px; gap:6px 16px; }
  .header-actions { margin-left:auto; }
  header nav { order:3; flex:1 1 100%; height:44px; overflow-x:auto; scrollbar-width:none; margin:0 -10px; }
  header nav::-webkit-scrollbar { display:none; }
  #app > section { padding-top:28px; }
  .remote-body { flex-direction:column; }
  .remote-side { width:100%; grid-template-columns:repeat(auto-fit, minmax(160px,1fr)); }
  #remote-canvas, #remote-video { max-width:100%; }
}

/* ---------- Móvil ---------- */
@media (max-width:640px) {
  :root { --gutter:16px; }
  body { font-size:15px; }
  button, input, select, .more summary { min-height:40px; }
  header h1 { font-size:16px; }
  .header-actions button { padding:0 12px; }
  .page-head h2 { font-size:22px; }
  .fleet-bar { grid-template-columns:minmax(0,1fr); }
  .seg { width:100%; }
  .seg button { flex:1; padding:0 6px; }
  .fleet-filters { gap:10px; }
  .sel { flex:1 1 calc(50% - 5px); display:grid; gap:4px; }
  .sel:first-child { flex-basis:100%; }
  .sel select { max-width:none; width:100%; }
  .fleet-filters > .muted:last-child { margin-left:0; }
  .unit { padding:16px; gap:4px 16px; }
  .unit-actions { flex-wrap:nowrap; gap:6px; }
  .unit-actions > button { flex:1 1 0; min-width:0; padding:0 8px; font-size:13.5px; }
  .unit-actions .more summary { padding:0 10px; }
  .act { padding:12px 14px; grid-template-columns:auto minmax(0,1fr); }
  .act > .muted:last-child { grid-column:2; }
  #det-map { height:220px; }
  table.kv td:first-child { width:42%; }
  /* Diálogos a pantalla completa */
  dialog { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; margin:0; padding:0 16px; border:0; border-radius:0; }
  #group-dialog, #apk-dialog, #remote-dialog, #enroll-dialog, #det-dialog { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; }
  .det-body { margin:0 -16px; padding:0 16px 16px; }
  .remote-head { margin:0 -16px 12px; padding:14px 16px 12px; }
  .dialog-actions { margin:16px -16px 0; padding:12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .dialog-actions > button { flex:1 1 auto; }
  .dialog-actions > .ghost:last-child { margin-left:0; }
  .dev-row > input:not([type=checkbox]), .dev-row > select, .dev-row > .grow { flex-basis:100%; }
  .toasts { right:12px; left:12px; bottom:12px; width:auto; }
}

@media (max-width:400px) { .brand .badge { display:none; } }

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

/* ---------- Instalación por USB (diálogo «Enrolar equipo» → «USB / ADB») ---------- */
.usb-intro { max-width:100ch; margin:0 0 14px; font-size:13.5px; line-height:1.55; }
.usb-grid { display:grid; grid-template-columns:minmax(0, 5fr) minmax(0, 6fr); gap:20px; align-items:start; }
.usb-col { display:grid; gap:16px; min-width:0; }
.usb-card { min-width:0; padding:16px 18px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.usb-card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; }
.usb-card-head h3 { margin:0; }
.usb-card p { margin:8px 0; }
.usb-tag { display:inline-flex; align-items:center; gap:6px; padding:2px 10px; border-radius:999px; font-size:12.5px; color:var(--muted); background:var(--sunken); white-space:nowrap; }
.usb-tag.ok { color:var(--live-ink); background:color-mix(in srgb, var(--live) 14%, transparent); }
.usb-tag.ok::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--live); }
.usb-tag.wait { color:var(--warn-ink); background:var(--warn-tint); }
.usb-known { list-style:none; margin:0; padding:0; display:grid; gap:6px; }
.usb-known li { display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--line); border-radius:var(--r-sm); background:var(--sunken); }
.usb-known-name { font-weight:500; color:var(--ink); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.usb-known li > :last-child { margin-left:auto; }
.usb-known li button { min-height:30px; }
.usb-device { margin-top:12px; padding-top:12px; border-top:1px solid var(--line); }
.usb-device > b { font-size:16px; }
.usb-device > .muted { margin:2px 0 8px; }
.usb-checks { list-style:none; margin:0; padding:0; display:grid; gap:4px; font-size:14px; }
.usb-checks li { position:relative; padding-left:22px; }
.usb-checks li::before { position:absolute; left:0; top:0; width:16px; text-align:center; font-weight:700; }
.usb-checks li.ok::before { content:"✓"; color:var(--live-ink); }
.usb-checks li.bad { color:var(--err); }
.usb-checks li.bad::before { content:"✗"; color:var(--err); }
.usb-checks li.neutral::before { content:"•"; color:var(--muted); }
.usb-field { display:grid; gap:6px; font-size:13.5px; font-weight:500; color:var(--ink); }
.usb-field input { width:100%; font-family:var(--mono); font-size:13.5px; }
.usb-msg { font-size:13px; margin:6px 0 0; }
.usb-msg:empty { display:none; }
.usb-msg.warn { color:var(--warn-ink); }
.usb-msg.error { color:var(--err); }
#usb-unsupported { margin:0 0 16px; padding:12px 14px; background:var(--err-tint); border-radius:var(--r-sm); }
.usb-steps { margin:8px 0; padding:0; list-style:none; counter-reset:step; display:grid; gap:2px; }
.usb-steps li { counter-increment:step; display:flex; align-items:center; gap:10px; padding:6px 8px; border-radius:var(--r-sm); font-size:14px; }
.usb-steps li::before { content:counter(step); flex:none; display:grid; place-items:center; width:22px; height:22px; border-radius:50%;
  font-size:12px; font-weight:600; color:var(--muted); background:var(--sunken); border:1px solid var(--line-strong); }
.step-tag { margin-left:auto; font-size:12.5px; color:var(--muted); }
.usb-steps li.step-run { background:var(--warn-tint); }
.usb-steps li.step-run::before { content:"…"; color:var(--warn-ink); border-color:var(--warn); }
.usb-steps li.step-run .step-tag { color:var(--warn-ink); }
.usb-steps li.step-ok::before, .usb-steps li.step-skip::before { content:"✓"; color:var(--on-brand); background:var(--brand); border-color:var(--brand); }
.usb-steps li.step-skip .step-tag { color:var(--muted); }
.usb-steps li.step-fail { background:var(--err-tint); color:var(--err); }
.usb-steps li.step-fail::before { content:"✗"; color:#fff; background:var(--err); border-color:var(--err); }
.usb-steps li.step-off { opacity:.5; }
button.usb-big { min-height:42px; padding:0 20px; font-size:15px; }
.usb-shortcuts { display:grid; grid-template-columns:repeat(auto-fill, minmax(180px, 1fr)); gap:8px; }
.usb-shortcuts button { justify-content:flex-start; white-space:normal; text-align:left; line-height:1.25; padding:8px 12px; }
.usb-term { position:sticky; top:72px; display:flex; flex-direction:column; min-height:0; } /* bajo la cabecera fija del diálogo */
/* Alto: lo que queda del diálogo bajo la cabecera, las pestañas y la intro, para que la terminal se vea entera al abrir. */
.usb-log { margin:0; height:calc(100vh - 470px); height:calc(100dvh - 470px); max-height:720px; min-height:260px; overflow:auto; padding:12px 14px;
  background:#0f1512; color:#d4ddd8; border-radius:var(--r-sm); font:12.5px/1.55 var(--mono); white-space:pre-wrap; word-break:break-word; }
.usb-log .l-cmd { color:#7fe3b8; font-weight:600; }
.usb-log .l-err { color:#ff8f8f; }
.usb-log .l-ok { color:#55e69d; }
.usb-log .l-warn { color:#f5b056; }
.usb-log .l-info { color:#93a39b; }
.usb-quick { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 8px; }
.usb-quick button { min-height:28px; padding:0 10px; font:12px var(--mono); }
.usb-term-form { display:flex; gap:8px; }
.usb-term-form input { flex:1; min-width:0; font-family:var(--mono); font-size:13.5px; }
#usb-panel.usb-busy { cursor:progress; }
.usb-manual { margin-top:16px; padding-top:12px; border-top:1px solid var(--line); }
.usb-manual summary { cursor:pointer; font-size:13.5px; color:var(--muted); }
.usb-manual summary:hover { color:var(--ink); }
@media (max-width: 980px) {
  .usb-grid { grid-template-columns:minmax(0, 1fr); }
  .usb-term { position:static; }
  .usb-log { height:50vh; }
}

/* ---------- Equipos: carpetas (grupos y subgrupos) a la izquierda, como un explorador de archivos ---------- */
.explorer { display:grid; grid-template-columns:260px minmax(0, 1fr); gap:28px; align-items:start; }
.explorer-main { min-width:0; }
.tree-pane { position:sticky; top:76px; display:flex; flex-direction:column; max-height:calc(100vh - 100px); padding:12px 8px 10px;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.tree-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:0 6px 10px; border-bottom:1px solid var(--line); margin-bottom:6px; }
.tree-head b { font-size:13px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
button.small { min-height:28px; padding:0 10px; font-size:12.5px; }
.tree { list-style:none; margin:0; padding:0; overflow:auto; flex:1; min-height:0; }
.tree ul { list-style:none; margin:0; padding:0; }
.tree-row { display:flex; align-items:center; gap:6px; min-height:34px; padding:0 8px 0 calc(4px + var(--lvl, 0) * 22px); border-radius:var(--r-sm);
  color:var(--fg); font-size:14px; cursor:pointer; user-select:none; outline-offset:-2px; }
.tree-row:hover { background:var(--hover); color:var(--ink); }
.tree-row.sel { background:var(--brand-tint); color:var(--brand); font-weight:600; }
.tree-row .twisty { flex:none; width:20px; min-height:20px; height:20px; padding:0; border:0; border-radius:4px; background:transparent; color:var(--muted); }
.tree-row .twisty svg { width:12px; height:12px; transition:transform .15s; }
.tree-row .twisty.open svg { transform:rotate(90deg); }
.tree-row .lock { width:14px; height:14px; color:var(--warn-ink); }
/* ＋ junto a cada grupo: crea un subgrupo. En las filas que no lo llevan queda un hueco del mismo ancho (los totales se alinean). */
.tree-row .add-sub { flex:none; width:24px; min-height:24px; height:24px; padding:0; border:0; border-radius:6px;
  background:transparent; color:var(--muted); font-size:15px; line-height:1; }
.tree-row .add-sub:hover { background:var(--brand-tint); color:var(--brand); }
.tree-row .add-sub:disabled { visibility:hidden; }
.tree-row .twisty:disabled { visibility:hidden; }
.tree-row .twisty:hover { color:var(--ink); background:transparent; }
.tree-label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tree-count { flex:none; min-width:22px; padding:0 6px; border-radius:999px; background:var(--sunken); color:var(--muted); font-size:12px; font-weight:500; text-align:center; }
.tree-row.sel .tree-count { background:var(--surface); color:var(--brand); }
.pill.mini { margin:0; padding:0 6px; font-size:10.5px; line-height:1.7; }
.tree-hint { margin:8px 6px 0; font-size:12px; }
.ico { display:inline-flex; flex:none; width:18px; height:18px; }
.ico svg { width:100%; height:100%; }
.dirty-dot { flex:none; width:8px; height:8px; border-radius:50%; background:var(--warn); }
/* Destino al arrastrar un equipo. */
.drop-over, .tree-row.drop-over { background:var(--brand-tint) !important; color:var(--brand) !important; box-shadow:inset 0 0 0 2px var(--brand); }

.folder-head { display:grid; gap:10px; margin-bottom:18px; padding-bottom:18px; border-bottom:1px solid var(--line); }
.crumbs { display:flex; flex-wrap:wrap; align-items:center; gap:4px 6px; font-size:13px; color:var(--muted); }
.crumbs .crumb { min-height:0; padding:2px 6px; border:0; background:transparent; color:var(--brand); font-size:13px; font-weight:500; }
.crumbs .crumb:hover { background:var(--brand-tint); }
.crumbs .here { color:var(--ink); font-weight:600; }
.folder-title { display:flex; flex-wrap:wrap; align-items:center; gap:8px 10px; color:var(--brand); }
.folder-title .ico { width:26px; height:26px; }
.folder-title h2 { margin:0; color:var(--ink); font-size:22px; }
.folder-title .pill { margin:0; }
.folder-desc { margin:0; }
.folder-row { display:grid; grid-template-columns:70px minmax(0, 1fr) auto; align-items:center; gap:6px 12px; }
.folder-row > b { font-size:13px; color:var(--muted); font-weight:600; }
.folder-row .chips { margin:0; }
.pill.profile.inherited { background:transparent; box-shadow:inset 0 0 0 1px var(--violet); }
.folder-actions { display:flex; flex-wrap:wrap; gap:8px; margin-left:auto; }
button.danger-text { color:var(--err); }
button.danger-text:hover { background:var(--err-tint); color:var(--err); }

.check-inline { display:inline-flex; align-items:center; gap:6px; font-size:13.5px; color:var(--fg); cursor:pointer; }

/* Ventanas de mover equipos y de asignar perfiles. */
.move-list, .assign-list { display:grid; gap:2px; max-height:min(52vh, 420px); overflow:auto; margin:8px 0; padding:6px; border:1px solid var(--line); border-radius:var(--r-sm); }
.move-list .dev-row, .assign-list .dev-row { padding:6px 8px; border-radius:var(--r-sm); }
.move-list .dev-row:hover, .assign-list .dev-row:hover { background:var(--hover); }
.assign-list .dev-row.inherited { opacity:.75; }
#move-search { width:100%; }
/* Perfiles → grupos y subgrupos como árbol. */
.assign-tree { display:flex; flex-direction:column; align-items:flex-start; gap:6px; max-height:360px; overflow:auto; margin-top:8px; }
.assign-tree .chip .ico { width:15px; height:15px; color:var(--muted); }
.assign-tree .chip.device { padding-top:3px; padding-bottom:3px; font-size:13px; }
.assign-tree .assign-section { margin-top:8px; font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
#profile-targets-search { width:100%; margin-top:6px; }
.pill.device { background:var(--sunken); color:var(--fg); }

@media (max-width:960px) {
  .explorer { grid-template-columns:1fr; gap:16px; }
  .tree-pane { position:static; max-height:280px; }
  .folder-row { grid-template-columns:1fr; }
}
/* En pantallas táctiles no se puede arrastrar: se mueve con «Agregar equipos…». */
@media (pointer: coarse) { .tree-hint { display:none; } }
