/* ============================================================
   Munazza · Today's Leads — warm editorial, phone-first.
   Palette: deep ink, warm sand, confident emerald (grow/go).
   Type: Fraunces (display serif) + DM Sans (body) + Newsreader (message copy).
   ============================================================ */

:root {
  --ink: #1c1a17;
  --ink-soft: #2a2723;
  --sand: #f4ece0;
  --sand-deep: #e7dac6;
  --paper: #fbf7f0;
  --paper-card: #fffdf9;
  --emerald: #1f7a55;
  --emerald-bright: #25925f;
  --emerald-ink: #0e3b29;
  --clay: #b4623a;
  --gold: #c79a3e;
  --line: #d9ccb8;
  --muted: #7c7268;
  --shadow: 26px 26px 60px -30px rgba(28, 26, 23, 0.45);

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;

  --font-display: "Fraunces", Georgia, serif;
  --font-read: "Newsreader", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

/* The [hidden] attribute must always win over display:flex/grid/block below.
   Without this, .sheet/.gate/.app (which set display) ignore `hidden`. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  background-image:
    radial-gradient(120% 80% at 100% 0%, rgba(199, 154, 62, 0.10) 0%, transparent 50%),
    radial-gradient(120% 90% at 0% 100%, rgba(31, 122, 85, 0.08) 0%, transparent 55%);
  background-attachment: fixed;
}

/* Subtle film grain so it feels crafted, not templated */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ===================== LOGIN GATE ===================== */
.gate {
  position: relative; z-index: 2;
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 40px 30px 34px;
  box-shadow: var(--shadow);
  text-align: left;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.gate-mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--ink); color: var(--sand);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 20px;
  letter-spacing: 1px; margin-bottom: 26px;
}
.gate-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(30px, 8vw, 38px); line-height: 1.05; letter-spacing: -0.02em;
}
.gate-title em { font-style: italic; color: var(--emerald); }
.gate-sub { color: var(--muted); margin: 12px 0 28px; font-size: 16px; }

.field { display: block; margin-bottom: 18px; }
.field span {
  display: block; font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.field input {
  width: 100%; font-family: var(--font-body); font-size: 18px;
  padding: 16px 18px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--paper);
  color: var(--ink); transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  outline: none; border-color: var(--emerald);
  box-shadow: 0 0 0 4px rgba(31, 122, 85, 0.12);
}
.gate-btn { width: 100%; margin-top: 4px; }
.gate-error { color: var(--clay); font-size: 14px; margin-top: 14px; font-weight: 500; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 16px;
  padding: 16px 20px; border-radius: var(--r-md);
  border: none; cursor: pointer; text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-go {
  background: var(--emerald); color: #fff;
  box-shadow: 0 10px 22px -10px rgba(31, 122, 85, 0.7);
}
.btn-go:active { background: var(--emerald-bright); }
.btn-soft { background: var(--sand-deep); color: var(--ink-soft); }
.btn-line { background: transparent; border: 1.5px solid var(--line); color: var(--ink-soft); }
.btn-star { background: var(--ink); color: var(--gold); }

/* ===================== TOP BAR ===================== */
.app { position: relative; z-index: 2; max-width: 560px; margin: 0 auto; padding-bottom: calc(40px + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(14px); background: rgba(251, 247, 240, 0.82);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--sand);
  display: grid; place-items: center; font-family: var(--font-display); font-size: 13px; font-weight: 600;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.link-quiet { background: none; border: none; color: var(--muted); font-family: var(--font-body); font-size: 14px; cursor: pointer; }

/* ===================== HERO ===================== */
.hero { padding: 30px 22px 8px; animation: rise 0.6s cubic-bezier(0.2,0.7,0.2,1) both; }
.hero-date { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.hero-headline {
  font-family: var(--font-display); font-weight: 400; letter-spacing: -0.02em;
  font-size: clamp(30px, 8.5vw, 42px); line-height: 1.04; margin: 12px 0 14px;
}
.hero-headline em { font-style: italic; color: var(--emerald); }
.count-pill {
  display: inline-block; font-family: var(--font-display); font-style: italic;
  color: var(--clay); font-size: 1.05em;
}
.hero-note { color: var(--muted); font-size: 15.5px; max-width: 34ch; }

.progress-row { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.progress-track { flex: 1; height: 8px; border-radius: 99px; background: var(--sand-deep); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--emerald), var(--emerald-bright));
  transition: width 0.5s cubic-bezier(0.2,0.7,0.2,1); }
.progress-label { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }

.find-more { width: 100%; margin-top: 20px; font-size: 17px; padding: 17px; }
.find-more[disabled] { opacity: 0.7; }
.find-more.is-loading .find-more-label::after {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 10px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%;
  vertical-align: -2px; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Quick "didn't work out" flags in the detail sheet */
.sheet-flags { padding: 14px 24px 4px; border-top: 1px solid var(--line); margin-top: 14px; }
.flags-label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.flag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.flag-btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 10px 14px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: transparent; color: var(--clay);
  -webkit-tap-highlight-color: transparent; transition: all 0.15s;
}
.flag-btn:active { background: rgba(180,98,58,0.1); transform: scale(0.96); }

/* ===================== FILTERS ===================== */
.filters { display: flex; gap: 8px; padding: 22px 22px 6px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; font-family: var(--font-body); font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 99px; border: 1.5px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: all 0.18s ease; -webkit-tap-highlight-color: transparent;
}
.chip.is-active { background: var(--ink); color: var(--sand); border-color: var(--ink); }

/* ===================== SUB-BAR (count + type filter) ===================== */
.subbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px 4px; gap: 12px;
}
.showing { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.type-btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 9px 15px; border-radius: 18px; cursor: pointer;
  border: 1.5px solid var(--line); background: transparent; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: all 0.18s ease; -webkit-tap-highlight-color: transparent;
}
.type-btn .caret { font-size: 11px; opacity: 0.7; }
/* Active "Food ✕" token state */
.type-btn.is-on { background: var(--emerald); color: #fff; border-color: var(--emerald); }
.type-btn.is-on .caret { display: none; }
.type-btn .clear-x {
  display: none; margin-left: 2px; font-size: 13px; opacity: 0.9;
  width: 20px; height: 20px; line-height: 20px; text-align: center;
  border-radius: 50%; background: rgba(255,255,255,0.18);
}
.type-btn.is-on .clear-x { display: inline-block; }

/* ===================== CATEGORY SHEET ===================== */
.cat-sheet { max-height: 70dvh; }
.cat-scroll { overflow-y: auto; padding: 40px 16px 8px; }
.cat-title { font-family: var(--font-display); font-weight: 500; font-size: 24px; letter-spacing: -0.01em; padding: 0 8px 8px; }
.cat-list { list-style: none; }
.cat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px; border-radius: var(--r-md); cursor: pointer;
  font-size: 17px; color: var(--ink); -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.cat-row:active { background: var(--sand); }
.cat-row .cat-left { display: flex; align-items: center; gap: 12px; }
.cat-row .dot { width: 10px; height: 10px; border-radius: 50%; background: transparent; border: 1.5px solid var(--line); flex: 0 0 auto; }
.cat-row.is-selected .dot { background: var(--emerald); border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(31,122,85,0.15); }
.cat-row.is-selected { font-weight: 600; }
.cat-row .cat-count { font-size: 15px; color: var(--muted); font-weight: 600; }
.cat-row.is-empty { opacity: 0.4; pointer-events: none; }

/* ===================== LEAD CARDS ===================== */
.list { padding: 14px 18px 8px; display: flex; flex-direction: column; gap: 14px; }
.card {
  position: relative; background: var(--paper-card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 20px 18px; cursor: pointer; overflow: hidden;
  box-shadow: 0 18px 36px -28px rgba(28,26,23,0.5);
  transition: transform 0.14s ease, box-shadow 0.2s ease;
  animation: cardIn 0.5s cubic-bezier(0.2,0.7,0.2,1) both;
}
.card:active { transform: scale(0.985); }
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--sand-deep);
}
.card[data-status="interested"]::before { background: var(--gold); }
.card[data-status="contacted"]::before { background: var(--emerald); }
.card[data-status="contacted"] { opacity: 0.66; }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-cat { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--clay); font-weight: 700; }
.card-name { font-family: var(--font-display); font-weight: 500; font-size: 21px; line-height: 1.12; letter-spacing: -0.015em; margin-top: 5px; }
.card-area { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.card-badge {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  padding: 5px 10px; border-radius: 99px; text-transform: uppercase;
}
.badge-wa { background: rgba(31,122,85,0.12); color: var(--emerald-ink); }
.badge-call { background: rgba(180,98,58,0.14); color: var(--clay); }
.badge-star { background: var(--ink); color: var(--gold); }

.card-preview {
  font-family: var(--font-read); font-size: 15.5px; color: var(--ink-soft);
  margin-top: 14px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-cta { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.card-cta .btn { flex: 1; padding: 13px 14px; font-size: 15px; }
.icon-btn {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 14px;
  border: 1.5px solid var(--line); background: transparent;
  display: grid; place-items: center; font-size: 19px; cursor: pointer; color: var(--ink-soft);
  -webkit-tap-highlight-color: transparent; transition: transform 0.12s;
}
.icon-btn:active { transform: scale(0.92); }

/* ===================== EMPTY ===================== */
.empty { text-align: center; padding: 70px 30px; animation: rise 0.5s ease both; }
.empty-mark {
  width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--emerald); color: #fff; display: grid; place-items: center; font-size: 30px;
}
.empty-title { font-family: var(--font-display); font-size: 26px; font-weight: 500; }
.empty-sub { color: var(--muted); margin-top: 8px; max-width: 32ch; margin-inline: auto; }
.empty-link { color: var(--emerald); font-weight: 600; text-decoration: none; }

.footer { text-align: center; padding: 30px 30px 8px; color: var(--muted); font-size: 13.5px; }

/* ===================== DETAIL SHEET ===================== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(28,26,23,0.5); backdrop-filter: blur(3px); animation: fade 0.25s ease both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto;
  background: var(--paper-card);
  border-radius: 28px 28px 0 0;
  border: 1px solid var(--line); border-bottom: none;
  box-shadow: 0 -20px 50px -20px rgba(28,26,23,0.5);
  max-height: 90dvh; display: flex; flex-direction: column;
  padding-bottom: calc(18px + var(--safe-b));
  animation: sheetUp 0.4s cubic-bezier(0.2,0.8,0.2,1) both;
}
.sheet::before { content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 44px; height: 5px; border-radius: 99px; background: var(--line); }
.sheet-close {
  position: absolute; top: 18px; right: 18px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--sand); color: var(--ink-soft); font-size: 15px; cursor: pointer;
}
.sheet-scroll { overflow-y: auto; padding: 38px 24px 10px; -webkit-overflow-scrolling: touch; }
.sheet-cat { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--clay); font-weight: 700; }
.sheet-name { font-family: var(--font-display); font-weight: 500; font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; margin: 6px 0 12px; }
.sheet-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.sheet-meta span { font-size: 13px; color: var(--muted); background: var(--sand); padding: 5px 11px; border-radius: 99px; }

.msg-block { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 14px; }
.msg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.msg-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; }
.msg-tag.wa { background: rgba(31,122,85,0.14); color: var(--emerald-ink); }
.msg-tag.em { background: rgba(199,154,62,0.18); color: #6f5418; }
.msg-src { font-size: 11px; color: var(--muted); font-style: italic; }
.msg-subject { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.msg-body { font-family: var(--font-read); font-size: 16px; line-height: 1.55; color: var(--ink-soft); white-space: pre-wrap; }

.sheet-actions { display: flex; gap: 10px; padding: 12px 24px 8px; }
.sheet-actions .btn-go { flex: 2; }
.sheet-actions .btn-soft { flex: 1; }
.sheet-status { display: flex; gap: 10px; padding: 6px 24px 0; }
.sheet-status .btn { flex: 1; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translateX(-50%);
  z-index: 40; background: var(--ink); color: var(--sand);
  padding: 13px 22px; border-radius: 99px; font-size: 14.5px; font-weight: 600;
  box-shadow: 0 14px 30px -12px rgba(0,0,0,0.5); animation: toastIn 0.3s ease both;
}

/* ===================== ANIMATIONS ===================== */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: transl(-50%, 10px); } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Desktop (your Tower): stay a calm centered column, never a stretched dashboard */
@media (min-width: 640px) {
  .hero { padding-top: 44px; }
  .card:hover { transform: translateY(-3px); box-shadow: 0 26px 44px -28px rgba(28,26,23,0.55); }
  .chip { cursor: pointer; }
}
