/* =========================================================================
   Control de Mantenimiento IGIRD — estilo Apple, solo modo claro
   ========================================================================= */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text2: #6e6e73;
  --text3: #86868b;
  --line: #e5e5ea;
  --fill: #f2f2f7;
  --fill2: #e8e8ed;
  --blue: #0071e3;
  --blue-h: #0077ed;
  --red: #ff3b30;
  --orange: #ff9500;
  --green: #34c759;
  --yellow: #ffcc00;
  --purple: #5e5ce6;
  --teal: #32ade6;
  --gray: #8e8e93;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --shadow-h: 0 2px 6px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.10);
  --ease: cubic-bezier(.2,.8,.2,1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --nav-h: 56px;
  --tab-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 16px; } .mt2 { margin-top: 28px; } .mb { margin-bottom: 16px; }

/* ---------- Barra superior translúcida ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.topbar .wrap { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { height: 32px; width: 32px; object-fit: contain; border-radius: 8px; }
.brand span { font-size: 15px; }
.nav { display: flex; gap: 4px; flex: 1; align-items: center; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--text); font-size: 13.5px; padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  transition: background .2s var(--ease);
}
.nav a:hover { background: rgba(0,0,0,.05); text-decoration: none; }
.nav a.active { background: rgba(0,113,227,.1); color: var(--blue); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-size: 18px; color: var(--text); background: transparent; border: 0; cursor: pointer;
  transition: background .2s var(--ease);
}
.icon-btn:hover { background: rgba(0,0,0,.06); text-decoration: none; }
.badge {
  position: absolute; top: 1px; right: 0; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1; border: 2px solid #fff;
}
.badge:empty, .badge[data-n="0"] { display: none; }
.bell.blink { animation: blink 2s var(--ease) infinite; }
@keyframes blink { 0%,100% { transform: rotate(0) } 10% { transform: rotate(14deg) } 20% { transform: rotate(-12deg) } 30% { transform: rotate(8deg) } 40% { transform: rotate(0) } 50%,90% { opacity: 1 } 70% { opacity: .55 } }

/* Menú de usuario */
.user-menu { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#0a84ff,#5e5ce6);
  color: #fff; font-weight: 600; font-size: 14px; display: grid; place-items: center; border: 0; cursor: pointer;
}
.dropdown {
  position: absolute; right: 0; top: 46px; min-width: 240px; background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-radius: var(--r-md); box-shadow: var(--shadow-h); border: 1px solid rgba(0,0,0,.06);
  padding: 6px; display: none; animation: pop .18s var(--ease);
}
.dropdown.open { display: block; }
.dropdown .who { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dropdown .who b { display: block; }
.dropdown a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); font-size: 14px; }
.dropdown a:hover { background: var(--fill); text-decoration: none; }
.dropdown a.danger { color: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98) } to { opacity: 1; transform: none } }

/* ---------- Contenido ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; }
main.wrap { padding-top: 26px; padding-bottom: 60px; min-height: calc(100vh - var(--nav-h)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1, .h1 { font-size: 34px; font-weight: 700; line-height: 1.1; }
.page-head .sub { color: var(--text2); margin-top: 6px; font-size: 15px; }
.title-icon { display: flex; align-items: center; gap: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
h2.section { font-size: 22px; font-weight: 700; margin: 34px 0 14px; display: flex; align-items: center; gap: 10px; }
h2.section .count { font-size: 13px; color: var(--text2); font-weight: 500; background: var(--fill2); padding: 2px 9px; border-radius: 999px; }

.card {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 22px;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.card.pad0 { padding: 0; overflow: hidden; }
.card h3 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.card-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-h); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Íconos tipo app ---------- */
.app-icon {
  width: 52px; height: 52px; border-radius: 13px; display: grid; place-items: center; font-size: 27px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.08); flex-shrink: 0;
}
.app-icon.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 18px; }
.app-icon.lg { width: 64px; height: 64px; border-radius: 16px; font-size: 34px; }
.ic-CLI { background: linear-gradient(160deg,#5ac8fa,#0a84ff); }
.ic-EXT { background: linear-gradient(160deg,#ff6961,#ff3b30); }
.ic-PLA { background: linear-gradient(160deg,#ffb340,#ff9500); }
.ic-ELE { background: linear-gradient(160deg,#ffe066,#ffb800); }
.ic-SEG { background: linear-gradient(160deg,#63e083,#34c759); }
.ic-HID { background: linear-gradient(160deg,#7fd8ff,#32ade6); }
.ic-INM { background: linear-gradient(160deg,#c7c7cc,#8e8e93); }
.ic-ILU { background: linear-gradient(160deg,#fff3a6,#ffd60a); }
.ic-SAN { background: linear-gradient(160deg,#9b99ff,#5e5ce6); }

/* Tarjetas de categoría */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.cat-card { display: flex; flex-direction: column; gap: 14px; color: var(--text); padding: 20px; }
.cat-card:hover { text-decoration: none; }
.cat-card .name { font-weight: 600; font-size: 16px; line-height: 1.25; }
.cat-card .big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.cat-card .meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Píldoras ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5;
  background: var(--fill2); color: var(--text2);
}
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.verde, .pill.funcionando, .pill.atendido, .pill.preventivo { background: rgba(52,199,89,.14); color: #1f8a3c; }
.pill.rojo, .pill.fuera_de_servicio, .pill.incidencia, .pill.nuevo, .pill.vencido { background: rgba(255,59,48,.12); color: #d70015; }
.pill.naranja, .pill.en_reparacion, .pill.en_proceso, .pill.correctivo, .pill.por_vencer { background: rgba(255,149,0,.15); color: #c25e00; }
.pill.azul, .pill.recarga { background: rgba(0,113,227,.11); color: var(--blue); }
.pill.gris, .pill.baja, .pill.cancelado { background: var(--fill2); color: var(--text2); }
.pill.solid-red { background: var(--red); color: #fff; }
.pill.solid-orange { background: var(--orange); color: #fff; }
.sem { display: inline-flex; align-items: center; gap: 6px; }
.sem::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--gray); flex-shrink: 0; }
.sem.rojo::before { background: var(--red); } .sem.naranja::before { background: var(--orange); } .sem.verde::before { background: var(--green); }
.t-rojo { color: #d70015; } .t-naranja { color: #c25e00; } .t-verde { color: #1f8a3c; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: 999px; border: 0; cursor: pointer;
  font: 500 15px var(--font); background: var(--fill2); color: var(--text); white-space: nowrap;
  transition: background .2s var(--ease), transform .15s var(--ease), opacity .2s; text-decoration: none !important;
}
.btn:hover { background: #dcdce1; }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-h); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: #e6342a; }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.ghost:hover { background: rgba(0,113,227,.08); }
.btn.tinted { background: rgba(0,113,227,.1); color: var(--blue); }
.btn.tinted:hover { background: rgba(0,113,227,.16); }
.btn.tinted-red { background: rgba(255,59,48,.1); color: #d70015; }
.btn.tinted-red:hover { background: rgba(255,59,48,.16); }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn.lg { padding: 14px 26px; font-size: 17px; }
.btn.block { width: 100%; }
form.inline { display: inline; margin: 0; }

/* ---------- Formularios ---------- */
.form-card { max-width: 760px; }
.form-section { margin-bottom: 26px; }
.form-section > h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); margin: 0 0 10px 4px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text2); }
.req::after { content: " *"; color: var(--red); }
.row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0 14px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search],
input[type=email], input[type=datetime-local], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--fill); color: var(--text); font: 15px var(--font); outline: none;
  transition: background .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%236e6e73' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,.15); }
input[readonly], select:disabled, input:disabled { color: var(--text2); background: var(--fill2); cursor: not-allowed; }
input[readonly]:focus { box-shadow: none; border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }
.input-group { position: relative; }
.input-group input { padding-right: 46px; }
.input-group .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; font-size: 17px; color: var(--text2); }
.input-group .eye:hover { background: rgba(0,0,0,.05); }

/* Interruptor iOS */
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #e9e9eb; border-radius: 999px; transition: background .25s var(--ease); cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .25s var(--ease); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- Control segmentado ---------- */
.segmented {
  display: inline-flex; background: var(--fill2); border-radius: 10px; padding: 2px; gap: 0; position: relative;
}
.segmented button, .segmented a, .segmented label {
  position: relative; border: 0; background: transparent; padding: 7px 18px; border-radius: 8px;
  font: 500 14px var(--font); color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background .25s var(--ease), box-shadow .25s var(--ease); text-decoration: none !important;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented .active, .segmented input:checked + span {
  background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600;
}
.segmented.full { display: flex; width: 100%; }
.segmented.full > * { flex: 1; }
.segmented label { padding: 0; }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span { display: block; width: 100%; padding: 9px 18px; border-radius: 8px; text-align: center; transition: all .25s var(--ease); }

/* Tipo de servicio: botones grandes */
.tipo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tipo-opt { position: relative; cursor: pointer; }
.tipo-opt input { position: absolute; opacity: 0; }
.tipo-opt span {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: var(--r-md);
  background: var(--fill); border: 2px solid transparent; font-weight: 600; font-size: 14px; text-align: center;
  transition: all .2s var(--ease);
}
.tipo-opt span i { font-style: normal; font-size: 22px; }
.tipo-opt input:checked + span { background: rgba(0,113,227,.08); border-color: var(--blue); color: var(--blue); }
.tipo-opt input:focus-visible + span { box-shadow: 0 0 0 4px rgba(0,113,227,.2); }

/* Foto */
.photo-drop {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--r-md);
  background: var(--fill); border: 2px dashed #d2d2d7; cursor: pointer; transition: border-color .2s;
}
.photo-drop:hover { border-color: var(--blue); }
.photo-drop input { display: none; }
.photo-drop .ph { width: 72px; height: 72px; border-radius: 12px; background: #fff; display: grid; place-items: center; font-size: 28px; overflow: hidden; flex-shrink: 0; }
.photo-drop .ph img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfbfd; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr:hover { background: #fafafc; }
.tbl tr.vencido-row { background: rgba(255,59,48,.045); }
.tbl tr.vencido-row:hover { background: rgba(255,59,48,.08); }
.thumb { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; background: var(--fill); }
.thumb-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; }
.code { font-weight: 600; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; letter-spacing: -.01em; }

/* Menú ⋯ por fila */
.more { position: relative; display: inline-block; }
.more > button { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; color: var(--text2); }
.more > button:hover { background: var(--fill2); }
.more .dropdown { top: 34px; min-width: 170px; }

/* Buscador */
.search { position: relative; flex: 1; max-width: 360px; min-width: 200px; }
.search input { padding-left: 40px; border-radius: 999px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 15px center; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list a.li-link { display: flex; align-items: center; gap: 12px; color: var(--text); width: 100%; }
.list a.li-link:hover { text-decoration: none; }
.empty { color: var(--text2); text-align: center; padding: 26px 10px; font-size: 14px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 6px; }
.ok-all { color: #1f8a3c; font-weight: 600; font-size: 17px; text-align: center; padding: 28px; }

/* ---------- Bitácora: línea de tiempo ---------- */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.tl-item { display: grid; grid-template-columns: 64px 1fr; gap: 16px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px; }
.tl-date { text-align: center; padding-top: 2px; }
.tl-date .mon { color: var(--red); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tl-date .day { font-size: 30px; font-weight: 300; line-height: 1.05; letter-spacing: -.03em; }
.tl-date .yr { font-size: 11px; color: var(--text2); }
.tl-body { min-width: 0; }
.tl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tl-head h4 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.tl-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 18px; margin-bottom: 10px; }
.kv div { font-size: 14px; }
.kv span { display: block; font-size: 11.5px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.tl-block { background: var(--fill); border-radius: 12px; padding: 10px 14px; margin-top: 8px; font-size: 14px; white-space: pre-line; }
.tl-block > b { display: block; font-size: 11.5px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; white-space: normal; }
.tl-block.dict { background: rgba(0,113,227,.06); }
.tl-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.tl-photo { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; cursor: zoom-in; }

/* ---------- Ficha de equipo ---------- */
.ficha { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.ficha-photo { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--r-lg); cursor: zoom-in; display: block; box-shadow: var(--shadow); margin-bottom: 18px; }
.dl { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 26px; margin: 0; }
.dl > div { padding: 11px 0; border-bottom: 1px solid var(--line); }
.dl dt { font-size: 12px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.dl dd { margin: 2px 0 0; font-size: 15px; word-break: break-word; }
.qr-box { text-align: center; }
.qr-box img { width: 220px; max-width: 100%; border-radius: 12px; }
.qr-box .url { font-size: 11.5px; color: var(--text2); word-break: break-all; margin: 8px 0 14px; }

/* Avisos */
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--r-md); margin-bottom: 18px; font-weight: 500; }
.banner .ic { font-size: 22px; }
.banner .grow { flex: 1; }
.banner.red { background: rgba(255,59,48,.1); color: #b0000f; }
.banner.orange { background: rgba(255,149,0,.13); color: #9c4c00; }
.banner.blue { background: rgba(0,113,227,.08); color: #004f9e; }
.banner.green { background: rgba(52,199,89,.12); color: #1a7533; }
.banner a { font-weight: 600; color: inherit; text-decoration: underline; }
.banner-big { padding: 18px 22px; font-size: 16px; }
.banner-big b { font-size: 18px; }

/* Flash */
.flashes { position: fixed; top: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100vw - 24px)); pointer-events: none; }
.flash {
  pointer-events: auto; padding: 13px 18px; border-radius: var(--r-md); font-size: 14.5px; font-weight: 500;
  background: rgba(255,255,255,.95); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-h); display: flex; gap: 10px; align-items: center; animation: drop .4s var(--ease);
  border-left: 4px solid var(--blue); transition: opacity .4s, transform .4s var(--ease);
}
.flash.ok { border-left-color: var(--green); }
.flash.error { border-left-color: var(--red); }
.flash.out { opacity: 0; transform: translateY(-10px); }
.flash .x { margin-left: auto; border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--text2); }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) } to { opacity: 1; transform: none } }
.flashes.static { position: static; transform: none; width: auto; margin-bottom: 14px; }

/* Toast */
.toast {
  position: fixed; right: 20px; bottom: 24px; z-index: 95; max-width: 360px; background: rgba(29,29,31,.92); color: #fff;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-radius: var(--r-md); padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display: flex; gap: 12px; align-items: flex-start; animation: drop .4s var(--ease); cursor: pointer;
}
.toast b { display: block; }
.toast .t-sub { font-size: 13px; opacity: .8; margin-top: 2px; }

/* ---------- Hoja iOS (confirmación) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: none; align-items: flex-end; justify-content: center; animation: fade .25s var(--ease); }
.sheet-bg.open { display: flex; }
.sheet {
  background: #fff; width: min(480px, 100%); border-radius: 22px 22px 0 0; padding: 22px 22px calc(22px + env(safe-area-inset-bottom));
  animation: up .35s var(--ease); box-shadow: 0 -10px 40px rgba(0,0,0,.2);
}
@media (min-width: 761px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: #d1d1d6; margin: -8px auto 14px; }
.sheet h3 { font-size: 19px; margin-bottom: 8px; }
.sheet p { color: var(--text2); margin: 0 0 16px; }
.sheet .btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
@keyframes up { from { transform: translateY(100%) } to { transform: none } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* Visor de imagen */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 110; display: none; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; animation: fade .2s; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* Escáner */
.scanner { position: fixed; inset: 0; background: #000; z-index: 120; display: none; flex-direction: column; }
.scanner.open { display: flex; }
.scanner video, .scanner #qr-reader { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; top: 50%; left: 50%; width: 240px; height: 240px; transform: translate(-50%,-55%); border: 3px solid rgba(255,255,255,.9); border-radius: 28px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.scanner .bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); text-align: center; color: #fff; }
.scanner .bar p { margin: 0 0 12px; }

/* ---------- Barra inferior iOS (celular) ---------- */
.tabbar { display: none; }

/* ---------- Indicadores / dashboard ---------- */
.kpi { padding: 20px 22px; }
.kpi .lbl { font-size: 13px; color: var(--text2); font-weight: 600; }
.kpi .val { font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: 4px; }
.kpi .val.green { color: #1f8a3c; } .kpi .val.red { color: #d70015; } .kpi .val.orange { color: #c25e00; }
.chart-card { padding: 22px; min-height: 340px; display: flex; flex-direction: column; }
.chart-card .chart-box { position: relative; flex: 1; min-height: 260px; }
.chart-card .nodata { flex: 1; display: grid; place-items: center; color: var(--text2); font-size: 14px; text-align: center; }

/* ---------- Tickets ---------- */
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.ticket { display: flex; flex-direction: column; gap: 10px; }
.ticket .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ticket .folio { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.ticket .falla { background: var(--fill); border-radius: 12px; padding: 10px 14px; font-size: 14px; white-space: pre-line; }
.ticket .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

/* ---------- Historial de cambios ---------- */
.diff-item { border-bottom: 1px solid var(--line); }
.diff-item:last-child { border-bottom: 0; }
.diff-head { display: grid; grid-template-columns: 160px 1fr auto; gap: 12px; align-items: center; padding: 14px 18px; cursor: pointer; }
.diff-head:hover { background: #fafafc; }
.diff-body { display: none; padding: 0 18px 16px; }
.diff-item.open .diff-body { display: block; }
.diff-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.diff-table td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; word-break: break-word; }
.diff-table td:first-child { color: var(--text2); font-weight: 600; width: 180px; }
.diff-table del { color: #d70015; background: rgba(255,59,48,.08); padding: 1px 4px; border-radius: 4px; }
.diff-table ins { color: #1f8a3c; background: rgba(52,199,89,.12); padding: 1px 4px; border-radius: 4px; text-decoration: none; }

/* ---------- Contraseñas ---------- */
.pwd-rules { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 4px 14px; font-size: 13px; color: var(--text2); }
.pwd-rules li::before { content: "○"; display: inline-block; width: 18px; color: #c7c7cc; font-weight: 700; }
.pwd-rules li.ok { color: #1f8a3c; }
.pwd-rules li.ok::before { content: "✓"; color: var(--green); }
.strength { height: 6px; border-radius: 3px; background: var(--fill2); overflow: hidden; margin-top: 4px; }
.strength i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .3s var(--ease), background .3s; }
.strength-lbl { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ---------- Páginas públicas y login ---------- */
.public-body { background: radial-gradient(1200px 600px at 10% -10%, #e8f1ff 0, transparent 60%), radial-gradient(900px 500px at 110% 0, #fdeef0 0, transparent 55%), var(--bg); min-height: 100vh; }
.public { max-width: 520px; margin: 0 auto; padding: 22px 16px calc(40px + env(safe-area-inset-bottom)); }
.public-logo { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 6px 0 20px; }
.public-logo img { height: 44px; object-fit: contain; }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 16px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: var(--r-lg); box-shadow: 0 2px 6px rgba(0,0,0,.04), 0 20px 60px rgba(0,0,0,.08); padding: 30px 28px; }
.logos { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.logos img { max-height: 64px; max-width: 48%; object-fit: contain; }
.logos.solo { justify-content: center; }
.login-card h1 { font-size: 26px; font-weight: 700; text-align: center; }
.login-card .sub { text-align: center; color: var(--text2); font-size: 13.5px; margin: 6px 0 22px; }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-row img { width: 200px; height: 64px; max-width: calc(100% - 48px); border-radius: var(--r-sm); background: var(--fill); display: block; }
.captcha-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 600; text-align: center; }
.captcha-input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; }
.login-foot { text-align: center; color: var(--text2); font-size: 13px; margin-top: 22px; max-width: 400px; }

.qr-hero { text-align: center; }
.qr-hero .photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: 18px; margin-bottom: 14px; cursor: zoom-in; }
.qr-hero .code { font-size: 26px; margin: 10px 0 2px; display: block; }
.menu-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.menu-btn {
  display: flex; align-items: center; gap: 16px; background: #fff; border-radius: 18px; padding: 18px; box-shadow: var(--shadow);
  color: var(--text); transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.menu-btn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-h); }
.menu-btn:active { transform: scale(.98); }
.menu-btn .ic { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; font-size: 25px; flex-shrink: 0; }
.menu-btn .ic.red { background: rgba(255,59,48,.12); } .menu-btn .ic.blue { background: rgba(0,113,227,.1); }
.menu-btn b { display: block; font-size: 17px; }
.menu-btn small { color: var(--text2); font-size: 13.5px; }
.menu-btn .chev { margin-left: auto; color: #c7c7cc; font-size: 22px; }

.check-anim { width: 92px; height: 92px; margin: 10px auto 16px; }
.check-anim circle { stroke: var(--green); stroke-width: 4; fill: none; stroke-dasharray: 280; stroke-dashoffset: 280; animation: draw .7s var(--ease) forwards; }
.check-anim path { stroke: var(--green); stroke-width: 6; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 80; stroke-dashoffset: 80; animation: draw .45s .55s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0 } }
.folio-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; text-align: center; margin: 4px 0 6px; }

/* ---------- Etiquetas QR (imprimir) ---------- */
.labels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.label-qr { background: #fff; border: 1px dashed #c7c7cc; border-radius: 12px; padding: 10px 8px; text-align: center; break-inside: avoid; page-break-inside: avoid; }
.label-qr .lh { font-size: 9px; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.label-qr img { width: 100%; max-width: 150px; display: block; margin: 4px auto; }
.label-qr .lc { font-weight: 700; font-size: 14px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.label-qr .la { font-size: 11px; color: var(--text2); }
.label-qr .lt { font-size: 10px; margin-top: 4px; font-weight: 600; }


/* ---------- Inventario a pantalla completa ---------- */
body.wide main.wrap, body.wide .topbar .wrap { max-width: none; padding-left: 28px; padding-right: 28px; }
.td-actions .row-btns { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }

/* ---------- Buscador de equipo (Registrar servicio) ---------- */
.buscar-eq-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer; margin-bottom: 14px;
  background: rgba(0,113,227,.06); border: 1.5px solid rgba(0,113,227,.25); border-radius: var(--r-md); padding: 14px 16px;
  font: inherit; color: var(--text); transition: background .2s var(--ease), border-color .2s, transform .15s var(--ease);
}
.buscar-eq-btn:hover { background: rgba(0,113,227,.1); border-color: var(--blue); }
.buscar-eq-btn:active { transform: scale(.99); }
.buscar-eq-btn .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--blue); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.buscar-eq-btn b { display: block; font-size: 16px; color: var(--blue); }
.buscar-eq-btn small { color: var(--text2); font-size: 13px; }
.buscar-eq-btn .chev, .eq-result .chev { margin-left: auto; color: #c7c7cc; font-size: 22px; }
.equipo-info { display: flex; gap: 12px; align-items: flex-start; background: rgba(52,199,89,.08); border: 1px solid rgba(52,199,89,.3); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 14px; animation: pop .25s var(--ease); }
.eq-kv { margin: 6px 0 0 !important; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; gap: 4px 14px !important; }
.eq-kv div { font-size: 13px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; animation: fade .2s var(--ease); }
.modal-bg.open { display: flex; }
.modal {
  background: #fff; width: min(760px, 100%); max-height: calc(100vh - 40px); border-radius: var(--r-lg); padding: 20px 22px 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.25); display: flex; flex-direction: column; animation: pop .25s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-size: 20px; margin: 0; }
.modal-results { overflow-y: auto; margin-top: 12px; flex: 1; min-height: 160px; padding: 2px; -webkit-overflow-scrolling: touch; }
.eq-result {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; font: inherit; color: var(--text);
  transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.eq-result:hover { background: #f7faff; border-color: var(--blue); }
.eq-result:active { transform: scale(.99); }
.eq-result .grow { flex: 1; min-width: 0; display: block; }
.eq-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eq-top .code { font-size: 15px; }
.eq-result .eq-kv span, .equipo-info .eq-kv span { display: block; }
#buscar-campo button { padding: 8px 6px; font-size: 13.5px; }


/* ---------- Opciones del equipo (hoja modal) ---------- */
.opts-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; }
.acciones { width: min(460px, 100%); padding: 18px 18px 16px; overflow-y: auto; }
.acciones .grab { display: none; width: 38px; height: 5px; border-radius: 3px; background: #d1d1d6; margin: -6px auto 12px; }
.acc-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.acc-foto { width: 64px; height: 64px; border-radius: 16px; overflow: hidden; flex-shrink: 0; display: grid; place-items: center; background: var(--fill); }
.acc-foto img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.acc-foto .app-icon { width: 64px; height: 64px; border-radius: 16px; font-size: 32px; }
.acc-tit { flex: 1; min-width: 0; }
.acc-tit .code { font-size: 19px; }
.acc-head .icon-btn { align-self: flex-start; background: var(--fill); width: 32px; height: 32px; font-size: 14px; color: var(--text2); }
.acc-datos { background: var(--fill); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px !important; grid-template-columns: repeat(3, minmax(0,1fr)) !important; }
.acc-datos:empty { display: none; }
.opt-list { background: var(--fill); border-radius: var(--r-md); overflow: hidden; margin-bottom: 12px; }
.opt-list form { margin: 0; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; background: transparent; border: 0;
  border-bottom: 1px solid var(--line); font: 500 15.5px var(--font); color: var(--text); text-align: left; cursor: pointer;
  text-decoration: none !important; transition: background .15s;
}
.opt-list > :last-child .opt, .opt-list > .opt:last-child { border-bottom: 0; }
.opt:hover { background: #e9e9ee; }
.opt:active { background: #dedee3; }
.opt .oi { width: 30px; height: 30px; border-radius: 8px; background: #fff; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.opt .chev { margin-left: auto; color: #c7c7cc; font-size: 20px; }
.opt.primary { color: var(--blue); font-weight: 600; }
.opt.warn { color: #c25e00; }
.opt.danger { color: #d70015; }


/* ---------- Login horizontal ---------- */
.login-body { background: radial-gradient(900px 600px at 0% 0%, #dbe9ff 0, transparent 60%), radial-gradient(800px 600px at 100% 100%, #fde3ef 0, transparent 55%), radial-gradient(700px 500px at 100% 0%, #e3fbf1 0, transparent 50%), #f5f5f7; }
.lg-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.lg-card { width: 100%; max-width: 960px; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; border-radius: 28px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.04), 0 30px 80px rgba(20,40,90,.14); animation: pop .5s var(--ease); }
.lg-brand { position: relative; overflow: hidden; color: #fff; padding: 36px 38px; display: flex; flex-direction: column; gap: 26px;
  background: linear-gradient(140deg, #0a84ff 0%, #5e5ce6 48%, #bf5af2 100%); }
.lg-orbs i { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .55; animation: flotar 9s ease-in-out infinite; }
.lg-orbs i:nth-child(1) { width: 260px; height: 260px; right: -80px; top: -70px; background: radial-gradient(circle at 30% 30%, #64d2ff, transparent 65%); }
.lg-orbs i:nth-child(2) { width: 220px; height: 220px; left: -70px; bottom: -60px; background: radial-gradient(circle at 60% 40%, #ff6ec7, transparent 65%); animation-delay: -3s; }
.lg-orbs i:nth-child(3) { width: 140px; height: 140px; right: 30%; bottom: 18%; background: radial-gradient(circle, #30d158, transparent 65%); opacity: .35; animation-delay: -6s; }
@keyframes flotar { 0%,100% { transform: translate(0,0) } 50% { transform: translate(14px,-18px) } }
.lg-logos { position: relative; display: flex; gap: 10px; flex-wrap: wrap; }
.lg-logos span { background: rgba(255,255,255,.95); border-radius: 14px; padding: 8px 12px; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.lg-logos img { height: 46px; max-width: 170px; object-fit: contain; display: block; }
.lg-brand-tx { position: relative; }
.lg-kicker { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.lg-brand h1 { font-size: 40px; line-height: 1.05; font-weight: 800; letter-spacing: -.03em; margin: 10px 0 12px; }
.lg-brand p { margin: 0; opacity: .9; font-size: 14px; max-width: 360px; }
.lg-feats { position: relative; list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lg-feats li { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.lg-feats span { width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 16px; backdrop-filter: blur(6px); }
.lg-form { padding: 40px 40px 30px; display: flex; flex-direction: column; justify-content: center; }
.lg-form h2 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.lg-input { position: relative; }
.lg-input .lg-ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .55; pointer-events: none; z-index: 1; }
.lg-wrap .lg-input input { padding-left: 42px; height: 48px; border-radius: 12px; }
.lg-captcha { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center; }
.lg-captcha img { width: 150px; height: 48px; border-radius: 12px; display: block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.lg-refresh { width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, #ff9f0a, #ff375f); box-shadow: 0 4px 12px rgba(255,55,95,.35); transition: transform .4s var(--ease); }
.lg-refresh:hover { transform: rotate(180deg); }
.lg-captcha .captcha-input { height: 48px; border-radius: 12px; min-width: 0; letter-spacing: .25em; }
.lg-submit { background: linear-gradient(135deg, #0a84ff, #5e5ce6); color: #fff; height: 52px; font-weight: 600; box-shadow: 0 10px 24px rgba(10,132,255,.3); }
.lg-submit:hover { background: linear-gradient(135deg, #0077ed, #4f4ddb); }
.lg-foot { text-align: center; color: var(--text2); font-size: 13px; margin: 22px 0 0; }
@media (max-width: 820px) {
  .lg-wrap { padding: 16px 12px; align-items: flex-start; }
  .lg-card { grid-template-columns: 1fr; border-radius: 24px; }
  .lg-brand { padding: 24px 22px; gap: 16px; }
  .lg-brand h1 { font-size: 30px; margin: 6px 0 6px; }
  .lg-brand h1 br { display: none; }
  .lg-feats { display: none; }
  .lg-logos img { height: 38px; max-width: 140px; }
  .lg-form { padding: 24px 20px 22px; }
  .lg-captcha { grid-template-columns: 1fr auto; }
  .lg-captcha img { width: 100%; max-width: 220px; height: 56px; }
  .lg-captcha .captcha-input { grid-column: 1 / -1; }
}

/* ---------- Escritorio grande ---------- */
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ficha { grid-template-columns: 1fr; }
  .labels { grid-template-columns: repeat(3, 1fr); }
}

/* =========================================================================
   Celular (≤ 760 px)
   ========================================================================= */
@media (max-width: 760px) {
  body { font-size: 15px; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  body.public-body, body.no-tabbar { padding-bottom: 0; }
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 18px; }
  .topbar .nav { display: none; }
  .topbar .hide-m { display: none; }
  .brand span { font-size: 16px; }
  .page-head h1, .h1 { font-size: 30px; }
  .page-head { margin-bottom: 16px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  h2.section { font-size: 20px; margin-top: 28px; }
  .card { padding: 18px; border-radius: 18px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .cat-card { padding: 16px; gap: 10px; }
  .cat-card .big { font-size: 26px; }
  .app-icon { width: 46px; height: 46px; font-size: 24px; border-radius: 12px; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .pwd-rules { grid-template-columns: 1fr; }

  /* 16px para que el iPhone no haga zoom */
  input[type=text], input[type=password], input[type=date], input[type=number], input[type=search],
  input[type=email], input[type=datetime-local], select, textarea { font-size: 16px; padding: 12px 14px; }

  form .actions .btn.lg { flex: 1 1 100%; }
  .tipo-grid { grid-template-columns: repeat(2, 1fr); }
  .tipo-opt span { padding: 16px 8px; font-size: 15px; }

  .search { max-width: none; width: 100%; }
  .toolbar .segmented { width: 100%; }
  .toolbar .segmented > * { flex: 1; }

  /* Tablas → tarjetas */
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .card.pad0:has(.tbl.cards) { background: transparent; box-shadow: none; overflow: visible; }
  .tbl.cards tr { background: #fff; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 12px; padding: 10px 14px; position: relative; border-left: 4px solid transparent; }
  .tbl.cards tr.vencido-row { border-left-color: var(--red); background: #fff; }
  .tbl.cards tr.porvencer-row { border-left-color: var(--orange); }
  .tbl.cards td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .tbl.cards td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; text-align: left; flex-shrink: 0; }
  .tbl.cards td[data-label=""]::before, .tbl.cards td:not([data-label])::before { display: none; }
  .tbl.cards td.td-photo { position: absolute; top: 12px; right: 12px; width: auto; padding: 0; }
  .tbl.cards td.td-main { justify-content: flex-start; text-align: left; font-size: 16px; padding-right: 52px; }
  .tbl.cards td.td-actions { justify-content: flex-end; }

  .tl-item { grid-template-columns: 48px 1fr; gap: 12px; padding: 14px; border-radius: 18px; }
  .tl-date .day { font-size: 26px; }
  .kv { grid-template-columns: 1fr 1fr; }
  .ticket-grid { grid-template-columns: 1fr; }
  .diff-head { grid-template-columns: 1fr auto; }
  .diff-head .d-date { grid-column: 1 / -1; font-size: 12px; }
  .diff-table td:first-child { width: 110px; }
  .flashes { top: 10px; }
  .toast { left: 12px; right: 12px; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); max-width: none; }
  .labels { grid-template-columns: repeat(2, 1fr); }

  body.wide main.wrap { padding-left: 16px; padding-right: 16px; }
  .tbl.cards td.td-actions .row-btns { width: 100%; justify-content: space-between; }
  .tbl.cards td.td-actions .row-btns .btn { flex: 1; }
  .modal-bg { padding: 0; align-items: stretch; }
  .modal { width: 100%; max-height: none; height: 100%; border-radius: 0; padding: calc(14px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom)); animation: up .3s var(--ease); }
  #buscar-campo button { font-size: 12.5px; padding: 8px 2px; }
  .eq-kv { grid-template-columns: 1fr 1fr !important; }

  .acciones-bg { align-items: flex-end; }
  .modal.acciones { height: auto; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .acciones .grab { display: block; }
  .acc-datos { grid-template-columns: 1fr 1fr !important; }
  .opt { padding: 15px 14px; font-size: 16px; }

  /* Barra inferior iOS */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.8); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid rgba(0,0,0,.1);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: var(--tab-h); color: var(--gray); font: 500 10.5px var(--font); background: none; border: 0; cursor: pointer; text-decoration: none !important;
  }
  .tabbar .ti { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
  .tabbar .active { color: var(--blue); }
  .tabbar .active .ti { filter: none; opacity: 1; }
  .tabbar .plus { justify-content: flex-start; padding-top: 4px; }
  .tabbar .plus span.circle { width: 52px; height: 52px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 30px; font-weight: 300; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,113,227,.4); margin-top: -14px; }
  .tabbar .badge { top: 6px; right: calc(50% - 22px); }
}

/* =========================================================================
   Impresión
   ========================================================================= */
@media print {
  .topbar, .tabbar, .flashes, .toast, .no-print, .actions, .btn { display: none !important; }
  body { background: #fff; padding: 0; }
  main.wrap { padding: 0; max-width: none; }
  .card { box-shadow: none; }
  .labels { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .label-qr { border: 1px dashed #999; }
}
