:root {
  --bg: #f4f7f9;
  --card: #ffffff;
  --text: #101820;
  --muted: #52616d;
  --line: #d7e0e7;
  --primary: #0756a3;
  --primary-deep: #07335d;
  --primary-text: #ffffff;
  --ok: #17824b;
  --warn: #b76a00;
  --bad: #b42318;
  --pending: #fff4d6;
  --radius-control: 10px;
  --radius-surface: 14px;
  --shadow: 0 14px 38px rgba(7, 51, 93, .1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, "Avenir Next", "Segoe UI", system-ui, sans-serif;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}
::selection { color: #fff; background: var(--primary); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 22px 18px; }
h1, h2, h3 { letter-spacing: -.02em; }
h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.05; }
h3 { margin: 0 0 10px; font-size: 1.05rem; }
small { color: var(--muted); font-weight: normal; }

/* Barra superior */
.top {
  position: sticky; top: 0; z-index: 10; min-height: 58px; background: var(--primary-deep); color: #fff;
  display: flex; gap: 16px; align-items: center; padding: 9px max(18px, calc((100vw - 1004px) / 2));
  box-shadow: 0 8px 24px rgba(7, 51, 93, .16);
}
.top a { color: rgba(255,255,255,.78); text-decoration: none; }
.top a:hover { color: #fff; }
.brand-app { display: inline-flex; align-items: center; gap: 12px; color: #fff !important; font-weight: 800; }
.brand-app img { width: 148px; height: auto; padding: 3px 6px; border-radius: 7px; background: #fff; }
.brand-app span { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.25); }
.top-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.volver::before { content: "←"; margin-right: 7px; }

/* Pestañas */
.tabs {
  position: sticky; top: 58px; z-index: 9; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line);
  display: flex; overflow-x: auto; padding: 0 max(8px, calc((100vw - 1024px) / 2));
  scrollbar-width: thin;
}
.tabs button {
  flex: 0 0 auto; border: 0; background: none; padding: 14px 15px; font: inherit; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs i { font-style: normal; font-size: .75rem; background: var(--bad); color: #fff; border-radius: 10px; padding: 1px 6px; margin-left: 4px; }
.tabs i:empty { display: none; }
.tabs i.ok { background: var(--ok); }
.tab { display: none; }
.tab.on { display: block; }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-surface); padding: 18px; margin-bottom: 14px; }
.card.items header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.card.items header h3 { margin: 0; flex: 1 1 auto; }
.nota { color: var(--muted); margin: 0 0 10px; font-size: .9rem; }
.fijo { font-weight: 600; background: #f9fafb; border: 1px dashed var(--line); padding: 8px 10px; border-radius: 8px; }

/* Campos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.campo { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.campo span { font-weight: 600; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; font: inherit; font-size: 16px; color: var(--text); padding: 10px 11px; border: 1px solid #bac7d1; border-radius: var(--radius-control); background: #fff;
}
input[type=text], textarea { text-transform: uppercase; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid rgba(7,86,163,.16); outline-offset: 0; }
.req { color: var(--bad); }
.pendiente { background: var(--pending) !important; }
.pct { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.pct input { width: 80px; }

/* Filas con selector */
.fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.fila .et { font-size: .9rem; flex: 1 1 180px; }
.fila select { width: 120px; }
.fila.pendiente { background: var(--pending); margin: 0 -14px; padding: 7px 14px; }

/* Botones segmentados */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 10px; border: 1px solid #bac7d1; border-radius: 9px; font-size: .8rem; font-weight: 700;
  cursor: pointer; user-select: none; background: #fff; color: #374151; min-width: 48px; text-align: center;
}
.seg input:focus-visible + label { outline: 2px solid var(--primary); }
.seg input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg input:checked + label.op-bueno, .seg input:checked + label.op-no, .seg input:checked + label.op-activo,
.seg input:checked + label.op-vigente, .seg input:checked + label.op-estandar { background: var(--ok); border-color: var(--ok); }
.seg input:checked + label.op-malo, .seg input:checked + label.op-malareparacion, .seg input:checked + label.op-si,
.seg input:checked + label.op-inactivo, .seg input:checked + label.op-vencido, .seg input:checked + label.op-noestandar { background: var(--bad); border-color: var(--bad); }
.seg input:checked + label.op-repintado, .seg input:checked + label.op-rayon, .seg input:checked + label.op-normal { background: var(--warn); border-color: var(--warn); }
.seg input:checked + label.op-noaplica { background: #4b5563; border-color: #4b5563; }

/* Accesorios */
.acc-h, .acc-f { display: grid; grid-template-columns: 2fr 1.3fr 1fr; gap: 6px; margin-bottom: 6px; }
.acc-h span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.acc-t { text-align: right; margin-top: 6px; }

/* Fotos */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.foto .et { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.marco { position: relative; background: #f8fafb; border: 2px dashed #bac7d1; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.marco img { width: 100%; height: 100%; object-fit: contain; display: none; }
.marco img[src] { display: block; }
.marco img[src] + .vacio { display: none; }
.marco .vacio { color: var(--muted); font-size: .85rem; }
.foto.pendiente .marco { border-color: var(--warn); background: var(--pending); }
.foto .acciones { display: flex; gap: 6px; margin-top: 6px; }

/* Botones */
.btn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 10px 16px;
  border: 1px solid #bac7d1; border-radius: var(--radius-control); background: #fff; color: var(--text); font: inherit; font-weight: 750;
  text-decoration: none; cursor: pointer; transition: background .16s ease-out, border-color .16s ease-out, transform .16s ease-out;
}
.btn:hover { border-color: #90a2b0; background: #f7f9fa; }
.btn:active { transform: translateY(1px); }
.btn.primario { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primario:hover { background: var(--primary-deep); border-color: var(--primary-deep); }
.btn.mini { min-height: 44px; padding: 8px 11px; font-size: .8rem; }
.btn:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid #57a7f5; outline-offset: 3px; }

/* Barra inferior */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(255,255,255,.98); border-top: 1px solid var(--line);
  display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px max(16px, calc((100vw - 1004px) / 2));
  box-shadow: 0 -8px 24px rgba(7,51,93,.08);
}
#faltan { margin-right: auto; font-size: .85rem; color: var(--bad); }
#faltan.ok { color: var(--ok); }

/* Avisos y listas */
.aviso { max-width: 1040px; margin: 10px auto 0; padding: 11px 16px; border-radius: 10px; }
.aviso.ok { background: #dcfce7; color: var(--ok); }
.aviso.error { background: #fee2e2; color: var(--bad); }
.faltan { columns: 2 260px; background: var(--card); border-radius: 12px; padding: 14px 14px 14px 32px; }
.panel { padding-top: 34px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head .nota { margin-top: 8px; }
.search-wrap { max-width: 560px; margin-bottom: 22px; }
.search-wrap label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .8rem; font-weight: 750; }
.lista .item { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--card); border-bottom: 1px solid var(--line); padding: 16px 2px; }
.item-id { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 3px 12px; }
.item-number { color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.item-id strong { font-size: 1.2rem; letter-spacing: .05em; }
.item-id small { grid-column: 1 / -1; }
.lista small { display: block; }
.lista .acciones { display: flex; gap: 6px; }
.empty { max-width: 660px; padding: 46px 0; border-top: 1px solid var(--line); }
.empty h2 { margin: 0 0 8px; font-size: 1.5rem; }
.empty p { margin: 0 0 20px; color: var(--muted); }
.no-results { padding: 30px 0; color: var(--muted); }
p.acciones { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .barra .btn { padding: 10px 12px; font-size: .85rem; }
  #faltan { display: none; }
  .seg label { padding: 8px 9px; }
  .brand-app img { width: 126px; }
  .brand-app span { display: none; }
  .top-actions a:first-child { display: none; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head .btn { width: 100%; }
  .lista .item { align-items: stretch; flex-direction: column; padding: 17px 0; }
  .lista .acciones .btn { flex: 1; }
}

/* Salir y pantalla de ingreso */
.top .salir { margin-left: auto; font-size: .9rem; }
.login { max-width: 380px; }
.login-page { min-height: 100svh; background: var(--primary-deep); }
.login-page .top { box-shadow: none; border-bottom: 1px solid rgba(255,255,255,.14); }
.caja-login { background: var(--card); border-radius: 14px; padding: 28px; margin-top: clamp(34px, 9vh, 90px);
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.caja-login h1 { margin: -4px 0 4px; font-size: 1.75rem; line-height: 1.08; }
.login-label { margin: 0; color: var(--primary); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.caja-login label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.caja-login input[type=text], .caja-login input[type=password] { text-transform: none; }
.caja-login .aviso { margin: 0; }
.caja-login .btn { justify-content: center; }

.dlg {
  width: min(420px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
}
.dlg::backdrop { background: rgba(7, 51, 93, .45); }
.dlg-caja {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.dlg-caja h2 { margin: 0; font-size: 1.35rem; }
.dlg-acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.dlg-acciones .btn { flex: 1 1 140px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
