:root {
  /* —— Design tokens (Black Lab Dashboard Hybrid, Stage 2) —— */
  --bg-primary: #14161a;
  --bg-secondary: #1a1d22;
  --surface-solid: #22262c;
  --surface-elevated: #2b3038;
  --surface-hover: rgba(255,255,255,.064);
  --surface-active: rgba(255,255,255,.105);

  --text-primary: #F4EFE7;
  --text-secondary: rgba(244,239,231,.70);
  --text-muted: rgba(244,239,231,.58);

  --border: rgba(235,229,220,.15);
  --border-subtle: rgba(235,229,220,.09);

  --accent: #C92F2A;
  --accent-hover: #B92824;
  --accent-active: #9F1F1B;
  --accent-soft: rgba(201,47,42,.14);

  --success: #5CB87A;
  --warning: #E8B84D;
  --danger: #E85D5D;
  --info: #4F8FA8;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-dialog: 18px;

  --control-height: 40px;
  --control-padding-y: 8px;
  --control-padding-x: 12px;
  --control-border-width: 1px;
  --control-radius: var(--radius-md);
  --control-font-size: 14px;
  --control-line-height: 1.25;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --shadow-surface: 0 8px 24px rgba(0,0,0,.18);
  --shadow-dialog: 0 28px 90px rgba(0,0,0,.30);

  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-size-product: 25px;
  --font-size-page: 1.25rem;
  --font-size-section: 1.05rem;
  --font-size-body: 14px;
  --font-size-label: 13px;
  --font-size-caption: 12px;
  --font-size-table-head: 12px;
  --font-size-kpi: 2rem;
  --font-size-finance: 1.1rem;
  --line-height-body: 1.45;

  --focus-ring: 0 0 0 3px rgba(201,47,42,.28);
  --focus-border: rgba(235,228,216,.42);

  /* Stacking layers (page < drawer < floating; modal uses browser top-layer) */
  --z-page: 1;
  --z-sticky: 10;
  --z-drawer-backdrop: 50;
  --z-drawer: 60;
  --z-floating: 1100;
  --z-popover: 1200;
  --z-toast: 1300;
  --z-modal-chrome: 2;
  --z-modal-floating: 40;

  --cream: #ebe4d8;
  --accent-num: #D2483E;
  --appt: #3d8f86;
  --appt-bg: rgba(61,143,134,.22);
  /* Muted client palette for calendar cards (deterministic by client_id). */
  --appt-client-1-bg: rgba(52, 78, 112, 0.42);
  --appt-client-1-border: rgba(110, 148, 196, 0.42);
  --appt-client-1-accent: #6a8fbe;
  --appt-client-2-bg: rgba(48, 68, 92, 0.44);
  --appt-client-2-border: rgba(98, 128, 158, 0.40);
  --appt-client-2-accent: #7a96ae;
  --appt-client-3-bg: rgba(36, 86, 82, 0.42);
  --appt-client-3-border: rgba(72, 148, 140, 0.40);
  --appt-client-3-accent: #4f9e94;
  --appt-client-4-bg: rgba(92, 36, 42, 0.40);
  --appt-client-4-border: rgba(168, 78, 84, 0.38);
  --appt-client-4-accent: #b45a5e;
  --appt-client-5-bg: rgba(92, 68, 32, 0.40);
  --appt-client-5-border: rgba(176, 132, 72, 0.38);
  --appt-client-5-accent: #c49a58;
  --appt-client-6-bg: rgba(58, 72, 40, 0.42);
  --appt-client-6-border: rgba(118, 140, 78, 0.38);
  --appt-client-6-accent: #8fa05a;
  --appt-client-7-bg: rgba(72, 48, 86, 0.42);
  --appt-client-7-border: rgba(138, 108, 162, 0.38);
  --appt-client-7-accent: #9a7eb0;
  --appt-client-8-bg: rgba(64, 58, 52, 0.44);
  --appt-client-8-border: rgba(140, 128, 112, 0.40);
  --appt-client-8-accent: #a89880;
  --off-hours: rgba(255,255,255,.035);
  --cal-off-shift-gradient:
    linear-gradient(
      135deg,
      rgba(110, 20, 24, 0.38) 0%,
      rgba(58, 15, 18, 0.48) 45%,
      rgba(25, 20, 22, 0.72) 100%
    );
  --cal-off-shift-hatch:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.018) 0,
      rgba(255, 255, 255, 0.018) 1px,
      transparent 1px,
      transparent 9px
    );
  --cal-off-day-gradient:
    linear-gradient(
      135deg,
      rgba(120, 22, 28, 0.46) 0%,
      rgba(62, 14, 18, 0.58) 48%,
      rgba(22, 16, 18, 0.78) 100%
    );
  --cal-missing-schedule-gradient:
    linear-gradient(
      135deg,
      rgba(92, 62, 24, 0.36) 0%,
      rgba(58, 40, 18, 0.48) 45%,
      rgba(28, 22, 16, 0.70) 100%
    );
  --cal-missing-schedule-hatch:
    repeating-linear-gradient(
      135deg,
      rgba(235, 200, 120, 0.04) 0,
      rgba(235, 200, 120, 0.04) 1px,
      transparent 1px,
      transparent 9px
    );
  --cal-shift-edge: rgba(213, 47, 47, 0.35);
  --cal-off-label-text: rgba(255, 178, 178, 0.82);
  --cal-missing-label-text: rgba(240, 210, 150, 0.88);
  --ease: cubic-bezier(.23,1,.32,1);

  /* —— Legacy aliases (single system; no competing values) —— */
  --bg: var(--bg-primary);
  --bg-soft: var(--bg-secondary);
  --graphite: var(--surface-solid);
  --graphite-2: var(--surface-elevated);
  --surface: var(--surface-hover);
  --surface-strong: var(--surface-active);
  --line: var(--border);
  --line-soft: var(--border-subtle);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --soft: var(--text-muted);
  --red: var(--accent);
  --red-hover: var(--accent-hover);
  --shadow: var(--shadow-dialog);
  --ok: var(--success);
  --pending: var(--warning);
  --radius: var(--radius-lg);

  --cal-surface: var(--bg-secondary);
  --cal-secondary: var(--surface-solid);
  --cal-time-col: var(--bg-primary);
  --cal-slot: rgba(255,255,255,.018);
  --cal-slot-hover: rgba(201,47,42,.065);
  --cal-slot-hover-ring: rgba(201,47,42,.16);
  /* Geometry lock: must stay in sync with app.js rowHeight (28) and gridTemplateRows */
  --cal-row-height: 28px;
  --cal-time-col-width: 64px;
  --cal-hour-line: rgba(235,229,220,.22);
  --cal-half-line: rgba(235,229,220,.10);

  font-family: var(--font);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: proportional-nums;
}
.app,
main {
  min-width: 0;
  max-width: 100%;
}
.calendar-scroll,
.table-wrap,
.topbar,
.toolbar,
.calendar-toolbar {
  max-width: 100%;
  min-width: 0;
}

.hidden { display: none !important; }

/* —— Typography scale (applied to existing structure) —— */
.type-product,
.wordmark--nav { font-size: var(--font-size-product); }
.type-page,
.dialog-header h2 { font-size: var(--font-size-page); font-weight: 700; letter-spacing: -.02em; }
.type-section,
.toolbar > strong { font-size: var(--font-size-section); font-weight: 650; color: var(--text-primary); }
.type-body { font-size: var(--font-size-body); }
.type-label,
.booking-col label,
label.check { font-size: var(--font-size-label); }
.type-caption,
.muted,
.cal-staff-role { font-size: var(--font-size-caption); }
.type-table-head,
th {
  font-size: var(--font-size-table-head);
  font-weight: 600;
  letter-spacing: .02em;
}
.type-kpi,
.card .value {
  font-size: var(--font-size-kpi);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.type-finance,
.client-drawer-stat .value,
.appt strong {
  font-variant-numeric: tabular-nums;
}
.cal-time,
.date-display,
.card .value,
.client-drawer-stat .value {
  font-variant-numeric: tabular-nums;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(circle at 18% 0%, rgba(201,47,42,.14), transparent 42%),
    radial-gradient(ellipse at 80% 100%, rgba(255,255,255,.03), transparent 45%),
    var(--bg-primary);
}
.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-dialog);
  padding: var(--space-6);
  width: min(360px, 100%);
  display: grid;
  gap: var(--space-3);
  box-shadow: var(--shadow-dialog);
  text-align: center;
}
.login-card .wordmark--login {
  justify-content: center;
}
.login-card h1 { margin: 0; }
.login-card p { margin: 0; color: var(--text-secondary); font-size: var(--font-size-label); }

/* —— Form system —— */
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  background: var(--surface-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease), background .14s var(--ease);
}
input::placeholder,
textarea::placeholder {
  color: rgba(244,239,231,.52);
}
input:hover:not(:disabled):not([readonly]),
select:hover:not(:disabled),
textarea:hover:not(:disabled):not([readonly]) {
  border-color: var(--border);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.date-display:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: .48;
  cursor: not-allowed;
  background: rgba(255,255,255,.03);
  color: var(--text-muted);
}
input[readonly],
textarea[readonly] {
  background: var(--surface-elevated);
  color: var(--text-primary);
  opacity: 1;
  cursor: default;
  border-style: dashed;
}
input:invalid:not(:placeholder-shown):not(:focus),
select:invalid:not(:focus),
textarea:invalid:not(:placeholder-shown):not(:focus) {
  border-color: rgba(232,93,93,.55);
}
input[type="search"] {
  min-width: min(280px, 100%);
}
input[type="checkbox"] {
  width: auto;
  min-height: 0;
  min-width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
@media (min-width: 1025px) {
  input, select, textarea { min-height: 36px; padding: 8px 12px; }
  input[type="checkbox"] { min-height: 0; }
}

/* —— Button system —— */
button {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  min-height: 40px;
  cursor: pointer;
  background: var(--surface-solid);
  color: var(--text-primary);
  transition:
    filter .14s var(--ease),
    transform .14s var(--ease),
    background .14s var(--ease),
    border-color .14s var(--ease),
    box-shadow .14s var(--ease),
    color .14s var(--ease);
}
button:hover:not(:disabled) {
  background: var(--surface-elevated);
  border-color: var(--border);
}
button:focus { outline: none; }
button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--focus-border);
}
button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  filter: none;
}
button.primary:active:not(:disabled) {
  background: var(--accent-active);
  transform: none;
}
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
button.ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: transparent;
}
button.destructive,
button.danger {
  background: rgba(232,93,93,.12);
  border-color: rgba(232,93,93,.35);
  color: var(--danger);
}
button.destructive:hover:not(:disabled),
button.danger:hover:not(:disabled) {
  background: rgba(232,93,93,.2);
}
button.icon-btn {
  min-width: 40px;
  width: 40px;
  padding-inline: 0;
  display: inline-grid;
  place-items: center;
}
button:disabled,
button[aria-busy="true"] {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}
button[aria-busy="true"] {
  position: relative;
}

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

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 10px var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(20,22,26,.94);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-surface);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 760; letter-spacing: -.02em; }
.brand-suffix,
.wordmark__suffix {
  font-size: .58em;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: .42em;
  letter-spacing: .02em;
  align-self: center;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: -.045em;
}
.wordmark__black {
  color: var(--cream);
  font-weight: 760;
  letter-spacing: -.045em;
}
.wordmark__lab {
  color: #090606;
  position: relative;
  display: inline-block;
  padding: .13em .36em .16em .34em;
  z-index: 0;
  font-weight: 780;
  letter-spacing: -.052em;
  font-size: 1.18em;
  line-height: 1;
  vertical-align: baseline;
}
.wordmark__lab::before {
  content: "";
  position: absolute;
  inset: .03em -.08em .01em -.06em;
  z-index: -1;
  background: linear-gradient(135deg, #D94A3A 0%, var(--accent) 46%, var(--accent-hover) 100%);
  border-radius: .20em;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%, 0 20%);
  box-shadow: 0 14px 34px rgba(122,18,18,.26), inset 0 1px 0 rgba(255,255,255,.16);
}
.wordmark__lab::after {
  content: "";
  position: absolute;
  left: .12em;
  right: .18em;
  top: .09em;
  height: 1px;
  z-index: 1;
  background: linear-gradient(90deg, rgba(255,255,255,.20), transparent);
  opacity: .75;
  pointer-events: none;
}
.wordmark--nav { font-size: var(--font-size-product); }
.wordmark--login {
  font-size: clamp(30px, 5vw, 38px);
  justify-content: center;
  margin-bottom: 4px;
}
.wordmark--login .wordmark__lab {
  font-size: 1.22em;
  padding: .115em .34em .145em .33em;
}
.wordmark--login .wordmark__lab::before {
  inset: .045em -.055em .02em -.045em;
  border-radius: .17em;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%, 0 18%);
}

.tabs { display: flex; gap: var(--space-2); flex: 1; flex-wrap: wrap; }
.tab {
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-weight: 500;
  min-height: 40px;
  padding: 8px 14px;
}
.tab:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: transparent;
}
.tab.active {
  color: var(--text-primary);
  border-color: var(--border);
  background: var(--surface-hover);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.tab:focus-visible {
  box-shadow: var(--focus-ring);
  border-color: var(--focus-border);
}

main { flex: 1; padding: var(--space-4) var(--space-5) var(--space-6); }
.view { display: block; }
.toolbar, .calendar-toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  padding: var(--space-2) 0;
}
.calendar-toolbar {
  gap: var(--space-2);
  align-items: center;
}
.calendar-toolbar .ui-control,
.calendar-toolbar .date-display,
.calendar-toolbar .bl-select-trigger,
.calendar-toolbar #today-btn,
.calendar-toolbar #schedule-day-btn,
.calendar-toolbar #new-appointment-btn {
  box-sizing: border-box;
  height: var(--control-height);
  min-height: var(--control-height);
  max-height: var(--control-height);
  padding: var(--control-padding-y) var(--control-padding-x);
  border-width: var(--control-border-width);
  border-style: solid;
  border-radius: var(--control-radius);
  font-size: var(--control-font-size);
  line-height: var(--control-line-height);
}
.calendar-toolbar .date-field {
  flex: 0 0 auto;
  min-width: min(240px, 100%);
}
.calendar-toolbar .date-display {
  min-width: 240px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  letter-spacing: -.01em;
  background: var(--surface-elevated);
  border-color: var(--border);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
  color: var(--text-primary);
}
.calendar-toolbar .date-display:hover:not(:disabled),
.calendar-toolbar .date-display:focus-visible {
  /* keep size stable */
  padding: var(--control-padding-y) var(--control-padding-x);
}
.calendar-toolbar #prev-day,
.calendar-toolbar #next-day {
  width: var(--control-height);
  height: var(--control-height);
  min-width: var(--control-height);
  min-height: var(--control-height);
  max-height: var(--control-height);
  padding: 0;
  border-radius: var(--control-radius);
  border-width: var(--control-border-width);
}
.calendar-toolbar #today-btn,
.calendar-toolbar #schedule-day-btn {
  background: var(--surface-solid);
  border-color: var(--border);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
}
.calendar-toolbar #schedule-day-btn:hover:not(:disabled),
.calendar-toolbar #today-btn:hover:not(:disabled) {
  background: var(--surface-elevated);
}
.calendar-toolbar #new-appointment-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
}
.calendar-toolbar .calendar-staff-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--font-size-caption);
  color: var(--text-secondary);
  height: var(--control-height);
}
.calendar-toolbar .calendar-staff-filter .bl-select {
  min-width: 180px;
  max-width: min(220px, 100%);
}
.calendar-toolbar .calendar-staff-filter .bl-select-trigger {
  background: var(--surface-solid);
  border-color: var(--border);
}
.calendar-staff-notices {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  min-width: 0;
}
.calendar-staff-notices:empty {
  display: none;
}
.calendar-staff-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-size: var(--font-size-caption);
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
.calendar-staff-notice--missing {
  border-color: rgba(212,160,74,.35);
  background: rgba(212,160,74,.08);
}
.calendar-staff-notice .ghost {
  flex: 0 0 auto;
}
.calendar-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
@media (max-width: 700px) {
  .calendar-staff-filter {
    width: 100%;
  }
  .calendar-staff-filter select {
    flex: 1 1 auto;
    max-width: none;
  }
}
@media (max-width: 768px) {
  .calendar-toolbar #new-appointment-btn { margin-left: 0; }
  .calendar-toolbar .date-display { min-width: min(220px, 100%); font-size: 14px; }
}
@media (max-width: 390px) {
  .calendar-toolbar { gap: var(--space-2); }
  .calendar-toolbar .date-display { width: 100%; min-width: 0; }
}
.toolbar-sep { color: var(--text-muted); }

.date-field { position: relative; display: inline-block; }
.date-field.block { display: block; width: 100%; }
.date-field.compact .date-display { min-width: 150px; }
.date-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-solid);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.date-display:hover:not(:disabled) {
  background: var(--surface-elevated);
  border-color: var(--border);
}
.date-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: min(300px, 92vw);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-dialog);
  padding: 14px;
  box-shadow: var(--shadow-dialog);
}
.date-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
}
.date-popover-head button {
  background: transparent;
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  min-height: 32px;
  min-width: 32px;
}
.date-weekdays, .date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.date-weekdays { color: var(--text-muted); font-size: var(--font-size-caption); margin-bottom: 6px; }
.date-grid button {
  aspect-ratio: 1;
  padding: 0;
  min-height: 0;
  min-width: 0;
  height: auto;
  width: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.date-grid button:hover:not(:disabled) { background: var(--surface-hover); }
.date-grid button.is-today { border-color: var(--border); }
.date-grid button.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.date-popover-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.date-popover-actions button { flex: 1; font-size: 13px; }

.calendar-scroll {
  overflow: auto;
  max-height: calc(100vh - 148px);
  max-width: 100%;
  background: var(--cal-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1px;
  box-shadow: var(--shadow-surface);
  scrollbar-color: var(--surface-active) transparent;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}
.calendar-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.calendar-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.calendar-scroll::-webkit-scrollbar-thumb {
  background: var(--surface-active);
  border: 2px solid var(--cal-surface);
  border-radius: 999px;
}
.calendar-grid {
  display: grid;
  min-width: 900px;
  background: var(--cal-surface);
  color: var(--text-primary);
  border-radius: calc(var(--radius-lg) - 1px);
  overflow: visible;
  border: 1px solid var(--border-subtle);
}
@media (max-width: 1440px) {
  .calendar-grid { min-width: 820px; }
}
@media (max-width: 1280px) {
  .calendar-grid { min-width: 760px; }
  .cal-header-cell { padding: 12px 10px; min-height: 64px; }
}
@media (max-width: 1024px) {
  main { padding: 12px 14px 24px; }
  .calendar-grid { min-width: 680px; }
  .calendar-scroll { max-height: calc(100vh - 132px); }
}
.cal-header {
  display: contents;
}
.cal-header-cell {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--cal-secondary);
  border-bottom: 1px solid var(--cal-hour-line);
  border-right: 1px solid var(--border-subtle);
  padding: 12px 12px;
  min-height: 68px;
  box-shadow: 0 1px 0 rgba(0,0,0,.18);
}
.cal-header-cell.time-col {
  position: sticky;
  left: 0;
  z-index: 7;
  width: var(--cal-time-col-width);
  min-width: var(--cal-time-col-width);
  background: var(--cal-time-col);
  color: var(--text-muted);
  font-size: 12px;
  box-shadow: 1px 0 0 var(--border-subtle), 0 1px 0 rgba(0,0,0,.18);
}
.cal-staff-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cal-staff-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-time {
  position: sticky;
  left: 0;
  z-index: 3;
  width: var(--cal-time-col-width);
  min-width: var(--cal-time-col-width);
  box-sizing: border-box;
  padding: 0 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  border-right: 1px solid var(--cal-hour-line);
  border-bottom: 1px solid var(--cal-half-line);
  height: var(--cal-row-height);
  min-height: var(--cal-row-height);
  max-height: var(--cal-row-height);
  display: flex;
  align-items: flex-start;
  padding-top: 3px;
  background: var(--cal-time-col);
  box-shadow: 1px 0 0 rgba(0,0,0,.12);
}
.cal-time.minor {
  color: var(--text-muted);
  font-size: 10px;
  border-bottom-style: dashed;
  border-bottom-color: var(--cal-half-line);
}
.cal-time:not(.minor) {
  border-bottom-color: var(--cal-hour-line);
  font-weight: 600;
}
.cal-cell {
  position: relative;
  box-sizing: border-box;
  height: var(--cal-row-height);
  min-height: var(--cal-row-height);
  max-height: var(--cal-row-height);
  overflow: visible;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--cal-half-line);
  padding: 1px;
  background: var(--cal-slot);
  transition: background .14s var(--ease), box-shadow .14s var(--ease);
}
.cal-cell[data-time$=":00"] {
  border-bottom: 1px solid var(--cal-hour-line);
}
.cal-cell.is-off,
.cal-cell.calendar-slot--outside-shift {
  background:
    var(--cal-off-shift-hatch),
    var(--cal-off-shift-gradient);
  cursor: not-allowed;
  border-bottom-color: rgba(213, 47, 47, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(213, 47, 47, 0.10),
    inset 0 -1px 0 rgba(213, 47, 47, 0.08);
}
.cal-cell.calendar-slot--outside-shift[data-time$=":00"] {
  border-bottom-color: rgba(213, 47, 47, 0.12);
}
.cal-cell.calendar-slot--outside-shift.calendar-slot--full-day-off {
  background:
    var(--cal-off-shift-hatch),
    var(--cal-off-day-gradient);
  box-shadow:
    inset 0 1px 0 rgba(213, 47, 47, 0.14),
    inset 0 -1px 0 rgba(213, 47, 47, 0.10);
}
.cal-cell.calendar-slot--outside-shift.calendar-slot--missing-schedule {
  background:
    var(--cal-missing-schedule-hatch),
    var(--cal-missing-schedule-gradient);
  border-bottom-color: rgba(212, 160, 74, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(212, 160, 74, 0.12),
    inset 0 -1px 0 rgba(212, 160, 74, 0.08);
}
.cal-cell.calendar-slot--outside-shift.calendar-slot--edge-before-work {
  border-bottom: 1px solid var(--cal-shift-edge);
  box-shadow:
    inset 0 1px 0 rgba(213, 47, 47, 0.10),
    inset 0 -1px 0 rgba(213, 47, 47, 0.22);
}
.cal-cell.calendar-slot--outside-shift.calendar-slot--edge-after-work {
  border-top: 1px solid var(--cal-shift-edge);
  box-shadow:
    inset 0 1px 0 rgba(213, 47, 47, 0.22),
    inset 0 -1px 0 rgba(213, 47, 47, 0.08);
}
.cal-cell.calendar-slot--missing-schedule.calendar-slot--edge-before-work {
  border-bottom-color: rgba(212, 160, 74, 0.4);
}
.cal-cell.calendar-slot--missing-schedule.calendar-slot--edge-after-work {
  border-top-color: rgba(212, 160, 74, 0.4);
}
.cal-cell:hover:not(.calendar-slot--outside-shift):not(.is-off) {
  background: var(--cal-slot-hover);
  box-shadow: inset 0 0 0 1px var(--cal-slot-hover-ring);
  cursor: pointer;
}
.cal-off-band-label {
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 12px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cal-off-band-label > span {
  display: inline-block;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.35;
  color: var(--cal-off-label-text);
  background: rgba(12, 8, 10, 0.55);
  border: 1px solid rgba(213, 47, 47, 0.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  overflow-wrap: anywhere;
}
.cal-off-band-label--missing > span {
  color: var(--cal-missing-label-text);
  background: rgba(18, 14, 10, 0.58);
  border-color: rgba(212, 160, 74, 0.28);
}
@media (max-width: 390px) {
  .cal-off-band-label {
    padding: 8px;
  }
  .cal-off-band-label > span {
    padding: 5px 8px;
    font-size: 11px;
  }
}
.cal-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(201,47,42,.34);
}
.cal-now-line::before {
  content: attr(data-time);
  position: absolute;
  left: -52px;
  top: -8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 4px;
}

.appt {
  position: relative;
  z-index: 3;
  box-sizing: border-box;
  align-self: stretch;
  justify-self: stretch;
  width: auto;
  min-width: 0;
  height: 100%;
  min-height: 0;
  max-height: none;
  margin: 1px;
  border-radius: 6px;
  padding: 3px 5px 2px;
  font-size: 11px;
  line-height: 1.2;
  background: var(--appt-bg);
  color: var(--text-primary);
  border: 1px solid transparent;
  border-left: 3px solid var(--appt);
  border-top: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  transition: filter .14s var(--ease), box-shadow .14s var(--ease), border-color .14s var(--ease);
  pointer-events: auto;
}
.appt.client-color-1 {
  --appt-client-accent: var(--appt-client-1-accent);
  border-left-color: var(--appt-client-1-accent);
  border-top-color: var(--appt-client-1-accent);
}
.appt.client-color-2 {
  --appt-client-accent: var(--appt-client-2-accent);
  border-left-color: var(--appt-client-2-accent);
  border-top-color: var(--appt-client-2-accent);
}
.appt.client-color-3 {
  --appt-client-accent: var(--appt-client-3-accent);
  border-left-color: var(--appt-client-3-accent);
  border-top-color: var(--appt-client-3-accent);
}
.appt.client-color-4 {
  --appt-client-accent: var(--appt-client-4-accent);
  border-left-color: var(--appt-client-4-accent);
  border-top-color: var(--appt-client-4-accent);
}
.appt.client-color-5 {
  --appt-client-accent: var(--appt-client-5-accent);
  border-left-color: var(--appt-client-5-accent);
  border-top-color: var(--appt-client-5-accent);
}
.appt.client-color-6 {
  --appt-client-accent: var(--appt-client-6-accent);
  border-left-color: var(--appt-client-6-accent);
  border-top-color: var(--appt-client-6-accent);
}
.appt.client-color-7 {
  --appt-client-accent: var(--appt-client-7-accent);
  border-left-color: var(--appt-client-7-accent);
  border-top-color: var(--appt-client-7-accent);
}
.appt.client-color-8 {
  --appt-client-accent: var(--appt-client-8-accent);
  border-left-color: var(--appt-client-8-accent);
  border-top-color: var(--appt-client-8-accent);
}
.appt-break {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  align-self: stretch;
  justify-self: stretch;
  width: auto;
  min-width: 0;
  height: 100%;
  min-height: 0;
  margin: 1px;
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-secondary);
  background: repeating-linear-gradient(
    135deg,
    rgba(235, 229, 220, 0.06),
    rgba(235, 229, 220, 0.06) 5px,
    rgba(235, 229, 220, 0.11) 5px,
    rgba(235, 229, 220, 0.11) 10px
  );
  border: 1px dashed var(--border);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.appt-break-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appt-break-remove {
  flex: none;
  width: 14px;
  height: 14px;
  line-height: 12px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
}
.appt-break-remove:hover {
  background: rgba(235, 229, 220, 0.14);
  color: var(--text-primary);
}
.appt-client-accent {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--appt-client-accent, var(--appt));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.appt-status-chip {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 2px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.appt.status-pending {
  background: rgba(90, 110, 140, 0.36);
  border-color: rgba(150, 175, 210, 0.45);
}
.appt.status-confirmed {
  background: rgba(44, 104, 70, 0.34);
  border-color: rgba(104, 210, 145, 0.48);
}
.appt.status-arrived {
  background: rgba(20, 112, 88, 0.52);
  border-color: rgba(72, 220, 170, 0.72);
}
.appt.status-noshow {
  background: rgba(125, 28, 35, 0.50);
  border-color: rgba(235, 86, 94, 0.70);
  opacity: 1;
}
.appt.status-cancelled {
  background: rgba(70, 74, 82, 0.42);
  border-color: rgba(150, 155, 165, 0.40);
  opacity: 0.78;
  text-decoration: none;
}
.appt.status-cancelled .appt-client-link,
.appt.status-cancelled .appt-service,
.appt.status-cancelled .appt-time {
  text-decoration: line-through;
  opacity: 0.85;
}
.appt.is-outside-shift {
  z-index: 4;
  box-shadow: 0 0 0 1px rgba(212,160,74,.45), 0 2px 8px rgba(0,0,0,.18);
}
.appt-outside-warning {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.3;
  background: rgba(212, 160, 74, 0.22);
  color: #f0d9a8;
}
.appt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}
.appt-row-meta {
  margin-bottom: 0;
  flex-shrink: 0;
}
.appt .appt-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  font-size: 11px;
}
.appt .appt-service,
.appt .appt-phone,
.appt .appt-client-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.appt .appt-client-link {
  font-weight: 600;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
}
.appt .appt-phone {
  opacity: 0.9;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.appt .appt-status-chip {
  flex-shrink: 0;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  padding: 1px 5px;
  line-height: 1.25;
}
.appt.is-compact {
  padding: 2px 4px;
  gap: 0;
}
.appt.is-compact .appt-status-chip {
  max-width: 40%;
}
.appt.is-compact .appt-service {
  font-size: 10px;
  opacity: 0.92;
}
.appt.is-hour .appt-phone {
  display: none;
}
.appt.is-hour.has-phone-room .appt-phone {
  display: block;
}
.appt-group-segments {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin-top: 2px;
}
.appt-group-segment {
  min-width: 0;
  padding: 2px 0 2px 6px;
  border-left: 2px solid rgba(255, 255, 255, 0.18);
}
.appt-group-segment-time {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}
.appt-group-segment-service {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}
.appt.is-group {
  gap: 2px;
}
.appt-details-dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: min(88vh, 760px);
  border: 1px solid rgba(140, 90, 90, 0.35);
  background:
    linear-gradient(165deg, rgba(46, 40, 42, 0.98) 0%, rgba(26, 26, 30, 0.99) 55%, rgba(20, 20, 24, 1) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 18px 48px rgba(0, 0, 0, 0.45);
}
.appt-details-dialog .dialog-header {
  border-bottom: 1px solid rgba(201, 47, 42, 0.22);
  padding: 14px 18px;
}
.appt-details-dialog .dialog-body {
  padding: 14px 18px;
  overflow: auto;
  max-height: min(62vh, 520px);
}
.appt-details-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 12px;
  align-items: start;
}
.appt-details-section {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}
.appt-details-section h3 {
  margin: 0 0 10px;
  font-size: var(--font-size-body);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(201, 47, 42, 0.2);
}
.appt-details-dl {
  display: grid;
  gap: 8px;
  margin: 0;
}
.appt-details-dl > div {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px;
  align-items: start;
}
.appt-details-dl dt {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-size-caption);
}
.appt-details-dl dd {
  margin: 0;
  color: var(--text-primary);
  word-break: break-word;
}
.appt-details-dl select {
  width: auto;
  min-height: 0;
  padding: 4px 8px;
  font-size: var(--font-size-caption);
}
.appt-details-footer {
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
}
.appt-details-abonement {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.16);
}
.appt-details-note {
  margin-top: 8px;
  font-size: var(--font-size-caption);
}
.appt-details-stats {
  margin-top: 8px;
  font-size: var(--font-size-caption);
}
.appt-status-action-btn {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}
.appt-status-action-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}
.appt-status-action-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.appt-status-action-btn[data-status="arrived"].is-current {
  background: rgba(46, 125, 90, 0.35);
  border-color: rgba(90, 190, 140, 0.65);
  color: #d8f5e6;
}
.appt-status-action-btn[data-status="confirmed"].is-current {
  background: rgba(48, 110, 108, 0.32);
  border-color: rgba(96, 180, 170, 0.55);
  color: #d7f2ef;
}
.appt-status-action-btn[data-status="noshow"].is-current {
  background: rgba(150, 100, 40, 0.35);
  border-color: rgba(220, 160, 70, 0.6);
  color: #f8e4c4;
}
.appt-status-action-btn[data-status="cancelled"].is-current {
  background: rgba(140, 50, 50, 0.35);
  border-color: rgba(201, 47, 42, 0.55);
  color: #f3d0ce;
}
.appt-status-action-btn.is-loading {
  opacity: 0.72;
  cursor: wait;
}
.appt-status-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.appt-status-action-btn .status-check {
  margin-right: 4px;
}
.appt-group-picker {
  display: grid;
  gap: 8px;
}
.appt-group-picker-item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
@media (max-width: 720px) {
  .appt-details-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 420px) {
  .appt-details-dialog {
    width: calc(100vw - 12px);
    max-height: 94vh;
  }
  .appt-details-dl > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .appt-details-footer {
    flex-direction: column;
    align-items: stretch;
  }
}

.cal-off-band-label > span {
  font-weight: 600;
  color: #1c1915;
  background: rgba(212,160,74,.92);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.appt:hover {
  filter: brightness(1.12);
  box-shadow: 0 3px 12px rgba(0,0,0,.24);
}
.appt:focus-visible,
.appt:has(.appt-client-link:focus-visible) {
  outline: none;
  box-shadow: var(--focus-ring);
}
.appt strong { display: block; font-size: 12px; color: var(--text-primary); }
.appt-client-link {
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: underline;
  text-decoration-color: rgba(244,239,231,.28);
  text-underline-offset: 2px;
}
.appt-client-link:hover {
  color: var(--cream);
  text-decoration-color: rgba(201,47,42,.55);
  filter: none;
  background: transparent;
}
.appt-client-link:focus-visible {
  box-shadow: none;
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.appt-service,
.appt-time {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appt-service {
  margin-top: 1px;
  color: var(--text-secondary);
  font-size: 11px;
}
.appt-time {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
/* Status keeps left accent only — client tint background stays */
.appt.status-pending { border-left-width: 3px; }
.appt.status-confirmed { border-left-width: 3px; }
.appt.status-arrived { border-left-width: 3px; }
.appt.status-noshow { border-left-width: 3px; }
.appt.status-cancelled { border-left-width: 3px; }
.calendar-empty {
  padding: 48px 28px;
  color: var(--text-secondary);
  text-align: center;
  background: var(--cal-surface);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-body);
  line-height: 1.5;
  max-width: 36em;
  margin: 0 auto;
}

.client-row { cursor: pointer; }
.client-name-link {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 0;
  height: auto;
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(244,239,231,.25);
  text-underline-offset: 2px;
}
.client-name-link:hover {
  color: var(--cream);
  background: transparent;
  filter: none;
  text-decoration-color: rgba(201,47,42,.5);
}

.client-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.client-drawer.is-open { pointer-events: auto; }
.client-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.58);
  opacity: 0;
  transition: opacity .18s var(--ease);
}
.client-drawer.is-open .client-drawer-overlay { opacity: 1; }
.client-drawer-panel {
  position: relative;
  width: min(460px, 100%);
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--surface-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transform: translateX(100%);
  transition: transform .2s var(--ease);
}
.client-drawer.is-open .client-drawer-panel { transform: translateX(0); }
.client-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  flex-shrink: 0;
}
.client-drawer-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.client-drawer-subtitle {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: var(--font-size-label);
}
.client-drawer-subtitle a {
  color: var(--text-primary);
  text-decoration: none;
}
.client-drawer-subtitle a:hover { text-decoration: underline; }
.client-drawer-body {
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--space-5) var(--space-5) var(--space-6);
  display: grid;
  gap: var(--space-5);
  align-content: start;
  scrollbar-color: var(--surface-active) transparent;
  scrollbar-width: thin;
}
.client-drawer-section {
  display: grid;
  gap: var(--space-3);
}
.client-drawer-section h3 {
  margin: 0;
  font-size: var(--font-size-caption);
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 600;
}
.client-drawer-section--upcoming {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(165deg, rgba(42, 40, 44, 0.92), rgba(24, 24, 28, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.client-drawer-section--upcoming h3 {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(201, 47, 42, 0.22);
  color: var(--text-secondary);
}
.client-drawer-empty {
  color: var(--text-secondary);
  font-size: var(--font-size-body);
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-hover);
  border: 1px dashed var(--border-subtle);
  text-align: center;
}
.client-drawer-empty--upcoming::before {
  content: '📅';
  display: block;
  margin-bottom: 6px;
  opacity: 0.5;
  font-size: 18px;
}
.client-drawer-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.client-drawer-stat {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  border: 1px solid var(--border-subtle);
  min-width: 0;
  min-height: 72px;
  box-sizing: border-box;
}
.client-drawer-stat--success {
  background: rgba(46, 110, 80, 0.22);
  border-color: rgba(90, 180, 130, 0.42);
  box-shadow: 0 0 0 1px rgba(90, 180, 130, 0.08);
}
.client-drawer-stat--danger {
  background: rgba(120, 48, 48, 0.28);
  border-color: rgba(201, 47, 42, 0.42);
  box-shadow: 0 0 0 1px rgba(201, 47, 42, 0.08);
}
.client-drawer-stat .value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.client-drawer-stat .label {
  margin-top: 2px;
  font-size: var(--font-size-caption);
  color: var(--text-muted);
}
.client-drawer-stats-note {
  margin: 0;
  font-size: var(--font-size-caption);
  color: var(--text-muted);
}
.client-drawer-list { display: grid; gap: 0; }
.client-drawer-item {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.client-drawer-item:last-child { border-bottom: none; }
.client-drawer-item-title {
  font-weight: 600;
  font-size: var(--font-size-body);
  color: var(--text-primary);
}
.client-drawer-item-meta {
  margin-top: 4px;
  font-size: var(--font-size-label);
  color: var(--text-secondary);
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.client-drawer-abonement {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  display: grid;
  gap: var(--space-3);
}
.client-drawer-abonements {
  display: grid;
  gap: var(--space-3);
}
.client-drawer-abonement-completed {
  opacity: 0.92;
  border: 1px solid var(--border-subtle);
}
.client-drawer-subheading {
  margin: var(--space-2) 0 0;
  font-size: var(--font-size-label);
  font-weight: 650;
  color: var(--text-secondary);
}
.toolbar-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-label);
  color: var(--text-secondary);
}
.toolbar-filter select {
  min-width: 9rem;
}
.client-drawer-abonement-head {
  display: grid;
  gap: var(--space-2);
}
.client-drawer-abonement .package-name {
  font-weight: 700;
  font-size: var(--font-size-section);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.client-drawer-finance {
  display: grid;
  gap: 6px;
  padding-top: 2px;
}
.client-drawer-finance-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--font-size-label);
  color: var(--text-secondary);
}
.client-drawer-finance-row .finance-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-primary);
}
.client-drawer-loading,
.client-drawer-error {
  min-height: 120px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: var(--space-6) var(--space-4);
}
.client-drawer-loading { color: var(--text-secondary); }
.client-drawer-error { color: var(--danger); }
.client-drawer-note {
  font-size: var(--font-size-body);
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.client-drawer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: 6px;
}
.client-drawer-actions .btn-abonement-action {
  min-height: var(--control-height);
  height: var(--control-height);
  padding: var(--control-padding-y) var(--control-padding-x);
  border-radius: var(--control-radius);
  border: 1px solid rgba(201, 47, 42, 0.45);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text-primary);
  font-size: var(--control-font-size);
  line-height: var(--control-line-height);
  cursor: pointer;
}
.client-drawer-actions .btn-abonement-action:hover:not(:disabled) {
  background: rgba(201, 47, 42, 0.16);
  border-color: rgba(201, 47, 42, 0.65);
}
.client-drawer-actions .btn-abonement-action:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
@media (max-width: 480px) {
  .client-drawer-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .client-drawer-panel { width: min(520px, 92vw); }
}
@media (max-width: 768px) {
  .client-drawer-panel { width: min(640px, 94vw); }
}
@media (max-width: 480px) {
  .client-drawer-panel {
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    border-left: none;
  }
  .client-drawer-header { padding: var(--space-4); }
  .client-drawer-body { padding: var(--space-4) var(--space-4) var(--space-6); }
}

.table-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  max-width: 100%;
  box-shadow: var(--shadow-surface);
  scrollbar-gutter: stable;
  scrollbar-color: var(--surface-active) transparent;
  scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--surface-active);
  border: 2px solid var(--bg-secondary);
  border-radius: 999px;
}
.table-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--font-size-body);
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-body);
  min-width: 640px;
}
#services-list table { min-width: 560px; }
#abonements-list table { min-width: 860px; }
th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-solid);
  font-size: var(--font-size-table-head);
  letter-spacing: .02em;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--border-subtle);
}
td {
  color: var(--text-primary);
  max-width: 280px;
}
td.cell-phone,
td.cell-date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
td.cell-name {
  max-width: 240px;
}
td.cell-name .client-name-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
td.cell-service {
  max-width: 280px;
}
td.cell-service .svc-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
th.finance-head {
  text-align: right;
}
.finance-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  font-feature-settings: "tnum" 1;
}
.finance-cell .currency {
  margin-left: .2em;
  font-weight: 500;
  color: var(--text-muted);
}
.amount-sale { color: var(--text-primary); }
.amount-paid { color: var(--text-secondary); font-weight: 500; }
.amount-due { color: var(--warning); }
.amount-due.is-zero { color: var(--text-muted); font-weight: 500; }
.sessions-left {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-primary);
}
.table-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.table-actions .ghost {
  min-height: 36px;
  padding: 6px 12px;
}
#services-list.table-wrap {
  background:
    linear-gradient(165deg, rgba(48, 42, 44, 0.96) 0%, rgba(28, 28, 32, 0.98) 48%, rgba(22, 22, 26, 1) 100%);
  border: 1px solid rgba(120, 90, 90, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 10px 28px rgba(0, 0, 0, 0.35);
}
#services-list table {
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
}
#services-list thead th {
  background: linear-gradient(180deg, rgba(58, 54, 56, 0.98), rgba(40, 38, 42, 0.98));
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(180, 70, 70, 0.28);
  box-shadow: none;
}
#services-list tbody td {
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  height: 48px;
  padding-top: 10px;
  padding-bottom: 10px;
}
#services-list tbody tr {
  transition: background 0.14s var(--ease);
}
#services-list tbody tr:hover td,
#services-list tbody tr:focus-within td {
  background: rgba(92, 48, 48, 0.38);
  transition: background 0.14s var(--ease);
}
#services-list tbody tr:hover td:first-child,
#services-list tbody tr:focus-within td:first-child {
  border-radius: 8px 0 0 8px;
  box-shadow: inset 3px 0 0 rgba(201, 47, 42, 0.7);
}
#services-list tbody tr:hover td:last-child,
#services-list tbody tr:focus-within td:last-child {
  border-radius: 0 8px 8px 0;
}
#services-list tbody tr:focus-within td {
  outline: none;
}
#services-list .amount-sale {
  color: #f2d4d2;
}
#services-list .svc-edit-price-btn {
  border-color: rgba(201, 47, 42, 0.35);
  color: var(--text-primary);
}
#services-list .svc-edit-price-btn:hover {
  background: rgba(201, 47, 42, 0.16);
  border-color: rgba(201, 47, 42, 0.55);
}
#services-list .svc-edit-price-btn:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}
tbody tr:hover td { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

.import-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  cursor: pointer;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-surface);
}
.card .value { font-size: var(--font-size-kpi); font-weight: 700; color: var(--accent-num); font-variant-numeric: tabular-nums; }
.card .label { color: var(--text-secondary); margin-top: 4px; font-size: var(--font-size-caption); }

/* Settings view (branch info, contacts, socials, requisites) */
.settings-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 880px;
}
.settings-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-surface);
}
.settings-section h3 {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-section);
  color: var(--text-primary);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.settings-field--wide {
  grid-column: 1 / -1;
}

/* Analytics tab (Feature 6) — report cards, proportional status/source bars, trend arrows */
#view-dashboard { display: flex; flex-direction: column; gap: var(--space-5); }
.analytics-structure {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
}
.report-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-surface);
}
.report-section h3 {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-section);
  color: var(--text-primary);
}
.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.report-toolbar h3 { margin: 0; }
.bar-group { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; align-items: center; gap: 12px; }
.bar-label { color: var(--text-secondary); font-size: var(--font-size-caption); }
.bar-track { background: var(--bg-tertiary, var(--border)); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--accent-num); height: 100%; border-radius: 999px; }
.bar-count { color: var(--text-primary); font-size: var(--font-size-caption); font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend { margin-left: 6px; font-size: 0.8em; }
.trend-up { color: var(--success, #2e9e5b); }
.trend-down { color: var(--danger, #d64545); }
.trend-flat { color: var(--text-muted); }
.settings-field .field-error {
  margin: 0;
}
@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
.settings-save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
}
.settings-save-row #settings-save-status {
  transition: opacity .2s ease;
}
.settings-save-row #settings-save-status.status-success { color: var(--success); }
.settings-save-row #settings-save-status.status-error { color: var(--danger); }

/* Services & categories view (grouped by user-defined folder).
   #services-list keeps the existing .table-wrap dark-card treatment as the single
   outer panel; each .service-group is just a labelled subsection inside it, separated
   by a divider rather than its own nested card. */
.services-groups {
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-5) var(--space-5);
  gap: var(--space-5);
}
.service-group + .service-group {
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}
.service-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.service-group-header h3 {
  margin: 0;
  font-size: var(--font-size-section);
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}
.service-group-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.service-group-actions button.icon-btn {
  min-width: 32px;
  width: 32px;
  height: 32px;
}
.service-row-inactive td { opacity: .5; }
.service-row-inactive .svc-name::after {
  content: ' (скрыта)';
  color: var(--text-muted);
  font-weight: 400;
}
.staff-row-fired td { opacity: .6; }
.client-row-archived td { opacity: .6; }

.client-sort-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.client-sort-th:hover { color: var(--text-primary); }
.sort-indicator {
  margin-left: .35em;
  font-size: .75em;
}

.client-category-badge {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  white-space: nowrap;
}
.client-category-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.client-category-manage-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.client-category-manage-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.client-category-manage-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.client-category-manage-row .icon-btn {
  width: 32px;
  height: 32px;
}
#service-create-package-fields {
  display: grid;
  gap: var(--space-3);
}

.booking-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-dialog);
  padding: 0;
  background: var(--surface-elevated);
  color: var(--text-primary);
  width: min(960px, 96vw);
  max-width: calc(100vw - 24px);
  max-height: min(92vh, 920px);
  max-height: min(92dvh, 920px);
  overflow: hidden;
  box-shadow: var(--shadow-dialog);
}
.booking-dialog.narrow { width: min(440px, 96vw); }
.booking-dialog::backdrop { background: rgba(0,0,0,.62); }
.abonement-adjustment-success-lead {
  margin: 0 0 var(--space-3);
  color: var(--text-secondary);
}
.abonement-adjustment-success-summary {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.abonement-adjustment-success-package {
  min-width: 0;
}
.abonement-adjustment-success-row {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.abonement-adjustment-success-label {
  color: var(--text-secondary);
  font-size: var(--font-size-caption);
}
.abonement-adjustment-success-values {
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: anywhere;
}
.abonement-adjustment-template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}
.abonement-adjustment-template-actions .ghost {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
#abonement-adjustment-reason-template {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.booking-dialog > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
  overflow: hidden;
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: var(--z-modal-chrome);
}
.dialog-header h2 {
  margin: 0;
  font-size: var(--font-size-page);
  font-weight: 700;
  letter-spacing: -.02em;
  min-width: 0;
  overflow-wrap: anywhere;
}
.dialog-body {
  padding: var(--space-4) var(--space-5);
  display: grid;
  gap: var(--space-3);
  overflow: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
}
.dialog-body label {
  display: grid;
  gap: 4px;
  font-size: var(--font-size-label);
  color: var(--text-secondary);
}
.dialog-field-primary label,
label.dialog-field-primary {
  color: var(--text-primary);
  font-weight: 600;
}
.dialog-field-readonly {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text-secondary);
  font-size: var(--font-size-label);
}
.dialog-field-readonly strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.icon-close {
  background: transparent;
  border: 1px solid transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-secondary);
  padding: 4px 8px;
  min-height: 40px;
  min-width: 40px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.icon-close:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.icon-close:focus-visible {
  box-shadow: var(--focus-ring);
  border-color: var(--focus-border);
  outline: none;
}
.booking-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.38fr) minmax(0, 0.9fr);
  gap: 0;
  overflow: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
}
@media (max-width: 900px) {
  .booking-columns { grid-template-columns: 1fr; }
}
.booking-col {
  padding: var(--space-4) var(--space-5);
  border-right: 1px solid var(--border-subtle);
  display: grid;
  gap: var(--space-3);
  align-content: start;
  min-width: 0;
}
.booking-col:last-child { border-right: none; }
.booking-col h3 {
  margin: 0 0 4px;
  font-size: var(--font-size-caption);
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 600;
}
.booking-col label {
  display: grid;
  gap: 4px;
  font-size: var(--font-size-label);
  color: var(--text-secondary);
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: var(--z-modal-chrome);
}
.dialog-footer .primary { order: 2; }
.dialog-footer .ghost { order: 1; }
.appointment-slot-hint:empty { display: none; }
.appointment-slot-hint.is-error,
.field-error {
  color: var(--danger);
  font-size: var(--font-size-caption);
  margin: 4px 0 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.field-error.hidden { display: none; }
.field-error--form {
  margin: 12px 16px 0;
}
.required-legend {
  margin: 0 20px 8px;
  font-size: var(--font-size-caption);
  color: var(--text-muted);
}
.req {
  color: var(--accent-num, #D2483E);
  font-weight: 700;
  margin-left: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.field-label {
  display: block;
  min-width: 0;
}
.client-create-duplicate {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(201, 47, 42, 0.35);
  border-radius: var(--radius-md);
  background: rgba(201, 47, 42, 0.08);
}
.client-create-duplicate.hidden { display: none; }
.dialog-footer-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
#client-create-form .is-invalid,
#appointment-form .is-invalid {
  border-color: rgba(201, 47, 42, 0.55);
}
#appointment-form .is-invalid:focus,
#appointment-form .date-field.is-invalid .date-display:focus,
#appointment-form select.is-invalid:focus,
#appointment-form input.is-invalid:focus {
  border-color: rgba(201, 47, 42, 0.7);
  box-shadow: var(--focus-ring);
}
@media (max-width: 390px) {
  .required-legend {
    margin: 0 12px 8px;
  }
  .field-error--form {
    margin: 10px 12px 0;
  }
}
select:disabled,
input:disabled,
textarea:disabled {
  opacity: .55;
  cursor: not-allowed;
}
form.is-busy .primary,
button.primary:disabled {
  opacity: .7;
  cursor: wait;
}
.picker-results {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  box-shadow: var(--shadow-dialog);
  margin: 0;
  padding: 4px;
}
.picker-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-size-label);
}
.picker-item-btn {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  border-radius: 8px;
}
.picker-item-btn:hover,
.picker-item-btn.is-active {
  background: rgba(255, 255, 255, 0.06);
}
.picker-item-btn.is-selected,
.picker-item-btn:active {
  background: rgba(36, 92, 64, 0.42);
  border: 1px solid rgba(104, 210, 145, 0.45);
}
.picker-item-name {
  color: var(--text-primary);
  font-weight: 600;
}
.picker-item-phone {
  color: var(--text-muted);
  font-size: var(--font-size-caption);
}
.picker-item:hover { background: var(--surface-hover); }
.picker-item:last-child { border-bottom: none; }
.bl-overlay-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-floating);
  pointer-events: none;
}
.bl-overlay-root .bl-select-list,
.bl-overlay-root .picker-results {
  pointer-events: auto;
}
/* Host inside open <dialog> (top-layer fallback when Popover API is unavailable) */
.bl-dialog-overlay-host {
  position: absolute;
  inset: 0;
  z-index: var(--z-modal-floating);
  pointer-events: none;
  overflow: visible;
}
.bl-dialog-overlay-host > * {
  pointer-events: auto;
  z-index: 50;
}
.bl-overlay-root .bl-select-list,
.bl-overlay-root .picker-results,
.bl-dialog-overlay-host .bl-select-list,
.bl-dialog-overlay-host .picker-results {
  z-index: 50;
}
/* Popover API: strip UA popover centering so fixed coords from getBoundingClientRect work */
.bl-select-list[popover],
.picker-results[popover] {
  margin: 0;
  inset: unset;
  position: fixed;
  z-index: var(--z-popover);
  overflow: auto;
}
.bl-select-list[popover]:not(:popover-open),
.picker-results[popover]:not(:popover-open) {
  display: none;
}
.selected-client {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-raised, rgba(40, 44, 52, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-body);
  color: var(--text-primary);
}
.selected-client-check {
  display: none;
  flex-shrink: 0;
  font-weight: 700;
  color: rgba(120, 220, 160, 0.95);
}
.selected-client--valid {
  background: rgba(36, 92, 64, 0.42);
  border-color: rgba(104, 210, 145, 0.55);
  color: var(--text-primary);
}
.selected-client--valid .selected-client-check {
  display: inline-block;
}
.selected-client--error {
  background: var(--accent-soft);
  border-color: rgba(201, 47, 42, 0.45);
}
.selected-client #selected-client-text,
.selected-client #ab-selected-client-text {
  flex: 1;
  min-width: 0;
}
.chip-clear {
  background: transparent;
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
  line-height: 1;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.chip-clear:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.chip-clear:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}
.muted { color: var(--text-muted); font-size: var(--font-size-caption); }
.new-client-block summary { cursor: pointer; color: var(--text-primary); margin-bottom: 8px; }

.schedule-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}
#schedule-dialog .dialog-body {
  overflow: visible;
  flex: 0 1 auto;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}
#schedule-dialog.booking-dialog {
  max-height: min(88vh, 680px);
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row label.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.schedule-row input[type="checkbox"] { width: auto; }
.schedule-row .field-error {
  grid-column: 1 / -1;
  margin: 0;
}

/* Status chips — text + tone (Concept C density) */
.status-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.cell-service .status-chip-row {
  margin-top: 6px;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: .01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-chip--neutral {
  color: var(--text-secondary);
  background: var(--surface-hover);
  border-color: var(--border-subtle);
}
.status-chip--info {
  color: #9ec9d8;
  background: rgba(79,143,168,.18);
  border-color: rgba(79,143,168,.28);
}
.status-chip--success {
  color: #9fd4b0;
  background: rgba(92,184,122,.16);
  border-color: rgba(92,184,122,.28);
}
.status-chip--warning {
  color: #efd08a;
  background: rgba(232,184,77,.16);
  border-color: rgba(232,184,77,.28);
}
.status-chip--danger {
  color: #f0a0a0;
  background: rgba(232,93,93,.16);
  border-color: rgba(232,93,93,.28);
}

@media (max-width: 700px) {
  .schedule-row { grid-template-columns: 1fr; }
  .booking-dialog,
  .booking-dialog.narrow {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: min(96vh, 100dvh);
  }
  .dialog-header,
  .dialog-body,
  .dialog-footer,
  .booking-col {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .client-drawer-overlay,
  .client-drawer-panel,
  .booking-dialog {
    transition: none !important;
  }
}

/* Custom select — Black Lab (no system blue) */
.bl-select {
  position: relative;
  width: 100%;
}
.bl-select-trigger {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.bl-select-trigger:hover:not(:disabled) {
  border-color: rgba(201, 47, 42, 0.45);
}
.bl-select-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.bl-select.is-invalid .bl-select-trigger,
.field-label:has(select.is-invalid) .bl-select-trigger {
  border-color: rgba(201, 47, 42, 0.75);
}
.bl-select.is-disabled .bl-select-trigger,
.bl-select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.bl-select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bl-select-caret {
  flex-shrink: 0;
  opacity: 0.7;
}
.bl-select-list {
  position: fixed;
  z-index: var(--z-popover);
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border-radius: 10px;
  border: 1px solid rgba(140, 90, 90, 0.4);
  background: linear-gradient(180deg, #2c2a2e, #1c1c20);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.bl-select-list.hidden {
  display: none !important;
}
.bl-select-option-empty {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: var(--font-size-label);
  pointer-events: none;
}
.bl-select-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.bl-select-option--service {
  display: grid;
  gap: 2px;
}
.bl-select-option-label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.bl-select-option-price {
  color: var(--text-muted);
  font-size: var(--font-size-caption);
  font-variant-numeric: tabular-nums;
}
.bl-select-option:hover,
.bl-select-option.is-active {
  background: rgba(255, 255, 255, 0.08);
}
.bl-select-option.is-selected {
  background: rgba(36, 92, 64, 0.48);
  border: 1px solid rgba(104, 210, 145, 0.5);
  color: var(--text-primary);
}
.bl-select-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.bl-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Client create success */
#client-create-success-dialog.success-dialog {
  border: 1px solid rgba(90, 180, 130, 0.35);
  background: linear-gradient(165deg, rgba(36, 48, 42, 0.98), rgba(22, 24, 28, 0.99));
}
.success-dialog-body {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  padding-top: 4px;
}
.success-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(46, 125, 90, 0.28);
  border: 1px solid rgba(90, 190, 140, 0.55);
  box-shadow: 0 0 0 6px rgba(90, 180, 130, 0.08);
  color: #d8f5e6;
  font-size: 24px;
  font-weight: 700;
}
.success-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(46, 125, 90, 0.2);
  border: 1px solid rgba(90, 180, 130, 0.4);
  color: #d8f5e6;
  font-size: var(--font-size-caption);
  font-weight: 600;
}
.success-dialog-message {
  margin: 0;
  color: var(--text-primary);
  max-width: 28ch;
}

/* Multi-service appointment items */
.appointment-items-panel {
  display: grid;
  gap: 10px;
}
.appointment-item {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 12px;
  min-width: 0;
  box-sizing: border-box;
}
.appointment-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.appointment-item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}
.appointment-item-grid .field-label,
.appointment-item-grid .bl-select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.appointment-item-grid .field-label--service {
  grid-column: 1 / -1;
}
.appointment-item-calc {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  align-items: start;
}
.appointment-item-calc-label {
  display: block;
  font-size: var(--font-size-caption);
  color: var(--text-muted);
  margin-bottom: 4px;
}
.appointment-item-qty-block {
  min-width: 0;
}
.appointment-item-price-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.appointment-item-calc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.appointment-item-calc-row input.appt-item-price {
  width: 120px;
  max-width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.appointment-item-calc-total strong {
  font-size: 1.05rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.appointment-item-calc-time span:last-child {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.appointment-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.appointment-qty button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
}
.appointment-qty button:hover:not(:disabled) {
  background: var(--surface-hover);
}
.appointment-qty button:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}
.appointment-qty input {
  width: 56px;
  text-align: center;
  min-height: 32px;
  height: 32px;
}
.appointment-items-summary {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: var(--font-size-body);
}
.appointment-items-summary.is-valid {
  border-color: rgba(104, 210, 145, 0.45);
  background: rgba(36, 92, 64, 0.28);
}
.appointment-items-summary.is-error {
  border-color: rgba(201, 47, 42, 0.35);
  background: rgba(201, 47, 42, 0.08);
}
.appointment-single-fields.hidden,
.appointment-items-panel.hidden {
  display: none !important;
}
@media (max-width: 640px) {
  .appointment-item-grid {
    grid-template-columns: 1fr;
  }
  .appointment-item-calc {
    grid-template-columns: 1fr;
  }
}
