/* ============================================================================
   SISAPR — Sistema de diseño (basado en el mock HydroTrack)
   Paleta: fondo verde-negro profundo + acento lima neón + textos verde-gris
   Mobile-first: pensado para teléfonos en terreno.
   ========================================================================== */

:root {
  --bg: #0a0e09;
  --bg-soft: #0e130c;
  --surface: #131a11;
  --surface-2: #182013;
  --surface-3: #1e2818;
  --border: #26311e;
  --border-strong: #33411f;
  --text: #e9f2dd;
  --text-muted: #9aab8c;
  --text-faint: #6e7f62;
  --lime: #c9f73f;
  --lime-bright: #e2ff6a;
  --lime-soft: rgba(201, 247, 63, 0.12);
  --lime-border: rgba(201, 247, 63, 0.35);
  --on-lime: #141a06;
  --green: #7cefa0;
  --green-soft: rgba(124, 239, 160, 0.12);
  --amber: #ffc864;
  --amber-soft: rgba(255, 200, 100, 0.12);
  --red: #ff7a6b;
  --red-soft: rgba(255, 122, 107, 0.12);
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --nav-h: 64px;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(201, 247, 63, 0.06), transparent 60%),
    radial-gradient(circle at 1px 1px, rgba(154, 171, 140, 0.05) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  overscroll-behavior-y: contain;
}

#app { max-width: 520px; margin: 0 auto; }

/* ------------------------------- topbar ---------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(10, 14, 9, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--lime-soft);
  border: 1px solid var(--lime-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lime);
  flex: none;
}

.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
}

.chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.chip-lime  { color: var(--lime);  border-color: var(--lime-border);  background: var(--lime-soft); }
.chip-lime .dot  { background: var(--lime); }
.chip-green { color: var(--green); border-color: rgba(124,239,160,.35); background: var(--green-soft); }
.chip-green .dot { background: var(--green); }
.chip-amber { color: var(--amber); border-color: rgba(255,200,100,.35); background: var(--amber-soft); }
.chip-amber .dot { background: var(--amber); }
.chip-red   { color: var(--red);   border-color: rgba(255,122,107,.35); background: var(--red-soft); }
.chip-red .dot   { background: var(--red); }

button.chip { cursor: pointer; }

/* -------------------------------- vistas --------------------------------- */

.view {
  padding: 14px 14px calc(var(--nav-h) + 34px);
  animation: fadeUp 0.22s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.view-head { margin: 4px 0 12px; }

.h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.h2 { font-size: 16px; font-weight: 700; margin: 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }

.label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 6px;
}

.label-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--lime);
  border: 1px solid var(--lime-border);
  background: var(--lime-soft);
  border-radius: 999px;
  padding: 3px 8px;
}

/* -------------------------------- tarjetas -------------------------------- */

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.card + .card, .stack > * + * { margin-top: 12px; }

.card-lime {
  border-color: var(--lime-border);
  background: linear-gradient(180deg, rgba(201,247,63,.08), var(--surface));
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.divider { height: 1px; background: var(--border); margin: 12px 0; border: 0; }

/* --------------------------------- botones -------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  min-height: 46px;
  padding: 12px 18px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform .06s ease, filter .15s ease, background .15s ease;
  user-select: none;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--lime-bright), var(--lime));
  color: var(--on-lime);
  box-shadow: 0 6px 18px rgba(201, 247, 63, 0.22);
}
.btn-primary:disabled { box-shadow: none; }

.btn-ghost { background: #2a3a20; border-color: #4f6638; color: var(--text); }
.btn-ghost:hover { background: #34482a; border-color: #62804a; color: #fff; }

.btn-danger { background: var(--red-soft); border-color: rgba(255,122,107,.4); color: var(--red); }

.btn-sm { min-height: 34px; padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

/* --------------------------------- formularios ---------------------------- */

.field { margin-bottom: 12px; }

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 13px;
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.textarea { min-height: 74px; resize: vertical; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(201, 247, 63, 0.15);
}

.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.input-mono { font-family: var(--mono); letter-spacing: .5px; }

.input-err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,122,107,.15); }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aab8c' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.search-box { position: relative; }
.search-box .input { padding-left: 38px; }
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}

/* ------------------------------- listas / filas --------------------------- */

.row-list { display: flex; flex-direction: column; gap: 9px; }

.row-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: border-color .12s ease, transform .06s ease;
}

.row-card:active { transform: scale(.985); border-color: var(--lime-border); }

.row-ic {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  background: var(--lime-soft);
  border: 1px solid var(--lime-border);
  color: var(--lime);
  display: flex; align-items: center; justify-content: center;
}

.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row-side { color: var(--text-faint); flex: none; display: flex; align-items: center; gap: 8px; }

/* --------------------------------- grillas -------------------------------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.stat {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.stat-num { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--lime); }
.stat-num.small-num { font-size: 18px; }
.stat-lab { font-family: var(--mono); font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }

/* ------------------------------- barra inferior --------------------------- */

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  background: rgba(12, 16, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 9px;
  background: none;
  border: 0;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--lime); }
.nav-item.active::before {
  content: "";
  position: absolute;
  top: 0; left: 22%; right: 22%;
  height: 2px;
  background: var(--lime);
  border-radius: 0 0 3px 3px;
}

.nav-badge {
  position: absolute;
  top: 5px; right: calc(50% - 22px);
  min-width: 16px; height: 16px;
  border-radius: 999px;
  background: var(--amber);
  color: #201502;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* --------------------------------- login ---------------------------------- */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
}

.login-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--lime-soft);
  border: 1px solid var(--lime-border);
  color: var(--lime);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 34px rgba(201, 247, 63, 0.16);
}

.brand-title {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 7px;
  margin: 14px 0 2px;
  color: var(--text);
}

.brand-tagline {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
}

.login-card { width: 100%; max-width: 380px; margin-top: 26px; }

.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.form-error {
  display: none;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  border: 1px solid rgba(255,122,107,.4);
  color: var(--red);
  font-size: 13px;
}
.form-error.show { display: block; }

.foot-note {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.8;
}

/* --------------------------------- switch --------------------------------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}

.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 19px; height: 19px;
  left: 2px; top: 2px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .15s ease, background .15s ease;
}
.switch input:checked + .switch-track { background: var(--lime-soft); border-color: var(--lime-border); }
.switch input:checked + .switch-track::before { transform: translateX(19px); background: var(--lime); }

/* --------------------------------- toast ---------------------------------- */

.toast-zone {
  position: fixed;
  top: 14px; left: 0; right: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 14px;
}

.toast {
  max-width: 480px;
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--lime-border);
  border-radius: 13px;
  color: var(--text);
  padding: 12px 15px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toastIn .25s ease;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.toast svg { flex: none; margin-top: 1px; }
.toast-ok   { border-color: rgba(124,239,160,.45); }
.toast-ok svg   { color: var(--green); }
.toast-err  { border-color: rgba(255,122,107,.45); }
.toast-err svg  { color: var(--red); }
.toast-info { border-color: var(--lime-border); }
.toast-info svg { color: var(--lime); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}

.toast.out { opacity: 0; transition: opacity .3s ease; }

/* --------------------------------- modal ---------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 8, 4, 0.72);
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .18s ease;
  padding: 0;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
  max-height: 86vh;
  max-height: 86dvh;
  overflow: auto;
}

@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-title { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.modal-text { color: var(--text-muted); font-size: 14px; margin: 0 0 16px; white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ------------------------------ consumo preview --------------------------- */

.consumo-box {
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: center;
}

.consumo-num {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--lime);
  letter-spacing: 1px;
}

.consumo-num.neg { color: var(--red); }
.consumo-sub { font-family: var(--mono); font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.gps-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 6px 0;
}
.gps-line .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}
.gps-line.ok .dot { background: var(--green); animation: pulse 1.8s ease infinite; }
.gps-line.err .dot { background: var(--red); }
.gps-line.wait .dot { background: var(--amber); animation: pulse 1.1s ease infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,247,63,.35); }
  50% { box-shadow: 0 0 0 6px rgba(201,247,63,0); }
}

/* ------------------------------- historial -------------------------------- */

.hist-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
}

.hist-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hist-cliente { font-weight: 600; font-size: 13.5px; }
.hist-consumo { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--lime); grid-column: 2; grid-row: 2 / span 2; align-self: center; }
.hist-sub { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.hist-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* --------------------------- detalle clave/valor -------------------------- */

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.kv-item { min-width: 0; }
.kv-val { font-size: 13.5px; color: var(--text); word-break: break-word; }
.kv-val.mono { font-size: 12.5px; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--surface-3);
}
.badge-green { color: var(--green); border-color: rgba(124,239,160,.35); background: var(--green-soft); }
.badge-amber { color: var(--amber); border-color: rgba(255,200,100,.35); background: var(--amber-soft); }
.badge-lime { color: var(--lime); border-color: var(--lime-border); background: var(--lime-soft); }
.badge-red { color: var(--red); border-color: rgba(255,122,107,.35); background: var(--red-soft); }

/* ------------------------------- QR scanner ------------------------------- */

.qr-video-box {
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-video-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --------------------------------- varios --------------------------------- */

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 34px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
}
.empty svg { width: 34px; height: 34px; margin-bottom: 8px; opacity: .7; }

.banner {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.banner svg { flex: none; margin-top: 1px; }
.banner-warn { background: var(--amber-soft); border: 1px solid rgba(255,200,100,.35); color: var(--amber); }
.banner-info { background: var(--lime-soft); border: 1px solid var(--lime-border); color: var(--text-muted); }

.spin {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: giro .7s linear infinite;
  display: inline-block;
  vertical-align: -3px;
}
@keyframes giro { to { transform: rotate(360deg); } }

.back-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.back-btn {
  background: none; border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none;
}

.list-note { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); margin: 10px 2px 8px; }

hr.spacer { border: 0; height: 10px; }

.center { text-align: center; }
.mt-6 { margin-top: 6px; }
.mt-12 { margin-top: 12px; }
.mt-18 { margin-top: 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

@media (min-width: 480px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; }
}
