/* Control de Activos — hoja de estilos */

:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --sunken: #efefea;
  --line: #e4e4df;
  --line-2: #d3d3cc;
  --text: #1b1c1a;
  --muted: #6b6d68;
  --accent: #af272f;
  --accent-hover: #8e1f26;
  --accent-soft: #f9e8e9;
  --accent-text: #af272f;
  --ink: #1b1c1a;
  --ok: #1d7a4b;
  --warn: #9a5b06;
  --warn-soft: #fbf2df;
  --warn-line: #ecd3a3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 8px;
  --radius-sm: 6px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sidebar: 232px;
  color-scheme: light;
}

/* Modo oscuro: automático según el dispositivo, o forzado con el botón (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121412;
    --surface: #1a1c1a;
    --sunken: #222522;
    --line: #2b2e2b;
    --line-2: #3a3e3a;
    --text: #e8e9e5;
    --muted: #9b9e98;
    --accent: #c2353e;
    --accent-hover: #d4454e;
    --accent-soft: #3a1a1c;
    --accent-text: #f2a5aa;
    --ink: #e8e9e5;
    --ok: #5cbf8a;
    --warn: #e0a84a;
    --warn-soft: #2d2517;
    --warn-line: #54431f;
    --danger: #f07167;
    --danger-soft: #2e1a18;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121412;
  --surface: #1a1c1a;
  --sunken: #222522;
  --line: #2b2e2b;
  --line-2: #3a3e3a;
  --text: #e8e9e5;
  --muted: #9b9e98;
  --accent: #c2353e;
  --accent-hover: #d4454e;
  --accent-soft: #3a1a1c;
  --accent-text: #f2a5aa;
  --ink: #e8e9e5;
  --ok: #5cbf8a;
  --warn: #e0a84a;
  --warn-soft: #2d2517;
  --warn-line: #54431f;
  --danger: #f07167;
  --danger-soft: #2e1a18;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14.5px/1.5 var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h2.mini { font-size: 14px; margin: 28px 0 10px; }
code { font-family: var(--mono); font-size: .86em; font-weight: 500; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pre { white-space: pre-line; }
.i { width: 18px; height: 18px; flex-shrink: 0; }
.mark { width: 26px; height: 26px; color: var(--accent); flex-shrink: 0; }
[hidden] { display: none !important; }

/* ---------- Estructura ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 15px; padding: 2px 8px 18px; }
.brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--muted); font: 500 14px var(--sans); background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link:hover { background: var(--sunken); color: var(--text); text-decoration: none; }
.nav-link.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.me form { margin: 0; }

.app main { margin-left: var(--sidebar); max-width: calc(1120px + var(--sidebar)); padding: 28px 36px 48px; }
.mobilebar, .tabbar { display: none; }
.bare main { max-width: 420px; margin: 0 auto; padding: 16px; }

/* ---------- Encabezados ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.eyebrow { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 6px; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.section-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.count-pill { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--sunken); border-radius: 4px; padding: 1px 7px; }
.crumb { margin: 0 0 14px; font-size: 13.5px; }
.crumb a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.crumb .i { width: 16px; height: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ---------- Superficies ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.narrow { max-width: 440px; }

.flash, .error {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px;
}
.flash { background: var(--accent-soft); color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.flash .i { margin-top: 2px; }
.error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font: 500 14px var(--sans); cursor: pointer; white-space: nowrap;
}
.btn .i { width: 17px; height: 17px; }
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.qr { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.qr:hover { opacity: .9; }
.btn.ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); background: transparent; border-color: transparent; padding: 0 6px; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn .n { font-size: 12px; font-weight: 600; background: rgba(127, 127, 127, .22); border-radius: 4px; padding: 0 6px; line-height: 18px; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px;
  font: 400 14.5px var(--sans); color: var(--text); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 11px; min-height: 38px;
}
textarea { resize: vertical; }
/* Captura en mayúsculas (el servidor también las guarda así). Correo, usuario y contraseñas se respetan. */
.app main input:not([type=email]):not([type=password]):not([type=date]):not([type=file]):not([name=username]):not([name=current]),
.app main textarea { text-transform: uppercase; }
.app main .keep-case input, .app main .keep-case textarea, .app main input::placeholder, .app main textarea::placeholder { text-transform: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); margin: 0; font-weight: 400; font-size: 14px; }
label.check input { width: 16px; min-height: 0; height: 16px; margin: 0; accent-color: var(--accent); }

.form { padding: 0; }
.form fieldset { border: 0; margin: 0; padding: 18px 20px 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; border-bottom: 1px solid var(--line); }
.form fieldset:last-of-type { border-bottom: 0; }
.form legend { float: left; width: 100%; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 14px; padding: 0; }
.form legend small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 4px; }
.form .full { grid-column: 1 / -1; }
.form > .actions { justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--sunken); border-radius: 0 0 var(--radius) var(--radius); }
.card.form.narrow, form.form.narrow { padding: 18px 20px; }
.form.narrow > .btn, .card .form > .btn { margin-top: 4px; }
.card .form { padding: 0; }
.card .form fieldset, .card .form label { padding-left: 0; padding-right: 0; }

.photo-input {
  grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 22px 16px; text-align: center; cursor: pointer; background: var(--bg);
}
.photo-input:hover { border-color: var(--accent); }
.photo-input .i { width: 24px; height: 24px; color: var(--accent-text); }
.photo-input span { font-weight: 600; color: var(--text); font-size: 14px; }
.photo-input input { display: none; }
.gallery { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-bottom: 12px; }
.gallery:empty { display: none; }
.ph { position: relative; margin: 0; }
.ph img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); display: block; border: 1px solid var(--line); }
.ph span { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.ph span input { width: 14px; height: 14px; min-height: 0; margin: 0; accent-color: var(--danger); }
.ph.new span { color: var(--accent-text); font-weight: 600; }

/* ---------- Inicio ---------- */
.stats {
  display: flex; flex-wrap: wrap; gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.stat { flex: 1 1 140px; background: var(--surface); padding: 14px 18px 16px; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
a.stat:hover { background: var(--bg); text-decoration: none; }
.stat b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.warn b { color: var(--warn); }
.bar { display: grid; grid-template-columns: minmax(150px, 2fr) 1fr 44px; gap: 12px; align-items: center; color: var(--text); padding: 6px 0; font-size: 14px; }
.bar:hover { text-decoration: none; }
.bar span { line-height: 1.3; }
@media (max-width: 640px) {
  /* En el celular el nombre va arriba completo y la barra abajo. */
  .bar { grid-template-columns: 1fr 44px; row-gap: 4px; padding: 8px 0; }
  .bar span { grid-column: 1 / -1; font-size: 13px; }
}
.bar i { display: block; height: 8px; border-radius: 2px; background: var(--accent); min-width: 3px; }
.bar b { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:first-child { padding-top: 0; }
.timeline li:last-child { border-bottom: 0; padding-bottom: 0; }
.timeline small { display: block; margin-top: 1px; }
.timeline .pre { margin-top: 4px; }
.tag { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 6px; }
.tag.alta { color: var(--accent-text); }
.tag.verificacion { color: var(--ok); }
.tag.reasignacion, .tag.baja { color: var(--warn); }
.tag.qr { color: var(--ink); }
.tag.qr_eliminado { color: var(--muted); }

/* ---------- Estado y marcas ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status.reparacion::before { background: var(--warn); }
.status.baja { color: var(--muted); }
.status.baja::before { background: var(--line-2); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 12px; font-weight: 500; padding: 0 7px; line-height: 20px; border-radius: 4px;
  border: 1px solid var(--line-2); color: var(--muted);
}
.badge .i { width: 13px; height: 13px; }
.badge.qr-ok { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge.qr-pending { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }

/* ---------- Listas ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; }
.filters input, .filters select { margin: 0; flex: 1 1 170px; width: auto; }
.filters input[type=search] { flex: 3 1 240px; }
.filters label.check { flex: 0 0 auto; white-space: nowrap; }
.filters label.check input { flex: none; }
.find { margin: 0 0 12px; }

.table-wrap { padding: 0; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--bg); }
.list td code { color: var(--text); }
.list .badge { margin-left: 4px; }
tr.inactive td { opacity: .5; }
.thumb { width: 52px; padding-right: 0 !important; }
.thumb img { width: 38px; height: 38px; object-fit: cover; border-radius: 5px; display: block; }

.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.rows > * { border-bottom: 1px solid var(--line); }
.rows > *:last-child { border-bottom: 0; }
.person, .asset-card, .row-link { display: flex; align-items: center; gap: 14px; padding: 12px 16px; color: var(--text); }
.person:hover, .asset-card:hover, .row-link:hover { background: var(--bg); text-decoration: none; }
.inactive { opacity: .55; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 600; font-size: 13px; letter-spacing: .02em;
}
.avatar.big { width: 56px; height: 56px; font-size: 19px; }
img.avatar { object-fit: cover; padding: 0; }
.avatar-add { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--accent-text); }
.avatar-add:hover { text-decoration: none; }
.avatar-add .cam { position: absolute; top: 36px; left: 36px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; border: 2px solid var(--bg); }
.avatar-add .cam .i { width: 14px; height: 14px; }
.avatar-add small { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.emp-photo img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.lease-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
@media (max-width: 900px) { .lease-fields { grid-template-columns: 1fr; } }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.who b { font-weight: 600; }
.who small, .who p { overflow: hidden; text-overflow: ellipsis; }
.count { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.count b { color: var(--text); font-weight: 600; }

.profile { display: flex; align-items: center; gap: 16px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.profile .who p { margin: 2px 0 0; color: var(--muted); }
.profile h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.asset-card img, .asset-card .nophoto { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.asset-card > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
/* La caja de "sin foto" es una miniatura cuadrada, no la columna de texto. */
.asset-card > div.nophoto { display: grid; place-items: center; flex: 0 0 56px; width: 56px; height: 56px; gap: 0; }
.asset-card b { font-weight: 600; }
.asset-card .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 2px; }
.asset-card code { color: var(--muted); font-size: 12.5px; }
.nophoto { display: grid; place-items: center; background: var(--sunken); color: var(--muted); }
.nophoto .i { width: 20px; height: 20px; }
.nophoto.big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 0; height: auto; padding: 18px 12px;
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; text-align: center; }
.nophoto.big .btn { margin-top: 2px; }
.nophoto.big .i { width: 26px; height: 26px; }

.row-link { width: 100%; background: none; border: 0; font: 500 14.5px var(--sans); cursor: pointer; text-align: left; }
.row-link .i { color: var(--muted); }
.account-links form { margin: 0; }

/* ---------- Botón de tema ---------- */
.theme-toggle { display: flex; align-items: center; gap: 10px; }
.theme-toggle .moon { display: none !important; }
:root[data-theme="dark"] .theme-toggle .sun { display: none !important; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline-flex !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none !important; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline-flex !important; }
}
.mobilebar .theme-toggle { margin-left: auto; width: 40px; height: 40px; justify-content: center; border: 0; background: none; color: var(--text); border-radius: var(--radius-sm); cursor: pointer; }
.mobilebar .theme-toggle:hover { background: var(--sunken); }
.mobilebar .theme-toggle .t { display: none; }
.theme-toggle .sun, .theme-toggle .moon { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Foto ampliada ---------- */
.zoom { cursor: zoom-in; display: block; }
.avatar-zoom { border-radius: 50%; flex-shrink: 0; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 92vh; overflow: visible; }
.lightbox::backdrop { background: rgba(10, 10, 10, .85); }
.lightbox img { display: block; max-width: 96vw; max-height: 88vh; border-radius: 10px; object-fit: contain; cursor: zoom-out; }
.lb-close { position: fixed; top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 20px; cursor: pointer; }

/* ---------- Zona de eliminación ---------- */
.danger-zone { margin-top: 16px; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; font-size: 14px; list-style: none; }
.danger-zone summary::-webkit-details-marker { display: none; }
.danger-zone[open] summary { margin-bottom: 10px; }
.danger-zone form { display: flex; flex-direction: column; gap: 4px; max-width: 520px; }
.danger-zone .fine { margin: 0 0 10px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; align-self: flex-start; }
.btn.danger-solid:hover { opacity: .9; }

/* ---------- Formatos ---------- */
.formats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.reasons { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lbl { font-size: 13px; font-weight: 500; color: var(--muted); }
.sign-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.sign-box canvas { width: 100%; height: 180px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: #fff; touch-action: none; }
.signer-photo img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius-sm); }
.doc.official header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; text-align: left; }
.doc.official header .org { text-transform: uppercase; font-size: 11pt; }
.doc.official header .area { margin: 2px 0; color: #444; }
.doc.official header h1 { font-size: 13pt; margin-top: 6px; }
.doc .folio { width: auto; margin: 0; }
.doc .folio th { background: #f1f1ee; }
.doc .kv th { width: 26%; text-transform: uppercase; font-size: 9pt; }
.doc .grid { font-size: 9pt; }
.doc .grid .cap { text-align: center; letter-spacing: .08em; }
.doc .grid .mono { font-family: var(--mono); font-size: 8.5pt; }
.reasons-print { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 4px 0 10px; font-size: 9.5pt; }
.reasons-print b { width: 100%; }
.doc .notes { margin: 6px 0; }
.signs.three { grid-template-columns: repeat(3, 1fr); gap: 28px; align-items: end; }
.sign { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.sign .role { text-transform: uppercase; letter-spacing: .06em; color: #444; font-weight: 600; }
.sign .sig { height: 70px; display: flex; align-items: flex-end; justify-content: center; }
.sign .sig img { max-height: 70px; max-width: 100%; }
.sign .line { display: block; width: 100%; border-top: 1px solid #000; margin: 2px 0 4px; }
.evidence { display: flex; gap: 12px; align-items: center; margin-top: 24px; border-top: 1px dashed #bbb; padding-top: 10px; }
.evidence img { width: 26mm; height: 26mm; object-fit: cover; border-radius: 2mm; }
.evidence small { color: #555; font-size: 8pt; }
@media (max-width: 700px) { .signs.three { grid-template-columns: 1fr; } .doc.official header { flex-direction: column; } }

/* Selección de bienes en formatos */
.empty-note { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; font-size: 14px; }
.doc.general .grid td.none { padding: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.doc .none-note { font-size: 9pt; }
.pick-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pick-bar #sel-count { margin-right: auto; }
.asset-pick { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 0; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--text); font-weight: 400; font-size: 14px; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--bg); }
.pick-row:has(input:checked) { background: var(--accent-soft); }
.pick-row input { width: 20px; height: 20px; min-height: 0; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.pick-row img, .pick-row .nophoto { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.pick-row .info { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Formatos institucionales (impresión carta) ---------- */
.doc.inst { max-width: 216mm; padding: 14mm 14mm 10mm; background: #fff; font-size: 9.5pt; color: #111; }
.inst-logos { display: flex; align-items: center; gap: 10px; }
.inst-logos i { width: 1.5px; height: 38px; background: #b38e5d; display: block; }
.inst-logos .lg-marina { height: 44px; }
.inst-logos .lg-sello { height: 40px; }
.inst-pie { margin-top: 18mm; }
.inst-pie img { width: 100%; display: block; }
.doc table.print-wrap, .doc table.print-wrap > * > tr > td { border: 0; padding: 0; margin: 0; }
.print-wrap .pie-space { display: none; }
.doc .signs.one { grid-template-columns: minmax(0, 1fr); max-width: 60%; margin: 16mm auto 0; }
.doc .signs.two { grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 14mm; }
.doc .signs.three { grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 18mm; align-items: start; }
.doc .signs.two { align-items: start; }
.doc .sign b { text-transform: uppercase; font-size: 9pt; }
.doc .sign small { text-transform: uppercase; font-size: 8pt; }

/* Carta (entrega de material) */
.carta-membrete { display: flex; justify-content: space-between; align-items: center; }
.carta-membrete .lg-figura { height: 26mm; }
.carta-org { text-align: right; margin-top: 8mm; font-weight: 700; font-size: 10pt; }
.carta-org p { margin: 0 0 1mm; }
.carta-org .carta-fecha { margin-top: 5mm; }
.carta-org .folio-mini { font-weight: 400; font-size: 8pt; color: #555; margin-top: 2mm; }
.doc .carta-title { text-align: center; font-size: 11pt; margin: 9mm 0 5mm; letter-spacing: .02em; text-transform: uppercase; }
.carta-text { font-size: 10pt; text-align: justify; line-height: 1.5; margin-bottom: 9mm; }
.carta-table { width: 82%; margin: 0 auto 6mm; border-collapse: collapse; }
.doc .carta-table th, .doc .carta-table td { border: 1px solid #333; padding: 7px 8px; text-align: center; font-size: 9.5pt; vertical-align: middle; }
.doc .carta-table th { background: #af272f; color: #fff; text-transform: uppercase; font-size: 9pt; }
.doc .carta-table td.desc { text-align: left; }
.carta .signs .role { font-size: 9pt; color: #111; }

/* General (resguardo de bienes muebles general, baja y traspaso) */
.gen-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 3px solid #af272f; padding-bottom: 8px; margin-bottom: 8px; }
.gen-head h1 { font-size: 12pt; text-transform: uppercase; margin: 0; text-align: right; color: #111; }
.doc .gen-kv { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.doc .gen-kv th, .doc .gen-kv td { border: 1px solid #999; padding: 3px 7px; font-size: 8.5pt; text-align: left; }
.doc .gen-kv th { width: 27%; background: #f7e3e4; text-transform: uppercase; font-weight: 700; }
.doc .gen-kv td.fecha { width: 22%; text-align: center; padding: 0; }
.doc .gen-kv td.fecha b, .doc .gen-kv td.fecha span { display: block; padding: 2px; }
.doc .gen-kv td.fecha b { background: #af272f; color: #fff; text-transform: uppercase; font-size: 8pt; }
.doc.general .grid { font-size: 7.5pt; }
.doc.general .grid th { background: #af272f; color: #fff; text-transform: uppercase; font-size: 7.5pt; text-align: center; }
.doc.general .grid th.cap { background: #7d1c22; letter-spacing: .08em; }
.doc.general .grid td { text-align: center; vertical-align: middle; padding: 6px 5px; }
.doc.general .grid td:nth-child(4) { text-align: center; }
.reasons-print span.on { font-weight: 700; }
.doc.general .legal { font-size: 7.5pt; border: 1px solid #999; padding: 5px 7px; margin: 8px 0 0; }
.gen-signs { border: 1px solid #999; border-top: 0; padding: 4mm 6mm 6mm; }
.gen-signs .signs.two { margin-top: 10mm; }
.gen-signs .signs.one { margin-top: 10mm; }
.doc-page .evidence { max-width: 216mm; margin: 0 auto 20px; display: flex; gap: 12px; align-items: center; padding: 10px 14mm; border-top: 1px dashed #bbb; }
.doc-page .evidence img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.doc-page .evidence small { color: #555; }
@media print {
  @page { size: letter; margin: 10mm; }
  .doc.inst { padding: 0; max-width: none; }
  .inst-pie { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; }
  .print-wrap tfoot { display: table-footer-group; }
  .print-wrap .pie-space { display: block; height: 24mm; }
  .gen-signs { padding: 2mm 6mm 3mm; break-inside: avoid; }
  .gen-signs .signs.two { margin-top: 3mm; }
  .gen-signs .signs.one { margin-top: 4mm; }
  .doc.inst .sign .sig { height: 52px; }
  .doc.inst .sign .sig img { max-height: 52px; }
  .inst-pie img { height: 20mm; width: auto; max-width: 100%; }
  .doc.general .grid thead { display: table-header-group; }
  .doc.general .grid tr, .doc .signs { break-inside: avoid; }
  .carta-table th, .doc.general .grid th, .doc .gen-kv th, .doc .gen-kv td.fecha b, .gen-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Usuarios y roles ---------- */
.role-consulta .w { display: none !important; }
.user-row { padding: 12px 16px; }
.user-main { display: flex; align-items: center; gap: 12px; }
.user-main form { margin: 0; }
.user-admin { margin: 10px 0 0 48px; }
.user-admin summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--accent-text); list-style: none; }
.user-admin summary::-webkit-details-marker { display: none; }
.user-admin summary .i { width: 15px; height: 15px; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; }
.inline-form label { flex: 1; margin: 0; }
.inline-form .btn { height: 38px; }
.user-admin .fine { margin: 8px 0 0; }
.roles-help { margin: 18px 0 0; font-size: 13px; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
.roles-help dt { font-weight: 600; }
.roles-help dd { margin: 0; color: var(--muted); }
@media (max-width: 900px) { .user-admin { margin-left: 0; } .inline-form { flex-direction: column; align-items: stretch; } }

/* ---------- Duplicados y asignación ---------- */
.error.dup { flex-direction: column; align-items: stretch; gap: 12px; color: var(--text); }
.error.dup a { color: var(--danger); font-weight: 600; }
.error.dup .actions { gap: 8px; }
.assign .current { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.assign .current p { margin: 0; }
.assign details summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--accent-text); list-style: none; }
.assign details summary::-webkit-details-marker { display: none; }
.assign details[open] summary { margin-bottom: 12px; }
.assign-form label { margin-bottom: 10px; }
.assign-form .fine { margin: 10px 0 0; }
.checklist { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.checklist label.check, label.check.deactivate { align-items: flex-start; }
.checklist label.check input, label.check.deactivate input { margin-top: 3px; }
.deactivate { padding: 12px; border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid var(--warn-line); margin-bottom: 14px !important; }

/* ---------- Ficha del bien ---------- */
.photo { width: 100%; max-height: 380px; object-fit: cover; border-radius: var(--radius-sm); display: block; margin-bottom: 10px; }
.photos .strip { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px; }
.photos .strip img { width: 64px; height: 64px; object-fit: cover; border-radius: 5px; display: block; border: 1px solid var(--line); }
.photos > a:only-child .photo { margin-bottom: 18px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 9px 20px; margin: 0; font-size: 14px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.details dt.group { grid-column: 1 / -1; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.details dd.group { display: none; }
.form .fine { margin: 0 0 14px; }
.qr-box { display: flex; gap: 18px; align-items: center; }
.qr-box > div:last-child { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.qr-box > div:last-child > div, .qr-box .btn { margin-right: 4px; }
.qr-box p { word-break: break-all; margin: 0 0 4px; }
.qr-img { width: 132px; flex-shrink: 0; background: #fff; padding: 6px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.qr-img svg { display: block; width: 100%; height: auto; }
.qr-empty p { margin: 0; font-size: 14px; }
.verify form { display: flex; flex-direction: column; gap: 8px; }
.verify input { margin: 0; }
.verify .btn.block { margin: 0; }
.public { max-width: 520px; margin: 24px auto; }
.public .login-brand { margin-bottom: 18px; }
.public h1 { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 14px; }
.public h2 { font-size: 17px; }
.scan #reader { max-width: 480px; margin: 0 auto; border-radius: var(--radius-sm); overflow: hidden; }

/* ---------- Acceso ---------- */
.login { max-width: 360px; margin: 14vh auto 0; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; margin-bottom: 40px; }
.login-brand.small { margin-bottom: 16px; }
.login h1 { margin-bottom: 22px; }
.login .btn.block { height: 40px; margin-top: 4px; }
.fine { color: var(--muted); font-size: 13px; margin-top: 22px; }

/* ---------- Etiquetas imprimibles ---------- */
.labels-page, .doc-page { background: #fff; color: #000; color-scheme: light; }
.labels-page .toolbar, .doc-page .toolbar { padding: 12px 20px; border-bottom: 1px solid #ddd; margin: 0; font-size: 14px; }
.labels-page .btn, .doc-page .btn { --surface: #fff; --text: #1b1c1a; --accent: #af272f; --accent-hover: #8e1f26; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, 90mm); gap: 4mm; padding: 8mm; }
.label { width: 90mm; height: 40mm; border: 1px dashed #aaa; border-radius: 2mm; padding: 3mm; display: flex; gap: 3.5mm; align-items: center; break-inside: avoid; color: #000; }
.label .qr { width: 34mm; height: 34mm; flex-shrink: 0; }
.label .qr svg { width: 100%; height: 100%; }
.label .txt { display: flex; flex-direction: column; overflow: hidden; gap: .6mm; }
.label .txt b { font: 600 14.5pt var(--mono); letter-spacing: -.01em; }
.label .txt span { font-size: 8.5pt; max-height: 3.6em; overflow: hidden; line-height: 1.25; }
.label .txt small { font-size: 6.5pt; color: #444; letter-spacing: .12em; text-transform: uppercase; }
@media print {
  .no-print { display: none !important; }
  .labels { padding: 0; }
  .label { border-color: #ccc; }
  @page { margin: 10mm; }
}

/* ---------- Resguardo imprimible ---------- */
.doc { max-width: 900px; margin: 0 auto; padding: 28px 24px; font-size: 10.5pt; }
.doc header { text-align: center; margin-bottom: 18px; }
.doc header h1 { font-size: 15pt; margin: 4px 0; text-transform: uppercase; letter-spacing: .08em; }
.doc header p { margin: 4px 0; }
.doc .org { font-weight: 700; }
.doc table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.doc th, .doc td { border: 1px solid #999; padding: 5px 7px; text-align: left; vertical-align: top; }
.doc .kv th { background: #f1f1ee; width: 16%; font-weight: 600; }
.doc .grid th { background: #af272f; color: #fff; font-weight: 600; }
.doc .grid td:nth-child(2) { font-family: var(--mono); font-size: 9pt; white-space: nowrap; }
.legal { text-align: justify; margin: 18px 0 72px; line-height: 1.55; }
.signs { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; text-align: center; }
.signs span { display: block; border-top: 1px solid #000; margin-bottom: 4px; }
.signs small { display: block; color: #444; }
@media print { .doc { padding: 0; } .doc .grid th, .doc .kv th { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- Teléfono ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobilebar {
    display: flex; align-items: center; position: sticky; top: 0; z-index: 10;
    height: 52px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .mobilebar .brand { padding: 0; font-size: 15px; }
  .mobilebar .mark { width: 24px; height: 24px; }
  .app main { margin: 0; padding: 18px 16px calc(88px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; inset: auto 0 0 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px 4px env(safe-area-inset-bottom);
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 6px; font-size: 11px; font-weight: 500; color: var(--muted); }
  .tab .i { width: 22px; height: 22px; }
  .tab:hover { text-decoration: none; }
  .tab.on { color: var(--accent-text); }

  h1 { font-size: 20px; }
  .page-head { flex-direction: column; align-items: stretch; margin-bottom: 18px; }
  .actions .btn, .actions form { flex: 1 1 auto; }
  .actions form .btn { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .form fieldset { grid-template-columns: 1fr; padding: 16px 16px 4px; }
  .form > .actions { padding: 12px 16px; }
  .profile { flex-wrap: wrap; }
  .profile .btn { margin-left: auto; }
  .count .badge { display: none; }

  .list thead { display: none; }
  .list tbody tr { display: grid; grid-template-columns: auto 1fr; padding: 10px 6px; border-bottom: 1px solid var(--line); }
  .list tbody tr:last-child { border-bottom: 0; }
  .list td { border: 0; padding: 1px 8px; grid-column: 2; }
  .list td.thumb { grid-column: 1; grid-row: 1 / span 6; width: auto; padding: 2px 4px 0 8px !important; }
  .list td.thumb:empty { display: none; }
  .list td.thumb:empty ~ td { grid-column: 1 / -1; }
  .list td[data-label] { font-size: 13px; color: var(--muted); }
  .list td[data-label]::before { content: attr(data-label) ": "; }
  .list td:last-child { padding-top: 4px; }
  .qr-box { flex-direction: column; align-items: center; text-align: center; }
  .qr-box > div:last-child { align-items: center; }
  .bar { grid-template-columns: 110px 1fr 32px; }
}

/* ---------- Paginación e importación ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0; }
.imp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 4px 0 10px; }
.imp-stats div { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.imp-stats b { display: block; font-size: 22px; }
.imp-stats small { color: var(--muted); }
.imp-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.imp-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.imp-table th, .imp-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.imp-table th { background: var(--surface-2, var(--bg)); font-weight: 600; }
.imp-status { flex: 1; font-size: 14px; }
@media (max-width: 640px) { .imp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.imp-people { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px; }
.imp-people details { margin-top: 6px; }
.imp-people summary { cursor: pointer; font-weight: 600; color: var(--accent-text); }
.imp-people .imp-table { margin-top: 8px; max-height: 360px; overflow: auto; }

/* ---------- Eliminar etiquetas QR ---------- */
.labels-page .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.labels-page .toolbar .actions { display: flex; gap: 8px; }
.btn.danger { color: #af272f; border-color: #e3b5b8; background: #fff; }
.btn.danger:hover { background: #fbeeee; }
.btn.danger:disabled { opacity: .5; }
.labels-flash { margin: 12px 20px 0; padding: 10px 14px; border-radius: 8px; background: #f6eeee; color: #7d1c22; font-size: 14px; }
.select-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px; background: #fff8f0; border-bottom: 1px solid #ecd9c2; font-size: 14px; }
.select-bar .actions { display: flex; gap: 8px; }
.label { position: relative; }
.label .pick { position: absolute; top: 2mm; right: 2mm; width: 22px; height: 22px; accent-color: #af272f; margin: 0; }
.selecting .label { cursor: pointer; }
.selecting .label:has(.pick:checked) { border: 2px solid #af272f; background: #fbeeee; }
.labels-page dialog { border: 0; border-radius: 12px; padding: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); color: #1b1c1a; background: #fff; }
.labels-page dialog::backdrop { background: rgba(0,0,0,.4); }
.labels-page dialog h3 { margin: 0 0 8px; font-size: 17px; }
.labels-page dialog p { margin: 0 0 14px; font-size: 14px; }
.labels-page dialog input[type=password] { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 16px; margin-bottom: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.qr-del { margin-top: 12px; font-size: 14px; }
.qr-del summary { cursor: pointer; color: var(--accent-text); font-weight: 600; font-size: 13.5px; }
.qr-del form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.qr-del input[type=password] { flex: 1 1 180px; }
.qr-del p { margin: 6px 0 0; word-break: normal; overflow-wrap: normal; }
.qr-del { word-break: normal; }
.doc .small-note { font-size: 7.5pt; color: #555; margin-top: 8px; }
.doc.general .grid.compact { table-layout: fixed; font-size: 7pt; }
.doc.general .grid.compact th { font-size: 6.5pt; padding: 3px 2px; }
.doc.general .grid.compact td { padding: 3px 3px; line-height: 1.25; }
.doc.general .grid.compact td:nth-child(2) { white-space: normal; word-break: break-all; font-size: 6.5pt; }
.doc-warn { max-width: 216mm; width: calc(100% - 24px); margin: 12px auto 0; padding: 10px 14px; border-radius: 8px; background: #fff6e5; color: #6b4a00; border: 1px solid #f0d9a8; font-size: 14px; box-sizing: border-box; }
.doc-page .toolbar { flex-wrap: wrap; }
@media print { .doc { zoom: 1 !important; } }
/* Los formatos son hojas carta: el navegador del celular no debe agrandar el texto por su cuenta,
   y una palabra o serie larga se parte antes de salirse de su celda. */
.doc-page { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.doc .grid th, .doc .grid td, .doc .gen-kv td, .doc .carta-table td { overflow-wrap: break-word; }
/* En pantalla la hoja conserva su ancho carta y el celular la muestra reducida, igual que impresa. */
@media screen { .doc.inst { width: 216mm; max-width: none; box-sizing: border-box; } }
.doc.general .grid.compact th { letter-spacing: 0; }
.list td:nth-child(2) { white-space: nowrap; }
