/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg0: #0f0f1a;
  --bg1: #16162a;
  --bg2: #1e1e35;
  --bg3: #252540;
  --accent: #7c6af7;
  --accent2: #a78bfa;
  --accent-dim: rgba(124,106,247,0.15);
  --green: #34d399;
  --green-dim: rgba(52,211,153,0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251,191,36,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96,165,250,0.12);
  --text1: #f1f0ff;
  --text2: #a9a8c8;
  --text3: #6b6a8a;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html { height: 100%; font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--bg0); color: var(--text1); overflow: hidden;
  padding-top: var(--safe-top);
}

/* ─── APP SHELL ─── */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ─── TOPBAR ─── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 10px; background: var(--bg1);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 600; color: var(--text1); flex: 1; letter-spacing: -0.3px; }
.topbar-icon { width: 32px; height: 32px; border-radius: 10px; background: var(--accent-dim); display: flex; align-items: center; justify-content: center; }
.topbar-logo { font-size: 16px; }
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 12px; flex: 1;
}
.search-bar input { background: none; border: none; outline: none; color: var(--text1); font-size: 14px; width: 100%; }
.search-bar input::placeholder { color: var(--text3); }
.search-icon { color: var(--text3); font-size: 13px; flex-shrink: 0; }

/* ─── CONTENT AREA ─── */
#content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(70px + var(--safe-bottom)); }

/* ─── BOTTOM NAV ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; background: var(--bg1); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 6px; cursor: pointer; border: none; background: none;
  color: var(--text3); font-size: 10px; letter-spacing: 0.2px;
  transition: color 0.2s; -webkit-tap-highlight-color: transparent;
  position: relative;
}
.nav-btn .nav-ico { font-size: 22px; line-height: 1; transition: transform 0.2s; }
.nav-btn.active { color: var(--accent2); }
.nav-btn.active .nav-ico { transform: scale(1.1); }
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 18px);
  background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
  border-radius: 8px; padding: 1px 4px; min-width: 14px; text-align: center;
}

/* ─── PAGES ─── */
.page { display: none; }
.page.active { display: block; }

/* ─── SECTION HEADERS ─── */
.section-pad { padding: 16px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }

/* ─── CARDS ─── */
.card {
  background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden;
}
.card-header { padding: 14px 16px 0; display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text1); }
.card-sub { font-size: 12px; color: var(--text3); }
.card-body { padding: 12px 16px 14px; }
.card-body-0 { padding: 0; }

/* ─── STAT CARDS ─── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat-card.purple::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.blue::before { background: var(--blue); }
.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text1); letter-spacing: -0.5px; }
.stat-trend { font-size: 11px; margin-top: 4px; }
.trend-up { color: var(--green); }
.trend-neutral { color: var(--text3); }
.trend-down { color: var(--red); }

/* ─── LIST ITEMS ─── */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--bg2); }
.item-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: -0.5px;
}
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 500; color: var(--text1); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-right { text-align: right; flex-shrink: 0; }
.item-amount { font-size: 13px; font-weight: 600; color: var(--text1); }
.item-date { font-size: 11px; color: var(--text3); margin-top: 2px; }
.chevron { color: var(--text3); font-size: 12px; }

/* ─── TAGS & PILLS ─── */
.tag { display: inline-flex; align-items: center; font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 20px; letter-spacing: 0.03em; }
.tag-mariage { background: rgba(251,191,36,0.15); color: var(--amber); }
.tag-portrait { background: var(--blue-dim); color: var(--blue); }
.tag-corporate { background: var(--green-dim); color: var(--green); }
.tag-event { background: rgba(167,139,250,0.15); color: var(--accent2); }

.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 20px; }
.pill-lead { background: var(--bg3); color: var(--text2); }
.pill-prospect { background: var(--amber-dim); color: var(--amber); }
.pill-active { background: var(--green-dim); color: var(--green); }
.pill-done { background: var(--blue-dim); color: var(--blue); }
.pill-urgent { background: var(--red-dim); color: var(--red); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: #6655e0; }
.btn-secondary { background: var(--bg3); color: var(--text1); border: 1px solid var(--border2); }
.btn-danger { background: var(--red-dim); color: var(--red); }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text2); transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: var(--bg3); transform: scale(0.94); }

/* ─── ACTION ROW (call/sms/mail) ─── */
.action-row { display: flex; gap: 8px; padding: 12px 16px; }
.action-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border-radius: var(--radius-sm); background: var(--bg2);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.15s;
  font-size: 11px; color: var(--text2); font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.action-btn .action-ico { font-size: 20px; }
.action-btn:active { background: var(--bg3); transform: scale(0.96); }
.action-btn.call { color: var(--green); }
.action-btn.sms { color: var(--blue); }
.action-btn.mail { color: var(--accent2); }
.action-btn.map { color: var(--amber); }
.action-btn.waze { color: #a3e635; }

/* ─── TIMELINE ─── */
.timeline-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.tl-icon {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.tl-call { background: var(--green-dim); }
.tl-mail { background: var(--blue-dim); }
.tl-note { background: var(--amber-dim); }
.tl-contract { background: var(--accent-dim); }
.tl-content { flex: 1; min-width: 0; }
.tl-title { font-size: 13px; font-weight: 500; color: var(--text1); margin-bottom: 3px; }
.tl-body {
  font-size: 12px; color: var(--text2); font-style: italic;
  background: var(--bg2); border-left: 2px solid var(--border2);
  border-radius: 0 6px 6px 0; padding: 6px 10px; margin: 4px 0;
  line-height: 1.5;
}
.tl-date { font-size: 11px; color: var(--text3); }

/* ─── MOODBOARD ─── */
.moodboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 16px 16px; }
.mood-thumb {
  aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  cursor: pointer; transition: transform 0.15s;
}
.mood-thumb:active { transform: scale(0.93); }
.mood-add {
  aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px dashed var(--border2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 22px; cursor: pointer;
}

/* ─── INFO ROWS ─── */
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 13px; color: var(--text3); }
.info-val { font-size: 13px; color: var(--text1); font-weight: 500; text-align: right; }
.info-val.link { color: var(--accent2); }
.info-val.success { color: var(--green); }
.info-val.danger { color: var(--red); }

/* ─── PIPELINE ─── */
.pipeline-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
.pipeline-scroll::-webkit-scrollbar { display: none; }
.pipeline-col { min-width: 220px; scroll-snap-align: start; }
.pipeline-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg2); border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border); border-bottom: none;
}
.pipeline-col-label { font-size: 12px; font-weight: 600; color: var(--text2); }
.pipeline-count {
  background: var(--bg3); color: var(--text3); font-size: 11px;
  padding: 2px 7px; border-radius: 10px;
}
.pipeline-cards { background: var(--bg2); border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); padding: 8px; min-height: 200px; }
.pipeline-card {
  background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 6px; cursor: pointer; transition: border-color 0.15s;
}
.pipeline-card:active { border-color: var(--border2); }
.pc-name { font-size: 13px; font-weight: 500; color: var(--text1); margin-bottom: 2px; }
.pc-type { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.pc-amount { font-size: 13px; font-weight: 700; color: var(--green); }
.pc-date { font-size: 10px; color: var(--text3); margin-top: 3px; }

/* ─── AGENDA ─── */
.agenda-day-header {
  padding: 8px 16px; background: var(--bg2);
  font-size: 12px; font-weight: 600; color: var(--accent2); letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.agenda-event {
  display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.agenda-event:active { background: var(--bg2); }
.agenda-time { font-size: 11px; color: var(--text3); width: 36px; flex-shrink: 0; padding-top: 3px; }
.agenda-bar { width: 3px; border-radius: 3px; flex-shrink: 0; }
.agenda-info { flex: 1; }
.agenda-name { font-size: 14px; font-weight: 500; color: var(--text1); margin-bottom: 2px; }
.agenda-detail { font-size: 12px; color: var(--text3); }

/* ─── MAP ─── */
.map-frame {
  background: var(--bg2); height: 260px; border-radius: var(--radius);
  margin: 0 16px 12px; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.map-placeholder { text-align: center; color: var(--text3); }
.map-placeholder .mp-icon { font-size: 40px; margin-bottom: 8px; }
.map-placeholder p { font-size: 13px; }
.nav-apps { display: flex; gap: 8px; padding: 0 16px 12px; }
.nav-app-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: var(--radius-sm); background: var(--bg2);
  border: 1px solid var(--border); cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text1); transition: all 0.15s; -webkit-tap-highlight-color: transparent;
}
.nav-app-btn:active { background: var(--bg3); }

/* ─── PROSPECTION ─── */
.record-btn-big {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #9b59e8);
  border: none; cursor: pointer; font-size: 16px; font-weight: 700;
  color: #fff; font-family: inherit; margin-bottom: 12px;
  transition: all 0.2s; -webkit-tap-highlight-color: transparent;
}
.record-btn-big:active { transform: scale(0.97); opacity: 0.9; }
.record-btn-big.recording { background: linear-gradient(135deg, var(--red), #c0392b); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }

.score-bar { height: 3px; border-radius: 2px; background: var(--bg3); margin-top: 6px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 2px; }

/* ─── STATS PAGE ─── */
.chart-wrap { padding: 0 16px 8px; }
.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 100px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { border-radius: 4px 4px 0 0; width: 100%; transition: height 0.3s; }
.bar-label { font-size: 9px; color: var(--text3); }
.donut-row { display: flex; align-items: center; gap: 16px; padding: 0 16px 16px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.legend-label { color: var(--text2); flex: 1; }
.legend-pct { color: var(--text1); font-weight: 600; }

/* ─── FORMS & MODALS ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.7);
  display: none; align-items: flex-end;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  width: 100%; background: var(--bg1); border-radius: 20px 20px 0 0;
  border: 1px solid var(--border); padding: 0 0 calc(16px + var(--safe-bottom));
  max-height: 90dvh; overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.modal-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border2); margin: 12px auto 8px; }
.modal-header { padding: 8px 16px 14px; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--text1); }
.modal-close { font-size: 22px; color: var(--text3); cursor: pointer; background: none; border: none; padding: 0; line-height: 1; }

.form-group { padding: 0 16px; margin-bottom: 14px; }
.form-label { font-size: 12px; color: var(--text3); margin-bottom: 6px; display: block; font-weight: 500; }
.form-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; color: var(--text1); font-size: 15px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-select { appearance: none; cursor: pointer; }

/* ─── TABS ─── */
.tab-bar {
  display: flex; gap: 6px; padding: 12px 16px 0; overflow-x: auto;
  -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--border);
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 7px 14px; border-radius: 20px; border: none; background: none;
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text3);
  white-space: nowrap; font-family: inherit; transition: all 0.2s;
  -webkit-tap-highlight-color: transparent; flex-shrink: 0;
}
.tab-btn.active { background: var(--accent-dim); color: var(--accent2); }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-state .es-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: calc(80px + var(--safe-bottom)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 12px;
  padding: 10px 18px; font-size: 13px; color: var(--text1); z-index: 300;
  opacity: 0; transition: all 0.3s; white-space: nowrap; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── FAB ─── */
.fab {
  position: fixed; right: 20px; bottom: calc(76px + var(--safe-bottom)); z-index: 90;
  width: 52px; height: 52px; border-radius: 16px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer; border: none;
  box-shadow: 0 4px 20px rgba(124,106,247,0.5);
  transition: all 0.2s; -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(0.92); }

/* ─── SCROLLBAR HIDE ─── */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ─── TRANSITIONS ─── */
.page { animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:translateY(0)} }

/* ─── BACK BUTTON ─── */
.back-btn {
  display: flex; align-items: center; gap: 4px; padding: 6px 0;
  background: none; border: none; cursor: pointer; color: var(--accent2);
  font-size: 15px; font-family: inherit;
}

/* ─── DETAIL HERO ─── */
.detail-hero {
  padding: 20px 16px 0; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.hero-avatar {
  width: 72px; height: 72px; border-radius: 22px; display: flex; align-items: center;
  justify-content: center; font-size: 24px; font-weight: 800; margin-bottom: 12px;
  letter-spacing: -1px;
}
.hero-name { font-size: 20px; font-weight: 700; color: var(--text1); margin-bottom: 4px; }
.hero-sub { font-size: 13px; color: var(--text3); margin-bottom: 12px; }

/* ─── PIPELINE PROGRESS BAR ─── */
.pipe-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 12px; gap: 2px; }
.pipe-seg { border-radius: 3px; }

/* ─── RELANCES ─── */
.relance-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.relance-item:last-child { border-bottom: none; }
.relance-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.relance-info { flex: 1; }
.relance-name { font-size: 13px; font-weight: 500; color: var(--text1); }
.relance-detail { font-size: 11px; color: var(--text3); margin-top: 1px; }

/* ─── RESPONSIVE desktop hint ─── */
@media (min-width: 600px) {
  body { max-width: 430px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
