/* Paladin Leads — design tokens & base */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

:root {
  /* color */
  --paper: #FAF8F3;
  --surface: #FFFFFF;
  --surface-2: #F4F1EA;
  --ink: #14110D;
  --ink-2: #3B362E;
  --ink-3: #6E665A;
  --ink-4: #9C9384;
  --hairline: #E7E2D6;
  --hairline-strong: #D8D1C0;

  /* brand */
  --gold: oklch(0.78 0.13 85);
  --gold-ink: oklch(0.55 0.11 80);
  --gold-soft: oklch(0.96 0.04 85);
  --shield-black: #14110D;

  --amber: oklch(0.72 0.13 75);
  --amber-bg: oklch(0.95 0.05 80);
  --amber-ink: oklch(0.42 0.10 70);

  --green: oklch(0.58 0.08 155);
  --green-bg: oklch(0.95 0.03 155);
  --green-ink: oklch(0.36 0.06 155);

  --blue: oklch(0.55 0.13 240);
  --blue-bg: oklch(0.96 0.03 240);
  --blue-ink: oklch(0.38 0.10 240);

  --red: oklch(0.58 0.16 25);
  --red-bg: oklch(0.96 0.04 25);

  /* spacing */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20, 17, 13, 0.04);
  --shadow: 0 1px 2px rgba(20, 17, 13, 0.04), 0 0 0 1px var(--hairline);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11';
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.mono { font-family: 'Geist Mono', ui-monospace, monospace; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============ App shell ============ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px 1fr;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--hairline);
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background-image: url('assets/paladin-shield.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex: none;
}
.brand-mark.sm { width: 28px; height: 28px; }
.brand-mark.lg { width: 44px; height: 44px; }
.brand-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-tag {
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: -2px;
}
.nav-section {
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 16px 10px 6px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14.5px;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #FAF8F3; }
.nav-item.active:hover { background: var(--ink); }
.nav-item .icon { width: 18px; height: 18px; flex: none; }
.nav-item .badge {
  margin-left: auto;
  background: var(--amber-bg);
  color: var(--amber-ink);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .badge { background: rgba(255,255,255,0.15); color: #fff; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  flex: none;
}
.user-chip-name { font-weight: 500; font-size: 14px; line-height: 1.2; }
.user-chip-biz { font-size: 12px; color: var(--ink-4); }

/* ============ Main ============ */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  padding: 20px 36px;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.topbar-left .crumb {
  font-size: 12.5px;
  color: var(--ink-4);
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content {
  padding: 28px 36px 60px;
  max-width: 1280px;
  width: 100%;
}

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.card-pad { padding: 22px 24px; }
.card-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-weight: 600; font-size: 15.5px; }
.card-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* Summary stat card */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.stat-label {
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 7px;
}
.stat-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.stat-delta {
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.delta-up { color: var(--green-ink); }
.delta-down { color: var(--red); }
.stat-label-icon {
  width: 16px;
  height: 16px;
  color: var(--ink-4);
}

/* ============ Source breakdown ============ */
.source-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}
.source-row:last-child { border-bottom: none; }
.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}
.source-name { font-weight: 500; min-width: 96px; }
.source-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.source-bar-fill {
  height: 100%;
  border-radius: 4px;
}
.source-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}
.source-pct {
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  min-width: 44px;
  text-align: right;
  font-size: 13px;
}

/* ============ Tables ============ */
.table-wrap {
  overflow-x: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  padding: 12px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
table.data th:first-child { padding-left: 24px; }
table.data th:last-child { padding-right: 24px; }
table.data td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
table.data td:first-child { padding-left: 24px; }
table.data td:last-child { padding-right: 24px; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 0.1s; }
table.data tbody tr:hover { background: oklch(0.985 0.005 80); cursor: pointer; }

.lead-name { font-weight: 600; color: var(--ink); }
.lead-contact { font-size: 13px; color: var(--ink-3); display: block; }
.cell-mono {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}
.cell-muted { color: var(--ink-3); }

/* ============ Badges ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-new { background: var(--amber-bg); color: var(--amber-ink); }
.badge-contacted { background: var(--blue-bg); color: var(--blue-ink); }
.badge-closed { background: var(--green-bg); color: var(--green-ink); }
.badge-lost { background: var(--surface-2); color: var(--ink-3); }

.src-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
}
.src-pill .dot { width: 7px; height: 7px; border-radius: 2px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  min-height: 38px;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--ink-2); }
.btn-secondary {
  background: var(--surface);
  border-color: var(--hairline-strong);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.field-help { font-size: 12.5px; color: var(--ink-4); }
.input, .select {
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14.5px;
  transition: border 0.12s, box-shadow 0.12s;
  width: 100%;
  min-height: 42px;
  color: var(--ink);
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px oklch(0.92 0.005 80);
}
.input::placeholder { color: var(--ink-4); }

/* search */
.search {
  position: relative;
  width: 280px;
}
.search .input { padding-left: 36px; }
.search-icon {
  position: absolute;
  top: 50%; left: 12px;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}

/* filter chips */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.chip {
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .count {
  background: var(--surface-2);
  color: var(--ink-3);
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.chip.on .count { background: rgba(255,255,255,0.15); color: #fff; }

/* ============ Login screen ============ */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  background: var(--paper);
}
.login-pane {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.login-pane .brand { border: none; padding: 0; margin: 0; }
.login-form-wrap {
  max-width: 380px;
  width: 100%;
  margin: auto 0;
}
.login-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.login-sub { color: var(--ink-3); margin: 0 0 32px; font-size: 15px; }
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-foot { font-size: 13px; color: var(--ink-4); }
.login-aside {
  background: var(--ink);
  color: var(--paper);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.login-aside-quote {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.3;
  max-width: 480px;
}
.login-aside-cite {
  margin-top: 24px;
  font-size: 14px;
  color: oklch(0.75 0.01 80);
}
.login-stat-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  border-top: 1px solid oklch(0.28 0.02 250);
  padding-top: 28px;
}
.login-stat-strip > div { padding-right: 16px; }
.login-stat-strip .v {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.login-stat-strip .l {
  font-size: 12px;
  color: oklch(0.7 0.01 80);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* shield background pattern */
.aside-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  display: grid;
  place-items: center;
}
.aside-bg svg { width: 80%; max-width: 600px; }

/* ============ Page heading ============ */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 2px;
}
.page-head .sub { color: var(--ink-3); font-size: 14px; }
.page-head .controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Section spacing ============ */
.row { display: grid; gap: 20px; }
.row-2 { grid-template-columns: 1.4fr 1fr; }
.gap-lg { gap: 24px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

/* ============ Mobile nav ============ */
.mobile-topbar {
  display: none;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.mobile-bottomnav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.mb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 500;
  min-height: 50px;
}
.mb-item.active { color: var(--ink); background: var(--surface-2); }
.mb-item .icon { width: 20px; height: 20px; }

/* ============ Lead card (mobile) ============ */
.lead-card-list { display: none; flex-direction: column; gap: 10px; padding: 14px; }
.lead-card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lead-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.lead-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
  font-size: 13.5px;
}
.lead-card-row .icon { width: 14px; height: 14px; color: var(--ink-4); }
.lead-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.lead-card-actions .btn { flex: 1; }

/* ============ Lead detail panel ============ */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 13, 0.35);
  z-index: 40;
  animation: fadeIn 0.15s ease;
}
.lead-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease;
  overflow: hidden;
}
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideIn { from { transform: translateX(32px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-section-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}
.panel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.panel-label {
  width: 80px;
  flex-shrink: 0;
  color: var(--ink-3);
  font-size: 13px;
}
.panel-notes {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}
.panel-notes:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px oklch(0.92 0.005 80);
}
.panel-call-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.panel-call-row:last-child { border-bottom: none; }

/* Status chips in panel */
.status-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.status-chip.on.status-new       { background: var(--amber-bg);  color: var(--amber-ink);  border-color: var(--amber-bg); }
.status-chip.on.status-contacted { background: var(--blue-bg);   color: var(--blue-ink);   border-color: var(--blue-bg); }
.status-chip.on.status-closed    { background: var(--green-bg);  color: var(--green-ink);  border-color: var(--green-bg); }
.status-chip.on.status-lost      { background: var(--surface-2); color: var(--ink-3);      border-color: var(--hairline-strong); }

@media (max-width: 760px) {
  .lead-panel { width: 100%; border-left: none; border-top: 1px solid var(--hairline); top: auto; height: 85vh; animation: slideUp 0.2s ease; }
  @keyframes slideUp { from { transform: translateY(32px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
}

/* ============ Status select (inline in leads table) ============ */
.status-select {
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.status-select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px oklch(0.92 0.005 80);
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-bottomnav { display: grid; }
  .content { padding: 18px 16px 100px; }
  .topbar { display: none; }
  .page-head h2 { font-size: 22px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 26px; }
  .card-pad { padding: 18px; }
  .desktop-table { display: none; }
  .lead-card-list { display: flex; }
  .filter-row { padding: 12px 14px; overflow-x: auto; flex-wrap: nowrap; }
  .filter-row .chip { flex: none; }
  .search { width: 100%; }
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-pane { padding: 28px 22px; min-height: 100vh; }
}
