/* registro-validadores — estilos unificados y adaptables */
:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --card: #fff;
  --text: #223446;
  --muted: #8292a0;
  --line: #e2e9ef;
  --primary: #175d90;
  --primary-hover: #104972;
  --danger: #b83c48;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { width: 100%; -webkit-text-size-adjust: 100%; }
body {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: not-allowed; }
input, select, textarea, button { min-width: 0; }
input, select, textarea { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(22px, 2.3vw, 28px); margin: 5px 0; line-height: 1.2; }
h2 { font-size: clamp(19px, 2vw, 23px); margin: 0 0 7px; line-height: 1.25; }
h3 { font-size: 16px; margin: 0; }
p { line-height: 1.5; }
:focus-visible { outline: 2px solid #4380ac; outline-offset: 2px; }

/* Cabecera y contenedor */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: block;
  width: 100%;
  min-height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 1240px);
  min-height: 64px;
  margin: 0 auto;
  padding: 8px 24px;
}
.brand {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.2px;
}
.brand i { flex: 0 0 auto; font-size: 22px; color: var(--primary); }
.brand span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.session-tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.session-status, .topbar-caption {
  max-width: 200px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.session-status.online { color: #26805b; }
.topbar-caption { margin-left: auto; }
.nav-back, #btnVolver { flex: 0 0 auto; }
.container, .wrap {
  width: min(100%, 1240px);
  max-width: 100%;
  margin: 0 auto;
  padding: 30px 24px 48px;
}
.view { min-width: 0; animation: aparecer .16s ease; }
@keyframes aparecer { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Botones y encabezados */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-width: 100%;
  padding: 9px 14px;
  background: var(--card);
  color: #1c5c87;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
  text-align: center;
  line-height: 1.25;
  transition: background .12s ease;
}
.btn i { flex: 0 0 auto; font-size: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: #cddbe6; }
.btn-outline:hover { background: #edf5fa; }
.btn-ghost { color: #637589; background: transparent; }
.btn-ghost:hover { background: #edf2f6; }
.btn-sm, .btn.small { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.btn-mini { min-height: 36px; padding: 6px 10px; font-size: 12px; }
.btn-icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #627789;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 17px;
}
.btn-icon:hover, .btn-mini:hover { background: #edf3f7; }
.danger { color: var(--danger) !important; }
.page-heading, .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.page-heading { margin-bottom: 23px; }
.page-heading > div:first-child, .section-header > :first-child { min-width: 0; }
.page-heading p { margin: 5px 0 0; color: var(--muted); }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; color: #859aaf; }
.section-header { margin-bottom: 14px; }
.section-header.separated, .section-header.spaced { margin-top: 26px; }

/* Vistas y tarjetas */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 20px; }
.stat, .panel, .registro-card, .sync-panel {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.stat { padding: 16px 18px; }
.stat span { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.stat strong { display: block; margin-top: 6px; font-size: clamp(19px, 2.4vw, 25px); }
.search {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 45px;
  margin-bottom: 15px;
  padding: 0 14px;
  border: 1px solid #dce5ed;
  border-radius: 11px;
  background: var(--card);
  color: #8795a4;
}
.search input { flex: 1 1 auto; min-width: 0; width: 100%; height: 43px; border: 0; background: transparent; outline: 0; }
.card-list { display: grid; min-width: 0; gap: 12px; }
.registro-card { overflow: hidden; }
.registro-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-width: 0;
  gap: 12px;
  padding: 17px 19px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.registro-link > div:first-child { flex: 1 1 auto; min-width: 0; }
.registro-link strong { display: block; font-size: 15px; overflow-wrap: anywhere; }
.registro-link p { margin: 5px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.registro-link > i { flex: 0 0 auto; color: #94a3af; }
.registro-link:not(.static):hover { background: #f8fbfd; }
.registro-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 12px 7px 19px;
  border-top: 1px solid #edf1f5;
}
.registro-bottom > span { min-width: 0; color: #8190a0; font-size: 12px; overflow-wrap: anywhere; }
.registro-bottom > div { display: flex; flex: 0 0 auto; align-items: center; gap: 3px; }
.panel { padding: 20px; margin-bottom: 17px; }
.datos-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 15px; }
.dato { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dato span { color: #8794a3; font-size: 12px; }
.dato strong { font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; margin-bottom: 17px; }
.two-cols .panel { min-width: 0; margin: 0; }
.mini-item { padding: 9px 0; border-bottom: 1px solid #edf2f6; overflow-wrap: anywhere; font-size: 13px; }
.mini-item:last-child { border: 0; }
.muted { margin: 0; color: #8795a4; font-size: 13px; }
.empty {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  padding: 36px 16px;
  border: 1px dashed #d1dce5;
  border-radius: 12px;
  background: var(--card);
  color: #8493a1;
  text-align: center;
}
.empty i { font-size: 28px; }
.empty strong { color: #566b7d; }
.empty p { margin: 0; font-size: 12px; }

/* Sincronización y herramientas */
.sync-panel { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px; margin-top: 24px; }
.sync-panel > div:first-child { flex: 1 1 auto; min-width: 0; }
.sync-panel p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.sync-buttons { display: flex; flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.global-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid #e1e8ee; }
.global-actions .btn { flex: 0 1 auto; }

/* Modal */
.modal-abierto { overflow: hidden; }
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop { position: absolute; inset: 0; background: #0c203b94; }
.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1150px, 100%);
  min-width: 0;
  max-height: min(92dvh, 940px);
  border-radius: 15px;
  background: var(--card);
  box-shadow: 0 25px 75px #0003;
  overflow: hidden;
}
.modal-header, .modal-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 15px 22px;
  background: var(--card);
}
.modal-header { justify-content: space-between; border-bottom: 1px solid #e7edf2; }
.modal-header h2 { min-width: 0; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.modal-footer { justify-content: flex-end; border-top: 1px solid #e7edf2; }
.modal-fill { flex: 1 1 auto; }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px 24px 24px;
}
.modal-body form { min-width: 0; }
.form-title { margin: 0 0 15px; font-size: 13px; color: #344b5d; }
.form-grid { display: grid; gap: 14px; min-width: 0; margin-bottom: 17px; }
.cols-1, .form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.cols-2, .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3, .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4, .form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5, .form-grid.cols-5 { grid-template-columns: 1.6fr repeat(4, minmax(0, 1fr)); }
.cols-9, .form-grid.cols-9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.form-scroll { width: 100%; max-width: 100%; overflow: visible; }
.form-scroll .cols-9 { min-width: 0; }
.field { position: relative; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { font-size: 12px; color: #637688; font-weight: 650; overflow-wrap: anywhere; }
.field input, .field select, .field textarea {
  display: block;
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 8px 11px;
  border: 1px solid #d5e0e8;
  border-radius: 9px;
  outline: 0;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}
.field textarea { height: auto; min-height: 88px; resize: vertical; }
.field input[readonly], .field input:disabled {
  background: #f1f4f7;
  color: #64748b;
  cursor: not-allowed;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: #4685b0; box-shadow: 0 0 0 3px #4685b018; }
.field input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.field input::-webkit-inner-spin-button, .field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.suggestions {
  position: absolute;
  z-index: 65;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  max-height: min(230px, 37dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #d8e2eb;
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 12px 30px #0002;
}
.suggestion { display: block; width: 100%; min-height: 43px; padding: 10px 12px; border: 0; border-bottom: 1px solid #eef2f5; background: var(--card); text-align: left; white-space: normal; }
.suggestion:hover, .suggestion:focus-visible { background: #f0f6fa; }
.suggestion strong { display: block; font-size: 12px; overflow-wrap: anywhere; }
.suggestion small { display: block; margin-top: 3px; color: #8794a1; overflow-wrap: anywhere; }
.lookup-note { margin: 7px 0 0; color: #7f91a1; font-size: 12px; overflow-wrap: anywhere; }
.form-subsection { margin-top: 14px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 11px; }
.form-subsection h3 { font-size: 13px; }
.line-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; padding: 8px 0; border-bottom: 1px solid #edf1f4; font-size: 12px; }
.line-item > span { min-width: 0; overflow-wrap: anywhere; }
.line-item > div { display: flex; flex: 0 0 auto; gap: 4px; }
.line-item:last-child { border: 0; }
.hint { margin: 6px 0 0; color: #8594a2; font-size: 12px; }

/* Clases anteriores, por si queda algún formulario heredado */
.grid2, .grid3, .grid4, .grid5, .grid7, .grid8, .grid9, .load-row { display: grid; gap: 8px; min-width: 0; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid5 { grid-template-columns: 2fr repeat(4, minmax(0, 1fr)); }
.grid7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.grid8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.grid9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.load-row { grid-template-columns: 2.2fr 1.3fr 1fr 1fr 1.2fr 70px; }
.row-card, .vehicle-card, .card { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--card); }
.actions, .kpi { display: flex; flex-wrap: wrap; gap: 8px; }

/* Tablets y portátiles compactos */
@media (max-width: 1100px) {
  .cols-9, .form-grid.cols-9, .grid9 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .grid8, .grid7 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .load-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .container, .wrap { padding: 24px 18px 38px; }
  .topbar-inner { padding-inline: 18px; }
  .datos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-4, .form-grid.cols-4, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-5, .form-grid.cols-5, .grid5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-5 > .field:first-child, .form-grid.cols-5 > .field:first-child { grid-column: 1 / -1; }
  .sync-panel { align-items: stretch; flex-direction: column; }
  .sync-buttons { justify-content: flex-start; }
}

/* Móviles grandes y tablets verticales */
@media (max-width: 760px) {
  .topbar-inner { min-height: 58px; padding: 7px 14px; gap: 8px; }
  .brand { font-size: 13px; gap: 7px; }
  .brand i { font-size: 19px; }
  .session-status, .topbar-caption { display: none; }
  .container, .wrap { padding: 22px 14px 32px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .page-heading > .btn { width: 100%; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .two-cols { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .panel { padding: 16px; }
  .section-header.separated, .section-header.spaced { margin-top: 22px; }
  .cols-3, .form-grid.cols-3, .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-9, .form-grid.cols-9, .grid9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid8, .grid7 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal-layer { padding: 0; }
  .modal-panel { width: 100%; height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .modal-header { padding: max(12px, env(safe-area-inset-top)) 15px 12px; }
  .modal-body { flex: 1 1 auto; padding: 16px 15px 20px; }
  .modal-footer { flex-wrap: wrap; padding: 12px 15px max(12px, env(safe-area-inset-bottom)); }
  .form-grid { gap: 12px; }
  .form-subsection { padding: 13px; }
  .global-actions .btn { flex: 1 1 145px; }
}

/* Celulares estándar */
@media (max-width: 520px) {
  .container, .wrap { padding: 17px 10px 28px; }
  .topbar-inner { padding-inline: 10px; }
  .session-tools { gap: 5px; }
  #btnSesion { width: 41px; height: 41px; min-height: 41px; padding: 0; gap: 0; font-size: 0; }
  #btnSesion i { font-size: 19px; }
  .brand span { font-size: 12px; }
  .stats { gap: 6px; }
  .stat { padding: 10px 8px; }
  .stat span { font-size: 11px; line-height: 1.25; }
  .stat strong { font-size: 20px; }
  .registro-link { padding: 14px 12px; }
  .registro-link strong { font-size: 14px; }
  .registro-bottom { padding: 6px 8px 6px 12px; }
  .registro-bottom > span { font-size: 11px; }
  .panel { padding: 14px; }
  .datos-grid { gap: 16px 12px; }
  .section-header { flex-wrap: wrap; align-items: flex-start; }
  .section-header > .btn { flex: 1 1 100%; }
  .sync-panel { padding: 15px; }
  .sync-buttons { flex-direction: column; }
  .sync-buttons .btn { width: 100%; }
  .modal-header h2 { font-size: 16px; }
  .modal-footer { display: flex; flex-wrap: wrap; gap: 8px; }
  .modal-fill { display: none; }
  .modal-footer .btn { flex: 1 1 calc(50% - 8px); white-space: normal; min-height: 42px; padding: 8px; font-size: 12px; }
  .cols-9, .form-grid.cols-9, .grid9 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid8, .grid7, .load-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lookup-note { font-size: 11px; }
}

/* Celulares muy pequeños (320-359 px) */
@media (max-width: 359px) {
  .brand { gap: 5px; }
  .brand i { font-size: 17px; }
  .brand span { font-size: 11px; }
  .container, .wrap { padding-inline: 9px; }
  .registro-bottom { flex-wrap: wrap; }
  .registro-bottom > div { margin-left: auto; }
  .datos-grid { grid-template-columns: minmax(0, 1fr); }
  .cols-2, .form-grid.cols-2,
  .cols-3, .form-grid.cols-3,
  .cols-4, .form-grid.cols-4,
  .cols-5, .form-grid.cols-5,
  .cols-9, .form-grid.cols-9,
  .grid2, .grid3, .grid4, .grid5, .grid7, .grid8, .grid9, .load-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .modal-footer .btn { flex-basis: 100%; }
}

/* Móviles en horizontal y equipos con poca altura */
@media (max-height: 550px) and (min-width: 761px) {
  .modal-layer { padding: 8px; }
  .modal-panel { max-height: calc(100dvh - 16px); }
  .modal-header, .modal-footer { padding-block: 9px; }
  .modal-body { padding-block: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  .btn { transition: none; }
}

input::placeholder,
textarea::placeholder {
  text-transform: none !important;
}