:root {
  --paper: #e4dac5;
  --surface: #ece3d2;
  --field: #f6f0e5;
  --side: #dfd4bd;
  --ink: #202c32;
  --muted: #51584d;
  --line: #c6bba5;
  --control: #8a8071;
  --sage: #3d5444;
  --sage-soft: #dce3d6;
  --rust: #903e29;
  --rust-fill: #a34931;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', Arial, sans-serif;
  --gutter: clamp(16px, 3vw, 48px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  text-size-adjust: 100%;
}
::selection { background: #cfdac9; color: var(--ink); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; overflow-wrap: anywhere; }
h1 { font-size: clamp(32px, 3.8vw, 46px); line-height: 1.12; margin-bottom: 14px; letter-spacing: -.025em; }
h2 { font-size: 26px; line-height: 1.2; margin-bottom: 12px; }
p { color: var(--muted); overflow-wrap: anywhere; }
p + p { margin-top: 8px; }
small, .muted { color: var(--muted); }
a { color: var(--rust); text-underline-offset: 4px; }
:where(button, a, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 3px;
}
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 5; background: var(--field); padding: 10px 14px; }
.skip-link:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; overflow: hidden; }

button, .link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--control);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .link:hover { background: #e0d6c1; }
button.primary { background: var(--sage); border-color: var(--sage); color: #fff; }
button.primary:hover { background: #314638; }
button:disabled { opacity: .6; cursor: wait; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--control);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font: 16px/1.35 var(--sans);
  caret-color: var(--rust);
}
textarea { min-height: 84px; resize: vertical; }
input[type='checkbox'] { width: 17px; min-height: 17px; margin: 0 5px 0 0; vertical-align: middle; accent-color: var(--sage); }
label { display: grid; gap: 6px; font-size: 14px; }
form { display: grid; gap: 14px; }
.panel form + h2, .panel form + form { margin-top: 26px; }
.panel p + form { margin-top: 16px; }

.crm-shell { min-width: 0; }
.crm-sidebar { padding: 18px var(--gutter) 12px; background: var(--side); border-bottom: 1px solid var(--line); }
body.logged-out .crm-sidebar { display: none; }
body.logged-out .crm-workspace { padding-top: 18px; }
.brand { display: inline-block; color: var(--ink); font: 28px/1.15 var(--serif); text-decoration: none; }
.brand small { display: block; margin-top: 5px; font: 12px/1.45 var(--sans); }
#nav { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 16px; }
#nav:empty { display: none; }
#nav button, .sidebar-actions button {
  border-color: transparent;
  background: transparent;
  justify-content: flex-start;
  padding-inline: 11px;
  font-size: 14px;
}
#nav button:hover, .sidebar-actions button:hover { background: var(--surface); }
#nav button.active { background: var(--sage-soft); border-color: #a4b29e; color: #263d2e; font-weight: 600; }
.sidebar-actions { display: flex; gap: 4px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; }
.crm-workspace { min-width: 0; }
main { max-width: 1340px; margin-inline: auto; padding: clamp(26px, 4.5vw, 56px) var(--gutter) 56px; }
main > .muted:first-child { margin-bottom: 8px; }
main > h1 + p { margin-bottom: 20px; max-width: 68ch; }

@media (min-width: 1060px) {
  .crm-shell { display: grid; grid-template-columns: 192px minmax(0, 1fr); }
  .crm-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    padding: 28px 14px 16px;
    height: 100vh;
    overflow: auto;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .crm-sidebar .brand { margin-inline: 10px; }
  #nav { display: grid; margin-top: 28px; }
  .sidebar-actions { margin-top: auto; display: grid; }
}

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(16px, 2.5vw, 24px);
  margin-bottom: 16px;
  min-width: 0;
}
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.metrics .panel { margin: 0; padding: clamp(10px, 2vw, 20px); }
.metrics strong { display: block; margin-top: 4px; font: clamp(22px, 3vw, 32px)/1.2 var(--serif); overflow-wrap: anywhere; color: var(--sage); }
#notice { position: fixed; z-index: 3; bottom: 16px; left: 16px; max-width: calc(100% - 32px); background: var(--sage); color: white; padding: 10px 16px; border-radius: 4px; }
#notice:empty { display: none; }
.login { max-width: 430px; margin: clamp(16px, 8vh, 84px) auto; }
details { margin: 20px 0; }
summary { cursor: pointer; }
#link-result label + label { margin-top: 12px; }
#link-result .actions + p { margin-top: 12px; }

@media (max-width: 750px) {
  .grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .metrics { gap: 8px; }
}

body.mobile-preview { max-width: 390px; margin-inline: auto; border-inline: 1px solid var(--line); }
html:has(.mobile-preview) { background: #d5cbb7; }
.mobile-preview .crm-shell { display: block; }
.mobile-preview .crm-sidebar { position: static; display: block; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
.mobile-preview #nav { display: flex; margin-top: 14px; }
.mobile-preview #nav:empty { display: none; }
.mobile-preview .sidebar-actions { display: flex; margin-top: 8px; }
.mobile-preview main { padding-inline: 16px; }
.mobile-preview .grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.mobile-preview .appointment-dialog { max-width: 358px; }

#app { container-type: inline-size; }
.crm-workspace:has(.schedule) main { padding-block: clamp(18px, 3vw, 34px) 18px; }

.schedule {
  --schedule-sage-line: #a4b29e;
  --schedule-done: #e6e7d9;
  --schedule-cancelled: #f0e1d5;
  --schedule-slot-height: 39px;
  --schedule-board-height: clamp(290px, calc(100dvh - 185px), 740px);
}
.schedule h1 { margin-bottom: 16px; }
.schedule-toolbar, .schedule-navigation, .schedule-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.schedule-toolbar { justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.schedule-arrows, .schedule-modes { display: inline-flex; }
.schedule-arrows button + button, .schedule-modes button + button { margin-inline-start: -1px; }
.schedule-arrows button, .schedule-modes button { border-radius: 0; padding-inline: 11px; }
.schedule-arrows button:first-child, .schedule-modes button:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.schedule-arrows button:last-child, .schedule-modes button:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }
.schedule-arrows button:focus-visible, .schedule-modes button:focus-visible { z-index: 1; }
.schedule-arrows [data-calendar-shift], .schedule-picker-head button { min-width: 38px; padding-block: 0; font-size: 22px; }
.schedule-modes [aria-pressed="true"] { background: var(--sage-soft); color: var(--sage); font-weight: 700; }

.schedule-date-control { position: relative; }
.schedule-period { gap: 9px; padding-inline: 10px; border-color: transparent; background: transparent; font-weight: 650; }
.schedule-period[aria-expanded="true"] { background: var(--surface); border-color: var(--line); }
.schedule-period > span:first-child::first-letter, .schedule-picker-head strong::first-letter { text-transform: uppercase; }
.schedule-date-icon {
  position: relative;
  width: 14px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  color: var(--sage);
}
.schedule-date-icon::before {
  content: "";
  position: absolute;
  inset: 2px 0 auto;
  border-top: 1px solid currentColor;
}
.schedule-picker {
  position: absolute;
  z-index: 6;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: min(320px, calc(100vw - 36px));
  border: 1px solid var(--control);
  border-radius: 6px;
  padding: 10px;
  background: var(--field);
  box-shadow: 0 9px 24px rgb(57 48 34 / 16%);
}
.schedule-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}
.schedule-picker-head button { min-height: 36px; }
.schedule-picker-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; text-align: center; }
.schedule-picker-grid small { padding-block: 3px; font-weight: 650; }
.schedule-picker-day {
  min-height: 37px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  font-variant-numeric: tabular-nums;
}
.schedule-picker-day.is-today { border-color: var(--sage); color: var(--sage); font-weight: 700; }
.schedule-picker-day.is-selected { background: var(--sage-soft); color: var(--sage); font-weight: 700; }

.schedule-board {
  max-block-size: var(--schedule-board-height);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}
.schedule-timeline {
  --schedule-columns: 62px minmax(0, 1fr);
  display: grid;
  grid-template-columns: var(--schedule-columns);
}
.schedule-timeline.is-week { --schedule-columns: 62px repeat(7, minmax(0, 1fr)); }
.schedule-timeline-head {
  position: sticky;
  z-index: 3;
  top: 0;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: var(--schedule-columns);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.schedule-time-corner, .schedule-day-count {
  align-self: center;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.schedule-timeline-date {
  column-gap: 6px;
  justify-content: flex-start;
  min-height: 44px;
  min-width: 0;
  padding: 4px 9px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: start;
  white-space: nowrap;
}
.schedule-timeline-date span { color: var(--muted); font-size: 13px; }
.schedule-timeline-date b { font: 21px/1 var(--serif); }
.schedule-timeline-date.is-selected { background: var(--sage-soft); }
.schedule-timeline-date.is-today {
  box-shadow: inset 0 -3px var(--sage);
  color: var(--sage);
}
.schedule-timeline-date.is-today b { font-weight: 700; }

.schedule-scale {
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.schedule-scale > span {
  display: block;
  height: var(--schedule-slot-height);
  padding: 3px 10px 0;
}
.schedule-track {
  position: relative;
  min-width: 0;
  border-inline-start: 1px solid var(--line);
  background: linear-gradient(to bottom, rgb(150 127 91 / 8%) 0 var(--work-top, 0%),
    transparent var(--work-top, 0%) var(--work-end, 100%), rgb(150 127 91 / 8%) var(--work-end, 100%) 100%);
}
.schedule-track.is-today {
  background-color: #eef1e8;
}
.schedule-slot {
  display: grid;
  align-items: center;
  justify-items: end;
  width: 100%;
  min-height: 0;
  height: var(--schedule-slot-height);
  padding: 0;
  border: 0;
  border-bottom: 1px dotted #d9d0c1;
  border-radius: 0;
  background: transparent;
}
.schedule-slot.is-hour { border-bottom-color: #e4dac9; }
.schedule-slot:nth-child(even) { border-bottom-style: solid; }
.schedule-slot span { visibility: hidden; margin-inline-end: 5px; font-size: 19px; line-height: 1; color: var(--sage); }
button.schedule-slot:hover, button.schedule-slot:focus-visible { background: var(--sage-soft); }
button.schedule-slot:hover span, button.schedule-slot:focus-visible span { visibility: visible; }
.schedule-board :focus-visible { outline-offset: -2px; }

.schedule-event {
  min-width: 0;
  justify-content: start;
  color: #263d2e;
  text-align: start;
  background: var(--sage-soft);
  border-color: var(--schedule-sage-line);
  overflow: hidden;
}
.schedule-event:hover { background: #d0dbc9; }
.schedule-event.is-done { background: var(--schedule-done); border-color: #bdbfae; color: #495447; }
.schedule-event.is-cancelled, .schedule-event.is-absent {
  background: var(--schedule-cancelled);
  border-color: #caaa9a;
  color: #783b2d;
}
.schedule-event:is(.is-done, .is-cancelled, .is-absent):hover { filter: brightness(.96); }
.schedule-event.is-cancelled .schedule-event-name { text-decoration: line-through; }
.schedule-event > span, .schedule-event > strong, .schedule-event > small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.schedule-event-time { font-variant-numeric: tabular-nums; }
.schedule-event .schedule-event-status { font-size: 10.5px; font-weight: 650; color: inherit; }
.schedule-track .schedule-event {
  position: absolute;
  z-index: 1;
  top: calc(var(--card-top) + 1px);
  inset-inline-start: calc(var(--card-left) + 2px);
  width: calc(var(--card-width) - 4px);
  height: calc(var(--card-height) - 2px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  align-content: start;
  gap: 1px 8px;
  padding: 4px 6px;
  font-size: 12px;
  line-height: 1.16;
}
.schedule-track .schedule-event:focus-visible { z-index: 2; }
.schedule-track .schedule-event[data-lanes="1"]:is(.is-cancelled, .is-absent, .is-tiny) {
  width: calc(var(--card-width) - 24px);
}
.schedule-timeline.is-week .schedule-event:not(.is-short) {
  padding-block: 3px;
  font-size: 11.5px;
  line-height: 1.1;
}
.schedule-timeline.is-week .schedule-event:not(.is-short) .schedule-event-name { font-size: 13px; }
.schedule-timeline.is-week .schedule-event:not(.is-short) .schedule-event-service {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  font-size: 11.5px;
}
.schedule-track .schedule-event-name { font-size: 14px; }
.schedule-track .schedule-event-service { font-size: 12px; }
.schedule-track .schedule-event.is-short { padding-block: 2px; }
.schedule-track .schedule-event.is-short .schedule-event-name { font-size: 12px; }
.schedule-track .schedule-event.is-tiny { font-size: 11px; gap: 0 6px; }
.schedule-track .schedule-event.is-tiny .schedule-event-service { font-size: 10.5px; }
.schedule-track .schedule-event.is-tiny .schedule-event-name { font-size: 11px; }
.schedule-track .schedule-event.is-tiny .schedule-event-status { grid-row: 3; }
.schedule-track .schedule-event.is-tiny:has(.schedule-event-status) .schedule-event-service { display: none; }
.schedule-timeline:not(.is-week) .schedule-event {
  grid-template-columns: minmax(0, 1fr) auto;
  padding-inline: 9px;
}
.schedule-timeline:not(.is-week) .schedule-event :is(.schedule-event-name, .schedule-event-service, .schedule-event-status) {
  grid-column: 1 / -1;
}
.schedule-event-price { grid-column: 2; grid-row: 1; font-size: 12px; }
.schedule-event.is-short .schedule-event-price { display: none; }
.schedule-now {
  position: absolute;
  z-index: 2;
  inset-inline: 0;
  border-top: 2px solid var(--rust);
  pointer-events: none;
}
.schedule-now::before {
  position: absolute;
  inset: -4px auto auto 0;
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rust);
}

.schedule-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: solid var(--line);
  border-width: 1px 0 0 1px;
  border-radius: 5px;
  max-block-size: calc(var(--schedule-board-height) - 56px);
  overflow: auto;
}
.schedule-month-weekday, .schedule-month-day, .schedule-month-blank {
  border: solid var(--line);
  border-width: 0 1px 1px 0;
}
.schedule-month-weekday {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  padding: 6px 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.schedule-month-day {
  min-width: 0;
  min-height: 48px;
  padding: 3px 4px 4px;
  background: var(--field);
}
.schedule-month-day.is-today { background: #eef1e8; box-shadow: inset 0 2px var(--sage); }
.schedule-month-day.is-selected { box-shadow: inset 0 0 0 1px var(--schedule-sage-line); }
.schedule-month-blank { background: rgb(150 127 91 / 9%); }
.schedule-month-date {
  min-height: 30px;
  min-width: 32px;
  justify-content: flex-start;
  border-color: transparent;
  padding: 0 5px;
  background: transparent;
  font-variant-numeric: tabular-nums;
}
.schedule-month-date b { font: 16px/1 var(--serif); }
.schedule-month-day.is-today .schedule-month-date b { font-weight: 700; color: var(--sage); }
.schedule-month .schedule-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 4px;
  width: 100%;
  min-height: 30px;
  margin-bottom: 2px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1.13;
}
.schedule-month .schedule-event-service { grid-column: 1 / -1; }
.schedule-month .schedule-event-status { grid-column: 1 / -1; }
.schedule-month .is-done .schedule-event-status { display: none; }
.schedule-month-more {
  justify-content: flex-start;
  min-height: 26px;
  width: 100%;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: var(--sage);
  font-size: 12px;
  font-weight: 700;
}
.schedule-month :focus-visible { outline-offset: -2px; }
.schedule-family { display: flex; margin-top: 14px; }

.crm-shell:has(.schedule--compact) .crm-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 8px;
  padding-block: 10px;
}
.crm-shell:has(.schedule--compact) .crm-sidebar .brand {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 24px;
}
.crm-shell:has(.schedule--compact) .sidebar-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  margin: 0;
  padding: 0;
  border: 0;
  gap: 0;
}
.crm-shell:has(.schedule--compact) #nav {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 5px;
}
.crm-shell:has(.schedule--compact) :is(#nav, .sidebar-actions) button {
  justify-content: center;
  min-width: 0;
  min-height: 36px;
  padding: 4px;
  font-size: 12px;
}

.schedule--compact .schedule-toolbar { gap: 7px; }
.schedule--compact .schedule-navigation { position: relative; font-size: 14px; gap: 4px; }
.schedule--compact .schedule-date-control { position: static; }
.schedule--compact .schedule-period { padding-inline: 6px; gap: 6px; }
.schedule--compact .schedule-arrows button { padding-inline: 8px; }
.schedule--compact .schedule-arrows [data-calendar-shift] { min-width: 32px; }
.schedule--compact .schedule-options { justify-content: space-between; width: 100%; }
.schedule--compact .schedule-modes { flex: 1; }
.schedule--compact .schedule-modes button { flex: 1; padding-inline: 6px; }
.schedule--compact .schedule-options > button { padding-inline: 10px; }
.schedule--compact .schedule-board { max-block-size: none; overflow: clip; }
.schedule--compact .schedule-timeline { --schedule-columns: 50px minmax(0, 1fr); }
.schedule--compact .schedule-scale > span, .schedule--compact .schedule-time-corner { padding-inline: 6px; }
.schedule--compact .schedule-month { max-block-size: none; overflow: clip; }
.schedule--compact .schedule-month-weekday { padding-inline: 0; text-align: center; }
.schedule--compact .schedule-month-day { min-height: 0; padding: 0; }
.schedule--compact .schedule-month-date {
  display: grid;
  justify-items: center;
  justify-content: center;
  align-content: start;
  gap: 4px;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 7px 0 3px;
  border: 0;
  border-radius: 0;
}
.schedule--compact .schedule-month-date span {
  min-width: 16px;
  padding: 1px 3px;
  border-radius: 3px;
  background: var(--sage-soft);
  color: var(--sage);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
}
.schedule-week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 10px;
}
.schedule-week-date {
  display: grid;
  justify-content: center;
  grid-template-rows: auto auto 4px;
  align-content: center;
  justify-items: center;
  min-width: 0;
  min-height: 52px;
  gap: 2px;
  padding: 4px 0;
  border-color: var(--line);
}
.schedule-week-date span { color: var(--muted); font-size: 11px; }
.schedule-week-date b { font-variant-numeric: tabular-nums; }
.schedule-week-date i { width: 4px; height: 4px; border-radius: 50%; background: var(--sage); }
.schedule-week-date.is-selected, .schedule-week-summary.is-selected { background: var(--sage-soft); }
.schedule-week-date.is-today, .schedule-week-summary.is-today { border-color: var(--sage); }
.schedule-week-list { display: grid; gap: 4px; }
.schedule-week-summary {
  display: grid;
  grid-template-columns: minmax(42px, auto) minmax(0, 1fr) auto;
  gap: 8px;
  justify-content: stretch;
  padding-inline: 9px;
  border-color: var(--line);
  text-align: start;
}
.schedule-week-summary-date { font-size: 12px; }
.schedule-week-summary-date strong { font-size: 15px; }
.schedule-week-summary-times { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
@media (min-width: 881px) and (max-width: 1059px) {
  .schedule { --schedule-board-height: clamp(280px, calc(100dvh - 341px), 670px); }
}
.schedule-week-summary-count { color: var(--sage); font-size: 12px; font-weight: 650; }

.day-agenda .appointment-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  width: 100%;
  margin-bottom: 6px;
  padding: 12px;
  border-color: #a4b29e;
  background: var(--sage-soft);
  color: #263d2e;
  text-align: left;
}
.day-agenda .appointment-row:last-child { margin-bottom: 0; }
.day-agenda .appointment-row:hover { background: #cfdac9; }
.appointment-identity { min-width: 0; overflow-wrap: break-word; }
.appointment-time { margin-inline-end: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.appointment-service, .appointment-status { overflow-wrap: anywhere; color: var(--sage); }
.appointment-status { grid-column: 1 / -1; }
@container (max-width: 300px) {
  .day-agenda .appointment-row { grid-template-columns: minmax(0, 1fr); }
}

.appointment-dialog {
  width: min(640px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--control);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.appointment-dialog::backdrop { background: rgb(29 35 34 / 48%); }
.appointment-dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 16px; }
.appointment-dialog-head h2 { margin: 4px 0 8px; }
.appointment-dialog-head button { flex-shrink: 0; }
.dialog-status:empty { display: none; }
.dialog-status { margin-top: 12px; color: var(--rust); }
.appointment-notify { display: flex; align-items: center; gap: 7px; }
.appointment-fields > * { flex: 1 1 190px; }
.price-control { display: grid; grid-template-columns: minmax(65px, 1fr) auto auto; align-items: end; gap: 6px; }
.price-control button { padding-inline: 9px; }
.price-control input { appearance: textfield; }
.price-control input::-webkit-inner-spin-button, .price-control input::-webkit-outer-spin-button { appearance: none; margin: 0; }

.family-body { --ink: #14192b; --muted: #515767; font-size: 16px; }
.family-header { border-bottom: 1px solid var(--line); }
.family-header-inner { max-width: 1140px; margin-inline: auto; padding: 20px var(--gutter); display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; }
.family-header-inner strong { font-family: var(--serif); font-size: 21px; font-weight: 400; }
.family-main { max-width: 1140px; }
.family-cover { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(160px, .75fr); gap: clamp(20px, 6vw, 80px); align-items: center; padding-block: clamp(14px, 4vw, 48px); }
.family-cover h1 { font-size: clamp(36px, 4.7vw, 56px); }
.family-cover p { max-width: 44ch; }
.family-cover form { max-width: 350px; margin-top: 23px; }
.family-cover form [role='status']:empty { display: none; }
.family-cover form [role='status'] { color: var(--rust); }
.family-body button.primary { background: var(--rust-fill); border-color: var(--rust-fill); }
.family-body button.primary:hover { background: var(--rust); }
.family-pencil { width: min(100%, 310px); height: auto; justify-self: end; mix-blend-mode: multiply; }
.family-summary { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; padding-bottom: 22px; }
.family-section { border-top: 1px solid var(--line); padding-top: 20px; margin-bottom: 26px; }
.family-section article { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.5fr) auto; align-items: baseline; gap: 5px 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.family-section article.recommendation { display: block; }
.family-section .recommendation p { margin-top: 5px; }
.family-section time { font-variant-numeric: tabular-nums; }
.family-appointment-status { font-size: 14px; }
.family-appointment-status span { white-space: nowrap; }
@media (max-width: 600px) {
  .family-cover { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 8px; }
  .family-pencil { width: 155px; justify-self: start; }
  .family-section article { grid-template-columns: minmax(0, 1fr) auto; }
  .family-section article time { grid-column: 1 / -1; }
}

/* Client directory and record */
.client-list-heading, .client-heading, .client-list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.client-list-heading { margin-bottom: 20px; }
.client-list-heading h1, .client-heading h1 { margin-bottom: 0; }
.client-list-controls { align-items: end; margin-bottom: 14px; }
.client-list-controls > label { width: min(100%, 350px); }
.client-filters, .client-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.client-filters [aria-pressed=true], .client-tabs [aria-pressed=true] {
  background: var(--sage-soft); color: var(--sage); border-color: #a4b29e; font-weight: 650;
}
.client-list-count { font-size: 13px; margin-bottom: 8px; }
.client-table { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.client-table-head, .client-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(105px, .55fr);
  gap: 18px;
  padding: 15px 18px;
}
.client-table-head { color: var(--muted); font-size: 12px; background: var(--side); }
.client-table-row {
  width: 100%; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  text-align: left; align-items: start; line-height: 1.4;
}
.client-table-row > span { min-width: 0; overflow-wrap: anywhere; }
.client-table-row strong { font-weight: 650; }
.client-table-row small { display: block; font-size: 12px; margin-top: 5px; }
.client-table-row time { font-variant-numeric: tabular-nums; font-size: 13px; }
.client-balance { color: var(--sage); font-variant-numeric: tabular-nums; font-weight: 650; }
.client-balance.is-negative { color: var(--rust); }
#new-client { margin-top: 18px; max-width: 620px; }
.client-back { padding-inline: 0; background: transparent; border-color: transparent; color: var(--sage); margin-bottom: 14px; }
.client-heading { align-items: start; }
.client-heading > div:first-child { flex: 1 1 340px; min-width: 0; }
.client-heading h1 { font-size: clamp(28px, 3.3vw, 40px); margin-top: 5px; overflow-wrap: break-word; }
.client-heading .actions { margin: 0; }
.client-summary {
  display: grid; grid-template-columns: minmax(145px, .6fr) minmax(0, 1.4fr);
  gap: 20px; margin: 24px 0; padding: 18px 0; border-block: 1px solid var(--line);
}
.client-summary section { display: grid; align-content: start; gap: 4px; min-width: 0; }
.client-summary .client-balance { font: 30px/1.25 var(--serif); }
.client-summary section > span { color: var(--muted); }
.client-tabs { margin-bottom: 18px; }
.client-tabs button { min-width: 95px; }
.client-card-content { max-width: 1020px; }
.client-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.client-profile > h2 { margin-bottom: 0; }
.client-profile input[type=radio], .client-choice input[type=radio] {
  width: 17px; min-height: 17px; margin: 0; flex-shrink: 0; accent-color: var(--sage);
}
.client-choice { display: flex; align-items: center; gap: 8px; }
.client-representatives { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 8px; }
.client-representatives h2 { margin-bottom: 16px; }
.client-representative { min-width: 0; padding: 14px; border: 1px solid var(--line); margin: 0 0 15px; border-radius: 4px; }
.client-representative legend { padding-inline: 6px; color: var(--sage); font-weight: 650; }
.client-representative-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; }
.client-representative-actions button { font-size: 13px; padding-inline: 8px; }
.client-form-status { color: var(--rust); }
.client-form-status:empty { display: none; }
.client-profile .actions { margin-top: 0; }
.client-inline-button {
  display: inline; width: fit-content; min-height: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--sage); text-align: start;
  text-decoration: underline; text-underline-offset: 3px; line-height: 1.5;
}
.client-visit {
  display: flex; width: 100%; justify-content: space-between; align-items: start;
  gap: 12px; padding: 14px 0; border: 0; border-top: 1px solid var(--line);
  border-radius: 0; background: transparent; text-align: left; line-height: 1.5;
}
.client-visit span:first-child { min-width: 0; }
.client-visit span:last-child { flex-shrink: 0; text-align: right; font-size: 13px; color: var(--muted); }
.client-visit strong { display: block; margin-top: 3px; }
.client-visit time { color: var(--muted); font-size: 13px; }
.client-ledger { padding: 0; margin: 0; list-style: none; }
.client-ledger-row {
  display: flex; gap: 16px; align-items: start; justify-content: space-between;
  padding-block: 15px; border-top: 1px solid var(--line);
}
.client-ledger-row > div:first-child { min-width: 0; }
.client-ledger-row p { margin-top: 4px; font-size: 14px; }
.client-ledger-row time, .client-ledger-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.client-ledger-amount { flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }
.client-note-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.client-note-heading time { font-size: 13px; color: var(--muted); }
.client-note-heading button { font-size: 13px; }
.client-note-body { white-space: pre-wrap; color: var(--ink); margin-bottom: 8px; }
.client-family form { margin-block: 16px; }
.client-family > button { margin-top: 12px; }
.clients-view button:disabled { cursor: not-allowed; }
@container (max-width: 750px) {
  .client-table-head { display: none; }
  .client-table-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px; }
  .client-table-row:first-child { border-top: 0; }
  .client-table-row > span:first-child { grid-column: 1; grid-row: 1; }
  .client-table-row > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .client-table-row > span:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .client-table-row > span:nth-child(3)::before { content: "Ближайший приём · "; font-size: 12px; color: var(--muted); }
  .client-table-row > .client-balance { grid-column: 2; grid-row: 1; font-size: 13px; }
  .client-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .client-tabs button { min-width: 0; padding-inline: 6px; font-size: 13px; }
}
@container (max-width: 480px) {
  .client-form-grid { grid-template-columns: minmax(0, 1fr); }
  .client-summary { grid-template-columns: minmax(0, 1fr); gap: 14px; margin-block: 18px; }
  .client-heading > div:first-child { flex-basis: 100%; }
  .client-heading .actions { width: 100%; }
  .client-heading .actions button { flex: 1; font-size: 13px; padding-inline: 7px; }
  .client-ledger-row { flex-direction: column; gap: 6px; }
  .client-ledger-amount { text-align: left; }
  .client-visit { flex-wrap: wrap; }
  .client-visit span:last-child { text-align: left; }
}

.bill-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.bill-heading h2 { margin: 0; }
.bill-row { padding-block: 16px; border-bottom: 1px solid var(--line); }
.bill-row:last-child { border-bottom: 0; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bill-row details, .message-item details, details.panel[open] > summary { margin-block: 12px; }
details.panel > summary { cursor: pointer; }
.is-negative { color: #963d32; font-weight: 700; }
.client-ledger-row small, .client-ledger-row time { display: block; margin-top: .4rem; }
.client-ledger-row button { margin-top: .6rem; }
