@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=DM+Sans:wght@400;500;700&display=swap');

:root {
  --tc-yellow: #f5d548;
  --tc-navy: #062159;
  --tc-navy-light: #123a86;
  --ink: #1c2230;
  --paper: #f5f6f8;
  --card: #ffffff;
  --border: #e6e5e0;
  --muted: #6b7280;
  --success-bg: #eaf6ec;
  --success-text: #1e6b34;
  --error-bg: #fbeaea;
  --error-text: #a3282c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 8px 24px rgba(20, 24, 40, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2 {
  font-family: 'Cormorant Garamond', serif;
  color: var(--tc-navy);
  font-weight: 700;
  margin: 0 0 4px;
}
h1 { font-size: 30px; }
h2 { font-size: 20px; }

a { color: var(--tc-navy); }

/* ============ App shell (sidebar + main) ============ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--tc-navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 20px;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--tc-yellow);
  color: var(--tc-navy);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  flex-shrink: 0;
}
.brand-name { font-family: 'Cormorant Garamond', serif; font-weight: 700; font-size: 17px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #b9c3de; margin-top: 2px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cfd7ee;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--tc-yellow); color: var(--tc-navy); font-weight: 700; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #e4e9f7; }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--tc-navy-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.logout-link { color: var(--tc-yellow); text-decoration: none; font-size: 13px; font-weight: 600; }
.logout-link:hover { text-decoration: underline; }

.app-main {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1180px;
}
.app-main-narrow { max-width: 620px; }

/* ============ Page head ============ */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.section-title { margin-top: 36px; margin-bottom: 14px; }

/* ============ Stat cards ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-accent { background: linear-gradient(135deg, var(--tc-navy), var(--tc-navy-light)); border: none; }
.stat-card-accent .stat-label { color: #c7d1ec; }
.stat-card-accent .stat-value { color: #fff; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.stat-value { font-family: 'Cormorant Garamond', serif; font-size: 30px; font-weight: 700; color: var(--tc-navy); }

/* ============ Funnel chart ============ */
.funnel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 8px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.funnel-title { margin-bottom: 14px; }
.funnel { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.funnel-row {
  display: grid;
  grid-template-columns: 100px 1fr 34px;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.funnel-label { font-size: 13px; font-weight: 600; color: var(--tc-navy); }
.funnel-bar-track {
  background: #f0efe9;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.funnel-bar { display: block; height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.funnel-bar-inquired   { background: #8fa0c9; }
.funnel-bar-interested { background: #e8b93a; }
.funnel-bar-booked     { background: #4d7fe0; }
.funnel-bar-paid       { background: #3fa564; }
.funnel-bar-completed  { background: var(--tc-navy); }
.funnel-bar-lost       { background: #c6c6c6; }
.funnel-count { font-size: 13px; font-weight: 700; text-align: right; color: var(--muted); }

/* ============ Buttons ============ */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--tc-navy);
  background: #fff;
  color: var(--tc-navy);
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(6,33,89,0.12); }
.btn-primary { background: var(--tc-navy); color: #fff; }
.btn-primary:hover { background: var(--tc-navy-light); }
.btn-small { padding: 7px 14px; font-size: 13px; }

/* ============ Alerts ============ */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* ============ Forms ============ */
.stack-form, .auth-form { display: flex; flex-direction: column; }
.stack-form label, .auth-form label { font-weight: 700; font-size: 13px; margin: 14px 0 6px; color: var(--tc-navy); }
.stack-form input, .stack-form select, .stack-form textarea, .auth-form input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  background: #fff;
}
.stack-form button, .auth-form button { margin-top: 24px; }

/* ============ Auth page ============ */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(160deg, var(--tc-navy) 0%, var(--tc-navy-light) 55%, var(--tc-navy) 100%);
}
.auth-card {
  background: var(--card);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(6, 33, 89, 0.35);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--tc-yellow); color: var(--tc-navy);
  font-family: 'Cormorant Garamond', serif; font-weight: 700; font-size: 18px;
  margin-bottom: 10px;
}
.auth-sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }

/* ============ Filter bar ============ */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .search-input {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; font-family: 'DM Sans', sans-serif; font-size: 14px;
}
.search-input { min-width: 220px; }
.clear-filters { font-size: 13px; color: var(--muted); }

/* ============ Table ============ */
.table-wrap { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); overflow-x: auto; box-shadow: var(--shadow); }
.lead-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.lead-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--border); background: #fafafa;
}
.lead-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.lead-table tr:last-child td { border-bottom: none; }
.lead-table tr:hover td { background: #fbfbf9; }
.empty-row { text-align: center; color: var(--muted); padding: 44px 16px !important; }

.name-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.row-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #eef1f8; color: var(--tc-navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ============ Stage pills ============ */
.stage-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.stage-inquired   { background: #eef1f8; color: #4a5677; }
.stage-interested { background: #fff3d6; color: #8a6300; }
.stage-booked     { background: #e0ecff; color: #1c4ea8; }
.stage-paid       { background: #dff5e3; color: #1e6b34; }
.stage-completed  { background: var(--tc-yellow); color: var(--tc-navy); }
.stage-lost       { background: #f2f2f2; color: #8a8a8a; }

/* ============ Lead detail ============ */
.back-link { font-size: 14px; text-decoration: none; display: inline-block; margin-bottom: 16px; }
.lead-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.detail-grid .label, .notes-block .label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 2px;
}
.notes-block { margin-top: 16px; }
.notes-block p { margin: 4px 0 0; }

.stage-form { margin-top: 12px; }
.stage-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-btn { border-color: var(--border); color: var(--ink); background: #fff; }
.stage-btn.active { background: var(--tc-navy); color: #fff; border-color: var(--tc-navy); }
.amount-field { margin-top: 18px; max-width: 260px; }
.amount-field label { display: block; font-size: 13px; font-weight: 700; color: var(--tc-navy); margin-bottom: 6px; }
.amount-field input { width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.hint { color: var(--muted); font-size: 13px; margin-top: 20px; }

/* ============ Mobile ============ */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; padding: 14px 18px; }
  .sidebar-brand { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
  .brand-text { display: none; }
  .sidebar-nav { flex-direction: row; flex: 1; margin-left: 16px; }
  .sidebar-footer { flex-direction: row; align-items: center; border-top: none; padding-top: 0; }
  .app-main { padding: 24px 18px 48px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .funnel-row { grid-template-columns: 84px 1fr 28px; }
}
@media (max-width: 560px) {
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 24px; }
}

/* ============ Page head actions + dropdown ============ */
.page-head-actions { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 260px;
  z-index: 20;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}
.dropdown-menu a:hover { background: #f5f6f8; }

/* ============ Analytics row (fewer, focused cards) ============ */
.analytics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

/* ============ Tabs row (status filter tabs) ============ */
.tabs-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab span { color: var(--muted); font-weight: 700; font-size: 12px; }
.tab.active { background: var(--tc-navy); color: #fff; border-color: var(--tc-navy); }
.tab.active span { color: var(--tc-yellow); }

/* ============ Status + payment pills (7 statuses) ============ */
.status-pill, .payment-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-new_lead        { background: #e6ecff; color: #2a4bb8; }
.status-interested      { background: #f3e8ff; color: #7027b8; }
.status-registered      { background: #e0f2ff; color: #0d6ea8; }
.status-payment_pending { background: #fff3d6; color: #8a6300; }
.status-confirmed       { background: #dff5e3; color: #1e6b34; }
.status-no_response     { background: #f2f2f2; color: #6b7280; }
.status-lost            { background: #fbe4e4; color: #a3282c; }

.payment-not_paid { background: #fbe4e4; color: #a3282c; }
.payment-partial  { background: #fff3d6; color: #8a6300; }
.payment-paid     { background: #dff5e3; color: #1e6b34; }

/* ============ Table extras ============ */
.sub-text { font-size: 12px; color: var(--muted); margin-top: 2px; }
.actions-cell { display: flex; gap: 6px; white-space: nowrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); text-decoration: none; font-size: 14px;
  background: #fff;
}
.icon-btn:hover { background: #f5f6f8; }
.icon-btn-danger:hover { background: var(--error-bg); border-color: var(--error-text); }

/* ============ Form grid layouts ============ */
.grid-form .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-form .form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.grid-form label { display: block; }

/* ============ Lead detail extras ============ */
.lead-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.lead-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1fb959; }
.pill-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.inline-form { margin: 18px 0; }

/* ============ Follow-up section ============ */
.followup-form .form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; margin-bottom: 12px; }
.followup-form select, .followup-form input, .followup-form textarea {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-family: 'DM Sans', sans-serif; font-size: 14px; width: 100%;
}
.followup-form textarea { margin-bottom: 12px; }
.followup-list { display: flex; flex-direction: column; gap: 10px; }
.followup-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.followup-item-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.followup-item p { margin: 6px 0 0; font-size: 14px; }

/* ============ Mobile tweaks for new components ============ */
@media (max-width: 900px) {
  .analytics-row { grid-template-columns: 1fr 1fr; }
  .grid-form .form-row-2, .grid-form .form-row-3, .followup-form .form-row-3 { grid-template-columns: 1fr; }
}
