/* ================================================================
   Trust Auto — main.css  (v8 · Light mode · Brand Identity)
   Inspector en calle: claridad, contraste, botones grandes
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  /* Fondos */
  --bg:      #f0f2f5;
  --bg2:     #ffffff;
  --card:    #ffffff;
  --card2:   #f7f8fa;

  /* Bordes */
  --border:  #e2e6ed;
  --border2: #d0d5dd;

  /* Textos */
  --text:    #111827;
  --text2:   #6b7280;

  /* Marca */
  --blue:    #1971c2;
  --blue2:   #1565b0;
  --orange:  #e85d04;
  --orange2: #d45200;

  /* Estados */
  --ok:      #16a34a;
  --wear:    #d97706;
  --crit:    #dc2626;
  --pending: #9ca3af;

  /* Layout */
  --radius:  12px;
  --radius-sm: 8px;
  --shadow:  0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Layout ────────────────────────────────────────────────────── */
.container { max-width: 680px; margin: 0 auto; padding: 0 14px; }

/* ── Header ────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: #ffffff;
  border-bottom: 3px solid var(--orange);
  padding: 10px 0 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.header-brand { display: flex; align-items: center; gap: 9px; }
.header-brand img { width: 32px; height: 32px; border-radius: 7px; }
.header-brand h1 {
  font-size: 1rem; font-weight: 800;
  letter-spacing: -0.3px; margin: 0;
  color: var(--blue);
}
.header-actions { display: flex; gap: 5px; }

/* ── Action bars ───────────────────────────────────────────────── */
.action-row-1 {
  display: flex; align-items: center;
  gap: 6px; margin-top: 7px; flex-wrap: nowrap;
}
.action-row-2 {
  display: flex; gap: 6px; margin-top: 5px;
}
.action-row-2 .btn { flex: 1; justify-content: center; }

/* ── Progress ──────────────────────────────────────────────────── */
.progress-bar {
  height: 5px; background: var(--border);
  border-radius: 99px; overflow: hidden; margin-top: 7px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--orange));
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Banners ───────────────────────────────────────────────────── */
.banner { padding: 8px 14px; font-size: 0.8rem; font-weight: 600; text-align: center; }
.banner-edit    { background: rgba(25,113,194,0.1); color: var(--blue);  border-bottom: 1px solid rgba(25,113,194,0.2); }
.banner-discard { background: rgba(220,38,38,0.08); color: var(--crit);  border-bottom: 1px solid rgba(220,38,38,0.2); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 14px;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(25,113,194,0.3); }
.btn-primary:hover { background: var(--blue2); border-color: var(--blue2); }
.btn-danger  { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.25); color: var(--crit); box-shadow: none; }
.btn-danger:hover { background: rgba(220,38,38,0.15); }
.btn-ghost   { background: transparent; border-color: var(--border2); box-shadow: none; color: var(--text2); }
.btn-ghost:hover { background: var(--card2); color: var(--text); }
.btn-sm      { padding: 6px 11px; font-size: 0.78rem; }
.btn-icon    { padding: 7px; border-radius: var(--radius-sm); }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-label  {
  font-size: 0.72rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input, .form-select, .form-textarea {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px; /* evita zoom iOS */
  padding: 11px 13px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(25,113,194,0.12);
  background: #fff;
}
.form-textarea { resize: vertical; min-height: 52px; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

/* ── Grid ──────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Card ──────────────────────────────────────────────────────── */
.card      { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 16px; }

/* ── Section tabs ──────────────────────────────────────────────── */
.section-tabs {
  display: flex; gap: 5px;
  overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.section-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text2);
  font-size: 0.78rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 38px;
  box-shadow: var(--shadow-sm);
}
.tab-btn.active   { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(25,113,194,0.25); }
.tab-btn.complete { background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.3); color: var(--ok); }
.tab-count { font-size: 0.7rem; opacity: 0.8; }

/* ── Item cards ────────────────────────────────────────────────── */
.item-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 4px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: border-left-color 0.2s;
}
.item-card.status-ok       { border-left-color: var(--ok); }
.item-card.status-wear     { border-left-color: var(--wear); }
.item-card.status-critical { border-left-color: var(--crit); }
.item-num  { font-size: 0.68rem; color: var(--text2); margin-bottom: 3px; font-weight: 600; letter-spacing: 0.3px; }
.item-name { font-weight: 700; font-size: 0.96rem; margin-bottom: 8px; color: var(--text); }

/* ── Status buttons — el corazón de la app ─────────────────────── */
.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.status-btn {
  flex: 1; min-width: 0;
  padding: 12px 6px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.73rem; font-weight: 700;
  cursor: pointer; text-align: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* Inactivos — visibles pero suaves */
.status-btn[data-status="ok"]       { background: rgba(22,163,74,0.07);  color: var(--ok);   border-color: rgba(22,163,74,0.2); }
.status-btn[data-status="wear"]     { background: rgba(217,119,6,0.07);  color: var(--wear); border-color: rgba(217,119,6,0.2); }
.status-btn[data-status="critical"] { background: rgba(220,38,38,0.07);  color: var(--crit); border-color: rgba(220,38,38,0.2); }
.status-btn[data-status="pending"]  { background: var(--card2);          color: var(--text2);border-color: var(--border); }
/* Activos — sólidos y claros */
.status-btn.active[data-status="ok"]       { background: var(--ok);      color: #fff; border-color: var(--ok);      box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.status-btn.active[data-status="wear"]     { background: var(--wear);    color: #fff; border-color: var(--wear);    box-shadow: 0 2px 8px rgba(217,119,6,0.3); }
.status-btn.active[data-status="critical"] { background: var(--crit);    color: #fff; border-color: var(--crit);    box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.status-btn.active[data-status="pending"]  { background: var(--pending); color: #fff; border-color: var(--pending); }

/* ── Photos ────────────────────────────────────────────────────── */
.photos-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px; padding: 4px 0 4px 2px;
}
.photo-wrap {
  display: flex; flex-direction: column;
  align-items: stretch; gap: 3px; width: 80px;
}
.photo-wrap .photo-thumb {
  width: 80px; height: 80px;
  object-fit: cover; border-radius: 7px;
  border: 1.5px solid var(--border);
  cursor: pointer; display: block;
}
.photo-del {
  width: 80px; padding: 5px 0;
  border-radius: 6px;
  background: rgba(220,38,38,0.08);
  color: var(--crit);
  border: 1px solid rgba(220,38,38,0.2);
  font-size: 0.7rem; font-weight: 700;
  cursor: pointer; text-align: center;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; display: block;
}
.photo-del:active { background: var(--crit); color: #fff; }
.add-photo-btn {
  display: flex; flex-direction: column; align-items: center;
  width: 80px; height: 80px;
  border: 2px dashed var(--border2);
  border-radius: 7px; color: var(--text2);
  cursor: pointer; font-size: 0.68rem; gap: 4px;
  justify-content: center; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  background: var(--card2);
}
.add-photo-btn:active { border-color: var(--blue); color: var(--blue); background: rgba(25,113,194,0.05); }

/* ── Timer & save chip ─────────────────────────────────────────── */
.timer-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem;
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--blue); font-weight: 700;
  background: rgba(25,113,194,0.08);
  padding: 3px 8px; border-radius: 6px;
  border: 1px solid rgba(25,113,194,0.15);
}
.save-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.7rem; color: var(--ok);
}

/* ── Stats ─────────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-chip { display: flex; align-items: center; gap: 5px; font-size: 0.82rem; font-weight: 600; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 99px; font-size: 0.78rem; font-weight: 700; }
.badge-ok   { background: rgba(22,163,74,0.1);  color: #15803d;  border: 1.5px solid rgba(22,163,74,0.25); }
.badge-obs  { background: rgba(217,119,6,0.1);  color: #b45309;  border: 1.5px solid rgba(217,119,6,0.25); }
.badge-disc { background: rgba(220,38,38,0.1);  color: #b91c1c;  border: 1.5px solid rgba(220,38,38,0.25); }

/* ── Summary ───────────────────────────────────────────────────── */
.summary-section { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.summary-section h3 { margin: 0 0 10px; font-size: 0.9rem; font-weight: 700; color: var(--text); }
.summary-item { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.summary-item:last-child { border-bottom: none; }
.summary-item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.dot.ok       { background: var(--ok); }
.dot.wear     { background: var(--wear); }
.dot.critical { background: var(--crit); }
.dot.pending  { background: var(--pending); }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow);
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Lightbox ──────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox img { max-width: 95vw; max-height: 85vh; border-radius: 8px; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  color: #fff; font-size: 1.4rem; cursor: pointer;
  background: rgba(255,255,255,0.15); border: none;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── Login ─────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(145deg, #f0f4ff 0%, #e8f0fe 50%, #fff3ec 100%);
}
.login-card {
  width: 100%; max-width: 340px;
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 20px; padding: 36px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.1); text-align: center;
}
.login-logo { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 14px; object-fit: contain; }
.login-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; margin: 0 0 4px; color: var(--blue); }
.login-sub   { font-size: 0.88rem; color: var(--text2); margin: 0 0 4px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 20px 0 8px; }
.pin-dot  { width: 14px; height: 14px; border-radius: 50%; background: var(--border); transition: all 0.15s; }
.pin-dot.filled { background: var(--blue); transform: scale(1.1); }
.pin-dot.error  { background: var(--crit); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 24px; }
.key-btn {
  aspect-ratio: 1; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--card2); color: var(--text);
  font-size: 1.3rem; font-weight: 700;
  cursor: pointer; transition: all 0.12s; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; min-height: 60px;
  box-shadow: var(--shadow-sm);
}
.key-btn:hover  { background: var(--blue); color: #fff; border-color: var(--blue); }
.key-btn:active { transform: scale(0.94); background: var(--blue); color: #fff; border-color: var(--blue); }
.key-btn.delete { font-size: 1rem; color: var(--text2); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.pin-btn {
  padding: 18px; border: 1.5px solid var(--border);
  border-radius: 10px; background: var(--card2);
  color: var(--text); font-size: 1.2rem; font-weight: 700;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pin-btn:active { background: var(--blue); color: #fff; }
.pin-error {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  color: var(--crit); font-size: 0.85rem; margin-top: 8px;
  background: rgba(220,38,38,0.06); border: 1px solid rgba(220,38,38,0.2);
  border-radius: 8px; padding: 6px 12px;
}

/* ── History ───────────────────────────────────────────────────── */
.insp-card {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.insp-card:active { background: var(--card2); transform: scale(0.99); }
.insp-card-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%); z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  background: var(--text); color: #fff;
  border-radius: 10px; padding: 11px 20px;
  font-size: 0.875rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: toastIn 0.25s ease;
  max-width: 90vw; text-align: center;
}
.toast.success { background: var(--ok); }
.toast.error   { background: var(--crit); }
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
  .app-header, .section-tabs, .nav-buttons, .no-print { display: none !important; }
  .card { box-shadow: none !important; }
  .item-card { break-inside: avoid; }
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  #section-content .grid-2 { grid-template-columns: 1fr; }
  .item-name { font-size: 0.97rem; }
  .status-btn { padding: 13px 4px; font-size: 0.71rem; }
  .photo-wrap { width: 60px; }
  .photo-wrap .photo-thumb, .add-photo-btn { width: 60px; height: 60px; }
  .photo-del { width: 60px; font-size: 0.62rem; }
  .badge { font-size: 0.72rem; padding: 3px 9px; white-space: nowrap; }
}

/* ── Utility ───────────────────────────────────────────────────── */
.mt-1{margin-top:4px} .mt-2{margin-top:8px} .mt-3{margin-top:12px} .mt-4{margin-top:16px}
.mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px}
.flex{display:flex} .flex-1{flex:1} .items-center{align-items:center}
.justify-between{justify-content:space-between} .gap-2{gap:8px} .gap-3{gap:12px}
.text-sm{font-size:0.875rem} .text-xs{font-size:0.75rem} .text-muted{color:var(--text2)}
.font-bold{font-weight:700} .font-600{font-weight:600}
.w-full{width:100%} .hidden{display:none !important}
.text-ok{color:var(--ok)} .text-wear{color:var(--wear)} .text-crit{color:var(--crit)}

/* ── Spinner ───────────────────────────────────────────────────── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
