:root {
  --bg: #0e1113;
  --panel: #171b1f;
  --panel-2: #1d2227;
  --line: #2a3138;
  --text: #e8edf2;
  --muted: #93a1ad;
  --accent: #f5a524;
  --accent-ink: #17120a;
  --ok: #22c55e;
  --err: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(120% 60% at 50% 0%, #1a2026 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  overscroll-behavior: none;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(76px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .2px;
}

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 165, 36, .15);
}

.net {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.net.ok { color: #6ee7a2; border-color: rgba(34, 197, 94, .45); }
.net.bad { color: #fca5a5; border-color: rgba(239, 68, 68, .45); }

.chips-top { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 55%; }

main { flex: 1; }

.tab { display: none; }
.tab.active { display: block; animation: fade .18s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Boton de escaneo ---------- */
.scan-btn {
  width: 100%;
  height: 74px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffb747, var(--accent));
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .1px;
  box-shadow: 0 10px 24px -12px rgba(245, 165, 36, .70);
  cursor: pointer;
}

.scan-btn:active { transform: translateY(1px) scale(.998); }

.scan-ico {
  width: 26px; height: 26px;
  border: 2.5px solid var(--accent-ink);
  border-radius: 6px;
  position: relative;
  opacity: .85;
}
.scan-ico::after {
  content: "";
  position: absolute;
  left: 3px; right: 3px; top: 50%;
  height: 2.5px;
  background: var(--accent-ink);
  border-radius: 2px;
}

.manual { display: flex; gap: 8px; margin-top: 12px; }

input, select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

input:focus, select:focus { border-color: var(--accent); }

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 16px;
  height: 50px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.ghost:active { background: var(--panel-2); }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 12px;
  height: 50px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.primary:active { filter: brightness(.95); }
.primary:disabled { opacity: .5; }

/* ---------- Tarjetas ---------- */
.card {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}

.kv { margin: 0 0 12px; }
.kv .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 4px;
}
.kv .v {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .5px;
  word-break: break-all;
}
.kv .v.small { font-size: 15px; font-weight: 500; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.badge.ok { background: rgba(34, 197, 94, .14); color: #6ee7a2; }
.badge.warn { background: rgba(245, 165, 36, .14); color: #ffc46b; }
.badge.err { background: rgba(239, 68, 68, .14); color: #fca5a5; }

.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  word-break: break-all;
  color: #cfe0ee;
}

.row { display: flex; gap: 10px; margin-top: 14px; }
.row > * { flex: 1; }

.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.field input, .field select { margin-top: 6px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  flex: 1;
  min-width: 72px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip:active { border-color: var(--accent); color: var(--accent); }

.small { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; }

.hint {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 12px;
}

/* ---------- Lista / busqueda ---------- */
.search { margin-top: 4px; }

.list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.item:active { background: var(--panel-2); }

.item .vin {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
  letter-spacing: .4px;
}
.item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Tabs inferiores ---------- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(14, 17, 19, .92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tabs button {
  flex: 1;
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.tabs button.active { color: var(--accent); background: rgba(245, 165, 36, .08); }

/* ---------- Escaner ---------- */
.scanner {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner video { width: 100%; height: 100%; object-fit: cover; }

.frame {
  position: absolute;
  width: 74%; height: 34%;
  border: 3px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .45);
}

.scan-help {
  position: absolute;
  bottom: 110px;
  width: 100%;
  text-align: center;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 1px 6px #000;
}

.close {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 12px;
  background: #232a31;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 60;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(239, 68, 68, .5); }
.toast.ok { border-color: rgba(34, 197, 94, .5); }

.hidden { display: none !important; }

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: rot .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes rot { to { transform: rotate(360deg); } }
