:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --line: #d7e0ea;
  --line-strong: #c4d0dc;
  --text: #1f2a37;
  --muted: #637487;
  --brand: #c35a27;
  --brand-dark: #9d4218;
  --brand-soft: #fff1e9;
  --success: #1f8f6f;
  --success-soft: #e8f7f1;
  --warning: #d17a1f;
  --warning-soft: #fff4e2;
  --selected: #ef7d32;
  --selected-soft: #fff0e6;
  --danger: #b23b2f;
  --danger-soft: #fdeeee;
  --radius-xl: 14px;
  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --font-display: "Bahnschrift", "Segoe UI", sans-serif;
  --font-body: "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}

body.embedded-mode {
  overflow: hidden;
  background: transparent;
  --bitrix-mobile-nav-offset: 56px;
}

.page-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

body.embedded-mode .page-shell {
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}

@media (max-width: 860px) {
  html.embedded-mode,
  body.embedded-mode {
    background: #fff;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.embedded-mode {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  body.embedded-mode .page-shell {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    padding-bottom: var(--bitrix-mobile-nav-offset);
    background: #fff;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    transform: translateZ(0);
  }

  body.embedded-mode .app-shell {
    padding: 0;
    gap: 0;
  }

  body.embedded-mode .dashboard-panel {
    display: block !important;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 12px 12px 4px;
  }

  body.embedded-mode .sync-summary {
    display: none !important;
  }

  body.embedded-mode .log-panel {
    display: none;
  }

  body.embedded-mode .workflow-panel {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
  }

  body.embedded-mode .workflow-panel .panel__header {
    margin-bottom: 8px;
    padding: 12px 12px 0;
  }

  body.embedded-mode .panel__header p,
  body.embedded-mode .workflow-panel__intro p,
  body.embedded-mode .flow-status,
  body.embedded-mode .step-card__hint,
  body.embedded-mode .calendar-legend {
    display: none;
  }

  body.embedded-mode .mobile-manager-card {
    display: none !important;
  }

  body.embedded-mode .modal__header p,
  body.embedded-mode .modal__head p,
  body.embedded-mode .admin-user-bitrix-field,
  body.embedded-mode .user-card__inline-meta {
    display: none;
  }

  body.embedded-mode select,
  body.embedded-mode input[type="time"] {
    display: none !important;
  }

  body.embedded-mode .mobile-select-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }

  body.embedded-mode .mobile-select-picker--stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  body.embedded-mode .mobile-select-picker--grid4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.embedded-mode .mobile-select-picker--scroll {
    max-height: 220px;
    overflow-y: auto;
    align-content: start;
    padding-right: 2px;
  }

  body.embedded-mode .mobile-select-picker .button {
    flex: 0 0 auto;
    width: 100%;
    min-height: 40px;
    margin: 0;
  }

  body.embedded-mode .workflow-form {
    gap: 8px;
  }

  body.embedded-mode .step-card {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 12px;
  }

  body.embedded-mode .step-card--calendar {
    padding-left: 8px;
    padding-right: 8px;
  }

  body.embedded-mode .calendar-card {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 8px 0 0;
  }

  body.embedded-mode .calendar-card__top {
    align-items: center;
  }

  body.embedded-mode .calendar-title-group {
    display: grid;
    grid-template-columns: 1fr 5fr 1fr;
    align-items: center;
    width: 100%;
    gap: 8px;
  }

  body.embedded-mode .calendar-title-group strong {
    min-width: 0;
    text-align: center;
    justify-self: center;
  }

  body.embedded-mode .calendar-nav-button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    aspect-ratio: 1 / 1;
    padding: 0;
    justify-self: center;
  }

  body.embedded-mode .calendar-grid {
    gap: 4px;
  }

  body.embedded-mode .calendar-day {
    min-height: 52px;
    padding: 0;
    display: grid;
    place-items: center;
    text-align: center;
  }

  body.embedded-mode .calendar-day__number,
  body.embedded-mode .calendar-day__badge {
    position: static;
    display: grid;
    place-items: center;
    align-self: center;
    justify-self: center;
    width: 100%;
    height: 100%;
    margin: 0;
  }

  body.embedded-mode .calendar-day__badge {
    font-size: 20px;
  }

  body.embedded-mode .records-panel,
  body.embedded-mode .service-panel,
  body.embedded-mode .panel.records-panel {
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  body.embedded-mode .profile-card {
    border: none;
    background: transparent;
    padding: 0;
  }

  body.embedded-mode .profile-card__facts {
    grid-template-columns: 1fr;
  }

  body.embedded-mode .profile-card__fact--meta {
    display: none;
  }

  body.embedded-mode .profile-card__fact--manager {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 12px;
  }

  body.embedded-mode .modal {
    margin: 0;
    position: fixed;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    inset: 0;
    overflow: hidden;
  }

  body.embedded-mode .modal[open] {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
  }

  body.embedded-mode .modal.modal--mobile-open {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    z-index: 1000;
  }

  body.embedded-mode .modal__form,
  body.embedded-mode .modal__form--wide {
    width: 100vw;
    max-width: 100vw;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 16px 12px calc(24px + env(safe-area-inset-bottom) + var(--bitrix-mobile-nav-offset));
  }

  body.embedded-mode .modal__head,
  body.embedded-mode .modal__header,
  body.embedded-mode .modal__form .form-actions {
    flex: 0 0 auto;
  }

  body.embedded-mode .modal__body,
  body.embedded-mode .modal__body--scroll {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-right: 0;
    padding-bottom: var(--bitrix-mobile-nav-offset);
  }

  body.embedded-mode .modal__form > .form-grid {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-bottom: var(--bitrix-mobile-nav-offset);
  }

  body.embedded-mode .modal__body--scroll {
    overflow-y: auto;
  }
}

body.embedded-mode .session-field,
body.embedded-mode #loadWorkspaceButton {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  padding: 12px;
}

.dashboard-panel,
.workflow-panel,
.log-panel {
  grid-column: 1 / -1;
}

.records-panel {
  grid-column: span 6;
}

.records-panel--full {
  grid-column: 1 / -1;
}

.panel,
.modal__form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}

.panel {
  padding: 16px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 18px;
}

p {
  margin: 0;
}

.panel__header,
.step-card__header,
.dashboard-panel__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel__header {
  margin-bottom: 14px;
}

.panel__header p,
.step-card__hint,
.step-note,
.status-line,
.muted {
  color: var(--muted);
}

.panel__actions,
.form-actions,
.dashboard-panel__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.dashboard-panel__hidden {
  display: none;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.profile-card {
  min-height: 0;
  width: 100%;
}

.profile-card__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 72px;
  text-align: center;
}

.profile-card__retry {
  width: auto;
  min-height: 38px;
}

.profile-card__body,
.profile-card__facts {
  display: grid;
  gap: 12px;
  width: 100%;
}

.profile-card__body {
  height: 100%;
  align-items: stretch;
  justify-items: stretch;
  grid-template-columns: minmax(0, 1fr);
}

.profile-card__facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-card__fact {
  display: grid;
  align-content: start;
  width: 100%;
  min-width: 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  min-height: 100%;
}

.profile-card__fact-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  position: relative;
}

.metric-card--interactive {
  appearance: none;
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.metric-card--interactive:hover {
  border-color: rgba(195, 90, 39, 0.4);
  background: #fdf8f4;
}

.metric-card--interactive:focus-visible {
  outline: 2px solid rgba(195, 90, 39, 0.35);
  outline-offset: 2px;
}

.metric-card--interactive:active {
  transform: translateY(1px);
}

.metric-card strong {
  font-size: 34px;
  line-height: 1;
  font-family: var(--font-display);
}

.metric-card__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-card__split {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.metric-card__split-value--approved {
  color: #198754;
}

.metric-card__split-value--pending {
  color: #c35a27;
}

.sync-summary {
  display: none;
}

.compact-field {
  min-width: 170px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field textarea {
  min-height: 108px;
  resize: vertical;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #506070 50%),
    linear-gradient(135deg, #506070 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.hidden-fields {
  display: none;
}

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.button--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.button--secondary {
  background: #eef3f7;
  border-color: var(--line);
  color: var(--text);
}

.button--ghost {
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--text);
}

.button--danger {
  background: var(--danger-soft);
  border-color: #f3c6bf;
  color: var(--danger);
}

.button--segment {
  min-width: 164px;
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--text);
}

.button--segment.is-active,
.button--ghost.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.button--chip.is-active {
  background: var(--selected-soft);
  border-color: var(--selected);
  color: var(--brand-dark);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill--role {
  background: var(--success-soft);
  color: var(--success);
}

.pill--pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill--approved {
  background: var(--success-soft);
  color: var(--success);
}

.pill--pending-update {
  background: var(--selected-soft);
  color: var(--brand-dark);
}

.workflow-form {
  display: grid;
  gap: 12px;
}

.flow-status {
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  color: var(--text);
  line-height: 1.45;
}

.step-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}

.step-card[data-locked="true"] {
  opacity: 0.62;
  pointer-events: none;
  user-select: none;
}

.step-card[data-locked="true"] button,
.step-card[data-locked="true"] input,
.step-card[data-locked="true"] select,
.step-card[data-locked="true"] textarea,
.step-card[data-locked="true"] .mobile-select-picker {
  pointer-events: none !important;
}

.step-card__index {
  display: inline-flex;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-dark);
}

.segmented-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.calendar-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-title-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.calendar-title-group strong {
  min-width: 170px;
  font-size: 20px;
}

.calendar-nav-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 18px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.calendar-day {
  position: relative;
  min-height: 88px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.calendar-day:hover:not(:disabled) {
  border-color: var(--brand);
}

.calendar-day:disabled,
.calendar-day.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.calendar-day.is-outside {
  background: #fbfcfd;
  color: #8795a4;
}

.calendar-day.is-today {
  border-color: #7d96b0;
}

.calendar-day.is-selected {
  border-color: var(--selected);
  background: var(--selected-soft);
}

.calendar-day.is-in-range {
  background: #fff7f1;
  border-color: #f1b38f;
}

.calendar-day.is-occupied-pending {
  background: #fff6e8;
  border-color: #efc27a;
}

.calendar-day.is-occupied-approved {
  background: #edf9f3;
  border-color: #8bd0b6;
}

.calendar-day__number {
  font-size: 18px;
  font-weight: 700;
}

.calendar-day__badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 860px) {
  body.embedded-mode .calendar-day__number,
  body.embedded-mode .calendar-day__badge {
    position: static;
    display: grid;
    place-items: center;
    align-self: center;
    justify-self: center;
    width: 100%;
    height: 100%;
    margin: 0;
  }

  body.embedded-mode .calendar-day__badge {
    font-size: 20px;
  }

  body.modal-open,
  body.modal-open .page-shell {
    overflow: hidden;
  }

  body.modal-open {
    position: fixed;
    width: 100%;
    inset: 0;
  }
}

.system-message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f7fafc;
  line-height: 1.45;
}

.system-message--compact {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 13px;
}

.system-message.is-error {
  border-color: #efc2be;
  background: var(--danger-soft);
  color: var(--danger);
}

.system-message.is-success {
  border-color: #b7dfd1;
  background: var(--success-soft);
  color: var(--success);
}

.system-message.is-warning {
  border-color: #f0d3a2;
  background: var(--warning-soft);
  color: #a2600d;
}

.time-grid,
.form-grid,
.request-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.step-note {
  font-size: 13px;
}

.stack-list {
  display: grid;
  gap: 12px;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.admin-toolbar--requests {
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr) minmax(180px, 1fr);
}

.service-grid,
.service-panel {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.service-grid {
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
}

.service-panel--stack {
  grid-template-columns: minmax(0, 1fr);
}

.service-field {
  max-width: 520px;
}

.service-options {
  display: grid;
  gap: 10px;
}

.service-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.service-actions--spaced {
  padding-top: 4px;
}

.checkbox-row {
  display: inline-grid;
  grid-template-columns: 14px auto;
  align-items: center;
  justify-content: start;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-row input {
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  padding: 0;
  accent-color: var(--brand);
}

.checkbox-row span {
  line-height: 1.35;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  color: var(--muted);
}

.request-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}

.user-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}

.request-card--focused {
  outline: 2px solid rgba(195, 90, 39, 0.18);
}

.request-card__header,
.user-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.request-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.request-card__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}

.request-card__submitted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.request-card__facts {
  grid-template-columns: minmax(170px, 220px) minmax(130px, 150px) minmax(180px, 220px) minmax(0, 1fr);
  gap: 8px;
}

.request-card__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.user-card__meta,
.user-card__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-card__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.user-card__facts .fact {
  min-width: 180px;
  flex: 1 1 180px;
  padding: 8px 10px;
}

.user-card__title {
  display: grid;
  gap: 0;
}

.user-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  justify-content: flex-end;
}

.user-card__inline-meta {
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
}

.fact {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.fact__label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.fact__value {
  font-weight: 600;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.pagination__summary {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
}

.log-box {
  margin: 0;
  min-height: 180px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: #17202a;
  color: #e8edf3;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
}

.busy-overlay[hidden] {
  display: none;
}

.busy-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 20, 0.54);
}

.busy-overlay__content {
  position: relative;
  z-index: 1;
  min-width: 220px;
  max-width: min(92vw, 360px);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  background: rgba(20, 27, 36, 0.92);
  color: #fff;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.busy-overlay__spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: busy-spin 0.9s linear infinite;
}

.busy-overlay[data-mode="success"] .busy-overlay__spinner {
  display: grid;
  place-items: center;
  border-color: #2db86d;
  background: #2db86d;
  animation: none;
}

.busy-overlay[data-mode="success"] .busy-overlay__spinner::before {
  content: "✓";
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

body.is-busy {
  cursor: progress;
}

body.is-busy .button[disabled] {
  opacity: 0.68;
  cursor: not-allowed;
}

@keyframes busy-spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border: none;
  padding: 0;
  background: transparent;
  overflow: auto;
  background: rgba(18, 23, 30, 0.4);
}

.modal:not([open]) {
  display: none;
}

.modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal__form {
  width: min(860px, calc(100vw - 24px));
  padding: 22px;
}

.modal__form--wide {
  width: min(980px, calc(100vw - 24px));
  max-height: min(80vh, 900px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.modal__head {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.admin-directory-toolbar {
  display: flex;
  justify-content: flex-end;
}

.modal__body {
  min-height: 0;
}

.modal__body--scroll {
  overflow-y: auto;
  padding-right: 4px;
}

.modal__footer-spacer {
  height: 18px;
  flex: 0 0 auto;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal__form .form-actions {
  margin-top: 16px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .dashboard-summary,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .records-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 10px;
  }

  .panel__header,
  .step-card__header,
  .dashboard-panel__top,
  .calendar-card__top {
    flex-direction: column;
    align-items: stretch;
  }

  .calendar-title-group strong {
    min-width: 0;
  }

  .time-grid,
  .form-grid,
  .request-card__facts,
  .profile-card__facts,
  .profile-card__body,
  .request-card__body,
  .user-card__body,
  .admin-toolbar,
  .service-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .calendar-weekdays {
    display: none;
  }

  .calendar-day {
    min-height: 68px;
  }

  body.embedded-mode .calendar-day {
    min-height: 52px;
  }

  .segmented-controls,
  .dashboard-panel__actions,
  .panel__actions,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .button,
  .calendar-nav-button {
    width: 100%;
  }

  body.embedded-mode .calendar-title-group {
    grid-template-columns: 1fr 5fr 1fr;
  }

  /* Mobile dashboard: show only metric counters, hide profile */
  body.embedded-mode #profileCard,
  body.embedded-mode .profile-card,
  body.embedded-mode #syncSummary {
    display: none !important;
  }

  body.embedded-mode #profileCard.profile-card--unloaded {
    display: block !important;
    grid-column: 1 / -1;
  }

  body.embedded-mode .dashboard-summary {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  body.embedded-mode .metric-card {
    padding: 12px 8px;
    font-size: 13px;
  }

  body.embedded-mode .metric-card strong {
    font-size: 24px;
  }
}
