/* ============================================================
   Swipe Stats — playful-but-sleek dark theme, mobile-first
   ============================================================ */

:root {
  --bg: #12101c;
  --surface: #1c1930;
  --surface-2: #262036;
  --border: rgba(255, 255, 255, 0.08);

  --text: #ece9f5;
  --muted: #9b97b3;

  --tinder: #fe3c72;
  --hinge: #8a3fff;
  --grad: linear-gradient(100deg, #fe3c72 0%, #8a3fff 100%);

  --green: #22c55e;
  --red: #ef4444;

  --r: 18px;
  --r-sm: 12px;
  --nav-h: 64px;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* subtle ambient glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60% 40% at 15% 0%, rgba(254, 60, 114, 0.14), transparent 60%),
    radial-gradient(50% 40% at 100% 0%, rgba(138, 63, 255, 0.16), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px calc(14px) 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(18, 16, 28, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-accent,
.brand-big .brand-accent {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logout-form { margin: 0; }
.logout-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 50%;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  cursor: pointer;
}
.logout-btn:active { transform: scale(0.94); }

/* ---------- Content ---------- */
.content {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 24px;
}

.page-title { font-size: 1.6rem; font-weight: 800; margin: 6px 0 2px; letter-spacing: -0.02em; }
.page-sub { color: var(--muted); margin: 0 0 18px; font-size: 0.95rem; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.field-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--r-sm);
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(138, 63, 255, 0.3); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-danger { background: rgba(239, 68, 68, 0.14); color: #ff8585; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-small { padding: 9px 14px; font-size: 0.9rem; }
.btn-round {
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 1.6rem; line-height: 1; padding: 0;
  display: grid; place-items: center; flex: none;
}

/* ---------- App toggle ---------- */
.app-toggle { display: flex; gap: 10px; }
.app-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.app-btn.selected {
  color: #fff;
  border-color: var(--app-color);
  background: color-mix(in srgb, var(--app-color) 22%, var(--surface-2));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--app-color) 30%, transparent);
}

/* ---------- Quick add ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.quick-btn {
  padding: 22px 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
}
.quick-btn:active { transform: scale(0.96); background: color-mix(in srgb, var(--hinge) 20%, var(--surface-2)); }

.custom-row { display: flex; gap: 10px; }
.custom-row input, .custom-row textarea { flex: 1; }

/* ---------- Inputs ---------- */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 16px; /* prevents iOS zoom */
  padding: 13px 14px;
  font-family: inherit;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--hinge); }
textarea { resize: vertical; }
select { appearance: none; -webkit-appearance: none; }
label { display: block; }

/* ---------- Today card ---------- */
.today-card { text-align: center; }
.today-total { font-size: 3rem; font-weight: 800; line-height: 1; }
.today-total #today-total {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.today-unit { font-size: 1rem; color: var(--muted); margin-left: 6px; font-weight: 600; }
.today-split { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.pill {
  font-size: 0.85rem; color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--app-color);
  padding: 6px 12px; border-radius: 999px;
}
.pill b { color: var(--text); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(22, 19, 34, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem; font-weight: 600;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--text); }
.nav-item.active svg { stroke: url(#grad); }
.nav-item.active { position: relative; }
.nav-item.active span,
.nav-item.active { color: #fff; }
.nav-item.active svg path,
.nav-item.active svg line,
.nav-item.active svg circle,
.nav-item.active svg polyline { stroke: #fe5c8a; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 80vh;
  display: flex; flex-direction: column; justify-content: center;
  gap: 22px; padding: 12px 0;
}
.auth-logo { text-align: center; }
.brand-big { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; }
.auth-tagline { color: var(--muted); margin: 6px 0 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 16px; }
.auth-card label { font-size: 0.85rem; color: var(--muted); margin: 14px 0 6px; }
.auth-card label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-top: 14px; }
.auth-card label.checkbox input { width: auto; }
.auth-switch { text-align: center; color: var(--muted); margin: 16px 0 0; font-size: 0.9rem; }
.auth-switch a, a { color: #fe5c8a; }

/* ---------- Flash / toast ---------- */
.flashes { margin-bottom: 14px; }
.flash { padding: 12px 14px; border-radius: var(--r-sm); margin-bottom: 8px; font-size: 0.92rem; }
.flash-error { background: rgba(239, 68, 68, 0.14); color: #ffb0b0; border: 1px solid rgba(239, 68, 68, 0.3); }
.flash-success { background: rgba(34, 197, 94, 0.14); color: #9af0b8; border: 1px solid rgba(34, 197, 94, 0.3); }

.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #2a2540; color: #fff;
  padding: 12px 18px; border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #4a2230; color: #ffc4c4; }

/* ---------- People list ---------- */
.people-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.person-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  box-shadow: var(--shadow);
}
.person-card:active { transform: scale(0.99); }
.person-avatar {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; color: #fff;
  background: var(--grad); font-size: 0.85rem;
}
.person-main { flex: 1; min-width: 0; }
.person-id { font-weight: 700; font-size: 0.95rem; }
.person-desc { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

.app-badge {
  font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  display: inline-block; color: #fff;
}
.app-badge.tinder { background: rgba(254, 60, 114, 0.22); color: #ff90ad; }
.app-badge.hinge { background: rgba(255, 255, 255, 0.18); color: #f4f4f8; }
.app-badge.bumble { background: rgba(255, 198, 41, 0.22); color: #ffd75e; }

.stage-chip {
  font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: #fff; white-space: nowrap;
}

.empty-state { text-align: center; color: var(--text); padding: 40px 12px; }
.empty-state .muted { font-size: 0.9rem; }
.offline-state { padding-top: 80px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
/* The class selector above would otherwise beat the [hidden] attribute and
   keep modals permanently visible — re-assert display:none when hidden. */
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 560px;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--border);
  /* Extra bottom padding so the sheet's content clears the fixed bottom nav. */
  padding: 20px 18px calc(24px + var(--nav-h) + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.8rem; line-height: 1; cursor: pointer; }
.modal textarea, .modal select, .modal input { margin-bottom: 14px; }
.modal .field-label { margin-top: 4px; }

/* Confirm sheet */
.confirm-text { font-size: 1.1rem; margin: 2px 0 22px; }
.confirm-text b {
  font-size: 1.4rem;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions .btn { margin-top: 0; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 4px 0 16px; }
.timeline li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.timeline li:last-child { border-bottom: none; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: none; }
.timeline-body { flex: 1; min-width: 0; }
.timeline-stage { font-weight: 700; font-size: 0.95rem; }
.timeline-time { color: var(--muted); font-size: 0.78rem; }
.timeline-note { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.timeline-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 4px; }

/* ---------- Swipe log list (remove logged likes) ---------- */
.swipe-log-list { list-style: none; padding: 0; margin: 4px 0 8px; }
.swipe-log-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.swipe-log-list li:last-child { border-bottom: none; }
.swipe-log-body { flex: 1; min-width: 0; }
.swipe-log-count { font-weight: 700; font-size: 0.98rem; }
.swipe-log-time { color: var(--muted); font-size: 0.78rem; }

.add-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; margin-bottom: 18px; }
.add-action select { grid-column: 1 / 2; margin-bottom: 0; }
.add-action input { grid-column: 1 / 2; margin-bottom: 0; }
.add-action button { grid-row: 1 / 3; grid-column: 2 / 3; align-self: stretch; }

/* ---------- Analytics ---------- */
.range-toggle {
  display: flex; gap: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px; margin-bottom: 18px;
}
.range-btn {
  flex: 1; padding: 9px; border: none; border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 700; font-size: 0.9rem; cursor: pointer;
}
.range-btn.selected { background: var(--grad); color: #fff; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; box-shadow: var(--shadow);
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-value { font-size: 1.9rem; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat-value.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-sub { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

.sankey-card { padding: 14px; }
.sankey { width: 100%; min-height: 420px; }

/* ---------- Install-as-PWA popup ---------- */
.install-popup {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 70;
  display: flex; justify-content: center;
}
.install-popup[hidden] { display: none; }
.install-card {
  position: relative;
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: sheet-up 0.25s ease;
}
.install-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.install-icon { border-radius: 13px; }
.install-card h3 { margin: 8px 0 4px; font-size: 1.15rem; }
.install-card p { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }
.install-steps {
  text-align: left; color: var(--muted); font-size: 0.9rem;
  margin: 4px 0 0; padding-left: 22px;
}
.install-steps li { margin: 5px 0; }
.install-steps b { color: var(--text); }
