:root {
  --bg: #0f172a;
  --card: #ffffff;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #1d4ed8;
  --green: #16a34a;
  --yellow: #f59e0b;
  --red: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: #0f172a;
  min-height: 100vh;
}

.app-header {
  background: var(--bg);
  color: #fff;
  padding: 18px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h1 { font-size: 1.15rem; }
.app-header p { font-size: 0.75rem; color: #94a3b8; }

.sync-indicator { font-size: 1.4rem; transition: color .3s; }
.sync-indicator.online { color: #4ade80; }
.sync-indicator.offline { color: #f87171; }

/* ─── Pantalla de login (full-screen) ────────────────────────────────────── */
.pantalla-login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(900px 500px at 30% -10%, #1d4ed8 0%, #0f172a 55%, #020617 100%);
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border-radius: 16px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  text-align: center;
}
.login-brand { font-size: 2rem; }
.login-card h1 { font-size: 1.2rem; }
.login-sub { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.login-card input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #f8fafc;
  color: var(--text);
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.auth-error { font-size: 0.78rem; color: var(--red); }
.login-hint { font-size: 0.7rem; color: #94a3b8; }
.login-hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; color: var(--primary); }

.auth-box { max-width: 560px; margin: 0 auto; padding: 10px 16px 0; text-align: right; }
.auth-box .btn { padding: 8px 12px; font-size: 0.78rem; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

.view { background: var(--card); border-radius: 14px; padding: 18px; box-shadow: 0 4px 20px rgba(0,0,0,.18); }
.hidden { display: none; }

.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: #e2e8f0;
  color: #0f172a;
  transition: transform .1s, filter .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.secondary { background: #f1f5f9; border: 1px solid var(--border); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.back { background: transparent; color: #475569; padding: 8px 0; margin-bottom: 8px; }

.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  border: 1px solid var(--border);
  border-left: 6px solid var(--muted);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background .15s;
}
.card:active { background: #f8fafc; }
.card h3 { font-size: 0.95rem; }
.card p { font-size: 0.8rem; color: var(--muted); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  margin-top: 6px;
}
.badge.VERDE { background: var(--green); }
.badge.AMARILLO { background: var(--yellow); color: #451a03; }
.badge.ROJO { background: var(--red); }
.badge.sync { background: #334155; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
legend { font-weight: 700; font-size: 0.85rem; padding: 0 6px; color: #334155; }

label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 10px; color: #334155; }
input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
}
textarea { resize: vertical; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.gps-info { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

.estado-group { margin-bottom: 10px; }
.estado-group .eg-label { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  color: #334155;
}
.seg button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.galeria { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.galeria .foto {
  position: relative;
  width: 90px; height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.galeria .foto img { width: 100%; height: 100%; object-fit: cover; }
.galeria .foto .meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 0.55rem; color: #fff; background: rgba(0,0,0,.6);
  padding: 2px 4px;
}
.galeria .foto .del {
  position: absolute; top: 2px; right: 2px;
  background: rgba(220,38,38,.9); color: #fff;
  border: none; border-radius: 50%; width: 20px; height: 20px;
  font-size: 0.7rem; cursor: pointer; line-height: 1;
}

.hint { font-size: 0.72rem; color: var(--muted); margin-top: 8px; }
.consent-details { margin-bottom: 8px; }
.consent-details summary { cursor: pointer; font-size: 0.8rem; color: var(--primary); font-weight: 700; }
.consent-text { font-size: 0.72rem; color: var(--muted); line-height: 1.4; background: var(--bg); padding: 10px; border-radius: 8px; }
.consent-check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.78rem; font-weight: 600; }
.consent-check input { width: 18px; height: 18px; margin-top: 1px; flex: 0 0 auto; }

.triaje-preview {
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  color: #fff;
  text-align: center;
}
.triaje-preview.ris-VERDE { background: var(--green); }
.triaje-preview.ris-AMARILLO { background: var(--yellow); color: #451a03; }
.triaje-preview.ris-ROJO { background: var(--red); }
.triaje-preview h3 { font-size: 1.1rem; }
.triaje-preview p { font-size: 0.8rem; margin-top: 4px; }

.form-actions { margin-top: 8px; }

.detail-block { margin-bottom: 14px; }
.detail-block h3 { font-size: 0.95rem; margin-bottom: 8px; color: #334155; }
.detail-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.detail-row span:first-child { color: var(--muted); }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
