:root {
  --primary: #0f766e;
  --primary-dark: #0b544e;
  --bg: #f7f9f9;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(72px + var(--safe-bottom));
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding-bottom: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.login-logo { font-size: 42px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.login-form { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-form input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 16px;
}
.login-form button {
  margin-top: 20px;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.error-box {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

/* ---------- Layout general ---------- */
.topbar {
  position: sticky;
  top: 0;
  background: var(--primary);
  color: white;
  padding: calc(16px + var(--safe-top)) 20px 16px;
  font-weight: 600;
  font-size: 18px;
}

.content { padding: 16px; max-width: 640px; margin: 0 auto; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-number { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.section-title { font-size: 15px; color: var(--muted); margin: 20px 0 10px; text-transform: uppercase; letter-spacing: 0.03em; }

.list { display: flex; flex-direction: column; gap: 10px; }

.list-item {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}

.list-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.badge {
  background: #ecfdf5;
  color: var(--primary-dark);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- Conversaciones ---------- */
.msg-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  margin-top: 8px;
  max-width: 100%;
}
.msg-in { background: #f3f4f6; }
.msg-out { background: #d1fae5; }

.reply-form { display: flex; gap: 8px; margin-top: 10px; }
.reply-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.reply-form button {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 600;
}
.reply-status { font-size: 12px; margin-top: 4px; color: var(--muted); }

/* ---------- Nav inferior ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 calc(8px + var(--safe-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  gap: 2px;
}

.nav-logout { border: none; background: none; }
.nav-logout button {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  gap: 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --card-bg: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #374151;
  }
  .msg-in { background: #374151; }
  .msg-out { background: #064e3b; }
}
