/* ContactCRM — periwinkle/peach palette, mobile-first */

:root {
  /* Brand — periwinkle/lavender */
  --brand: #565aa0;
  --brand-hover: #45477b;
  --brand-deep: #34355a;
  --brand-haze: #f5f4fa;
  --brand-soft: #8b89be;

  /* Accent — peach/sunrise */
  --peach: #f8dcc2;
  --peach-deep: #e9b489;
  --peach-haze: #f7ede7;

  /* Blush */
  --blush-1: #e9d3d6;
  --blush-2: #f1e2e2;
  --blush-3: #f7eeee;

  /* Neutrals — silver-mauve */
  --neutral-deep: #6f6475;
  --neutral-haze: #f0ebef;

  /* Ink */
  --ink-heading: #26242f;
  --ink-body: #3d3a4c;

  /* System */
  --bg: #f6f1f4;
  --card: #ffffff;
  --border: rgba(86, 90, 160, 0.14);
  --shadow: 0 10px 30px rgba(52, 53, 90, 0.10);
  --gradient-sunrise: linear-gradient(178deg, #8b89be, #cdbcc4, #f2dccb, #f4e6e3);
  --radius: 14px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink-heading); font-weight: 650; }

button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--ink-body);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft);
  outline-offset: 1px;
  border-color: transparent;
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--brand-hover); }

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 500;
}
.btn-ghost:hover { background: var(--brand-haze); }

.btn-small { padding: 6px 12px; font-size: .85rem; }

.btn-danger {
  background: transparent;
  color: #a04a56;
  border: 1px solid rgba(160, 74, 86, .3);
  border-radius: 10px;
  padding: 9px 16px;
}
.btn-danger:hover { background: var(--blush-3); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-sunrise);
  padding: 24px;
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 44px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.login-logo { font-size: 44px; }
.login-tagline { color: var(--neutral-deep); line-height: 1.5; }
.login-note { font-size: .78rem; color: var(--neutral-deep); }

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--brand-deep); }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gradient-sunrise);
  box-shadow: 0 0 0 3px var(--brand-haze);
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; }
.user-name { font-size: .88rem; color: var(--neutral-deep); }

.main {
  flex: 1;
  padding: 20px 18px 90px;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Tab bar (bottom on mobile) ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--neutral-deep);
  font-size: .7rem;
}
.tab.active { color: var(--brand); font-weight: 600; }
.tab-icon { font-size: 1.15rem; line-height: 1; }

/* ---------- Cards & sections ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 16px;
}
.card h3 { margin-bottom: 12px; font-size: 1rem; }

.section-title {
  font-size: 1.35rem;
  margin: 6px 0 18px;
}

.hero {
  background: var(--gradient-sunrise);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 18px;
  color: var(--brand-deep);
}
.hero h2 { font-size: 1.25rem; margin-bottom: 4px; }
.hero p { font-size: .9rem; opacity: .85; }

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.stat-label { font-size: .8rem; color: var(--neutral-deep); margin-top: 2px; }

/* ---------- Lists ---------- */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--neutral-haze);
  cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--brand-haze); border-radius: 8px; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--brand-haze);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 600; color: var(--ink-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: .8rem; color: var(--neutral-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--brand-haze);
  color: var(--brand);
}
.chip.peach { background: var(--peach-haze); color: #a06a35; }
.chip.blush { background: var(--blush-2); color: #96606a; }

/* ---------- Toolbar row ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar input[type="search"] { flex: 1; min-width: 160px; }
.toolbar select { width: auto; }

/* ---------- Kanban ---------- */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.kanban-col {
  flex: 0 0 240px;
  background: var(--brand-haze);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 120px;
}
.kanban-col.drag-over { background: var(--peach-haze); }
.kanban-col h4 {
  font-size: .85rem;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  color: var(--brand-deep);
}
.kanban-count { color: var(--neutral-deep); font-weight: 500; }
.kanban-card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(52,53,90,.07);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card .row-title { font-size: .9rem; }

.pipeline-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 4px;
}
.pipeline-chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-body);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: .85rem;
  white-space: nowrap;
}
.pipeline-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 36, 47, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.modal h2 { margin-bottom: 16px; font-size: 1.15rem; }
.modal .field { margin-bottom: 13px; }
.modal label { display: block; font-size: .8rem; font-weight: 600; color: var(--neutral-deep); margin-bottom: 5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* ---------- Detail view ---------- */
.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.detail-header .avatar { width: 64px; height: 64px; font-size: 1.3rem; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--neutral-haze);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--peach-haze);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: .9rem;
}
.activity-time { font-size: .74rem; color: var(--neutral-deep); }

.back-link {
  background: none; border: none;
  color: var(--brand);
  font-weight: 600;
  padding: 0;
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.empty-state {
  text-align: center;
  color: var(--neutral-deep);
  padding: 36px 16px;
}
.empty-state .big { font-size: 2.2rem; margin-bottom: 8px; }

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
  .tabbar {
    position: sticky;
    top: 57px;
    bottom: auto;
    order: -1;
    border-top: none;
    border-bottom: 1px solid var(--border);
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
  }
  .app { flex-direction: column; }
  .main { order: 1; padding-bottom: 40px; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 7px; padding: 14px 16px; font-size: .88rem; }
  .tab.active { box-shadow: inset 0 -2px 0 var(--brand); }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
