/* Variant 01: permanent client context beside the visit, one shared form. */
.appointment-modal.appointment-editor {
  --appointment-rail: 300px;
  width: min(1040px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
  overflow: hidden;
}
.appointment-editor .appointment-editor-header {
  display: grid;
  grid-template-columns: calc(var(--appointment-rail) - 20px) minmax(0, 1fr) 40px;
  gap: 20px;
  align-items: center;
  flex: 0 0 auto;
  padding: 20px;
}
.appointment-editor-heading { min-width: 0; }
.appointment-editor-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.appointment-editor-close {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); cursor: pointer;
}
.appointment-editor-close svg, .appointment-editor-photos svg, .appointment-editor-sale-empty svg,
.appointment-editor .visit-quick-actions svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.appointment-editor .appointment-editor-palette {
  display: grid; grid-template-columns: repeat(10, minmax(0, 38px)); gap: 4px;
  width: min(416px, calc(100% - 20px)); min-width: 0; margin: 0;
}
.appointment-editor .appointment-editor-palette label {
  display: grid; place-items: center; min-width: 0; width: 100%; height: 40px; padding: 4px;
  border-radius: 9px; border: 1px solid transparent; cursor: pointer;
}
.appointment-editor .appointment-editor-palette label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.appointment-editor .appointment-editor-palette label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.appointment-editor .appointment-editor-palette span { width: 100%; height: auto; aspect-ratio: 1; border-radius: 7px; border: 1px solid #14263626; }
.appointment-editor .appointment-editor-body { padding: 0; min-height: 0; max-height: none; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.appointment-editor-workspace { display: grid; grid-template-columns: var(--appointment-rail) minmax(0, 1fr); }
.appointment-editor-rail { min-width: 0; background: #f7fafb; border-right: 1px solid var(--line); }
.appointment-editor-main { min-width: 0; }
.appointment-editor-section { min-width: 0; padding: 20px; border-bottom: 1px solid var(--line); }
.appointment-editor-section h3 { margin: 0 0 15px; font-size: 15px; font-weight: 650; color: var(--ink); }
.appointment-editor .field { min-width: 0; }
.appointment-editor .field > label { font-size: 12px; }
.appointment-editor-client .appointment-client-control,
.appointment-editor-client .appointment-client-control.has-client-phone { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
.appointment-editor-client .appointment-client-control .input,
.appointment-editor-client .appointment-client-control .input:focus {
  width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid #a8dcd5; border-radius: 10px; background: #fff; font-size: 14px; font-weight: 600;
}
.appointment-editor-client .appointment-client-phone { padding: 0; margin-top: 10px; font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
.appointment-editor-client .appointment-client-contact { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 4px; min-width: 0; margin-top: 4px; }
.appointment-editor-client .appointment-client-contact[hidden] { display: none; }
.appointment-editor-client .appointment-client-contact .appointment-client-phone { flex: 0 1 auto; margin: 0; min-width: 0; }
.appointment-editor-client .appointment-client-history { margin-left: auto; min-height: 36px; padding: 6px 0; font-size: 11.5px; white-space: nowrap; }
.appointment-client-history-actions { margin: 16px 20px; flex-wrap: wrap; }
.appointment-client-history-actions h4 { margin: 0; }
.appointment-client-history-actions .btn { min-height: 44px; }
.appointment-client-card .client-clinical-pagination { margin: 0 20px 16px; }
.appointment-editor-client .visit-reminders { margin: 14px 0 0; justify-content: flex-start; width: auto; gap: 7px; }
.appointment-editor-client .visit-reminders .clinical-alert-badge { max-width: 100%; }
.appointment-editor-client .visit-reminders .appointment-document-badge,
.appointment-editor-client .visit-reminders .appointment-document-badge .clinical-alert-label { width: auto; }
.appointment-editor-client .visit-quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 15px; }
.appointment-editor-client .visit-quick-actions > :first-child { grid-column: 1 / -1; }
.appointment-editor-client .visit-quick-actions .btn { min-width: 0; padding: 9px 5px; min-height: 40px; font-size: 12px; gap: 5px; }
.appointment-editor .visit-problem-inline { display: flex; flex-direction: column; align-items: stretch; margin: 0; padding: 0; border: 0; gap: 12px; }
.appointment-editor .visit-problem-inline-label { font-size: 15px; font-weight: 650; color: var(--ink); }
.appointment-editor .visit-problem-inline-select { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; }
.appointment-editor .visit-problem-inline-tags { justify-content: flex-start; min-height: 34px; }
.appointment-editor .visit-problem-inline-tag { max-width: 100%; }
.appointment-editor .visit-problem-inline-state { font-size: 12px; line-height: 1.6; }
.appointment-editor-problems-disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; list-style: none; cursor: pointer; font-size: 15px; font-weight: 650; color: var(--ink); }
.appointment-editor-problems-disclosure > summary::-webkit-details-marker { display: none; }
.appointment-editor-problems-disclosure > summary::after { content: ""; width: 8px; height: 8px; flex: 0 0 8px; margin-right: 4px; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); opacity: .75; transform: rotate(45deg); }
.appointment-editor-problems-disclosure[open] > summary::after { transform: rotate(225deg); }
.appointment-editor-problems-disclosure > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
.appointment-editor-problems-content { padding-top: 12px; }
.appointment-editor-problems .visit-problem-inline-label { display: none; }
.appointment-editor-photos { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.appointment-editor-photos > [data-saved-visit-photos] { display: contents; }
.appointment-editor-photos .saved-visit-photo-label { display: none; }
.appointment-editor-photos .saved-visit-photo-grid { display: contents; }
.appointment-editor-photos .saved-visit-photo-thumb,
.appointment-editor-photos .saved-visit-photo-more,
.appointment-editor-photos .appointment-photo-preview,
.appointment-editor-photo-add { width: 76px; height: 76px; flex: 0 0 76px; }
.appointment-editor-photos .appointment-photo-preview { position: relative; margin: 0; display: block; }
.appointment-editor-photos .appointment-photo-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.appointment-editor .appointment-photo-remove { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: #fffffff0; color: var(--muted); font-size: 18px; cursor: pointer; }
.appointment-editor-photo-add { position: relative; }
.appointment-editor-photo-add label { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-align: center; padding: 4px; border: 1px dashed #74c8bc; border-radius: 10px; background: #f0faf7; color: #108375; font-size: 11px; cursor: pointer; }
.appointment-editor-photo-add label:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.appointment-editor-photo-selection { display: block; margin-top: 9px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.appointment-editor-photo-selection:empty { display: none; }
.appointment-editor .appointment-editor-audit { padding: 14px 20px; }
.appointment-editor-audit .appointment-record-meta { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font-size: 11px; color: var(--muted); line-height: 1.6; }
.appointment-editor-audit .link-button { justify-self: start; font-size: 11px; }
.appointment-editor .appointment-time-grid { grid-template-columns: minmax(0, 1fr) 160px 112px; gap: 12px; }
.appointment-editor .appointment-service-row { grid-template-columns: minmax(0, 1fr) 100px 100px 40px; gap: 10px; }
.appointment-editor .appointment-service-row + .appointment-service-row { padding-top: 12px; border-top: 1px solid var(--line); }
.appointment-editor .appointment-service-row .input,
.appointment-editor .appointment-service-row .select { min-height: 44px; }
.appointment-editor .appointment-service-row .field > label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.appointment-editor .appointment-service-row .field { gap: 0; }
.appointment-editor .appointment-service-remove { width: 40px; height: 44px; }
.appointment-editor .appointment-service-price-control { position: relative; min-width: 0; }
.appointment-editor .appointment-service-price-control .input { width: 100%; padding-right: 28px; }
.appointment-editor .appointment-service-price-control > span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.appointment-editor .appointment-services-footer { align-items: flex-start; gap: 14px; }
.appointment-editor .appointment-services-summary { min-width: 0; }
.appointment-editor .appointment-availability-hint { font-size: 11px; font-weight: 400; max-width: 360px; }
.appointment-editor .appointment-add-service { font-size: 12px; min-height: 44px; flex-shrink: 0; }
.appointment-editor .appointment-sale-summary { margin: 0; grid-template-columns: 130px minmax(0, 1fr) auto; padding: 16px; gap: 14px; min-height: 94px; }
.appointment-editor .appointment-sale-summary-head { flex-wrap: wrap; }
.appointment-editor .appointment-sale-summary-head small { width: 100%; margin: 0; }
.appointment-editor .appointment-sale-summary-values { gap: 12px; }
.appointment-editor .appointment-sale-summary-values b { font-size: 17px; white-space: nowrap; }
.appointment-editor .appointment-sale-summary-open { padding: 12px; min-height: 44px; background: white; border: 1px solid #99d7cc; border-radius: 9px; }
.appointment-editor .appointment-sale-summary.is-cancelled .appointment-sale-summary-open { max-width: 150px; white-space: normal; line-height: 1.35; }
.appointment-editor-sale-empty { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; border: 1px solid #d6e7e2; border-left: 4px solid var(--primary); border-radius: 12px; background: #f5faf9; }
.appointment-editor-sale-empty > div { display: flex; align-items: center; gap: 10px; }
.appointment-editor-sale-empty small { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }
.appointment-editor-sale-icon { color: var(--primary); }
.appointment-editor-sale-empty .btn { font-size: 12px; gap: 7px; min-height: 44px; }
.appointment-editor-note .textarea { min-height: 100px; resize: vertical; }
.appointment-editor-note small { font-size: 11px; line-height: 1.6; color: var(--muted); }
.appointment-editor-status { display: flex; align-items: center; gap: 16px; background: #fbfcfd; }
.appointment-editor-status-label { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.appointment-editor-status .visit-status-toggle { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.appointment-editor .appointment-status-button { min-width: 0; min-height: 44px; padding: 7px; font-size: 12px; }
.appointment-editor .appointment-status-button[data-appointment-status="no_show"][aria-pressed="true"],
.appointment-editor .appointment-status-button[data-appointment-status="refused"][aria-pressed="true"] {
  color: #fff;
  background: #c2413b;
  border-color: #c2413b;
}
.appointment-editor .modal-footer { flex: 0 0 auto; padding: 14px 20px; background: #fff; }
.appointment-editor .modal-footer .btn { min-height: 44px; }
.appointment-editor .modal-footer .appointment-editor-cancel { color: #b95048; border: 1px solid #efcfc9; background: #fff8f7; }
.appointment-editor .inline-error { margin: 14px 20px; }
@media (max-width: 1100px) {
  .appointment-modal.appointment-editor { --appointment-rail: 270px; }
  .appointment-editor .appointment-time-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment-editor-time .field:first-child { grid-column: 1 / -1; }
  .appointment-editor .appointment-service-row { grid-template-columns: minmax(0, 1fr) 88px 88px 38px; gap: 8px; }
  .appointment-editor .appointment-sale-summary { grid-template-columns: 1fr auto; }
  .appointment-editor .appointment-sale-summary-values { grid-row: 2; grid-column: 1 / -1; }
  .appointment-editor-status { display: block; }
  .appointment-editor-status-label { display: block; margin-bottom: 10px; }
}
@media (max-width: 1000px) {
  .appointment-editor .appointment-editor-header { grid-template-columns: minmax(0, 1fr) 40px; gap: 12px; }
  .appointment-editor-close { grid-row: 1; grid-column: 2; }
  .appointment-editor .appointment-editor-palette { grid-row: 2; grid-column: 1 / -1; width: min(416px, 100%); }
}
@media (max-width: 760px) {
  .appointment-modal.appointment-editor { width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .appointment-editor .appointment-editor-header { padding: 14px 16px; }
  .appointment-editor-heading p { font-size: 11px; }
  .appointment-editor .appointment-editor-palette { width: 100%; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; }
  .appointment-editor .appointment-editor-palette label { height: 44px; max-width: 38px; padding: 2px; }
  .appointment-editor .appointment-editor-workspace { display: flex; flex-direction: column; }
  .appointment-editor-rail, .appointment-editor-main { display: none; }
  .appointment-editor-workspace > .appointment-editor-section { padding: 18px 16px; }
  .appointment-editor-workspace > .appointment-editor-client,
  .appointment-editor-workspace > .appointment-editor-audit { background: #f7fafb; }
  .appointment-editor-workspace > .appointment-editor-audit { padding: 14px 16px; }
  .appointment-editor-client .visit-quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .appointment-editor-client .visit-quick-actions > :first-child { grid-column: 1 / -1; }
  .appointment-editor-client .visit-quick-actions .btn { padding: 8px 5px; min-height: 44px; font-size: 12px; gap: 5px; }
  .appointment-editor-client .visit-quick-actions svg { width: 18px; height: 18px; flex: 0 0 18px; }
  .appointment-editor-client .visit-quick-actions [data-visit-add-problem] span,
  .appointment-editor-client .visit-quick-actions [data-visit-add-recommendation] span { font-size: 14px; }
  .appointment-editor .appointment-time-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment-editor .appointment-time-grid > .field:first-child { grid-column: 1 / -1; }
  .appointment-editor .appointment-service-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 10px; }
  .appointment-editor .appointment-service-search-field { grid-column: 1 / -1; }
  .appointment-editor-client .appointment-client-control .input { font-size: 16px; }
  .appointment-editor-client .appointment-client-history { min-height: 44px; font-size: 12px; }
  .appointment-client-history-actions { margin: 14px; gap: 10px; }
  .appointment-editor .appointment-service-remove { width: 44px; height: 44px; }
  .appointment-editor .appointment-services-footer { flex-direction: column; align-items: stretch; }
  .appointment-editor .appointment-add-service { align-self: flex-start; }
  .appointment-editor .appointment-services-summary { justify-items: start; text-align: left; gap: 7px; }
  .appointment-editor .appointment-sale-summary { grid-template-columns: 1fr; }
  .appointment-editor .appointment-sale-summary-values { grid-row: auto; grid-column: auto; justify-content: space-between; flex-wrap: wrap; }
  .appointment-editor .appointment-sale-summary-values > span { min-width: max-content; }
  .appointment-editor .appointment-sale-summary.is-cancelled .appointment-sale-summary-open { max-width: none; }
  .appointment-editor .appointment-sale-summary-open { justify-content: space-between; }
  .appointment-editor-sale-empty { align-items: stretch; flex-direction: column; }
  .appointment-editor .appointment-status-button { min-height: 44px; }
  .appointment-editor-status .visit-status-toggle { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment-editor-status { display: block; }
  .appointment-editor-status-label { display: block; margin-bottom: 10px; }
  .appointment-editor .modal-footer { display: flex; flex-direction: column; align-items: stretch; gap: 9px; padding: 10px 16px max(12px, env(safe-area-inset-bottom)); }
  .appointment-editor .modal-footer-left { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; width: 100%; }
  .appointment-editor .modal-footer-left:empty { display: none; }
  .appointment-editor .modal-footer-left .btn { width: 100%; min-height: 44px; padding: 7px; font-size: 12px; }
  .appointment-editor .modal-footer-right, .appointment-editor .modal-footer-right > .btn { width: 100%; }
}
