/* Componentes reutilizables. */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 650; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--brand); text-decoration: none; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--danger { color: var(--danger); border-color: #e3aaa5; }
.btn--danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { background: #0f4f31; border-color: #0f4f31; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--brand-tint); border-color: transparent; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 34px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---- Chips de estado (siempre con texto, nunca solo color) ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--off-bg); color: var(--off); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip--plain::before { display: none; }
.chip--ok { background: var(--ok-bg); color: var(--ok); }
.chip--warn { background: var(--warn-bg); color: var(--warn); }
.chip--danger { background: var(--danger-bg); color: var(--danger); }
.chip--info { background: var(--info-bg); color: var(--info); }
.chip--shared { background: #ece6fb; color: #4b2e9a; }
.chip--shared::before { display: none; }
.chip .icon { width: 13px; height: 13px; }

/* ---- Tarjetas y rejillas ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 16px 18px 0; }
.card__head p { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.card__body { padding: 16px 18px 18px; }
.card--flush .card__body { padding: 8px 0 0; }
.stack { display: grid; gap: 18px; }
.stack--sm { gap: 10px; }
.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); align-items: start; }
.grid--kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .grid--main { grid-template-columns: minmax(0, 1fr); } .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); } .grid { gap: 14px; } }

.kpi { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi__label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi__label .icon { width: 17px; height: 17px; }
.kpi__value { font-size: 2rem; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.kpi__hint { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.kpi--warn { border-color: #efcf84; background: #fffaf0; }
.kpi--danger { border-color: #e9b1ac; background: #fff7f6; }

/* ---- Cabecera de página y migas ---- */
.page-head { display: grid; gap: 8px; margin-bottom: 20px; }
.page-head__row { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-start; justify-content: space-between; }
.page-head__title { min-width: 0; }
.page-head__title p { color: var(--muted); margin-top: 4px; }
.page-head__eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; font-size: .86rem; color: var(--muted); }
.crumbs li { display: inline-flex; align-items: center; gap: 4px; }
.crumbs li:not(:last-child)::after { content: "›"; color: var(--line-strong); font-weight: 700; margin-left: 2px; }
.crumbs a { color: var(--ink-2); font-weight: 600; }
.crumbs [aria-current] { color: var(--muted); }
@media (max-width: 760px) {
  .crumbs li { display: none; }
  .crumbs li:nth-last-child(2) { display: inline-flex; }
  .crumbs li:nth-last-child(2)::after { display: none; }
  .crumbs li:nth-last-child(2) a::before { content: "‹ "; }
  .page-head__row .btn-row { width: 100%; }
}

/* ---- Listas de entidades ---- */
.rows { display: grid; }
.rows > li { border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 18px; color: inherit; text-decoration: none; min-height: 64px; }
a.item:hover { background: var(--surface-2); text-decoration: none; }
a.item:hover .item__title { color: var(--brand-dark); }
.item__icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--brand-tint); color: var(--brand-dark); }
.item__icon--warn { background: var(--warn-bg); color: var(--warn); }
.item__icon--danger { background: var(--danger-bg); color: var(--danger); }
.item__icon--ok { background: var(--ok-bg); color: var(--ok); }
.item__icon--off { background: var(--off-bg); color: var(--off); }
.item__icon .icon { width: 20px; height: 20px; }
.item__main { min-width: 0; flex: 1; }
.item__title { font-weight: 700; display: block; overflow-wrap: anywhere; }
.item__sub { display: block; color: var(--muted); font-size: .86rem; margin-top: 1px; overflow-wrap: anywhere; }
.item__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.item__go { color: var(--line-strong); flex: none; }
a.item:hover .item__go { color: var(--brand); }
@media (max-width: 640px) { .item { padding: 12px 14px; align-items: flex-start; } .item__meta { justify-content: flex-start; margin-top: 6px; } .item__go { display: none; } .item { flex-wrap: wrap; } .item__main { flex-basis: calc(100% - 60px); } .item__meta { margin-left: 54px; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 240px; }
.result-count { color: var(--muted); font-size: .86rem; margin-left: auto; }

/* ---- Pestañas ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px; border: 0; background: none; font-weight: 650; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab__count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--off-bg); color: var(--off); font-size: .75rem; display: grid; place-items: center; }
.tab[aria-selected="true"] .tab__count { background: var(--brand-tint); color: var(--brand-dark); }

/* ---- Ficha (campos de solo lectura) ---- */
.section + .section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.section__title { display: flex; align-items: center; gap: 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: var(--muted); margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 22px; }
.fld { min-width: 0; }
.fld--wide { grid-column: 1 / -1; }
.fld dt, .fld__label { font-size: .8rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fld dd, .fld__value { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.fld__value--empty { color: var(--muted); font-weight: 400; font-style: italic; }
.pending-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: .72rem; font-weight: 800; }
.pending-note { display: block; margin-top: 4px; font-size: .84rem; color: var(--warn); font-weight: 600; }
.lock-tag { color: var(--muted); display: inline-flex; }
.lock-tag .icon { width: 13px; height: 13px; }

/* ---- Formularios ---- */
.form { display: grid; gap: 16px; }
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form__grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form__grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 5px; align-content: start; }
.field > label, .field > .label { font-weight: 650; font-size: .88rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.req { color: var(--danger); font-weight: 800; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--brand); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 0; border-color: var(--brand); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); background: #fffafa; }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); }
.field__help { font-size: .82rem; color: var(--muted); }
.field__error { font-size: .84rem; color: var(--danger); font-weight: 650; display: flex; gap: 6px; align-items: flex-start; }
.input-unit { display: flex; }
.input-unit .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--muted); font-weight: 650; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 28px; font-weight: 550; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.check small { display: block; color: var(--muted); font-weight: 400; }
.field--scoped { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.checklist { display: grid; gap: 4px; max-height: 240px; overflow: auto; padding: 4px 2px; }
.checklist .check { padding: 6px 8px; border-radius: 7px; }
.checklist .check:hover { background: #fff; }

/* ---- Avisos ---- */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid; font-size: .92rem; }
.banner .icon { margin-top: 2px; width: 19px; height: 19px; }
.banner strong { display: block; }
.banner--info { background: var(--info-bg); border-color: #b3d9ec; color: #0b4560; }
.banner--warn { background: var(--warn-bg); border-color: #efcf84; color: #5e3700; }
.banner--danger { background: var(--danger-bg); border-color: #eeb1ac; color: #7d1812; }
.banner--ok { background: var(--ok-bg); border-color: #a9d9be; color: #0e4c2f; }
.banner--shared { background: #f0ebfc; border-color: #cfc2f0; color: #3b2380; }

.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty .icon { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--line-strong); }
.empty strong { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 4px; }

/* ---- Avatar ---- */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; font-size: .82rem; letter-spacing: .02em; }
.avatar--jr { background: var(--navy-2); }
.avatar--lg { width: 44px; height: 44px; font-size: 1rem; }

/* ---- Propuestas / diferencias ---- */
.prop { padding: 16px 18px; display: grid; gap: 12px; }
.prop__head { display: flex; gap: 12px; align-items: flex-start; }
.prop__head .check { margin-top: 2px; }
.diff { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; }
.diff__box { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; background: var(--surface-2); min-width: 0; }
.diff__box small { display: block; color: var(--muted); font-weight: 650; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.diff__box b { display: block; overflow-wrap: anywhere; }
.diff__box--new { border-color: #9fd2e9; background: var(--info-bg); }
.diff__arrow { display: grid; place-items: center; color: var(--muted); }
@media (max-width: 640px) { .diff { grid-template-columns: 1fr; } .diff__arrow { transform: rotate(90deg); height: 20px; } }
.prop__foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; color: var(--muted); font-size: .86rem; }
.selection-bar { position: sticky; bottom: 12px; z-index: 20; display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); margin-top: 14px; flex-wrap: wrap; }
.selection-bar .grow { flex: 1; font-weight: 650; }
@media (max-width: 760px) { .selection-bar { bottom: calc(var(--bottomnav-h) + 10px); } }

/* ---- Adjuntos ---- */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.attach { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.attach__thumb { aspect-ratio: 4 / 3; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; color: var(--muted); border: 0; width: 100%; padding: 0; }
.attach__thumb--doc { background: linear-gradient(160deg, #f4f8fb, #e3edf3); }
.attach__thumb--doc .icon { width: 38px; height: 38px; color: var(--brand); }
.attach__body { padding: 9px 11px 11px; display: grid; gap: 3px; }
.attach__name { font-weight: 650; font-size: .88rem; overflow-wrap: anywhere; }
.attach__meta { font-size: .78rem; color: var(--muted); }
.attach__foot { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.doc-row .item__icon { background: var(--info-bg); color: var(--info); }

.dropzone { display: grid; place-items: center; gap: 4px; text-align: center; padding: 22px 16px; border: 2px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-tint); }

/* ---- QR ---- */
.qr-card { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.qr-box { width: 220px; padding: 12px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; }
.qr-box svg { width: 100%; height: auto; }
.qr-url { overflow-wrap: anywhere; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 640px) { .qr-card { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* ---- Barra de estado apilada ---- */
.statusbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--off-bg); gap: 2px; }
.statusbar i { display: block; min-width: 4px; }
.statusbar .s-ok { background: #2f9e66; } .statusbar .s-warn { background: #e3a21a; } .statusbar .s-danger { background: #d9453c; } .statusbar .s-off { background: #8393a5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: .84rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---- Actividad ---- */
.timeline li { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline p { font-size: .92rem; }
.timeline time { color: var(--muted); font-size: .8rem; }
.timeline .avatar { width: 32px; height: 32px; font-size: .75rem; }

/* ---- Menú desplegable ---- */
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 150; min-width: 260px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu__head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu__head strong { display: block; }
.menu__head span { color: var(--muted); font-size: .84rem; }
.menu button, .menu a { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: none; text-align: left; color: var(--ink); font-weight: 600; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu .icon { color: var(--muted); }
.menu__label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 800; padding: 10px 12px 4px; }
.menu [aria-checked="true"] { background: var(--brand-tint); }
.menu [aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--brand-dark); font-weight: 800; }

/* ---- Modal / hoja inferior ---- */
.backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(11, 34, 52, .55); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.modal--wide { width: min(760px, 100%); }
.modal__head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal__head h2 { flex: 1; font-size: 1.2rem; }
.modal__body { padding: 4px 20px 18px; overflow-y: auto; }
.modal__foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .backdrop { place-items: end center; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92dvh; width: 100%; animation: sheet .2s ease-out; }
  .modal__foot { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal__foot .btn { flex: 1; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---- Búsqueda global ---- */
.palette { align-self: start; margin-top: 8vh; width: min(640px, 100%); }
.palette__input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette__input input { flex: 1; height: 56px; border: 0; background: none; font-size: 1.05rem; outline: none; min-width: 0; }
.palette__list { max-height: min(60vh, 460px); overflow-y: auto; padding: 8px; }
.palette__group { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: var(--muted); padding: 10px 10px 4px; }
.palette__opt { display: flex; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 9px; color: inherit; text-decoration: none; min-height: 52px; }
.palette__opt:hover, .palette__opt[aria-selected="true"] { background: var(--brand-tint); text-decoration: none; }
.palette__foot { padding: 9px 16px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
@media (max-width: 640px) { .palette { margin-top: 0; border-radius: 0 0 14px 14px; align-self: start; } .backdrop.is-search { place-items: start center; } }

/* ---- Aviso emergente ---- */
.toasts { position: fixed; z-index: 400; right: 18px; bottom: 18px; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--navy); color: #fff; padding: 12px 14px; border-radius: 11px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; font-weight: 550; }
.toast .icon { color: #7fe0b0; margin-top: 2px; }
.toast--warn .icon { color: #f3b13c; }
.toast--danger .icon { color: #ff9a92; }
@media (max-width: 760px) { .toasts { left: 12px; right: 12px; bottom: calc(var(--bottomnav-h) + 14px); max-width: none; } }

/* ---- Escáner ---- */
.scanner { position: relative; aspect-ratio: 1 / 1; max-width: 420px; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #08141e; display: grid; place-items: center; color: #b8cedc; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner__frame { position: absolute; inset: 14%; border: 3px solid var(--brand-light); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(8, 20, 30, .45); pointer-events: none; }
.scanner__hint { position: relative; padding: 18px; text-align: center; font-weight: 600; max-width: 280px; }

/* ---- Matriz de permisos ---- */
.matrix { width: 100%; border-collapse: collapse; font-size: .88rem; }
.matrix th, .matrix td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { font-size: .78rem; color: var(--muted); font-weight: 700; vertical-align: bottom; }
.matrix .yes { color: var(--ok); font-weight: 800; }
.matrix .no { color: var(--line-strong); }
.matrix .some { color: var(--warn); font-weight: 700; font-size: .8rem; }
.table-scroll { overflow-x: auto; }

/* ---- Configuración de campos ---- */
.fieldrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 18px; }
.fieldrow__order { display: grid; gap: 2px; }
.fieldrow__order .btn { min-height: 26px; width: 30px; }
.fieldrow__flags { display: flex; flex-wrap: wrap; gap: 5px; }
@media (max-width: 640px) { .fieldrow { grid-template-columns: auto minmax(0, 1fr); } .fieldrow > .btn-row { grid-column: 2 / 3; } }

/* ---- Inicio de sesión ---- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.login__side { background: var(--navy); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; background-image: radial-gradient(circle at 85% 10%, rgba(94, 179, 228, .22), transparent 45%); }
.login__side img { width: 110px; }
.login__side h1 { font-size: 2.1rem; max-width: 14ch; }
.login__side p { color: #a9c3d3; max-width: 36ch; margin-top: 12px; }
.login__main { padding: 48px 40px; display: grid; align-content: center; justify-items: center; }
.login__box { width: min(520px, 100%); display: grid; gap: 16px; }
.profile-btn { display: flex; gap: 14px; align-items: center; width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff; text-align: left; }
.profile-btn:hover { border-color: var(--brand); background: var(--brand-tint); }
.profile-btn strong { display: block; }
.profile-btn span span { display: block; color: var(--muted); font-size: .86rem; }
@media (max-width: 900px) { .login { grid-template-columns: minmax(0, 1fr); } .login__side { padding: 28px 22px; gap: 18px; } .login__side img { width: 76px; } .login__side h1 { font-size: 1.5rem; } .login__main { padding: 26px 18px 40px; } }

.divider { height: 1px; background: var(--line); margin: 6px 0; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.hl { background: #fff2b8; border-radius: 3px; }
@media print { .sidebar, .topbar, .bottomnav, .btn-row, .toasts { display: none !important; } .app { display: block; } }

/* ---- Ajustes finales ---- */
.topbar .topbar__menu { display: none; }
a.item__link { color: inherit; text-decoration: none; }
a.item__link:hover { text-decoration: none; }
a.item__link:hover .item__title { color: var(--brand-dark); }
summary.card__head::-webkit-details-marker { display: none; }
details[open] > summary .icon { transform: rotate(180deg); }
.btn-row .btn[aria-current="true"] { box-shadow: 0 0 0 2px var(--brand-light); }
@media (max-width: 1000px) { .topbar .topbar__menu { display: inline-flex; } }
@media (max-width: 760px) { .hide-mobile { display: none !important; } }
@media print {
  body.printing-label > *:not(.backdrop) { display: none !important; }
  body.printing-label .backdrop { position: static; background: none; padding: 0; display: block; }
  body.printing-label .modal { box-shadow: none; max-height: none; width: auto; }
  body.printing-label .modal__head, body.printing-label .modal__foot { display: none; }
}
.grid--cfg { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid--cfg { grid-template-columns: minmax(0, 1fr); } }
h1[tabindex="-1"]:focus, main:focus { outline: none; }

/* ---- Árbol de activos ---- */
.tree { padding: 8px 6px 10px; }
.tree ul { margin: 0; padding: 0; list-style: none; }
.tree ul.tree__children { margin-left: 21px; padding-left: 12px; border-left: 2px solid var(--line); }
.tree__item { position: relative; }
.tree__row { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 4px; border-radius: 9px; min-height: 48px; }
.tree__row:hover { background: var(--surface-2); }
.tree__toggle { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 0; background: none; border-radius: 7px; color: var(--muted); padding: 0; }
button.tree__toggle:hover { background: var(--brand-tint); color: var(--brand-dark); }
.tree__toggle .icon { transition: transform .15s; }
.tree__toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.tree__icon { width: 34px; height: 34px; border-radius: 9px; }
.tree__icon .icon { width: 18px; height: 18px; }
.tree__text { min-width: 0; flex: 1; display: grid; }
.tree__link { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
a.tree__link:hover { color: var(--brand-dark); }
.tree__sub { font-size: .84rem; color: var(--muted); overflow-wrap: anywhere; }
.tree__meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tree__item--empresa > .tree__row .tree__link { font-size: 1.04rem; }
.tree__item--empresa > .tree__row { background: var(--surface-2); }
.tree__item--equipo > .tree__row { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
.tree__item--equipo > .tree__row .tree__link { font-weight: 600; }
.tree__item--equipo.is-linked > .tree__row { background: #efe9fd; box-shadow: inset 3px 0 0 #6a45c9; }
@media (max-width: 760px) {
  .tree ul.tree__children { margin-left: 13px; padding-left: 6px; }
  .tree__row { flex-wrap: wrap; gap: 6px 8px; }
  .tree__meta { justify-content: flex-start; flex-basis: 100%; padding-left: 38px; }
}

@media (max-width: 760px) {
  .page-head .btn-row[role="group"] { width: 100%; flex-wrap: nowrap; gap: 6px; }
  .page-head .btn-row[role="group"] .btn { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: .84rem; }
  .page-head .btn-row[role="group"] .btn .icon { display: none; }
}

/* ---- Etiquetas QR: hoja imprimible y registro en campo ---- */
.print-sheet { display: grid; grid-template-columns: repeat(auto-fill, var(--mm)); gap: 0; justify-content: start; }
.etq { width: var(--mm); padding: calc(var(--mm) * .05); border: .25mm dashed #8a99a6; text-align: center; break-inside: avoid; background: #fff; color: #000; display: grid; gap: calc(var(--mm) * .02); align-content: start; }
.etq svg { width: 100%; height: auto; }
.etq__code { font: 700 calc(var(--mm) * .082) ui-monospace, Consolas, monospace; letter-spacing: .02em; line-height: 1.1; }
.etq__tit { font: 600 calc(var(--mm) * .058) var(--font); line-height: 1.15; overflow-wrap: anywhere; }
.etq-preview { padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow: auto; }
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body.printing-labels > *:not(.print-only) { display: none !important; }
  body.printing-labels .print-only { display: grid !important; }
  body.printing-labels { background: #fff; }
}
.reg { max-width: 640px; margin: 0 auto; }
.reg__code { display: flex; gap: 16px; align-items: center; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.reg__codetext { font-size: 1.7rem; font-weight: 800; letter-spacing: .04em; }
.reg-btn { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px; text-align: left; background: #fff; border: 2px solid var(--line-strong); border-radius: 14px; }
.reg-btn:hover { border-color: var(--brand); background: var(--brand-tint); }
.reg-btn strong { display: block; font-size: 1.05rem; }
.reg-btn small { display: block; color: var(--muted); font-size: .86rem; }
.reg-btn > span:nth-child(2) { flex: 1; }

.qr-box { max-width: 100%; }
.reg__code .qr-box { padding: 6px; border-radius: 10px; }
.reg__code > div:last-child { min-width: 0; }

/* Mapa de clientes */
.mapa { height: min(68vh, 620px); min-height: 320px; border-radius: 12px; overflow: hidden; background: var(--off-bg); }
.mapa__globo { display: grid; gap: 3px; min-width: 170px; }
.mapa__globo span { color: var(--muted); font-size: .86rem; }
.mapa__enlaces { display: flex; gap: 14px; margin-top: 4px; }
.mapa__ayuda { font-style: italic; }
.mapa--situar.leaflet-grab, .mapa--situar.leaflet-grab.leaflet-dragging { cursor: crosshair; }

/* Estado de sincronización con el servidor (barra superior) */
.sync-estado { display: inline-flex; flex: none; }
@media (max-width: 700px) { .sync-estado .chip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; } }
