:root {
  color-scheme: light;
  --bg: #f4f1ec;
  --panel: #ffffff;
  --panel-soft: #faf8f4;
  --ink: #1f2528;
  --muted: #71716d;
  --line: #ded7cc;
  --line-strong: #cfc4b5;
  --accent: #9a6f3e;
  --accent-dark: #6c4b27;
  --green: #2e7d62;
  --red: #a84b43;
  --blue: #285e91;
  --amber: #9a641c;
  --purple: #67539a;
  --teal: #2f7f86;
  --stage-new: #5b8fd6;
  --stage-answered: #a06c2d;
  --stage-qualified: #2f8f68;
  --stage-selection: #247f8d;
  --stage-appointment: #d18b25;
  --stage-warm: #735bb0;
  --stage-won: #2e8f4f;
  --stage-lost: #aa4d45;
  --soft-blue: #e2efff;
  --soft-brown: #ffefd9;
  --soft-green: #ddf3e7;
  --soft-teal: #def4f6;
  --soft-amber: #ffedc2;
  --soft-purple: #ebe3fb;
  --soft-red: #ffe1dd;
  --surface-blue: #f0f7ff;
  --surface-brown: #fff8ee;
  --surface-green: #eff9f3;
  --surface-teal: #eefafb;
  --surface-amber: #fff8e8;
  --surface-purple: #f6f2ff;
  --surface-red: #fff3f1;
  --shadow: 0 20px 70px rgba(55, 43, 31, 0.12);
  --shadow-soft: 0 12px 34px rgba(55, 43, 31, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.detail-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f4f1ec 0%, #e8dfd2 100%);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.sidebar h1,
.topbar h2,
.detail-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.screen-hint {
  max-width: 620px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  margin-top: 28px;
  display: grid;
  gap: 16px;
}

.login-form button,
#saveLeadButton {
  min-height: 38px;
  font-size: 14px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(154, 111, 62, 0.12);
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover,
.action-pill:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.form-error {
  margin: 0;
  color: var(--red);
}

.crm-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) minmax(360px, 430px);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 18px;
  background: #181d20;
  color: #fff;
}

.sidebar .eyebrow {
  color: #d9b37d;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.tab,
.ghost-button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
  min-height: 38px;
  padding: 8px 11px;
  font-size: 13px;
}

.tab.active {
  background: #fff;
  color: var(--ink);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
}

.sidebar-note {
  display: grid;
  gap: 3px;
  margin-bottom: 4px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-note strong {
  font-size: 13px;
}

.ghost-button.muted {
  color: rgba(255, 255, 255, 0.54);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(460px, 100%);
}

.topbar-actions input {
  min-width: 0;
}

.mobile-filters {
  display: none;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid #cfc4b5;
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.stat:nth-child(1) {
  border-top-color: var(--stage-new);
}

.stat:nth-child(2) {
  border-top-color: var(--stage-appointment);
}

.stat:nth-child(3) {
  border-top-color: var(--stage-qualified);
}

.stat:nth-child(4) {
  border-top-color: var(--red);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.stat.accent {
  border-color: rgba(154, 111, 62, 0.4);
  background: #fff8ee;
}

.content-area {
  min-height: 50vh;
}

.coach-banner,
.coach-card {
  border: 1px solid rgba(36, 127, 141, 0.28);
  border-left: 5px solid var(--stage-selection);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--soft-teal) 0%, #fff 100%);
  box-shadow: var(--shadow-soft);
}

.coach-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
}

.coach-banner strong,
.coach-card strong {
  display: block;
  color: var(--stage-selection);
  font-size: 13px;
}

.coach-banner p,
.coach-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.coach-card {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 11px 12px;
}

.coach-card span {
  display: inline-flex;
  width: fit-content;
  margin-top: 3px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
}

.today-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(154, 111, 62, 0.25);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffaf2 0%, #ffffff 100%);
  box-shadow: var(--shadow-soft);
}

.today-guide h3 {
  margin: 0;
  font-size: 16px;
}

.today-guide p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.guide-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.guide-steps span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.lead-list {
  display: grid;
  gap: 10px;
}

.lead-table {
  display: grid;
  gap: 7px;
}

.lead-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(120px, 0.75fr) minmax(160px, 1fr) minmax(180px, 1.2fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.lead-row.status-new,
.lead-card.status-new {
  background: linear-gradient(90deg, rgba(238, 246, 255, 0.95) 0%, #fff 28%);
  border-left: 4px solid var(--stage-new);
}

.lead-row.status-answered,
.lead-card.status-answered {
  background: linear-gradient(90deg, rgba(255, 246, 232, 0.96) 0%, #fff 28%);
  border-left: 4px solid var(--stage-answered);
}

.lead-row.status-qualified,
.lead-card.status-qualified {
  background: linear-gradient(90deg, rgba(237, 248, 241, 0.96) 0%, #fff 28%);
  border-left: 4px solid var(--stage-qualified);
}

.lead-row.status-selection,
.lead-card.status-selection {
  background: linear-gradient(90deg, rgba(237, 249, 250, 0.98) 0%, #fff 28%);
  border-left: 4px solid var(--stage-selection);
}

.lead-row.status-appointment,
.lead-card.status-appointment {
  background: linear-gradient(90deg, rgba(255, 247, 229, 0.98) 0%, #fff 28%);
  border-left: 4px solid var(--stage-appointment);
}

.lead-row.status-warm,
.lead-card.status-warm {
  background: linear-gradient(90deg, rgba(244, 240, 251, 0.98) 0%, #fff 28%);
  border-left: 4px solid var(--stage-warm);
}

.lead-row.status-lost,
.lead-card.status-lost {
  background: linear-gradient(90deg, rgba(255, 240, 238, 0.98) 0%, #fff 28%);
  border-left: 4px solid var(--stage-lost);
}

.lead-row.status-won,
.lead-card.status-won {
  background: linear-gradient(90deg, rgba(225, 246, 231, 0.98) 0%, #fff 28%);
  border-left: 4px solid var(--stage-won);
}

.lead-row.priority-hot,
.lead-card.priority-hot {
  box-shadow: 0 0 0 1px rgba(168, 75, 67, 0.18), var(--shadow-soft);
}

.lead-row.priority-warm,
.lead-card.priority-warm {
  box-shadow: 0 0 0 1px rgba(154, 100, 28, 0.16), var(--shadow-soft);
}

.lead-row:hover {
  border-color: rgba(154, 111, 62, 0.46);
  background: #fff;
  transform: translateY(-1px);
}

.lead-row-main,
.lead-row-next {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.lead-row-main strong,
.lead-row-next strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-row-main a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.lead-row-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.lead-row-info {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lead-row-info span,
.lead-row-info em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-row-info em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 800;
}

.lead-row-next span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.row-status-select,
.card-stage-control select {
  min-width: 122px;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 28px 4px 10px;
  background-color: #eefaff;
  border-color: rgba(47, 127, 134, 0.26);
  color: #24636a;
  font-size: 12px;
  font-weight: 800;
}

.card-stage-control {
  display: block;
}

.card-stage-control select {
  width: 100%;
  min-height: 34px;
  margin-top: 2px;
  border-radius: 8px;
  background-color: #fff;
  border-color: rgba(154, 111, 62, 0.28);
  color: var(--accent-dark);
}

.work-section {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.work-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px;
}

.work-section-header h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.work-section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-count {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 800;
}

.lead-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(55, 43, 31, 0.12), 0 1px 0 rgba(255, 255, 255, 0.85) inset;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.lead-card:hover {
  border-color: rgba(154, 111, 62, 0.55);
  box-shadow: 0 18px 38px rgba(55, 43, 31, 0.14), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  transform: translateY(-2px);
}

.lead-card[data-draggable-lead] {
  cursor: grab;
}

.lead-card[data-draggable-lead]:active {
  cursor: grabbing;
}

.lead-card.is-dragging {
  opacity: 0.86;
  transform: scale(0.99);
  box-shadow: 0 22px 46px rgba(55, 43, 31, 0.18);
}

.lead-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.lead-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  letter-spacing: 0;
}

.priority-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 999px;
  background: #b9b1a6;
  box-shadow: 0 0 0 4px rgba(185, 177, 166, 0.14);
}

.priority-hot {
  background: #fae5e1;
  color: var(--red);
}

.priority-warm {
  background: #fff0d5;
  color: var(--amber);
}

.priority-long {
  background: #e9f2ff;
  color: var(--blue);
}

.priority-unknown {
  background: #f0eee9;
  color: var(--accent-dark);
}

.priority-dot.priority-hot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(168, 75, 67, 0.13);
}

.priority-dot.priority-warm {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(154, 100, 28, 0.14);
}

.priority-dot.priority-long {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(40, 94, 145, 0.13);
}

.lead-summary {
  display: grid;
  gap: 8px;
}

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-badge,
.date-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eee8df;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.date-badge.overdue {
  background: #fae5e1;
  color: var(--red);
}

.date-badge.today {
  background: #fff0d5;
  color: #855a13;
}

.status-badge.status-new {
  background: var(--soft-blue);
  color: #245a99;
}

.status-badge.status-answered {
  background: var(--soft-brown);
  color: var(--stage-answered);
}

.status-badge.status-qualified {
  background: var(--soft-green);
  color: var(--stage-qualified);
}

.status-badge.status-selection {
  background: var(--soft-teal);
  color: var(--stage-selection);
}

.status-badge.status-lost {
  background: var(--soft-red);
  color: var(--stage-lost);
}

.status-badge.status-appointment {
  background: var(--soft-amber);
  color: #8a5a10;
}

.status-badge.status-warm {
  background: var(--soft-purple);
  color: var(--stage-warm);
}

.status-badge.status-won {
  background: #e1f6e7;
  color: var(--stage-won);
}

.status-badge.status-repeat {
  background: #f8e5d4;
  color: #91542d;
}

.priority-badge {
  background: #f0eee9;
  color: var(--accent-dark);
}

.lead-next {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--ink);
  font-size: 14px;
}

.lead-next span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.card-next-step {
  display: grid;
  gap: 4px;
  margin-top: 2px;
  padding: 10px 11px;
  border: 1px solid rgba(154, 111, 62, 0.2);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8ee 0%, #fff 100%);
}

.lead-request-date {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(91, 143, 214, 0.22);
  border-radius: 8px;
  background: rgba(240, 247, 255, 0.72);
}

.lead-request-date span,
.lead-comment span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lead-request-date strong {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.lead-comment {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid rgba(154, 111, 62, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffaf2 0%, #fff 100%);
}

.lead-comment p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-next-step span {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.card-next-step strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.card-next-step em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.card-next-step.today {
  border-color: rgba(209, 139, 37, 0.42);
  background: linear-gradient(135deg, var(--soft-amber) 0%, #fff 100%);
}

.card-next-step.overdue {
  border-color: rgba(168, 75, 67, 0.38);
  background: linear-gradient(135deg, var(--soft-red) 0%, #fff 100%);
}

.card-next-step.overdue span {
  color: var(--stage-lost);
}

.card-next-step.missing {
  border-style: dashed;
  background: linear-gradient(135deg, #f5f2ec 0%, #fff 100%);
}

.lead-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.lead-phone {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.lead-phone.muted {
  color: var(--muted);
  font-weight: 700;
}

.quick-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.quick-status-row button {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.quick-status-row button:hover,
.status-shortcuts button:hover,
.template-button:hover {
  border-color: rgba(154, 111, 62, 0.55);
  background: #fff9ef;
}

.lead-actions {
  display: flex;
  gap: 8px;
}

.mini-link {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 700;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.pipeline-column {
  min-width: 260px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(207, 196, 181, 0.9);
  border-radius: 8px;
  padding: 12px;
  border-top: 5px solid #cfc4b5;
  box-shadow: 0 14px 34px rgba(55, 43, 31, 0.1), 0 1px 0 rgba(255, 255, 255, 0.86) inset;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.pipeline-column.is-drop-target {
  border-color: rgba(31, 37, 40, 0.28);
  box-shadow: 0 18px 44px rgba(55, 43, 31, 0.14), 0 0 0 3px rgba(154, 111, 62, 0.14);
  transform: translateY(-2px);
}

.pipeline-column.is-saving {
  opacity: 0.74;
}

.pipeline-column.status-new {
  background: linear-gradient(180deg, var(--soft-blue) 0, var(--surface-blue) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-new);
}

.pipeline-column.status-answered {
  background: linear-gradient(180deg, var(--soft-brown) 0, var(--surface-brown) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-answered);
}

.pipeline-column.status-qualified {
  background: linear-gradient(180deg, var(--soft-green) 0, var(--surface-green) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-qualified);
}

.pipeline-column.status-selection {
  background: linear-gradient(180deg, var(--soft-teal) 0, var(--surface-teal) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-selection);
}

.pipeline-column.status-appointment {
  background: linear-gradient(180deg, var(--soft-amber) 0, var(--surface-amber) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-appointment);
}

.pipeline-column.status-warm {
  background: linear-gradient(180deg, var(--soft-purple) 0, var(--surface-purple) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-warm);
}

.pipeline-column.status-lost {
  background: linear-gradient(180deg, var(--soft-red) 0, var(--surface-red) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-lost);
}

.pipeline-column.status-won {
  background: linear-gradient(180deg, #cfeedd 0, var(--surface-green) 118px, rgba(255, 255, 255, 0.78) 100%);
  border-top-color: var(--stage-won);
}

.pipeline-column h3 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(207, 196, 181, 0.7);
  font-size: 14px;
  letter-spacing: 0;
}

.pipeline-column h3 span:last-child {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.pipeline-column .lead-card {
  grid-template-columns: 1fr;
  padding: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.empty-state span {
  display: block;
  max-width: 520px;
  font-size: 13px;
  line-height: 1.4;
}

.detail-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 22px;
  box-shadow: -12px 0 40px rgba(55, 43, 31, 0.06);
}

.detail-panel.status-new {
  border-top: 5px solid var(--stage-new);
}

.detail-panel.status-answered {
  border-top: 5px solid var(--stage-answered);
}

.detail-panel.status-qualified {
  border-top: 5px solid var(--stage-qualified);
}

.detail-panel.status-selection {
  border-top: 5px solid var(--stage-selection);
}

.detail-panel.status-appointment {
  border-top: 5px solid var(--stage-appointment);
}

.detail-panel.status-warm {
  border-top: 5px solid var(--stage-warm);
}

.detail-panel.status-lost {
  border-top: 5px solid var(--stage-lost);
}

.detail-panel.status-won {
  border-top: 5px solid var(--stage-won);
}

.detail-panel.priority-hot {
  background: linear-gradient(180deg, rgba(250, 229, 225, 0.45) 0, #fff 120px);
}

.detail-panel.priority-warm {
  background: linear-gradient(180deg, rgba(255, 240, 213, 0.52) 0, #fff 120px);
}

.detail-panel.priority-long {
  background: linear-gradient(180deg, rgba(233, 242, 255, 0.52) 0, #fff 120px);
}

.detail-panel form {
  padding-bottom: 72px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.analytics-box div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.analytics-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.analytics-box strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.analytics-box {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
}

.analytics-box div {
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: baseline;
  padding: 9px 10px;
  background: var(--surface-green);
  border-color: rgba(47, 143, 104, 0.32);
}

.analytics-box a {
  color: #2d66ad;
  text-decoration: none;
}

.status-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}

.status-shortcuts button {
  min-height: 34px;
  padding: 7px 9px;
  background: #fff;
  color: var(--accent-dark);
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
}

.action-pill {
  flex: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  background: var(--panel-soft);
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.action-pill.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.form-grid.work-core {
  background: linear-gradient(135deg, var(--soft-amber) 0%, #fffdf9 100%);
  border-color: rgba(209, 139, 37, 0.46);
  box-shadow: 0 12px 30px rgba(154, 100, 28, 0.1);
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.detail-module .form-grid {
  margin: 12px 14px 14px;
  padding: 0;
  border: 0;
  background: transparent;
}

.action-plan {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(47, 127, 134, 0.34);
  border-left: 5px solid var(--stage-selection);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--surface-teal) 0%, #fff 100%);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.action-plan-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.action-plan-header > div {
  min-width: 0;
}

.action-plan-header strong {
  display: block;
  color: var(--stage-selection);
  font-size: 14px;
}

.action-plan-header p,
.action-plan-note {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.action-plan-header > span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #fff;
  color: var(--stage-selection);
  font-weight: 900;
}

.action-plan-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.action-plan-done {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(47, 127, 134, 0.24);
}

.action-plan-done > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
  margin: 18px -22px -22px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.detail-actions .save-state {
  grid-column: 1 / -1;
}

.detail-actions button {
  min-height: 36px;
}

.detail-module {
  margin-top: 12px;
  padding: 0;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: #fffdf9;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(55, 43, 31, 0.06);
}

.detail-module.module-client {
  background: var(--surface-blue);
  border-color: rgba(91, 143, 214, 0.36);
  border-left-color: var(--stage-new);
}

.detail-module.module-analytics {
  background: var(--surface-green);
  border-color: rgba(47, 143, 104, 0.34);
  border-left-color: var(--stage-qualified);
}

.detail-module.module-extra {
  background: var(--surface-amber);
  border-color: rgba(209, 139, 37, 0.36);
  border-left-color: var(--stage-appointment);
}

.detail-module.module-activities {
  background: var(--surface-teal);
  border-color: rgba(36, 127, 141, 0.34);
  border-left-color: var(--stage-selection);
}

.detail-module.module-templates {
  background: var(--surface-purple);
  border-color: rgba(115, 91, 176, 0.32);
  border-left-color: var(--stage-warm);
}

.detail-module.module-timeline {
  background: var(--surface-brown);
  border-color: rgba(160, 108, 45, 0.32);
  border-left-color: var(--stage-answered);
}

.module-client .module-header h3,
.module-client .module-header::after {
  color: #245a99;
}

.module-analytics .module-header h3,
.module-analytics .module-header::after {
  color: var(--stage-qualified);
}

.module-extra .module-header h3,
.module-extra .module-header::after {
  color: #8a5a10;
}

.module-activities .module-header h3,
.module-activities .module-header::after {
  color: var(--stage-selection);
}

.module-templates .module-header h3,
.module-templates .module-header::after {
  color: var(--stage-warm);
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.module-header::-webkit-details-marker {
  display: none;
}

.module-header::after {
  content: "Раскрыть";
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-module[open] .module-header {
  border-bottom: 1px solid var(--line);
}

.detail-module[open] .module-header::after {
  content: "Свернуть";
}

.module-header h3 {
  margin: 0;
  font-size: 15px;
}

.module-header p,
.muted-text {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.activity-create {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(160px, 1fr) minmax(130px, 0.8fr) auto;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin: 12px 14px;
}

.activity-create.quick-create {
  margin: 0;
}

.activity-create > * {
  min-width: 0;
  max-width: 100%;
}

.activity-list,
.templates-list,
.timeline-list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.activity-item,
.timeline-item,
.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.activity-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.activity-item > div {
  min-width: 0;
}

.activity-item.today {
  border-color: rgba(209, 139, 37, 0.42);
  background: var(--soft-amber);
}

.activity-item.overdue {
  border-color: rgba(168, 75, 67, 0.38);
  background: var(--soft-red);
}

.activity-item.missing {
  border-style: dashed;
}

.activity-item.done {
  opacity: 0.68;
}

.action-plan-done .activity-item.done {
  opacity: 0.86;
}

.activity-item strong,
.timeline-item strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.activity-item span,
.timeline-item time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.activity-item .activity-completed {
  color: var(--green);
  font-weight: 800;
}

.activity-item p,
.timeline-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.activity-item button {
  min-height: 29px;
  padding: 5px 9px;
  background: var(--green);
  font-size: 12px;
}

.done-label {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.template-button {
  display: grid;
  gap: 2px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
}

.template-button small {
  color: var(--muted);
}

.empty-state.small {
  padding: 14px;
  font-size: 13px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.report-card h3 {
  margin: 0 0 12px;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.report-row:first-of-type {
  border-top: 0;
}

.report-row.warning strong {
  color: var(--red);
}

.save-state {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .crm-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .detail-panel {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(460px, 100%);
    z-index: 20;
    box-shadow: var(--shadow);
  }

  .pipeline {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
  }

  .lead-row {
    grid-template-columns: minmax(150px, 1.2fr) minmax(110px, 0.8fr) minmax(150px, 1fr) auto;
  }

  .lead-row-next {
    grid-column: 1 / -2;
  }
}

@media (max-width: 920px) {
  body {
    background: var(--bg);
  }

  .crm-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 14px;
    padding: 18px 16px;
  }

  .sidebar h1 {
    font-size: 34px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, minmax(118px, 1fr));
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .sidebar-footer {
    grid-template-columns: minmax(150px, 1fr) minmax(120px, 1fr) minmax(90px, 0.8fr);
    gap: 8px;
  }

  .sidebar-note,
  .ghost-button,
  .tab {
    min-height: 42px;
    padding: 9px 10px;
  }

  .workspace {
    padding: 18px 16px 28px;
  }

  .topbar {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
  }

  .topbar h2 {
    font-size: 26px;
  }

  .screen-hint {
    display: none;
  }

  .desktop-search {
    display: none !important;
  }

  .mobile-filters {
    display: block;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
  }

  .mobile-filters summary {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
  }

  .mobile-filters summary::-webkit-details-marker {
    display: none;
  }

  .mobile-filters summary::after {
    content: "⌄";
    color: var(--muted);
    font-size: 16px;
  }

  .mobile-filters[open] summary::after {
    content: "⌃";
  }

  #mobileFilterCount {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-filter-grid {
    display: grid;
    gap: 9px;
    padding: 0 12px 12px;
  }

  .mobile-filter-grid label {
    gap: 5px;
    font-size: 11px;
  }

  .stats-grid {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin: 0 -16px 12px;
    padding: 0 16px 4px;
    scrollbar-width: none;
  }

  .stat {
    flex: 0 0 auto;
    min-width: 92px;
    padding: 8px 10px;
    border-top-width: 3px;
    box-shadow: none;
  }

  .stat strong {
    margin-top: 0;
    font-size: 20px;
  }

  .pipeline {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin: 0 -16px;
    padding: 0 16px 10px;
    scroll-snap-type: x mandatory;
  }

  .pipeline-column {
    flex: 0 0 min(86vw, 380px);
    min-width: min(86vw, 380px);
    padding: 10px;
    scroll-snap-align: start;
  }

  .pipeline-column h3 {
    margin-bottom: 8px;
  }

  .pipeline-column .lead-list {
    gap: 8px;
  }

  .pipeline-column .empty-state {
    padding: 16px;
  }

  .lead-card {
    padding: 12px;
  }

  .pipeline-column .lead-card .lead-meta .status-badge:first-child {
    display: none;
  }

  .lead-card h3 {
    font-size: 15px;
  }

  .lead-meta {
    gap: 6px;
  }

  .detail-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 20;
    padding: 12px;
    background: #fff !important;
    border-left: 0;
    box-shadow: var(--shadow);
  }

  .detail-panel form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 88px;
  }

  .detail-header {
    order: 1;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .detail-header h2 {
    max-width: calc(100vw - 82px);
    overflow: hidden;
    font-size: 22px;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .detail-header .eyebrow {
    display: none;
  }

  .detail-header .icon-button {
    width: 40px;
    height: 40px;
    background: #fff;
    box-shadow: var(--shadow-soft);
  }

  .status-shortcuts {
    order: 2;
    margin-bottom: 0;
  }

  .form-grid.work-core {
    order: 3;
    gap: 9px;
    padding: 10px;
    box-shadow: none;
  }

  .action-plan {
    order: 4;
    margin-top: 0;
    width: 100%;
  }

  .quick-actions {
    order: 5;
    margin-bottom: 0;
  }

  .quick-actions .action-pill {
    min-height: 38px;
  }

  #nextStepCoach {
    order: 6;
    margin-bottom: 0;
  }

  .detail-module.module-client {
    order: 8;
  }

  .detail-module.module-extra {
    order: 9;
  }

  .detail-module.module-activities {
    order: 10;
  }

  .detail-module.module-templates {
    order: 11;
  }

  .detail-module.module-analytics {
    order: 12;
  }

  .detail-module.module-timeline {
    order: 13;
  }

  .detail-actions {
    order: 20;
    margin: 6px -12px -12px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    background: #fff;
    backdrop-filter: none;
  }
}

@media (max-width: 760px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .nav-tabs,
  .sidebar-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-note {
    grid-column: 1 / -1;
  }

  .topbar,
  .topbar-actions {
    display: grid;
    width: 100%;
  }

  .today-guide {
    display: none;
  }

  .coach-banner {
    margin-bottom: 10px;
    padding: 10px 11px;
  }

  .coach-banner p {
    font-size: 12px;
  }

  .stats-grid {
    display: flex;
    margin-bottom: 12px;
  }

  .stat {
    padding: 10px;
  }

  .stat strong {
    margin-top: 2px;
    font-size: 22px;
  }

  .lead-card {
    grid-template-columns: 1fr;
  }

  .lead-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px 8px;
    min-height: 0;
    padding: 11px;
    background: #fff;
    box-shadow: var(--shadow-soft);
  }

  .lead-row-main {
    grid-column: 1;
    grid-row: 1;
  }

  .lead-row-status {
    grid-column: 2;
    grid-row: 1;
  }

  .lead-row-info {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .lead-row-next {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .lead-row-actions {
    grid-column: 1 / -1;
    grid-row: 4;
    justify-content: stretch;
    align-items: center;
  }

  .row-status-select {
    flex: 1 1 auto;
    min-width: 0;
  }

  .lead-row-main {
    gap: 1px;
  }

  .lead-row-main strong {
    font-size: 12px;
  }

  .lead-row-main a,
  .lead-row-info,
  .lead-row-next strong {
    font-size: 11px;
  }

  .lead-row-next span {
    font-size: 10px;
  }

  .lead-row-status .priority-dot {
    display: none;
  }

  .lead-row-status .status-badge {
    min-height: 22px;
    padding: 2px 7px;
    font-size: 10px;
  }

  .lead-row-actions .mini-link {
    flex: 0 0 38px;
    min-width: 38px;
    height: 32px;
    font-size: 11px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .action-plan-header {
    align-items: flex-start;
  }

  .activity-create,
  .activity-create.quick-create {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .activity-create button,
  .activity-create input,
  .activity-create select {
    width: 100%;
  }

  .activity-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .activity-item button,
  .done-label {
    justify-self: start;
  }
}

@media (max-width: 520px) {
  .sidebar {
    gap: 9px;
    padding: 10px 12px;
  }

  .sidebar h1 {
    font-size: 24px;
  }

  .sidebar .eyebrow {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .nav-tabs,
  .sidebar-footer {
    gap: 6px;
  }

  .tab,
  .ghost-button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .sidebar-note {
    display: none;
  }

  .sidebar-note span {
    font-size: 10px;
  }

  .sidebar-note strong {
    font-size: 12px;
  }

  .workspace {
    padding: 12px 12px 24px;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .topbar-actions {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .stats-grid {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .work-section {
    gap: 8px;
    margin-bottom: 14px;
  }

  .work-section-header h3 {
    font-size: 14px;
  }

  .work-section-header p {
    display: none;
  }

  .pipeline {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .pipeline-column {
    flex-basis: 84vw;
    min-width: 84vw;
  }

  .analytics-box div,
  .status-shortcuts,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .status-shortcuts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .status-shortcuts button {
    min-height: 32px;
    padding: 6px 7px;
    font-size: 11px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .activity-create {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    gap: 8px;
  }

  .pipeline-column {
    border-radius: 7px;
  }

  .lead-card {
    border-radius: 7px;
  }

  .lead-meta {
    font-size: 12px;
  }

  .lead-contact,
  .lead-next {
    font-size: 13px;
  }
}
