/* CRM extensions inherit the published v4 palette and scale; no rules target client screens. */
.crm-scope {
  --bg: #f2f5fa;
  --surface: #fff;
  --ink: #161c3d;
  --muted: #545e7e;
  --line: #dce2ee;
  --primary: #2a45d4;
  --primary-dark: #1b2b8c;
  --soft: #e4eafb;
  --blue: #2a45d4;
  --blue-bg: #e4eafb;
  --amber: #6b4c00;
  --amber-bg: #fbf2dc;
  --red: #b4232f;
  --red-bg: #fcebed;
  --violet: #6255a0;
  --violet-bg: #eeeaf9;
  --radius: 16px;
  --shadow: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
  min-width: 0;
  background: transparent;
}
.crm-scope h1,
.crm-scope h2 {
  font-family: var(--display);
  letter-spacing: -0.01em;
  font-weight: 600;
}
.crm-scope h1 {
  font-size: 22px;
  line-height: 1.4;
}
.crm-scope h2 {
  font-size: 17px;
  line-height: 1.45;
}
.crm-scope h3 {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0;
}
.crm-scope button,
.crm-scope input,
.crm-scope select,
.crm-scope textarea {
  font-family: var(--font);
}
.crm-scope .btn {
  border-radius: 14px;
  min-height: 48px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
  gap: 8px;
  padding: 12px 16px;
  line-height: 1.4;
}
.crm-scope .btn.primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}
.crm-scope .btn.secondary {
  background: var(--mist);
  color: var(--primary-dark);
  border: 1px solid transparent;
}
.crm-scope .btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
}
.crm-scope .btn.danger {
  background: #fcebed;
  color: var(--danger);
  border: 1px solid #f4ccd0;
}
.crm-scope .icon-button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
}
.crm-scope .page-heading {
  align-items: flex-start;
  gap: 16px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.crm-scope .page-heading p {
  font-size: 14px;
  line-height: 1.5;
  margin-top: 8px;
}
.crm-scope .page-actions {
  gap: 8px;
  flex-wrap: wrap;
}
.crm-scope .summary-line {
  font-size: 12px;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
.crm-scope .panel {
  border-radius: 16px;
  box-shadow: none;
  overflow: hidden;
}
.crm-scope .toolbar {
  display: flex;
  flex-wrap: wrap;
  padding: 12px;
  gap: 8px;
}
.crm-scope .search-box {
  flex: 1 1 100%;
  min-width: 0;
}
.crm-scope kbd {
  display: none;
}
.crm-scope .search-box input {
  height: 44px;
  font-size: 14px;
}
.crm-scope .desktop-only {
  display: none;
}
.crm-scope .results-count {
  font-size: 11px;
}
.crm-scope .inline-filter select {
  min-height: 44px;
  max-width: 160px;
}
.crm-scope .pipeline-tabs {
  padding: 0 8px;
  overflow-x: auto;
  white-space: nowrap;
}
.crm-scope .pipeline-tab {
  min-height: 48px;
  font-size: 12px;
  padding: 12px 8px;
  gap: 4px;
}
.crm-scope .advanced-filters {
  grid-template-columns: 1fr 1fr;
  padding: 12px;
}
.crm-scope .advanced-filters label {
  min-width: 0;
}
.crm-scope .request-list {
  display: grid;
  gap: 12px;
  padding: 12px;
}
.crm-scope .request-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
}
.crm-scope .request-card:hover {
  border-color: var(--primary);
  background: #f9faff;
}
.crm-scope .request-card .row {
  gap: 8px;
  align-items: flex-start;
}
.crm-scope .request-card b {
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}
.crm-scope .request-card .badge {
  flex: none;
  white-space: normal;
  max-width: 120px;
}
.crm-scope .request-card .muted {
  font-size: 12px;
}
.crm-scope .badge {
  font-size: 11px;
  line-height: 1.4;
  border-radius: 8px;
}
.crm-scope .row {
  min-width: 0;
}
.crm-scope .row.wrap {
  flex-wrap: wrap;
}
.crm-scope input,
.crm-scope select,
.crm-scope textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  font-size: 16px;
  max-width: 100%;
  background: white;
}
.crm-scope :focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
.crm-scope .production-grid,
.crm-scope .task-grid,
.crm-scope .two-col,
.crm-scope .report-grid,
.crm-scope .settings-layout,
.crm-scope .stats-grid,
.crm-scope .form-grid,
.crm-scope .rules-list {
  grid-template-columns: minmax(0, 1fr);
}
.crm-scope .kanban-counts {
  overflow-x: auto;
  display: flex;
}
.crm-scope .kanban-counts > * {
  flex: 0 0 100px;
}
.crm-scope .production-card {
  min-width: 0;
}
.crm-scope .table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.crm-scope table {
  min-width: 600px;
  font-size: 13px;
}
.crm-scope .report-order {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.crm-scope .report-order strong {
  grid-column: 1/-1;
  text-align: left;
}
.crm-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 16px;
}
.crm-tools .text-button {
  min-height: 44px;
  font-size: 12px;
  gap: 4px;
}
.crm-tools label {
  min-width: 0;
}
.crm-tools select {
  font-size: 12px;
  max-width: 165px;
  padding: 8px;
  border-radius: 12px;
}
.crm-menu svg {
  width: 22px;
  height: 22px;
  flex: none;
}
.crm-menu .card {
  min-height: 60px;
}
.crm-menu .row {
  gap: 12px;
}
.crm-menu {
  gap: 12px;
}
.crm-client-status {
  margin-top: 0;
}
.crm-client-status .row {
  flex-wrap: wrap;
  gap: 8px;
}
.crm-scope dialog.detail-drawer,
.crm-scope dialog.modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(100%, 420px);
  height: min(100dvh, 860px);
  max-height: 100dvh;
  max-width: 100vw;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 20px 70px #161c3d25;
}
.crm-scope dialog:not([open]) {
  display: none;
}
.crm-scope dialog.detail-drawer[open] {
  display: flex;
  flex-direction: column;
}
.crm-scope dialog.modal {
  height: auto;
  max-height: min(90dvh, 820px);
  overflow: auto;
}
.crm-scope dialog::backdrop {
  background: #161c3d65;
  backdrop-filter: blur(3px);
}
.crm-scope .drawer-heading {
  padding: 16px;
  gap: 8px;
  background: #fff;
}
.crm-scope .drawer-heading h2 {
  font-size: 18px;
}
.crm-scope .drawer-tabs {
  flex: none;
  overflow-x: auto;
  padding: 0 12px;
  gap: 0;
  background: white;
}
.crm-scope .drawer-tabs button {
  padding: 12px 10px;
  min-height: 48px;
  font-size: 12px;
}
.crm-scope .drawer-content {
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.crm-scope .drawer-footer {
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  flex: none;
  background: white;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.crm-scope .drawer-footer .btn {
  flex: 1;
  min-width: 150px;
}
.crm-scope .detail-grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.crm-scope .detail-block {
  padding: 12px;
  min-width: 0;
  border-radius: 16px;
}
.crm-scope .detail-block b,
.crm-scope .detail-block p {
  overflow-wrap: anywhere;
}
.crm-scope .order-progress {
  font-size: 10px;
}
.crm-scope .item-measurements {
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.crm-scope .item-detail {
  border-radius: 16px;
  padding: 12px;
}
.crm-scope .item-detail > .row {
  flex-wrap: wrap;
}
.crm-scope .item-detail .row .row {
  flex-wrap: wrap;
}
.crm-scope .mini-item {
  min-width: 0;
}
.crm-scope .mini-item span {
  min-width: 0;
}
.crm-scope .modal-heading,
.crm-scope .modal-body,
.crm-scope .modal-footer {
  padding: 16px;
}
.crm-scope .modal-heading {
  background: white;
  position: sticky;
  top: 0;
  z-index: 2;
}
.crm-scope .modal-footer {
  background: white;
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
}
.crm-scope .modal-footer .btn {
  flex: 1;
  min-width: 0;
}
.crm-scope .form-grid {
  gap: 12px;
}
.crm-scope .draft-fields {
  grid-template-columns: 1fr 1fr;
}
.crm-scope .draft-item {
  padding: 12px;
  border-radius: 16px;
}
.crm-scope .draft-item-head {
  gap: 8px;
}
.crm-scope .form-error {
  border-radius: 12px;
}
.crm-scope .form-section-title {
  font-size: 16px;
}
.crm-v4-links {
  padding: 0 16px 16px;
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  background: var(--bg);
}
.crm-v4-links:empty {
  display: none;
}
.crm-photo-grid {
  display: flex;
  gap: 8px;
  overflow: auto;
}
.crm-photo-grid img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
}
.crm-photo-grid button {
  flex: none;
}
.crm-scope .price-breakdown {
  font-size: 14px;
}
.crm-scope .payment-balance {
  border-radius: 16px;
}
.crm-scope .order-total {
  border-radius: 16px;
}
#crm-print-area {
  display: none;
}
@media (max-width: 599px) {
  .crm-scope dialog.detail-drawer {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .crm-scope dialog.modal {
    width: calc(100% - 16px);
    border-radius: 20px;
    max-height: calc(100dvh - 24px);
  }
  .crm-scope .mobile-only {
    display: block;
  }
}
@media print {
  body > * {
    display: none !important;
  }
  body > #crm-dialogs {
    display: block !important;
  }
  #crm-print-area {
    display: block !important;
  }
}
.crm-scope .btn {
  width: auto;
}
.crm-scope .btn.full {
  width: 100%;
}
.crm-scope .toolbar .btn {
  flex: 0 0 auto;
}
.crm-scope .search-box input {
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}
.crm-scope .search-box {
  height: 44px;
}
.crm-scope .inline-filter select {
  font-size: 13px;
}
.crm-scope .toolbar-spacer {
  display: none;
}
.crm-scope .summary-line {
  margin-bottom: 16px;
}
.crm-scope .request-card .badge {
  width: auto;
  position: static;
  min-height: 0;
}
.crm-scope .pipeline-tab span {
  position: static;
}
.crm-scope .page-heading {
  margin-bottom: 16px;
}
.crm-scope .crm-v4-links .btn {
  width: 100%;
}
.crm-scope .detail-tabs {
  flex: none;
  overflow-x: auto;
  padding: 0 12px;
  gap: 0;
  background: white;
}
.crm-scope .detail-tabs button {
  padding: 12px 10px;
  min-height: 48px;
  font-size: 12px;
}
.crm-scope .drawer-heading,
.crm-scope .drawer-subhead {
  flex: none;
}
.crm-scope .drawer-footer {
  display: block;
}
.crm-scope .drawer-footer > .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.crm-scope .crm-v4-links {
  padding: 16px 0 0;
  max-height: none;
  overflow: visible;
}
.crm-scope .modal-content {
  padding: 16px;
}
.crm-scope dialog.modal {
  height: fit-content;
}
.crm-scope .modal-form {
  max-height: calc(100dvh - 26px);
}
.crm-scope .modal-footer {
  flex: none;
}
.crm-scope .modal-content {
  min-height: 0;
  flex: 1;
}
.crm-scope .modal-heading {
  flex: none;
}
@media print {
  body > #crm-print-area {
    display: block !important;
    position: static;
    width: 100%;
    padding: 24px;
    background: white;
  }
  #crm-print-area h1 {
    font-size: 20px;
  }
  #crm-print-area table {
    width: 100%;
    min-width: 0;
    margin: 24px 0;
  }
  #crm-print-area th,
  #crm-print-area td {
    padding: 8px;
    border: 1px solid #ddd;
    text-align: left;
  }
}
/* The phone shell uses compact labelled records instead of sideways desktop tables. */
.crm-scope .data-table {
  display: block;
  min-width: 0;
  width: 100%;
}
.crm-scope .data-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
  white-space: nowrap;
}
.crm-scope .data-table tbody {
  display: grid;
  gap: 12px;
  padding: 12px;
}
.crm-scope .data-table tr {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 0;
}
.crm-scope .data-table td {
  display: block;
  border: 0;
  padding: 0;
  min-width: 0;
  max-width: none;
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.crm-scope .data-table td::before {
  content: attr(data-label);
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 4px;
}
.crm-scope .data-table td:first-child {
  grid-column: 1/-1;
  padding-right: 36px;
}
.crm-scope .data-table td:first-child::before,
.crm-scope .data-table td:last-child::before {
  display: none;
}
.crm-scope .data-table td:last-child {
  position: absolute;
  right: 8px;
  top: 8px;
}
.crm-scope .data-table[data-kind='customers'] td:nth-child(2) {
  grid-column: 1/-1;
}
.crm-scope .data-table td small {
  font-size: 12px;
  line-height: 1.5;
  margin-top: 4px;
  white-space: normal;
}
.crm-scope .data-table .client-cell {
  padding: 0;
  display: flex;
  gap: 12px;
}
.crm-scope .table-wrap {
  overflow: visible;
}

.crm-scope .finance-strip,
.crm-scope .finance-strip.four {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
}
.crm-scope .finance-strip > div {
  min-width: 0;
  padding: 14px 12px;
  border: 0;
}
.crm-scope .finance-strip strong {
  font-size: 20px;
  overflow-wrap: anywhere;
}
.crm-scope .report-filters {
  flex-wrap: wrap;
}
.crm-scope .report-filters label {
  flex: 1 1 135px;
  min-width: 0;
}
.crm-scope .report-order > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.crm-menu .card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  min-height: 60px;
}
.crm-menu .card > span {
  display: flex;
  align-items: center;
  gap: 12px;
}
.crm-menu .icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}
.crm-scope .chart-track i {
  background: var(--primary);
}
.crm-scope .report-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}
.crm-scope .report-filters label {
  display: grid;
  gap: 6px;
  font-size: 12px;
}
.crm-scope .report-filters input {
  width: 100%;
  max-width: 100%;
  font-size: 14px;
}
.crm-scope .report-filters .btn {
  justify-self: start;
}

/* A production order number must be easy to tap on a phone. */
.crm-scope .production-card .text-button[data-action='open-order'] {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
}
.crm-scope .production-card .text-button { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; }
