@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand */
  --brand-bg:       #0d1b2e;
  --brand-mid:      #1a2e47;
  --brand-accent:   #1d6fd8;
  --brand-accent-h: #1458b0;
  --brand-amber:    #f59e0b;

  /* Surface */
  --bg:     #eef2f7;
  --panel:  #ffffff;
  --panel2: #f7f9fc;

  /* Text */
  --text:   #0d1b2e;
  --muted:  #5a6a7e;
  --light:  #ffffff;

  /* Border */
  --border:       #d5dde7;
  --border-focus: #1d6fd8;

  /* State colours */
  --ok:     #059669;
  --ok-bg:  #d1fae5;
  --warn:   #d97706;
  --warn-bg:#fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info:   #0284c7;
  --info-bg:#e0f2fe;

  /* Shape */
  --radius:    12px;
  --radius-sm:  8px;
  --shadow-xs: 0 1px 3px rgba(0,0,0,.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.10);
  --shadow-md: 0 4px 18px rgba(0,0,0,.12);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app-shell {
  min-height: 100vh;
  max-width: 960px;
  margin: 0 auto;
  padding-bottom: 84px;
}

/* ─── HEADER ─────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--brand-bg);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  box-shadow: var(--shadow-md);
}

.header-logo {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--brand-accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.header-logo svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.header-copy {
  flex: 1;
  min-width: 0;
}

.header-copy h1 {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .01em;
}

.header-copy p {
  margin: 1px 0 0;
  color: #93adc8;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.header-badge {
  flex-shrink: 0;
  background: #1a3052;
  border: 1px solid #2a4470;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .72rem;
  font-weight: 600;
  color: #93adc8;
  white-space: nowrap;
}

/* ─── LAYOUT ─────────────────────────────────────────────── */
.app-main {
  padding: 14px 12px;
  display: grid;
  gap: 14px;
}

.screen {
  display: none;
  gap: 14px;
  animation: fadeIn .18s ease;
}

.screen.active {
  display: grid;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

h2 {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-bg);
  letter-spacing: .01em;
}

h3 {
  margin: 0 0 2px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── SCREEN TITLE ────────────────────────────────────────── */
.screen-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  border-left: 4px solid var(--brand-accent);
}

.screen-title .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.screen-title .icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.screen-title h2 {
  margin: 0;
}

.screen-title small {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  display: block;
  margin-top: 1px;
}

/* ─── PANEL ───────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.panel-title svg {
  width: 14px;
  height: 14px;
  fill: var(--brand-accent);
  flex-shrink: 0;
}

/* ─── FORMS ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

input, select, button {
  font: inherit;
}

input, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--panel2);
  color: var(--text);
  min-height: 46px;
  font-size: .92rem;
  font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(29,111,216,.14);
  background: #fff;
}

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .03em;
  background: var(--panel2);
  color: var(--text);
  min-height: 46px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: #e2e9f3;
  border-color: #bac8d8;
}

.btn:active {
  transform: scale(.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-accent) 0%, #1458b0 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(29,111,216,.30);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2478e8 0%, var(--brand-accent) 100%);
  box-shadow: 0 4px 14px rgba(29,111,216,.38);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,.25);
}

.btn-lg {
  min-height: 58px;
  font-size: .97rem;
  border-radius: var(--radius);
  letter-spacing: .06em;
}

/* ─── SECTION HEAD ────────────────────────────────────────── */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.section-head small {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
}

/* ─── CARDS ───────────────────────────────────────────────── */
.card-list {
  display: grid;
  gap: 8px;
}

.record-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--panel);
  display: grid;
  gap: 5px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .15s;
}

.record-card[style*="cursor"] {
  border-left: 4px solid var(--border);
}

.record-card:has(.badge.EN_USO) {
  border-left: 4px solid var(--ok);
}

.record-card:has(.badge.REPARACION),
.record-card:has(.badge.REVISION) {
  border-left: 4px solid var(--warn);
}

.record-card:has(.badge.ALERTA),
.record-card:has(.badge.FUERA_SERVICIO) {
  border-left: 4px solid var(--danger);
}

.record-card:hover {
  box-shadow: var(--shadow-sm);
}

.record-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.record-top strong {
  font-size: .93rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  text-transform: uppercase;
}

.badge.EN_USO {
  background: var(--ok-bg);
  color: #065f46;
}

.badge.REPARACION,
.badge.REVISION {
  background: var(--warn-bg);
  color: #92400e;
}

.badge.ALERTA,
.badge.FUERA_SERVICIO {
  background: var(--danger-bg);
  color: #991b1b;
}

.meta {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 400;
}

/* ─── ACTION ROW ─────────────────────────────────────────── */
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ─── QR GRID ─────────────────────────────────────────────── */
.qr-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
}

.qr-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  background: var(--panel);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .15s;
}

.qr-item:hover {
  box-shadow: var(--shadow-sm);
}

.qr-code {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

/* QRCode.js crea canvas + img; ocultamos el canvas para evitar duplicado */
.qr-code canvas,
.qr-modal-code canvas {
  display: none !important;
}

.qr-code img,
.qr-modal-code img {
  display: block !important;
}

.qr-item {
  cursor: pointer;
}

.qr-item .meta {
  font-size: .7rem;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .04em;
}

/* ─── QR MODAL ──────────────────────────────────────────── */
.modal-qr-box {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 340px;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.modal-qr-box .qr-modal-code {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.modal-qr-label {
  font-size: .95rem;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text);
  text-align: center;
  word-break: break-all;
}

.modal-qr-close {
  width: 100%;
  padding: 11px;
  background: var(--brand-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}

.modal-qr-close:hover {
  background: var(--brand-accent-h);
}

/* ─── BOTTOM NAV ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--brand-bg);
  border-top: 1px solid #1a2e47;
  padding: 6px 8px 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  z-index: 30;
  box-shadow: 0 -4px 20px rgba(0,0,0,.25);
}

.nav-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 4px 4px;
  background: transparent;
  color: #6884a0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  transition: fill .15s;
}

.nav-btn:hover {
  color: #93adc8;
}

.nav-btn.active {
  background: #1a2e47;
  color: var(--brand-accent);
  border-radius: var(--radius-sm);
}

/* ─── TOAST ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 94px;
  transform: translateX(-50%) translateY(12px);
  background: var(--brand-bg);
  border: 1px solid var(--brand-mid);
  color: #fff;
  border-radius: 999px;
  padding: 9px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── INSTALL BANNER ───────────────────────────────────────── */
.install-banner {
  display: none; /* banner flotante obsoleto, reemplazado por pantalla dedicada */
}

/* ─── INSTALL SCREEN ──────────────────────────────────────── */
.install-status-grid {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--panel2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.status-item > div {
  display: grid;
  gap: 2px;
}

.status-item strong {
  font-size: .88rem;
}

.status-item small {
  font-size: .76rem;
  color: var(--muted);
}

.status-dot-lg {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
  transition: background .3s;
}

.status-dot-lg.ok     { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-dot-lg.warn   { background: var(--warn); }
.status-dot-lg.error  { background: var(--danger); }

.install-desc {
  margin: 0 0 12px;
  font-size: .87rem;
  color: var(--muted);
  line-height: 1.5;
}

.install-already {
  margin: 10px 0 0;
  font-size: .87rem;
  color: var(--ok);
  font-weight: 600;
  text-align: center;
}

.install-already.hidden { display: none; }

.install-details {
  cursor: pointer;
}

.install-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .87rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
  padding: 2px 0;
}

.install-details summary svg {
  width: 18px;
  height: 18px;
  fill: var(--brand-accent);
  flex-shrink: 0;
}

.install-details[open] summary {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.install-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--text);
}

.nav-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-amber);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.nav-btn { position: relative; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid > label:last-of-type:nth-child(odd),
  .form-grid > button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) {
  .app-main {
    padding: 18px 16px;
  }

  .screen {
    max-width: 820px;
    margin: 0 auto;
  }

  .bottom-nav {
    max-width: 960px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
  }
}

/* ─── UTILS ───────────────────────────────────────────────── */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.EN_USO        { background: var(--ok); }
.status-dot.REPARACION,
.status-dot.REVISION       { background: var(--warn); }
.status-dot.ALERTA,
.status-dot.FUERA_SERVICIO { background: var(--danger); }

/* ─── MODAL EDITAR CARRO ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--panel2);
  color: var(--text);
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.modal-actions .btn-primary {
  flex: 2;
}

/* ─── DANGER BUTTON ──────────────────────────────────────── */
.btn-danger {
  flex: 1;
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* ─── CARD EDIT BUTTON ───────────────────────────────────── */
.btn-card-edit {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: .9rem;
  margin-left: auto;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
}

.btn-card-edit:hover {
  background: var(--bg);
  color: var(--brand-accent);
}
