/* Instrumentación Pro by NMLogix — © 2026 NMLogix · Nelson Fernando Barraza */
:root {
  --bg: #0b1018; --bg2: #0e1520; --panel: #131c29; --panel2: #182334; --line: #243249; --line2: #30425f;
  --text: #e7edf6; --muted: #8d9cb4; --dim: #5f6f88;
  --accent: #f5a524; --accent2: #ffbe4d; --ink: #1a1203;
  --red: #f05252; --blue: #4c8dff; --green: #2fbf71; --purple: #a68bfa;
  --r: 14px; --r-sm: 10px;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow: 0 18px 50px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent2); }
[hidden] { display: none !important; }
body:not(.es-priv) .priv-only, body:not(.es-admin) .admin-only { display: none !important; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.c-accent { color: var(--accent); } .c-green { color: var(--green); } .c-purple { color: var(--purple); } .c-red { color: var(--red); }
.mono { font-family: var(--mono); }

/* ─── Botones ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 13.5px; background: var(--panel2); color: var(--text); white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--ink); }
.btn-primary:hover { background: var(--accent2); }
.btn-green { background: var(--green); color: #04180c; }
.btn-purple { background: var(--purple); color: #140b33; }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line2); }
.btn-ghost:hover { background: var(--panel2); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:hover { color: var(--text); border-color: var(--line2); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ─── Formularios ─── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; color: var(--text); outline: none; font-size: 14.5px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,165,36,.15); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.55; }
select.input { appearance: none; background-image: linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input.mono { font-family: var(--mono); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.form-error { color: #ff9aa5; background: rgba(240,82,82,.1); border: 1px solid rgba(240,82,82,.35); padding: 9px 12px; border-radius: var(--r-sm); font-size: 13px; margin: 0; }
.warn-box { color: #ffd38a; background: rgba(245,165,36,.08); border: 1px solid rgba(245,165,36,.3); padding: 9px 12px; border-radius: var(--r-sm); font-size: 12.5px; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--r-sm); background: rgba(166,139,250,.08); border: 1px solid rgba(166,139,250,.3); color: #cfc2ff; font-weight: 600; font-size: 13px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--purple); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); width: 36px; height: 36px; }

/* ─── Login ─── */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(245,165,36,.10), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 6px 0 0; font-size: 22px; text-align: center; letter-spacing: -.01em; }
.login-card > .muted { text-align: center; margin-top: -8px; margin-bottom: 4px; }
.login-foot { margin-top: 18px; color: var(--dim); font-size: 12px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--ink); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.brand-mark.lg { width: 58px; height: 58px; border-radius: 16px; font-size: 27px; margin: 0 auto; }

/* ─── Barra superior ─── */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(11,16,24,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1400px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; font-size: 15px; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--ink); background: var(--accent); }
.tab .count { font-style: normal; font-size: 11px; font-family: var(--mono); background: rgba(255,255,255,.12); padding: 0 6px; border-radius: 99px; }
.tab.active .count { background: rgba(0,0,0,.18); }
.tab .count:empty { display: none; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px 4px 4px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; border: 1px solid var(--line2); }
.user-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-txt b { color: var(--text); font-size: 12.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-txt small { font-size: 10.5px; letter-spacing: .04em; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r); padding: 6px; min-width: 220px; box-shadow: var(--shadow); z-index: 60; }
.dropdown button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 13.5px; }
.dropdown button:hover { background: var(--panel2); }
.dropdown .danger { color: #ff9aa5; }

/* ─── Contenido ─── */
.main { max-width: 1400px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; min-height: calc(100vh - 120px); }
.searchbar { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 6px 4px 14px; }
.searchbar:focus-within { border-color: var(--accent); }
.searchbar > i { color: var(--muted); }
.searchbar input { flex: 1; background: none; border: 0; outline: none; padding: 9px 0; font-size: 15px; min-width: 0; }
.searchbar input::-webkit-search-cancel-button { display: none; }
.view { display: flex; flex-direction: column; gap: 14px; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; letter-spacing: -.01em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; display: flex; gap: 9px; align-items: center; }
.panel .btn-row { margin-top: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line2); background: transparent; color: var(--muted); border-radius: 99px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.t-correctivo.active { background: var(--red); border-color: var(--red); color: #fff; }
.chip.t-preventivo.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.t-mejora.active { background: var(--green); border-color: var(--green); color: #04180c; }
.chip.t-privado.active { background: var(--purple); border-color: var(--purple); color: #140b33; }
.foot { text-align: center; color: var(--dim); font-size: 12px; padding: 20px 16px 28px; border-top: 1px solid var(--line); }
.foot b { color: var(--muted); }

/* ─── Grillas y tarjetas ─── */
.grid { display: grid; gap: 12px; }
.grid-bit { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-pdf { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.empty { grid-column: 1 / -1; text-align: center; padding: 50px 16px; color: var(--muted); border: 1px dashed var(--line2); border-radius: var(--r); }
.empty i { font-size: 28px; display: block; margin-bottom: 10px; color: var(--dim); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; min-width: 0; transition: border-color .15s; }
.card:hover { border-color: var(--line2); }
.card-bit { cursor: pointer; padding: 14px; gap: 10px; border-left: 3px solid var(--line2); }
.card-bit.t-CORRECTIVO { border-left-color: var(--red); }
.card-bit.t-PREVENTIVO { border-left-color: var(--blue); }
.card-bit.t-MEJORA { border-left-color: var(--green); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-top > small { white-space: nowrap; flex-shrink: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.card-title { font-weight: 700; font-size: 14.5px; word-break: break-word; }
.card-desc { color: #c3cddc; font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; word-break: break-word; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.card-meta span { display: inline-flex; gap: 6px; align-items: center; }
.card-thumbs { display: flex; gap: 6px; }
.card-thumbs img { width: 64px; height: 50px; object-fit: cover; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); }
.card-thumbs .more { width: 64px; height: 50px; border-radius: 8px; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.b-CORRECTIVO { color: #ff9aa5; border-color: rgba(240,82,82,.45); background: rgba(240,82,82,.1); }
.b-PREVENTIVO { color: #9fc1ff; border-color: rgba(76,141,255,.45); background: rgba(76,141,255,.1); }
.b-MEJORA { color: #87e6b1; border-color: rgba(47,191,113,.45); background: rgba(47,191,113,.1); }
.b-priv { color: #cfc2ff; border-color: rgba(166,139,250,.45); background: rgba(166,139,250,.1); text-transform: none; letter-spacing: 0; font-size: 11px; }
.b-tag { font-family: var(--mono); text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--accent2); border-color: rgba(245,165,36,.4); background: rgba(245,165,36,.08); }
.b-area { color: #cfc2ff; border-color: rgba(166,139,250,.4); }
.card-media { height: 150px; background: var(--bg2); display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.card-media img { height: 100%; min-width: 100%; object-fit: cover; scroll-snap-align: start; cursor: zoom-in; }
.card-media.multi img { min-width: 72%; border-right: 2px solid var(--bg); }
.card-media .ph { width: 100%; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 34px; }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h4 { margin: 0; font-size: 15px; word-break: break-word; }
.card-body p { margin: 0; color: #c3cddc; font-size: 13px; white-space: pre-line; word-break: break-word; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.card-actions .btn { flex: 1 1 auto; }
.card-admin { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.card-admin .icon-btn { width: 32px; height: 32px; background: rgba(11,16,24,.82); backdrop-filter: blur(4px); }
.card-wrap { position: relative; }
.creds { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.cred { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cred > span:first-child { color: var(--dim); width: 34px; flex-shrink: 0; font-size: 11px; }
.cred > b { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dfe7f3; }
.cred button { background: none; border: 0; color: var(--muted); padding: 2px 4px; }
.cred button:hover { color: var(--accent); }
.docs { display: flex; flex-direction: column; gap: 6px; }
.doc { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--r-sm); background: var(--bg2); border: 1px solid var(--line); text-align: left; width: 100%; color: var(--text); text-decoration: none; }
.doc:hover { border-color: var(--line2); }
.doc i.fi { font-size: 18px; width: 20px; text-align: center; }
.doc .dn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.doc small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.fi-pdf { color: var(--red); } .fi-xls { color: var(--green); } .fi-doc { color: var(--blue); } .fi-otro { color: var(--muted); }

/* ─── Detalle ─── */
.det-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12.5px; }
.det-meta span { display: inline-flex; gap: 6px; align-items: center; }
.det-desc { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.6; }
.det-section { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 4px 0 -4px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.gallery button { padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--bg2); aspect-ratio: 4/3; position: relative; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.gallery button:hover img { transform: scale(1.04); }

/* ─── Adjuntos en formularios ─── */
.attach { border: 1px dashed var(--line2); border-radius: var(--r-sm); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.attach-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.attach-btns .btn { flex: 1 1 140px; }
.attach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; }
.attach-list:empty { display: none; }
.att { position: relative; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--bg2); aspect-ratio: 1; }
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(240,82,82,.95); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.att .tag-new { position: absolute; left: 4px; bottom: 4px; font-size: 9.5px; font-weight: 700; background: var(--accent); color: var(--ink); border-radius: 4px; padding: 1px 5px; }
.att.doc-att { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; text-align: center; }
.att.doc-att i { font-size: 24px; }
.att.doc-att span { font-size: 10.5px; line-height: 1.2; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.att.borrando { opacity: .35; }
.attach-info { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.attach-info:empty { display: none; }

/* ─── Progreso ─── */
.progress-line { position: relative; height: 26px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden; }
.progress-line span { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(245,165,36,.35), rgba(245,165,36,.6)); transition: width .2s; }
.progress-line em { position: relative; font-style: normal; font-size: 12px; display: flex; height: 100%; align-items: center; justify-content: center; font-weight: 600; }

/* ─── Fotos a PDF ─── */
.pdf-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.pdf-item img { width: 100%; height: 130px; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--bg2); }
.pdf-item .n { position: absolute; top: 14px; left: 14px; background: var(--accent); color: var(--ink); font-weight: 700; font-size: 11px; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.pdf-item .ops { display: flex; justify-content: space-between; }
.pdf-item .ops button { background: none; border: 0; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.pdf-item .ops button:hover:not(:disabled) { color: var(--text); background: var(--panel2); }
.pdf-item .ops button:disabled { opacity: .25; }

/* ─── Admin ─── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat small { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat b { display: block; font-size: 22px; font-family: var(--mono); margin-top: 2px; }
.stat em { font-style: normal; color: var(--muted); font-size: 12px; }
.admin-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td:last-child { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.cred-table td { font-family: var(--mono); font-size: 12.5px; }

/* ─── Modal ─── */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(4,7,12,.72); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .18s ease-out; }
.modal-box.sm { max-width: 400px; }
.modal-box.lg { max-width: 820px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; min-width: 0; display: flex; gap: 9px; align-items: center; overflow: hidden; text-overflow: ellipsis; }
.modal-actions { display: flex; gap: 6px; }
.modal-body { padding: 16px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
.confirm-icon { font-size: 34px; color: var(--accent); text-align: center; }
.confirm-msg { text-align: center; margin: 0; color: #cfd8e6; white-space: pre-line; }

/* ─── Toasts ─── */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 4px solid var(--accent); border-radius: var(--r-sm); padding: 11px 14px; box-shadow: var(--shadow); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: pop .2s ease-out; pointer-events: auto; }
.toast.ok { border-left-color: var(--green); } .toast.ok i { color: var(--green); }
.toast.err { border-left-color: var(--red); } .toast.err i { color: var(--red); }
.toast i { margin-top: 3px; }

/* ─── Visores ─── */
.viewer { position: fixed; inset: 0; z-index: 150; background: #05080d; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: rgba(10,15,23,.94); border-bottom: 1px solid var(--line); z-index: 3; }
.viewer-count { font-family: var(--mono); font-size: 12.5px; background: var(--panel2); padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.viewer-tools { display: flex; gap: 4px; flex-shrink: 0; }
.vt { min-width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: #cfd8e6; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; }
.vt:hover { border-color: var(--line2); color: #fff; }
.vt.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.vt-pct { font-family: var(--mono); font-size: 12px; min-width: 56px; }
.vt-close:hover { color: #fff; background: var(--red); border-color: var(--red); }
.viewer-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: grab; }
.viewer-stage.dragging { cursor: grabbing; }
.viewer-stage.lupa-on { cursor: none; }
.viewer-stage > img { position: absolute; left: 50%; top: 50%; transform-origin: center center; will-change: transform; max-width: none; image-rendering: auto; }
.viewer-stage.anim > img { transition: transform .22s ease-out; }
.viewer-loading { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; color: var(--muted); font-size: 28px; pointer-events: none; }
.viewer-loading span { font-size: 13px; }
.loupe { position: absolute; width: 190px; height: 190px; border-radius: 50%; border: 3px solid var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.5); overflow: hidden; pointer-events: none; background: #05080d; z-index: 2; }
.loupe-in { position: absolute; transform-origin: 0 0; }
.loupe-in img { position: absolute; left: 50%; top: 50%; transform-origin: center center; max-width: none; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line2); background: rgba(19,28,41,.85); color: #fff; z-index: 3; font-size: 17px; }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-strip { display: flex; gap: 6px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); overflow-x: auto; background: rgba(10,15,23,.94); border-top: 1px solid var(--line); justify-content: safe center; z-index: 3; }
.viewer-strip button { flex-shrink: 0; width: 58px; height: 44px; border-radius: 7px; overflow: hidden; border: 2px solid transparent; padding: 0; background: var(--panel); opacity: .55; }
.viewer-strip button.active { border-color: var(--accent); opacity: 1; }
.viewer-strip img { width: 100%; height: 100%; object-fit: cover; }
.viewer-hint { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); background: rgba(19,28,41,.9); border: 1px solid var(--line); color: var(--muted); padding: 6px 12px; border-radius: 99px; font-size: 12px; white-space: nowrap; pointer-events: none; transition: opacity .6s; z-index: 3; }
.viewer-hint.fade { opacity: 0; }
.pdfv-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; background: #2a3243; }
.pdfv-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px; min-width: min-content; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.45); flex-shrink: 0; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-page .pn { position: absolute; bottom: -1px; right: -1px; background: rgba(0,0,0,.55); color: #fff; font: 11px var(--mono); padding: 2px 6px; border-top-left-radius: 6px; }

/* ─── Responsive ─── */
@media (max-width: 980px) {
  .user-txt { display: none; }
  .user-btn { padding: 4px; } .user-btn > i { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .topbar-in { padding: 8px 12px; }
  .brand small { display: none; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; background: rgba(11,16,24,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    padding: 6px 6px max(6px, env(safe-area-inset-bottom)); margin: 0; justify-content: space-around; gap: 2px; }
  .tab { flex: 1; flex-direction: column; gap: 3px; padding: 7px 2px; font-size: 10.5px; border-radius: 10px; min-width: 0; }
  .tab i { font-size: 17px; }
  .tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tab .count { position: absolute; top: 2px; right: calc(50% - 22px); font-size: 9.5px; padding: 0 4px; }
  .user-menu { margin-left: auto; }
  .main { padding: 12px; padding-bottom: 96px; gap: 12px; }
  .foot { padding-bottom: 96px; }
  .view-head > .btn, .view-head > .btn-row { width: 100%; }
  .view-head > .btn-row .btn { flex: 1; }
  .grid-bit, .grid-cards { grid-template-columns: 1fr; }
  .grid-pdf { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.lg { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; max-height: 94dvh; }
  .modal-box.sm { border-radius: 18px; margin: 16px; align-self: center; }
  .modal-body { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .viewer-tools { gap: 3px; }
  .vt { min-width: 34px; height: 36px; padding: 0 6px; }
  .vt-pct { min-width: 48px; }
  .viewer-name { display: none; }
  .viewer-top { justify-content: space-between; }
  .viewer-nav { width: 40px; height: 40px; }
  .viewer-nav.prev { left: 6px; } .viewer-nav.next { right: 6px; }
  .loupe { width: 160px; height: 160px; }
  .viewer-hint { bottom: 70px; white-space: normal; width: 88%; text-align: center; }
  .toasts { bottom: 88px; }
}
@media (max-width: 380px) {
  .vt[data-v="rot-l"] { display: none; }
}

/* ─── v2.1: seguridad, auditoría y Acerca de ─── */
.by-marca { text-align: center; margin: -10px 0 0; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: inherit; }
.link-btn:hover { color: var(--text); }
.login-foot a, .foot a { color: var(--muted); }
.badge.b-ok { color: #a7f0c7; border-color: rgba(47,191,113,.45); margin-left: 6px; }
#admin-alertas { display: grid; gap: 8px; margin-bottom: 14px; }
#admin-alertas:empty { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.panel-head h3 { margin: 0; }
.input-sm { width: auto; padding: 6px 10px; font-size: 13px; }
.table-aud td { font-size: 12.5px; }
.table-aud td:nth-child(4) { white-space: normal; min-width: 220px; }
.table-aud td:last-child { text-align: left; }
.table-aud tr.aud-alerta td { color: #ffb3bd; }
.table-aud tr.aud-alerta td:first-child { box-shadow: inset 3px 0 0 var(--red); }
#aud-mas { margin-top: 10px; }
.pasos { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: var(--r-sm); width: max-content; margin: 4px auto; }
.qr-box img, .qr-box canvas { display: block; }
.clave-2fa { text-align: center; font-size: 15px; letter-spacing: .06em; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; margin: 0; word-break: break-all; user-select: all; }
.codigos-rec { font-family: var(--mono); font-size: 15px; line-height: 1.8; text-align: center; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; margin: 12px 0; user-select: all; }
.acerca { text-align: center; display: grid; gap: 10px; justify-items: center; }
.acerca h3 { margin: 4px 0 0; font-size: 19px; }
.acerca h3 small { color: var(--accent); font-size: 13px; font-weight: 600; }
.acerca p { margin: 0; }
.acerca-datos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; margin: 4px 0; font-size: 13.5px; width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.acerca-datos dt { color: var(--muted); }
.acerca-datos dd { margin: 0; }
.acerca .small { font-size: 11.5px; }

/* ─── v2.2: agenda (preventivos y calibraciones), ficha de componente y etiquetas QR ─── */
.c-blue { color: var(--blue); }
.btn-blue { background: var(--blue); color: #fff; }
.tab .count.alerta { background: var(--red); color: #fff; }
.tab.active .count.alerta { background: var(--red); }
.b-vencido, .b-sin, .b-NO_CONFORME { color: #ff9aa5; border-color: rgba(240,82,82,.5); background: rgba(240,82,82,.12); }
.b-proximo, .b-AJUSTADO { color: #ffd48a; border-color: rgba(245,165,36,.5); background: rgba(245,165,36,.1); }
.b-aldia, .b-CONFORME { color: #a7f0c7; border-color: rgba(47,191,113,.45); background: rgba(47,191,113,.08); }
.b-pausado, .b-registrada { color: var(--muted); }
.chip.e-vencido.active { background: var(--red); border-color: var(--red); color: #fff; }
.chip.e-proximo.active { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.chip.e-aldia.active { background: var(--green); border-color: var(--green); color: #04180c; }
#agenda-stats .stat.st-venc b { color: var(--red); }
#agenda-stats .stat.st-prox b { color: var(--accent); }
.view[data-view="agenda"] > .panel { display: grid; gap: 10px; }
.card-prev { padding: 14px; gap: 8px; border-left: 3px solid var(--line2); }
.card-prev.est-vencido { border-left-color: var(--red); }
.card-prev.est-proximo { border-left-color: var(--accent); }
.card-prev.est-aldia { border-left-color: var(--green); }
.card-prev.est-pausado { opacity: .7; }
.card-prev h4 { margin: 0; font-size: 15px; }
.card-prev .card-actions { padding: 4px 0 0; }
.plazo { font-size: 12.5px; font-weight: 600; }
.plazo.vencido, .plazo.sin { color: #ff9aa5; } .plazo.proximo { color: #ffd48a; } .plazo.aldia { color: var(--muted); }
.prev-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.table-cal td:nth-child(2) { white-space: normal; min-width: 140px; }
.table-cal .link-btn { color: var(--accent2); text-decoration: none; font-family: var(--mono); font-weight: 600; }
.ficha-sec { display: grid; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.ficha-sec h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mini-lista { display: grid; gap: 6px; }
.mini-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; text-align: left; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; color: var(--text); font-size: 13px; }
.mini-item:is(button):hover { border-color: var(--line2); }
.mini-item > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mini-item small { color: var(--muted); white-space: nowrap; }
.cal-item { display: grid; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.cal-item .cal-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-item p { margin: 0; white-space: pre-wrap; font-size: 13.5px; }
.cal-datos { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.cal-datos dt { color: var(--muted); } .cal-datos dd { margin: 0; }
.checklist { display: grid; gap: 6px; }
.checklist .check { margin: 0; }
.hint-box { font-size: 13px; color: var(--muted); background: var(--bg2); border: 1px dashed var(--line2); border-radius: var(--r-sm); padding: 8px 12px; margin: 0; }
.etiqueta { display: flex; align-items: center; gap: 12px; background: #fff; color: #111; border-radius: 8px; padding: 10px 14px 10px 10px; width: max-content; max-width: 100%; margin: 0 auto; }
.etiqueta img { width: 120px; height: 120px; image-rendering: pixelated; flex-shrink: 0; }
.etiqueta div { display: grid; gap: 3px; min-width: 0; }
.etiqueta b { font: 700 22px var(--mono); letter-spacing: .02em; overflow-wrap: anywhere; }
.etiqueta span { font-size: 13px; color: #333; }
.etiqueta small { font-size: 10px; color: #666; }
.qr-url { font-size: 12px; word-break: break-all; text-align: center; color: var(--muted); margin: 0; }
@media (min-width: 761px) and (max-width: 1120px) {
  .tab { padding: 8px 9px; gap: 6px; font-size: 12.5px; }
  .tab span { white-space: nowrap; }
}
@media (min-width: 761px) and (max-width: 900px) {
  .brand > div:not(.brand-mark) { display: none; }
}
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4mm; }
  #print-area .etiqueta { width: auto; height: 30mm; border: 1px dashed #999; border-radius: 2mm; padding: 2mm 3mm 2mm 2mm; gap: 3mm; break-inside: avoid; margin: 0; }
  #print-area .etiqueta img { width: 25mm; height: 25mm; }
  #print-area .etiqueta b { font-size: 13pt; word-break: normal; overflow-wrap: anywhere; }
  #print-area .etiqueta span { font-size: 8pt; }
  #print-area .etiqueta small { font-size: 6pt; }
  #print-area.una { grid-template-columns: 1fr; }
  #print-area.una .etiqueta { justify-self: start; width: 70mm; }
}
