/* Sistema QR de máquinas · estilos. Mobile-first; sin dependencias. */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --navy: #0f172a;
  --accent: #d97706;
  --accent-ink: #92400e;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info-bg: #e0f2fe;
  --wa: #1fa855;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 20px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0 0 0.4rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0.3rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.right { text-align: right; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 0.8rem; }
.mb { margin-bottom: 0.8rem; }

/* Cabecera */
.top {
  background: var(--navy);
  color: #fff;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.top .brand { font-weight: 700; letter-spacing: 0.01em; }
.top .brand small { display: block; font-weight: 400; opacity: 0.75; font-size: 0.75rem; }
.top a { color: #fff; text-decoration: none; }
.top .user { font-size: 0.85rem; opacity: 0.85; }

/* Navegación del panel */
.nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  background: #1e293b;
  padding: 0.4rem 0.6rem;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 0.9rem;
}
.nav a.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Contenido */
.wrap { max-width: 720px; margin: 0 auto; padding: 1rem; padding-bottom: 6rem; }
.wrap.wide { max-width: 1040px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 0.9rem;
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.warn { border-left: 5px solid var(--warn); }
.card.bad { border-left: 5px solid var(--bad); }
.card.ok { border-left: 5px solid var(--ok); }

.chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--line);
  color: var(--ink);
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: #075985; }
.chip.demo { background: #ede9fe; color: #5b21b6; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.8rem; font-size: 0.95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.accent { background: var(--accent); }
.btn.wa { background: var(--wa); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad-bg); }
.btn.block { width: 100%; }
.btn.sm { padding: 0.4rem 0.7rem; min-height: 36px; font-size: 0.85rem; border-radius: 10px; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.btn-row .btn { flex: 1 1 auto; }

/* Formularios */
label.f { display: block; margin-bottom: 0.7rem; font-size: 0.9rem; color: var(--muted); }
label.f > span { display: block; margin-bottom: 0.2rem; }
label.f.req > span::after { content: " *"; color: var(--bad); }
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; margin: 0.6rem 0; font-size: 0.9rem; }
.check input { width: 1.25rem; height: 1.25rem; min-height: 0; margin-top: 0.1rem; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.7rem; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.9rem 0.2rem; margin: 0 0 0.9rem; }
legend { font-weight: 600; font-size: 0.95rem; padding: 0 0.3rem; }
.error { color: var(--bad); background: var(--bad-bg); padding: 0.6rem 0.8rem; border-radius: 10px; margin: 0.6rem 0; font-size: 0.9rem; }
.notice { color: #075985; background: var(--info-bg); padding: 0.6rem 0.8rem; border-radius: 10px; margin: 0.6rem 0; font-size: 0.9rem; }

/* Repuestos rápidos */
.quick { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.3rem 0 0.6rem; }
.quick button {
  font: inherit; font-size: 0.8rem; padding: 0.3rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; min-height: 32px;
}
.part-row { display: grid; grid-template-columns: 1fr 72px 40px; gap: 0.4rem; margin-bottom: 0.4rem; align-items: center; }
.part-row input { min-height: 40px; padding: 0.45rem 0.6rem; }
.part-row button { font: inherit; border: 0; background: transparent; color: var(--bad); font-size: 1.2rem; cursor: pointer; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 0.7rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0.2rem; }
.list a.item { display: block; color: inherit; text-decoration: none; }
.item-title { font-weight: 600; }
.item-sub { color: var(--muted); font-size: 0.85rem; }
.hist li { display: grid; grid-template-columns: 92px 1fr; gap: 0.6rem; }
.hist .fecha { font-weight: 600; font-size: 0.9rem; }
.hist .tipo { font-weight: 600; }
.hist .parts { font-size: 0.85rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tbl-wrap { overflow-x: auto; }

/* Ficha pública */
.hero { display: flex; gap: 0.9rem; align-items: flex-start; }
.hero img, .hero .noimg {
  width: 96px; height: 96px; border-radius: 12px; object-fit: cover; flex: none;
  background: #e5e7eb; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 2rem;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.stat { padding: 0.7rem 0.8rem; border-radius: 12px; background: var(--bg); }
.stat .lbl { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat .val { font-weight: 700; font-size: 1.05rem; }
.stat.ok { background: var(--ok-bg); color: var(--ok); }
.stat.warn { background: var(--warn-bg); color: var(--warn); }
.stat.bad { background: var(--bad-bg); color: var(--bad); }
.code-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 0.04em; }

/* Barra fija del técnico */
.staffbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff; border-top: 1px solid var(--line);
  padding: 0.6rem 0.8rem calc(0.6rem + env(safe-area-inset-bottom));
  display: flex; gap: 0.5rem; overflow-x: auto; justify-content: center;
}
.staffbar .btn { flex: 1 1 0; white-space: nowrap; padding: 0.6rem 0.6rem; font-size: 0.85rem; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 1rem 1rem 1.2rem;
}
@media (min-width: 640px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 18px; }
}
.modal h2 { display: flex; justify-content: space-between; align-items: center; }
.modal .x { font: inherit; border: 0; background: transparent; font-size: 1.4rem; cursor: pointer; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 0.7rem 1rem; border-radius: 12px; font-size: 0.9rem; z-index: 60;
  box-shadow: var(--shadow); max-width: 92vw;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Resumen */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; }
.tile { background: #fff; border-radius: 12px; padding: 0.8rem; box-shadow: var(--shadow); }
.tile .n { font-size: 1.6rem; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 0.8rem; }
.tile.bad .n { color: var(--bad); }
.tile.warn .n { color: var(--warn); }

/* Login */
.login { max-width: 380px; margin: 8vh auto; }
.login .logo { text-align: center; margin-bottom: 1rem; }

.qr-preview { width: 160px; height: 160px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.search { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.search input { flex: 1; }
.empty { color: var(--muted); text-align: center; padding: 1.2rem 0; }
