:root {
  --bg: #f4efe6;
  --bg-deep: #e6dccf;
  --paper: #fbf8f2;
  --paper-strong: #fffdf8;
  --ink: #1d1a17;
  --muted: #5d554c;
  --line: rgba(49, 37, 24, 0.12);
  --accent: #a06a3a;
  --accent-deep: #7a4b22;
  --forest: #314a3b;
  --shadow: 0 20px 60px rgba(61, 39, 15, 0.12);
  --radius: 24px;
  /* Shared by body + main column so CRM matches Studio canvas */
  --page-bg-image:
    radial-gradient(circle at top left, rgba(160, 106, 58, 0.18), transparent 30%),
    radial-gradient(circle at right center, rgba(49, 74, 59, 0.12), transparent 25%),
    linear-gradient(160deg, #efe8dc 0%, #f9f5ef 44%, #f1eadf 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: var(--page-bg-image);
  background-attachment: fixed;
  min-height: 100vh;
}

.main-panel .content {
  /* Reduce eye strain by limiting line length */
  max-width: 1200px;
  margin: 0 auto;
  min-width: 0;
}

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

.page-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 36px 28px;
  background: linear-gradient(180deg, rgba(29, 26, 23, 0.94), rgba(49, 40, 31, 0.92));
  color: #f8f2e8;
  display: grid;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar > div {
  width: 100%;
  min-width: 0;
}

.sidebar h1,
.hero h2,
.section-heading h3 {
  font-family: "Cormorant Garamond", serif;
  letter-spacing: 0.01em;
}

.sidebar h1 {
  font-size: 3rem;
  line-height: 0.95;
  margin: 0 0 14px;
}

.intro {
  margin: 0;
  color: rgba(248, 242, 232, 0.82);
  line-height: 1.6;
}

.card {
  background: rgba(255, 251, 245, 0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.sidebar .card {
  background: rgba(255, 248, 240, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.spotlight h2,
.mini-note h2 {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.sidebar .eyebrow {
  color: #d9aa7a;
}

.matter-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.matter-item {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: inherit;
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.matter-item:hover,
.matter-item.active {
  transform: translateY(-1px);
  border-color: rgba(217, 170, 122, 0.9);
  background: rgba(217, 170, 122, 0.12);
}

.matter-item__name,
.matter-item__meta {
  display: block;
}

.matter-item__name {
  font-weight: 700;
}

.matter-item__meta {
  opacity: 0.7;
  margin-top: 4px;
  font-size: 0.9rem;
}

.workflow-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
  color: rgba(248, 242, 232, 0.84);
}

/* Make Workflow card taller in sidebar */
.sidebar .mini-note {
  min-height: 220px;
}

.main-panel {
  padding: 30px;
  background: var(--page-bg-image);
  background-attachment: fixed;
  /* Lets the grid’s 1fr column shrink so inner overflow-x: auto can show scrollbars */
  min-width: 0;
}

.hero {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  min-width: 0;
}

/* Title block: don’t consume the whole row so the toolbar can stay one line */
.hero > div:first-child {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(480px, 42vw);
}

.hero h2 {
  margin: 0;
  font-size: 3rem;
}

.hero-copy {
  margin: 10px 0 0;
  max-width: 800px;
  color: var(--muted);
  line-height: 1.6;
}

/* CRM home: no top toolbar — let headline + copy span a readable width */
.crm-home .hero--no-actions > div:first-child {
  max-width: min(56rem, 100%);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex: 1 1 0%;
  min-width: 0;
  overflow: visible;
}

.hero-actions > * {
  flex: 0 0 auto;
}

.studio-quick-jump {
  flex: 1 1 420px;
  max-width: min(520px, 45vw);
  padding: 10px 12px;
}

.studio-quick-jump .crm-quick-jump-label {
  display: none;
}

.studio-quick-jump .crm-quick-jump-hint {
  display: none;
}

.studio-quick-jump .crm-quick-jump-results {
  max-height: min(55vh, 300px);
}

@media (max-width: 820px) {
  .studio-quick-jump {
    flex: 1 1 100%;
    max-width: none;
  }
}

/* Slightly tighter pills so the inquiry toolbar fits one row */
.hero-actions .btn {
  padding: 11px 14px;
  font-size: 0.875rem;
}

/* Inquiry picker: native select styling (avoid pill-shaped .btn on <select>) */
select.studio-matter-select {
  min-width: 200px;
  max-width: min(320px, 55vw);
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--paper-strong);
  border: 1px solid rgba(49, 37, 24, 0.14);
  color: var(--ink);
  appearance: auto;
}

select.studio-matter-select:focus {
  outline: none;
  border-color: rgba(160, 106, 58, 0.8);
  box-shadow: 0 0 0 4px rgba(160, 106, 58, 0.12);
}

.hero-actions select.studio-matter-select {
  padding: 10px 14px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

/* Full-bleed cards: avoids an empty third column beside span-2 blocks */
.workspace-grid .workspace-span-full {
  grid-column: 1 / -1;
}

.span-2 {
  grid-column: span 2;
}

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

.section-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.studio-output-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* CRM client profile — saved Studio memorandum */
.binding-doc-body {
  margin: 0;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 245, 0.65);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.55;
  max-height: 28rem;
  overflow-y: auto;
}

.unsaved-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-deep, #8b4513);
  white-space: nowrap;
}

.section-heading h3,
.card h2,
.card h3,
.card h4 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid label:nth-last-child(-n + 6),
.form-grid label textarea,
.form-grid label:has(textarea) {
  grid-column: span 2;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(49, 37, 24, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--paper-strong);
  color: var(--ink);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(160, 106, 58, 0.8);
  box-shadow: 0 0 0 4px rgba(160, 106, 58, 0.12);
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff8f1;
  box-shadow: 0 12px 24px rgba(160, 106, 58, 0.22);
}

.btn-danger {
  background: rgba(255, 248, 246, 0.95);
  color: #8b2e2e;
  border: 1px solid rgba(139, 46, 46, 0.45);
  font-weight: 700;
}

.btn-danger:hover {
  background: rgba(139, 46, 46, 0.1);
  border-color: rgba(139, 46, 46, 0.65);
}

.btn-secondary {
  background: rgba(255, 253, 248, 0.8);
  color: var(--ink);
  border: 1px solid rgba(49, 37, 24, 0.12);
}

.btn-block {
  width: 100%;
  display: block;
}
.btn-block + .btn-block { margin-top: 12px; }

/* CRM / Studio: segmented control — pills sit on the sidebar card (no dark track) */
.sidebar-app-nav {
  margin: 0;
  width: 100%;
}

.sidebar-nav-segmented {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0;
  width: 100%;
  align-items: stretch;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  height: auto;
}

.sidebar-nav-segment {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 14px;
  border-radius: 13px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  color: rgba(248, 242, 232, 0.52);
  background: transparent;
  border: 1px solid transparent;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.sidebar-nav-segment:not(.is-active) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(248, 242, 232, 0.78);
}

.sidebar-nav-segment:hover:not(.is-active) {
  color: rgba(248, 242, 232, 0.92);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.14);
}

.sidebar-nav-segment:focus-visible {
  outline: 2px solid rgba(217, 170, 122, 0.9);
  outline-offset: 2px;
}

.sidebar-nav-segment.is-active {
  color: #1d1a17;
  background: linear-gradient(180deg, #fffdf8, #f3e9dd);
  border: 1px solid rgba(255, 255, 255, 0.55);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}
.sidebar .muted {
  color: rgba(248, 242, 232, 0.82);
}
.sidebar .mini-note h2,
.sidebar .spotlight h2 {
  margin-top: 0;
  color: #f8f2e8;
  font-family: "Cormorant Garamond", serif;
}
.sidebar .mini-note p,
.sidebar .spotlight p {
  color: rgba(248, 242, 232, 0.82);
}

/* Compatibility for non-Studio pages using _layout.html */
a { color: inherit; }
/* main-panel provides outer padding; avoid double padding with .content */
.content {
  padding: 0;
  min-width: 0;
  width: 100%;
}
.page-title { font-family: var(--font-heading, "Cormorant Garamond", serif); font-size: 1.8rem; color: var(--ink); }

.page-title {
  letter-spacing: 0.01em;
}

.card h2,
.card h3,
.section-heading h3 {
  line-height: 1.15;
}

.card > h2,
.card > h3 {
  margin-bottom: 10px;
}

.muted {
  color: rgba(61, 52, 44, 0.82);
}
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 980px) { .grid { grid-template-columns: 1fr 1fr; } }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.split { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 980px) { .split { grid-template-columns: 1fr 1fr; } }
.split > div { min-width: 0; }

/* CRM — import transcript: file + checkbox not split across 2 columns */
.transcript-import-form .transcript-import-file-block {
  margin-top: 12px;
}

.transcript-import-form .transcript-import-file-block > label {
  margin-bottom: 8px;
}

.transcript-import-form .inline-checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
}

.transcript-import-form .inline-checkbox-label input[type="checkbox"] {
  width: auto;
  min-width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent-deep);
  cursor: pointer;
}

.transcript-import-form .inline-checkbox-label span {
  line-height: 1.35;
  font-weight: 600;
}

.client-transcript-cta {
  border: 1px solid rgba(160, 106, 58, 0.35);
  box-shadow: 0 8px 28px rgba(29, 26, 23, 0.06);
  background: linear-gradient(165deg, rgba(255, 252, 247, 0.98) 0%, rgba(250, 244, 235, 0.95) 100%);
}

.client-transcript-cta .client-transcript-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.client-transcript-cta .btn-cta-import {
  padding: 12px 22px;
  font-size: 1.05rem;
  font-weight: 700;
}

.client-files-drafts-card h4.client-files-drafts-heading {
  font-family: var(--font-heading, "Cormorant Garamond", serif);
  font-size: 1.15rem;
  margin: 20px 0 10px;
  color: var(--ink);
}

.client-files-drafts-card h4.client-files-drafts-heading:first-of-type {
  margin-top: 4px;
}

.client-files-drafts-divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
  opacity: 0.85;
}

/* CRM — Activity form + AI preview */
.crm-activity-card {
  border: 1px solid var(--line);
}

.crm-activity-card-head {
  margin-bottom: 16px;
}

.crm-activity-intro {
  margin: 10px 0 0;
  line-height: 1.5;
  max-width: 40rem;
}

.crm-activity-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .crm-activity-grid {
    grid-template-columns: minmax(140px, 180px) 1fr;
    align-items: start;
  }

  .crm-activity-field-full {
    grid-column: 1 / -1;
  }

  .crm-activity-field-wide {
    grid-column: 2 / -1;
  }

  .crm-activity-field:not(.crm-activity-field-full):not(.crm-activity-field-wide) {
    grid-column: 1;
  }
}

.crm-activity-field > label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 6px;
  color: var(--muted);
}

.crm-activity-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
  border-radius: 12px;
  padding: 12px 14px;
}

.activity-ai-panel {
  margin-top: 2px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(160, 106, 58, 0.2);
}

.activity-ai-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 12px 16px;
  justify-content: space-between;
}

.activity-ai-left {
  flex: 1 1 auto;
  min-width: 0;
}

.activity-ai-transcript-select {
  width: 100%;
  max-width: 520px;
}

.activity-ai-checkbox-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
}

.activity-ai-checkbox-label input {
  margin-top: 3px;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  accent-color: var(--accent-deep);
  cursor: pointer;
}

.activity-generate-btn {
  flex-shrink: 0;
  white-space: nowrap;
  /* Align with the transcript dropdown (below the label) */
  margin-top: 22px;
}

@media (max-width: 560px) {
  .activity-ai-toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .activity-generate-btn {
    margin-top: 0;
  }
}

.activity-ai-preview {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(29, 26, 23, 0.08);
}

.activity-ai-preview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 12px;
}

.activity-ai-preview-title {
  font-family: var(--font-heading, "Cormorant Garamond", serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}

.activity-ai-preview-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(180, 60, 50, 0.1);
  color: #6b2a22;
  font-size: 0.9rem;
}

.activity-ai-preview-body {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .activity-ai-preview-body {
    grid-template-columns: 1fr 1.2fr;
  }
}

.activity-ai-preview-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.activity-ai-preview-box {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(250, 246, 240, 0.95);
  border: 1px solid var(--line);
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  min-height: 2.5rem;
}

pre.activity-ai-preview-notes {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  max-height: 220px;
  overflow: auto;
}

.activity-ai-preview-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.activity-ai-preview-meta {
  margin: 10px 0 0;
}

.crm-activity-submit-row {
  margin-top: 18px;
  padding-top: 4px;
}

.crm-activity-grid .crm-activity-datetimes .crm-activity-field input[type="datetime-local"] {
  width: 100%;
}

.crm-activity-grid .crm-activity-datetimes {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
}

@media (max-width: 340px) {
  .crm-activity-grid .crm-activity-datetimes {
    grid-template-columns: 1fr;
  }
}

input, textarea, select { min-width: 0; }

/* CRM — tighten whitespace in client edit cards */
.crm-client-edit-card h3 {
  margin-top: 0;
}

.crm-client-edit-card .muted.small {
  margin-bottom: 8px;
}

.crm-client-edit-split {
  gap: 10px;
}

.crm-client-edit-card textarea {
  min-height: 92px;
  resize: vertical;
}

/* CRM — activity history timeline rail + day markers */
.crm-history-timeline-card p.muted.small {
  margin-bottom: 10px !important;
}

.crm-timeline-rail {
  position: relative;
  padding-left: 18px;
}

.crm-timeline-rail::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: rgba(49, 37, 24, 0.12);
  border-radius: 999px;
}

.crm-timeline-day {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 8px;
  padding-left: 4px;
}

.crm-timeline-day-dot {
  position: absolute;
  left: -14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(160, 106, 58, 0.65);
  box-shadow: 0 0 0 4px rgba(160, 106, 58, 0.10);
}

.crm-timeline-day-text {
  font-size: 0.85rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.crm-timeline-item-rail {
  position: relative;
}

.crm-timeline-item-rail::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(49, 74, 59, 0.55);
  box-shadow: 0 0 0 4px rgba(49, 74, 59, 0.10);
}

.crm-task-open.crm-timeline-item-rail::before {
  background: rgba(160, 106, 58, 0.75);
  box-shadow: 0 0 0 4px rgba(160, 106, 58, 0.12);
}

.crm-followup.crm-timeline-item-rail::before,
.crm-followup.crm-task-open.crm-timeline-item-rail::before {
  /* Distinct “action” dot for follow-ups (not brown/green) */
  background: rgba(92, 78, 122, 0.78);
  box-shadow: 0 0 0 4px rgba(92, 78, 122, 0.14);
}

.crm-task-overdue {
  border-color: rgba(180, 60, 50, 0.35) !important;
  background: rgba(180, 60, 50, 0.03) !important;
}

.crm-pill-due {
  background: rgba(160, 106, 58, 0.14);
  color: var(--accent-deep);
}

.crm-pill-due-overdue {
  background: rgba(180, 60, 50, 0.12);
  color: #6b2a22;
}

.crm-pill-followup {
  background: rgba(49, 74, 59, 0.12);
  color: var(--forest);
}

.crm-pill-lastcontact {
  background: rgba(29, 26, 23, 0.08);
  color: var(--ink);
}

.crm-task-due-line {
  margin-top: 6px;
  color: var(--accent-deep);
}

.crm-task-due-overdue {
  color: #6b2a22;
}

.crm-btn-delete {
  padding: 4px 10px !important;
  font-size: 0.78rem !important;
  border-radius: 999px !important;
  border-color: rgba(180, 60, 50, 0.28) !important;
  background: rgba(180, 60, 50, 0.05) !important;
  color: #6b2a22 !important;
}

.crm-btn-delete:hover {
  border-color: rgba(180, 60, 50, 0.42) !important;
  background: rgba(180, 60, 50, 0.08) !important;
}

.crm-btn-compact {
  padding: 4px 10px !important;
  font-size: 0.80rem !important;
  border-radius: 999px !important;
}

.crm-btn-tiny {
  padding: 3px 9px !important;
  font-size: 0.76rem !important;
}

.crm-btn-complete {
  /* Match compact delete pill sizing */
  padding: 4px 10px !important;
  font-size: 0.78rem !important;
  line-height: 1.1 !important;
  min-height: unset !important;

  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.35) !important;
  border-color: rgba(49, 37, 24, 0.16) !important;
  box-shadow: none !important;
  font-weight: 700 !important;
}

.crm-btn-complete:hover {
  background: rgba(255, 255, 255, 0.62) !important;
  border-color: rgba(49, 37, 24, 0.22) !important;
}

.crm-btn-complete:active {
  transform: translateY(1px);
}

.crm-activity-edit summary::-webkit-details-marker {
  display: none;
}

.small { font-size: 13px; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: rgba(49, 74, 59, 0.12); color: var(--forest); font-weight: 700; font-size: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid rgba(49, 37, 24, 0.10); padding: 11px 8px; text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.table tr:hover td { background: rgba(255, 255, 255, 0.35); }

/* Old button class compatibility (btn + 'secondary') */
.btn.secondary { background: rgba(255, 253, 248, 0.8); color: var(--ink); border: 1px solid rgba(49, 37, 24, 0.12); }
.btn.secondary { text-decoration: none; }

.template-preview {
  margin-top: 16px;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 240, 229, 0.9));
  border: 1px solid rgba(49, 37, 24, 0.08);
  min-height: 240px;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.7;
}

.transcript-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.transcript-crm-panel {
  margin-bottom: 14px;
  border-radius: 18px;
  border: 1px solid rgba(49, 37, 24, 0.1);
  background: rgba(255, 251, 245, 0.55);
  padding: 14px 16px;
}

.transcript-crm-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 10px;
}

.transcript-crm-panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.transcript-crm-bulk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.transcript-crm-bulk-sep {
  color: rgba(93, 85, 76, 0.45);
  user-select: none;
}

.btn-link {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--accent-deep);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link:hover {
  color: var(--accent);
}

.transcript-summary-block {
  margin: 18px 0 16px;
}

.transcript-summary-block h4 {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.15rem;
  color: var(--ink);
}

.transcript-summary-body {
  margin: 0;
  line-height: 1.55;
  max-height: 8.5rem;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(49, 37, 24, 0.08);
  background: rgba(255, 251, 245, 0.55);
}

.crm-transcript-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid rgba(49, 37, 24, 0.08);
  background: rgba(255, 255, 255, 0.45);
}

.crm-transcript-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  margin: 0;
  font-weight: 400;
  color: var(--ink);
  border-bottom: 1px solid rgba(49, 37, 24, 0.06);
  transition: background 140ms ease;
}

.crm-transcript-row:last-child {
  border-bottom: none;
}

.crm-transcript-row:hover {
  background: rgba(160, 106, 58, 0.06);
}

.crm-transcript-row:has(.crm-transcript-row-select input:focus-visible) {
  outline: 2px solid rgba(160, 106, 58, 0.45);
  outline-offset: -2px;
}

.crm-transcript-row-select {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
  margin: 0;
}

.crm-transcript-row input[type="checkbox"] {
  width: auto;
  min-width: 1rem;
  margin-top: 3px;
  accent-color: var(--accent-deep);
  cursor: pointer;
}

.crm-transcript-delete {
  flex-shrink: 0;
  margin-top: 2px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #8b3a3a;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.crm-transcript-delete:hover {
  color: #b91c1c;
}

.crm-transcript-row-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.crm-transcript-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-word;
}

.crm-transcript-meta {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.crm-transcript-empty,
.crm-transcript-error {
  margin: 0;
  padding: 10px 2px 4px;
}

.transcript-crm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.transcript-tools-nested {
  margin-top: 12px;
  margin-bottom: 0;
}

.transcript-advanced {
  margin-top: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.35);
}

.transcript-advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.file-input input {
  padding: 10px 0 0;
  border: none;
  background: transparent;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.tag-list,
.insight-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 10px;
}

.tag-list li {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(160, 106, 58, 0.08);
  border: 1px solid rgba(160, 106, 58, 0.18);
  color: var(--accent-deep);
  font-weight: 600;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.insight-list li {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(49, 37, 24, 0.08);
  color: var(--muted);
  line-height: 1.5;
}

/* Client detail — profile header + name edit */
.client-profile-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 20px;
  row-gap: 10px;
}

.client-profile-header-label {
  grid-column: 1 / -1;
  margin: 0;
}

.client-profile-name-form {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

.client-profile-actions {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.client-profile-actions .client-touch-form {
  display: inline-flex;
  margin: 0;
  align-items: center;
}

.client-profile-actions a.btn-danger {
  text-decoration: none;
}

.client-profile-below {
  grid-column: 1 / -1;
  grid-row: 3;
}

.client-profile-meta {
  margin-top: 6px;
}

.client-profile-pills {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.client-profile-name-form.client-name-form {
  margin: 0;
}

.client-name-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.client-name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.client-name-display {
  flex: 1 1 100%;
  min-width: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 600;
  line-height: 1.25;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.client-name-display strong {
  font-weight: 600;
}

.client-name-input {
  flex: 1 1 200px;
  min-width: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 600;
  line-height: 1.2;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(49, 37, 24, 0.1);
  background: rgba(251, 248, 242, 0.65);
  color: var(--ink);
}

@media (max-width: 720px) {
  .client-profile-header {
    grid-template-columns: 1fr;
  }

  .client-profile-name-form {
    grid-column: 1;
    grid-row: 2;
  }

  .client-profile-actions {
    grid-column: 1;
    grid-row: 3;
    justify-content: flex-start;
  }

  .client-profile-below {
    grid-row: 4;
  }
}

.client-name-input:focus {
  outline: none;
  border-color: rgba(160, 106, 58, 0.45);
  box-shadow: 0 0 0 3px rgba(160, 106, 58, 0.12);
}

/* AI workflow checklist (CRM + Studio) */
.ai-workflow-card .section-heading {
  margin-bottom: 12px;
}

.workflow-ai-list {
  margin: 0;
  padding-left: 1.35rem;
  line-height: 1.55;
}

.workflow-ai-list li {
  margin-bottom: 0.5rem;
}

/* Rendered plan / HTML preview — match warm paper theme (not stark white) */
.plan-render {
  background: var(--paper-strong);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  line-height: 1.55;
}

.plan-render a {
  color: var(--accent-deep);
}

/* CRM — compact Google Calendar CTA (top left) */
.crm-top-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 14px 20px;
  width: 100%;
  margin-bottom: 14px;
}

.crm-quick-jump {
  flex: 1 1 280px;
  min-width: 0;
  max-width: min(100%, 28rem);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 251, 245, 0.8);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.crm-quick-jump-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.crm-quick-jump-inner {
  position: relative;
}

.crm-quick-jump-inner input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(49, 37, 24, 0.14);
  font-size: 0.95rem;
  background: var(--paper-strong);
}

.crm-quick-jump-inner input[type="search"]:focus {
  outline: none;
  border-color: rgba(160, 106, 58, 0.8);
  box-shadow: 0 0 0 4px rgba(160, 106, 58, 0.12);
}

.crm-quick-jump-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  max-height: min(60vh, 320px);
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  box-shadow: 0 12px 40px rgba(29, 26, 23, 0.12);
}

.crm-quick-jump-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(29, 26, 23, 0.06);
}

.crm-quick-jump-item:last-child {
  border-bottom: none;
}

.crm-quick-jump-item:hover {
  background: rgba(160, 106, 58, 0.08);
}

.crm-quick-jump-name strong {
  font-weight: 700;
}

.crm-quick-jump-meta {
  margin-top: 4px;
  line-height: 1.35;
}

.crm-quick-jump-empty {
  padding: 12px 14px;
  margin: 0;
}

.crm-quick-jump-hint {
  margin: 8px 0 0;
  line-height: 1.4;
}

.crm-studio-docs-error {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(180, 60, 50, 0.08);
  border: 1px solid rgba(180, 60, 50, 0.25);
  color: #5c2a22;
  font-size: 0.9rem;
}

.crm-studio-docs-table .crm-studio-doc-inline summary {
  list-style: none;
}

.crm-studio-docs-table .crm-studio-doc-inline summary::-webkit-details-marker {
  display: none;
}

.crm-studio-doc-body-wrap {
  padding: 10px 0 0;
  text-align: left;
}

/* CRM — transcript preview: button above, preview right-aligned */
.crm-transcript-preview {
  display: inline-block;
  text-align: right;
}

.crm-transcript-preview summary {
  display: inline-flex;
  justify-content: flex-end;
}

.crm-transcript-preview[open] summary {
  margin-bottom: 8px;
}

.crm-transcript-preview .crm-studio-doc-body-wrap {
  display: flex;
  justify-content: flex-end;
  padding-top: 0;
}

.crm-transcript-preview pre.binding-doc-body {
  width: min(720px, 70vw);
  text-align: left;
}

.crm-studio-doc-legacy-row {
  background: rgba(160, 106, 58, 0.06);
}

a.studio-crm-link[hidden] {
  display: none !important;
}

.crm-actions-inline {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
}

.crm-timeline-actions {
  flex-wrap: wrap;
}

.crm-activity-edit {
  display: inline-block;
}

.crm-activity-edit > summary {
  display: inline-flex;
  align-items: center;
}

.crm-gcal-cta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  /* Match .card on Studio so CRM chrome sits on the same canvas */
  background: rgba(255, 251, 245, 0.8);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-width: min(100%, 32rem);
}

.crm-gcal-cta-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.crm-gcal-cta .btn {
  padding: 7px 12px;
  font-size: 0.82rem;
}

@media (max-width: 520px) {
  .crm-top-bar {
    justify-content: flex-start;
  }

  .crm-gcal-cta {
    max-width: none;
    width: 100%;
    justify-content: flex-start;
  }
}

/* CRM (contacts / pipeline) */
/* Google Calendar strip (CRM) — legacy full card; home uses .crm-gcal-cta */
.crm-gcal {
  padding: 20px 22px;
}

.crm-gcal-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.crm-gcal-copy {
  flex: 1 1 240px;
  min-width: 0;
}

.crm-gcal-eyebrow {
  margin: 0 0 4px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.crm-gcal-title {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.15;
}

.crm-gcal-desc {
  margin: 0 0 12px;
  max-width: 36rem;
  line-height: 1.5;
}

.crm-gcal-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.crm-gcal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.crm-gcal-sync-form {
  display: inline;
  margin: 0;
}

.crm-gcal-error {
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(160, 106, 58, 0.35);
  background: rgba(160, 106, 58, 0.06);
}

.crm-gcal-error-msg {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.crm-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.crm-stat {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 251, 245, 0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease;
}

.crm-stat:hover {
  transform: translateY(-2px);
  border-color: rgba(160, 106, 58, 0.35);
}

.crm-stat-value {
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.crm-stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.crm-stat-alert .crm-stat-value {
  color: #8b4513;
}

/* CRM home: pipeline can shrink with the window; horizontal scroll when content is wider */
.crm-home .workspace-grid,
.crm-home .workspace-grid > .card {
  min-width: 0;
}

.crm-home .crm-filters {
  min-width: 0;
  max-width: 100%;
}

.crm-home .crm-filter-scroll {
  max-width: 100%;
}

/* Wider than narrow viewports → table-wrap shows a horizontal scrollbar instead of crushing columns */
.crm-home .crm-table {
  min-width: 720px;
}

.crm-main-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 980px) {
  .crm-main-grid {
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    align-items: start;
  }
}

/* Pipeline filters: one row for search + dropdowns when width allows; table scrolls separately */
.crm-filters {
  --crm-filter-label-gap: 3px;
}

.crm-filters .crm-filter-field label,
.crm-filters label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  margin-bottom: var(--crm-filter-label-gap);
  white-space: nowrap;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* Pipeline: filter inputs use full card width; Apply/Reset live in .crm-pipeline-heading */
.crm-filter-scroll {
  width: 100%;
  min-width: 0;
  overflow: visible;
}

.crm-pipeline-heading {
  margin-bottom: 10px;
  align-items: flex-start;
}

.crm-pipeline-heading .crm-filter-actions {
  padding-top: 0;
  align-items: center;
  align-self: flex-start;
}

.crm-filter-fields {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: flex-end;
  width: 100%;
  min-width: 0;
}

/* Share row evenly; search gets a bit more space */
.crm-filter-fields > .crm-filter-field {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
}

.crm-filter-fields > .crm-filter-field:first-child {
  flex: 1.65 1 0;
  min-width: 5.5rem;
}

.crm-filter-fields input,
.crm-filter-fields select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.875rem;
  line-height: 1.25;
  border-radius: 12px;
  min-height: 38px;
  box-sizing: border-box;
}

.crm-filter-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.crm-filter-actions .btn,
.crm-filter-actions a.btn {
  padding: 8px 16px;
  font-size: 0.84rem;
  border-radius: 999px;
  line-height: 1.2;
  min-height: 38px;
  box-sizing: border-box;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* CRM home: horizontal scrollbar only on the contacts table when the viewport is tight */
.crm-home .table-wrap {
  scrollbar-gutter: stable;
}

.crm-table {
  table-layout: fixed;
  width: 100%;
}

.crm-table th {
  white-space: nowrap;
}

.crm-table th:nth-child(1),
.crm-table td:nth-child(1) {
  width: 22%;
}

.crm-table th:nth-child(2),
.crm-table td:nth-child(2) {
  width: 10%;
}

.crm-table th:nth-child(3),
.crm-table td:nth-child(3) {
  width: 11%;
}

.crm-table th:nth-child(4),
.crm-table td:nth-child(4) {
  width: 12%;
}

.crm-table th:nth-child(5),
.crm-table td:nth-child(5) {
  width: 16%;
}

.crm-table th:nth-child(6),
.crm-table td:nth-child(6) {
  width: 13%;
}

.crm-table th:nth-child(7),
.crm-table td:nth-child(7) {
  width: 16%;
}

.crm-table tbody td {
  vertical-align: middle;
}

.crm-table-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.crm-row-overdue td {
  background: rgba(160, 106, 58, 0.08);
}

.pill-type-lead {
  background: rgba(49, 74, 59, 0.12);
  color: var(--forest);
}

.pill-type-prospect {
  background: rgba(160, 106, 58, 0.18);
  color: var(--accent-deep);
}

.pill-type-client {
  background: rgba(29, 26, 23, 0.88);
  color: #f8f2e8;
}

.client-detail-activity-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.crm-history-fullwidth {
  width: 100%;
}

.crm-history-card .crm-timeline {
  margin-top: 4px;
}

.crm-timeline {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.crm-timeline-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.55);
}

.crm-timeline-item.crm-task-open {
  border-color: rgba(160, 106, 58, 0.45);
}

.crm-timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-bottom: 6px;
}

@media (max-width: 1180px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

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

  .workspace-grid .workspace-span-full {
    grid-column: auto;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .form-grid label:nth-last-child(-n + 6),
  .form-grid label:has(textarea) {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .main-panel,
  .sidebar {
    padding: 20px;
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }

  .hero > div:first-child {
    max-width: 100%;
  }

  .hero-actions {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
  }

  .hero h2,
  .sidebar h1 {
    font-size: 2.3rem;
  }
}

@media (max-width: 520px) {
  :root {
    --radius: 18px;
  }

  .main-panel,
  .sidebar {
    padding: 14px;
  }

  .card {
    padding: 16px;
  }

  .hero {
    margin-bottom: 16px;
  }

  .hero h2 {
    font-size: 2.0rem;
  }

  .hero-actions {
    gap: 10px;
  }

  .studio-quick-jump {
    padding: 8px 10px;
  }

  select.studio-matter-select {
    width: 100%;
    max-width: 100%;
  }

  .client-profile-actions {
    gap: 8px;
  }

  .client-profile-actions .btn,
  .client-profile-actions a.btn,
  .client-profile-actions form {
    width: 100%;
  }

  .client-profile-actions form button,
  .client-profile-actions a.btn {
    width: 100%;
    justify-content: center;
  }

  .table th,
  .table td {
    padding: 10px 6px;
  }

  .crm-filter-fields > div {
    max-width: none;
  }

  /* CRM client detail — mobile polish */
  .crm-client-detail .split {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .crm-client-detail .section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .crm-client-detail .section-heading .btn,
  .crm-client-detail .section-heading a.btn {
    width: 100%;
    justify-content: center;
  }

  .crm-client-detail .transcript-import-form .client-transcript-cta-actions .btn {
    width: 100%;
  }

  .crm-client-detail .crm-transcript-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .crm-client-detail .crm-actions-inline {
    width: 100%;
    justify-content: flex-start;
  }

  .crm-client-detail .crm-history-card .crm-timeline-item {
    padding: 12px 14px;
  }

  .crm-client-detail .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* CRM home — match Studio mobile rhythm */
  .crm-home .hero-actions > * {
    width: 100%;
  }

  .crm-home .crm-quick-jump {
    max-width: 100%;
    width: 100%;
  }

  .crm-home .crm-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .crm-home .crm-stat {
    padding: 14px 14px;
  }

  /* CRM home — ensure cards truly stack like Studio */
  .crm-home .workspace-grid {
    grid-template-columns: 1fr !important;
  }

  .crm-home .span-2 {
    grid-column: auto !important;
  }

  /* CRM home — narrow phones: stack filters + heading */
  .crm-home .crm-pipeline-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .crm-home .crm-pipeline-heading .crm-filter-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-self: stretch;
  }

  .crm-home .crm-filter-scroll {
    width: 100%;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .crm-home .crm-filter-fields {
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
  }

  .crm-home .crm-filter-fields > .crm-filter-field {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .crm-home .crm-filter-fields > .crm-filter-field:first-child {
    max-width: none;
  }

  .crm-home .crm-filter-actions .btn,
  .crm-home .crm-filter-actions a.btn {
    flex: 1 1 0;
    min-width: 9rem;
  }
}
