/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Nunito', sans-serif;
  background: #f7f5f2;
  color: #1a1a1a;
  min-height: 100dvh;
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ── Splash ── */
#splash {
  position: fixed; inset: 0;
  background: linear-gradient(145deg, #FF6B35, #f7334b);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  transition: opacity 0.5s, visibility 0.5s;
}
#splash.fade-out { opacity: 0; visibility: hidden; }
.splash-inner { text-align: center; color: white; }
.splash-icon { font-size: 64px; margin-bottom: 12px; animation: bounce 1s infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-10px); } }
#splash h1 { font-size: 36px; font-weight: 800; letter-spacing: -1px; }
#splash p { font-size: 16px; opacity: 0.85; margin-top: 8px; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

.app-header {
  background: white;
  border-bottom: 1px solid #ede9e4;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; max-width: 480px; margin: 0 auto; width: 100%;
}
.logo { font-size: 18px; font-weight: 800; color: #FF6B35; }
.header-stats { font-size: 12px; color: #888; display: flex; align-items: center; gap: 6px; }
.dot { color: #ccc; }

.content {
  flex: 1;
  padding-bottom: 80px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid #ede9e4;
  display: flex;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 10px 4px 8px;
  border: none; background: none; cursor: pointer;
  color: #aaa; font-family: 'Nunito', sans-serif;
  position: relative; transition: color 0.15s;
}
.nav-btn.active { color: #FF6B35; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 600; margin-top: 3px; }
.badge-dot {
  position: absolute; top: 8px; right: calc(50% - 14px);
  width: 8px; height: 8px; background: #f7334b;
  border-radius: 50%; border: 2px solid white;
}

/* ── Tabs ── */
.tab { padding: 16px; }

.tab-header { margin-bottom: 16px; }
.tab-header h2 { font-size: 22px; font-weight: 800; color: #1a1a1a; }
.tab-header p { font-size: 14px; color: #888; margin-top: 4px; }

/* ── Upload card ── */
.upload-card {
  background: white;
  border-radius: 20px;
  border: 2px dashed #e0dbd4;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}
.upload-card:hover { border-color: #FF6B35; }
.upload-card input[type=file] {
  position: absolute; inset: 0; opacity: 0;
  cursor: pointer; width: 100%; height: 100%; z-index: 2;
}
.upload-placeholder { padding: 32px 16px; text-align: center; }
.upload-icon { font-size: 40px; margin-bottom: 10px; }
.upload-text { font-size: 16px; font-weight: 700; color: #333; }
.upload-sub { font-size: 13px; color: #aaa; margin-top: 4px; }
.preview-img {
  width: 100%; max-height: 240px; object-fit: cover;
  display: block;
}

/* ── Analysis card ── */
.analysis-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid #ede9e4;
}
.analysis-loading {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: #888;
}
.spinner {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2.5px solid #e0dbd4;
  border-top-color: #FF6B35;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.analysis-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 10px;
}
.analysis-item { font-size: 13px; }
.analysis-item span { color: #aaa; display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.analysis-item strong { color: #1a1a1a; font-weight: 700; }
.analysis-title {
  font-size: 14px; font-weight: 700; color: #22c55e;
  display: flex; align-items: center; gap: 6px; margin-bottom: 2px;
}

/* ── Match alert ── */
.match-alert {
  background: linear-gradient(135deg, #fff7ed, #fff);
  border: 2px solid #FF6B35;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 14px;
}
.match-alert-title { font-weight: 800; font-size: 15px; color: #FF6B35; margin-bottom: 4px; }
.match-alert a { color: #FF6B35; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ── Form card ── */
.form-card {
  background: white;
  border-radius: 20px;
  padding: 16px;
  border: 1px solid #ede9e4;
}
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 700;
  color: #555; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid #e0dbd4; border-radius: 12px;
  font-family: 'Nunito', sans-serif; font-size: 15px; color: #1a1a1a;
  background: #faf9f7; outline: none; transition: border-color 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #FF6B35;
}
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.location-row { display: flex; gap: 8px; }
.location-row input { flex: 1; }
.gps-btn {
  flex-shrink: 0; padding: 0 14px;
  border: 1.5px solid #e0dbd4; border-radius: 12px;
  background: #faf9f7; font-family: 'Nunito', sans-serif;
  font-size: 13px; font-weight: 700; cursor: pointer;
  color: #555; transition: all 0.15s; white-space: nowrap;
  height: 48px;
}
.gps-btn:hover { border-color: #FF6B35; color: #FF6B35; background: #fff7ed; }
.gps-btn.loading { opacity: 0.6; pointer-events: none; }
.gps-status { font-size: 12px; color: #aaa; margin-top: 5px; min-height: 16px; }
.gps-ok { color: #22c55e; }
.gps-err { color: #ef4444; }

/* ── Buttons ── */
.btn-primary {
  width: 100%; padding: 16px;
  background: #1a1a1a; color: white;
  border: none; border-radius: 14px;
  font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 800;
  cursor: pointer; transition: all 0.15s; margin-top: 4px;
}
.btn-primary:hover { background: #333; }
.btn-primary:active { transform: scale(0.98); }
.btn-orange { background: #FF6B35; }
.btn-orange:hover { background: #e55a28; }

/* ── Section label ── */
.section-label {
  font-size: 13px; font-weight: 700; color: #888;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 4px; margin-bottom: 10px;
}

/* ── Match cards ── */
.match-card {
  background: white;
  border-radius: 20px;
  border: 1px solid #ede9e4;
  padding: 16px;
  margin-bottom: 12px;
}
.match-score-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.match-score {
  font-size: 28px; font-weight: 800;
  color: #22c55e;
}
.match-score.medium { color: #f59e0b; }
.match-score.low { color: #94a3b8; }
.match-date { font-size: 12px; color: #aaa; }
.match-photos {
  display: grid; grid-template-columns: 1fr 32px 1fr;
  gap: 0; align-items: center; margin-bottom: 12px;
}
.match-photo {
  border-radius: 12px; overflow: hidden;
  height: 100px; background: #f7f5f2;
  display: flex; align-items: center; justify-content: center;
}
.match-photo img { width: 100%; height: 100%; object-fit: cover; }
.match-photo-empty { font-size: 28px; }
.match-arrow { text-align: center; font-size: 18px; color: #ccc; }
.match-photo-label { font-size: 11px; color: #aaa; text-align: center; margin-top: 4px; }
.match-explanation { font-size: 14px; color: #555; line-height: 1.6; margin-bottom: 10px; }
.match-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.match-tag {
  background: #f0fdf4; color: #16a34a;
  border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 700;
}
.match-location { font-size: 13px; color: #888; margin-bottom: 10px; }
.match-contact-btn {
  width: 100%; padding: 12px;
  background: #fff7ed; color: #FF6B35;
  border: 1.5px solid #FF6B35; border-radius: 12px;
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 800;
  cursor: pointer; transition: all 0.15s;
}
.match-contact-btn:hover { background: #FF6B35; color: white; }

/* ── Report cards ── */
.report-card {
  background: white; border-radius: 16px;
  border: 1px solid #ede9e4;
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 8px;
}
.report-thumb {
  width: 56px; height: 56px; border-radius: 12px;
  overflow: hidden; background: #f7f5f2; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.report-thumb img { width: 100%; height: 100%; object-fit: cover; }
.report-name { font-size: 15px; font-weight: 700; color: #1a1a1a; }
.report-meta { font-size: 12px; color: #aaa; margin-top: 2px; }

.empty-state { text-align: center; padding: 48px 16px; color: #aaa; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: #555; margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
.modal {
  background: white; border-radius: 24px;
  padding: 32px 24px; text-align: center;
  max-width: 320px; width: 100%;
}
.modal-emoji { font-size: 48px; margin-bottom: 12px; }
.modal h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.modal p { font-size: 14px; color: #666; margin-bottom: 20px; line-height: 1.5; }

/* ── Install banner ── */
.install-banner {
  background: #1a1a1a; color: white;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px;
}
.install-banner button {
  background: #FF6B35; color: white; border: none;
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  font-family: 'Nunito', sans-serif; font-weight: 700; cursor: pointer; white-space: nowrap;
}

@media (min-width: 480px) {
  .content { padding: 0 0 80px; }
}

/* ── Auth screen ── */
.screen { min-height: 100dvh; }
.auth-wrap {
  max-width: 400px; margin: 0 auto;
  padding: 48px 24px 32px;
}
.auth-logo { font-size: 24px; font-weight: 800; color: #FF6B35; margin-bottom: 24px; }
.auth-wrap h2 { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.auth-sub { font-size: 14px; color: #888; margin-bottom: 24px; }
.social-btn {
  width: 100%; padding: 14px 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 14px; border: 1.5px solid #e0dbd4;
  background: white; font-family: 'Nunito', sans-serif;
  font-size: 15px; font-weight: 700; cursor: pointer;
  color: #333; transition: all 0.15s; margin-bottom: 8px;
}
.social-btn:hover { background: #faf9f7; border-color: #ccc; }
.social-btn.google:hover { border-color: #4285f4; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: #ccc; font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: #e0dbd4;
}
.auth-error {
  background: #fef2f2; color: #ef4444; border: 1px solid #fecaca;
  border-radius: 10px; padding: 10px 14px; font-size: 13px;
  margin-bottom: 14px;
}
.auth-ok { background: #f0fdf4 !important; color: #16a34a !important; border-color: #bbf7d0 !important; }
.auth-switch { text-align: center; font-size: 14px; color: #888; margin-top: 16px; }
.auth-switch a { color: #FF6B35; font-weight: 700; cursor: pointer; margin-left: 4px; }
.auth-skip { text-align: center; margin-top: 12px; }
.auth-skip a { font-size: 13px; color: #aaa; cursor: pointer; text-decoration: underline; }

/* ── Profile ── */
.profile-card {
  background: white; border-radius: 20px;
  border: 1px solid #ede9e4; padding: 16px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.profile-avatar {
  width: 48px; height: 48px; background: #FF6B35; color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; flex-shrink: 0;
}
.sign-out-btn {
  padding: 8px 14px; border-radius: 10px; border: 1px solid #e0dbd4;
  background: none; font-family: 'Nunito', sans-serif; font-size: 13px;
  font-weight: 700; cursor: pointer; color: #888; white-space: nowrap;
  margin-left: auto;
}
.sign-out-btn:hover { background: #faf9f7; }

.stats-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  margin-bottom: 20px;
}
.stat-box {
  background: #f7f5f2; border-radius: 14px;
  padding: 12px; text-align: center;
}
.stat-n { font-size: 24px; font-weight: 800; color: #1a1a1a; }
.stat-l { font-size: 11px; color: #aaa; margin-top: 2px; font-weight: 600; text-transform: uppercase; }

/* ── Activity feed ── */
.activity-feed { margin-bottom: 8px; }
.activity-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid #f0ece8;
}
.activity-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 14px; font-weight: 700; color: #1a1a1a; line-height: 1.4; }
.activity-sub { font-size: 12px; color: #aaa; margin-top: 2px; }
.activity-date { font-size: 11px; color: #ccc; margin-top: 3px; }
.badge-reunited {
  display: inline-block; background: #f0fdf4; color: #16a34a;
  border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700; margin-left: 6px;
}
.badge-closed {
  display: inline-block; background: #f7f5f2; color: #aaa;
  border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700; margin-left: 6px;
}

/* ── Edit button on report cards ── */
.edit-btn {
  flex-shrink: 0; padding: 8px 10px; border: 1px solid #e0dbd4;
  border-radius: 10px; background: none; cursor: pointer; font-size: 14px;
  color: #888; transition: all 0.15s; align-self: center;
}
.edit-btn:hover { background: #faf9f7; border-color: #FF6B35; }

/* ── Edit modal ── */
.modal-large { max-width: 480px; max-height: 85dvh; overflow-y: auto; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 18px; font-weight: 800; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: #f7f5f2; cursor: pointer; font-size: 14px; color: #888;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #ede9e4; }

/* ── Chat ── */
.modal-chat { max-width:480px; height:75dvh; display:flex; flex-direction:column; padding:0; }
.modal-chat .modal-header { padding:16px 16px 12px; border-bottom:1px solid #ede9e4; flex-shrink:0; }
.chat-messages { flex:1; overflow-y:auto; padding:12px 16px; display:flex; flex-direction:column; gap:8px; }
.msg-row { display:flex; flex-direction:column; max-width:80%; }
.msg-row.mine  { align-self:flex-end; align-items:flex-end; }
.msg-row.theirs{ align-self:flex-start; align-items:flex-start; }
.msg-sender { font-size:11px; color:#aaa; margin-bottom:3px; padding: 0 4px; }
.bubble-mine   { background:#FF6B35; color:white; border-radius:16px 16px 4px 16px; padding:10px 14px; font-size:14px; line-height:1.4; word-break:break-word; }
.bubble-theirs { background:#f7f5f2; color:#1a1a1a; border-radius:16px 16px 16px 4px; padding:10px 14px; font-size:14px; line-height:1.4; word-break:break-word; }
.msg-time { font-size:10px; color:#ccc; margin-top:3px; padding:0 4px; }
.chat-input-row { display:flex; gap:8px; padding:12px 16px; border-top:1px solid #ede9e4; flex-shrink:0; background:white; border-radius:0 0 24px 24px; }
.chat-input { flex:1; padding:10px 14px; border:1.5px solid #e0dbd4; border-radius:12px; font-family:'Nunito',sans-serif; font-size:14px; resize:none; outline:none; }
.chat-input:focus { border-color:#FF6B35; }
.chat-send-btn { width:44px; height:44px; border-radius:12px; background:#FF6B35; border:none; color:white; font-size:18px; cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.chat-send-btn:hover { background:#e55a28; }
.chat-badge { color:#ef4444; font-size:14px; margin-right:4px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Admin ── */
.flagged-card { border-color:#fecaca !important; background:#fff5f5 !important; }
.admin-btn { padding:6px 10px; border-radius:8px; border:1px solid #e0dbd4; background:none; font-family:'Nunito',sans-serif; font-size:12px; font-weight:700; cursor:pointer; color:#555; white-space:nowrap; }
.admin-btn:hover { background:#faf9f7; }
.admin-btn-danger { border-color:#fecaca; color:#ef4444; }
.admin-btn-danger:hover { background:#fef2f2; }
.admin-btn-ok { border-color:#bbf7d0; color:#16a34a; }
.admin-btn-ok:hover { background:#f0fdf4; }

/* ── Radius slider ── */
.range-input { width:100%; height:4px; border-radius:4px; accent-color:#FF6B35; cursor:pointer; }

/* ── Match badge ── */
.badge-mine { background:#fff7ed; color:#FF6B35; border-radius:6px; padding:2px 7px; font-size:11px; font-weight:700; margin-left:6px; }
.match-actions { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }

/* ── Flag button in reports ── */
.flag-report-btn { flex-shrink:0; padding:6px 8px; border:1px solid #ede9e4; border-radius:8px; background:none; cursor:pointer; font-size:14px; color:#ccc; }
.flag-report-btn:hover { border-color:#ef4444; color:#ef4444; }

/* ── Organizaciones ── */
.org-header-card {
  background: white; border-radius: 20px;
  border: 1px solid #ede9e4; padding: 16px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.org-logo-big {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: white; flex-shrink: 0;
}
.org-rate-bar {
  background: white; border-radius: 14px;
  border: 1px solid #ede9e4; padding: 14px;
  margin-bottom: 8px;
}
.rate-track {
  height: 8px; background: #f0ece8; border-radius: 4px; overflow: hidden;
}
.rate-fill {
  height: 100%; background: #22c55e; border-radius: 4px;
  transition: width 0.5s ease;
}
.org-public-link {
  background: #f7f5f2; border-radius: 12px;
  padding: 12px 14px; margin-top: 20px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
/* 5-column stats for org panel */
@media (max-width: 380px) {
  .stats-row[style*="repeat(5"] { grid-template-columns: repeat(3, 1fr) !important; }
}
