/* Shedar Logistics readability and responsive-chat layer.
   Loaded after the production bundle so the original application remains intact. */

:root {
  --shedar-font-caption: 13px;
  --shedar-font-small: 14px;
  --shedar-font-body: 16px;
  --shedar-font-strong: 17px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-size: var(--shedar-font-body);
  line-height: 1.5;
}

/* Calm text hierarchy: red is reserved for actions, alerts and destructive operations. */
.section-head .eyebrow,
.eyebrow,
.reports-head span {
  color: var(--color-text-muted, #667085) !important;
}

.section-head .eyebrow::before,
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: .9em;
  margin-right: 8px;
  border-radius: 99px;
  background: var(--red, #d90000);
  vertical-align: -.04em;
}

.entity-code,
.order-number,
.user-record > div > span {
  color: var(--color-text, #20242a) !important;
}

.user-record .superadmin-badge {
  color: #5d3db2 !important;
}

/* Shared navigation, page headings and controls */
.shedar-brand small,
.sidebar-caption,
.section-head .eyebrow,
.eyebrow,
.entity-code,
.driver-main > span,
.waybill-main > span,
.order-number,
.user-record > div > span,
.reports-head span {
  font-size: var(--shedar-font-caption);
  line-height: 1.35;
}

.sidebar-link,
.role-button,
.primary-button,
.outline-button,
.small-button,
.live-pill,
.header-profile-copy strong,
.header-account strong,
.header-profile-copy small,
.header-account small {
  font-size: var(--shedar-font-small);
}

.sidebar-link {
  min-height: 46px;
}

.section-head > div > p:last-child,
.entity-card > p,
.stops,
.contact-card dl div,
.contact-card address,
.permission-note,
.permission-box,
.error-banner,
.toast,
.map-message {
  font-size: var(--shedar-font-body);
  line-height: 1.5;
}

/* Tables and lists on every workspace tab */
.orders-table th,
.table-title span {
  font-size: var(--shedar-font-caption);
}

.orders-table td,
.search-input,
.filter-select {
  font-size: var(--shedar-font-body);
}

.orders-table td > b,
.driver-record b,
.waybill-card b,
.waybill-document-head b,
.meta-item b,
.timeline-item b,
.tracking-list b,
.backup-row b,
.user-record h3 {
  font-size: var(--shedar-font-strong);
  line-height: 1.4;
}

.orders-table td > small,
.driver-record p,
.waybill-card p,
.driver-record small,
.waybill-card small,
.waybill-document-head span,
.waybill-navigation-note,
.entity-footer,
.entity-footer button,
.entity-card button,
.status,
.record-status,
.kind-chip,
.meta-item span,
.button-note,
.side-title span,
.timeline-item small,
.tracking-list span,
.tracking-controls span,
.track-stats,
.route-meta > div > span:first-child,
.route-stops p,
.map-attribution-note {
  font-size: var(--shedar-font-small);
  line-height: 1.45;
}

.orders-table td {
  padding-block: 19px;
}

.status,
.record-status,
.kind-chip {
  min-height: 30px;
  padding-block: 6px;
}

/* Forms, dialogs and authentication */
.form-grid label > span,
.twofa-setup label span,
.login-card label span,
.login-hint,
.login-help,
.forgot-button,
.login-back,
.login-copy,
.login-description,
.login-error,
.first-login b,
.first-login span,
.first-login small,
.delete-warning,
.danger-link {
  font-size: var(--shedar-font-small) !important;
  line-height: 1.45;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.twofa-setup input,
.twofa-disable input,
.input-group input,
.login-submit,
.message-edit-input {
  min-height: 48px;
  font-size: var(--shedar-font-body);
}

.modal-copy,
.twofa-setup p,
.route-stops li,
.status-history a {
  font-size: var(--shedar-font-body);
}

/* Dispatcher reports: the production stylesheet used 7-10px here. */
.reports-head h2 {
  margin-top: 7px;
  font-size: 18px;
  line-height: 1.3;
}

.reports-head > b,
.report-icon {
  width: 34px;
  height: 34px;
  font-size: var(--shedar-font-caption);
}

.report-list article {
  min-height: 62px;
  gap: 12px;
  padding-block: 10px;
}

.report-list b {
  font-size: var(--shedar-font-small);
  line-height: 1.4;
}

.report-list p,
.report-list time,
.user-record p,
.user-role {
  font-size: 12px;
  line-height: 1.4;
}

/* Chat: readable desktop layout and bounded line lengths. */
.chat-shell {
  grid-template-columns: clamp(250px, 20vw, 310px) minmax(0, 1fr);
  height: clamp(540px, calc(100dvh - 220px), 920px);
  min-height: 0;
}

.chat-people {
  scrollbar-gutter: stable;
}

.chat-people h3,
.conversation-head b {
  font-size: var(--shedar-font-strong);
}

.chat-people button,
.chat-people b,
.chat-people small,
.conversation-head small,
.chat-history-note,
.message-menu button {
  font-size: var(--shedar-font-small);
  line-height: 1.35;
}

.chat-people button {
  min-height: 58px;
}

.conversation {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.conversation-head {
  min-height: 68px;
}

.messages {
  min-height: 0;
  padding: clamp(14px, 2vw, 24px);
  scroll-padding-block: 18px;
  -webkit-overflow-scrolling: touch;
}

.message {
  width: fit-content;
  max-width: min(76%, 760px);
}

.message p {
  overflow-wrap: anywhere;
  padding: 12px 15px;
  font-size: var(--shedar-font-body);
  line-height: 1.5;
}

.message span {
  font-size: var(--shedar-font-caption);
}

.message-menu-button {
  min-width: 40px;
  min-height: 30px;
  font-size: var(--shedar-font-body);
}

.message-form {
  grid-template-columns: 50px minmax(0, 1fr) 50px;
  gap: 9px;
  padding: 11px;
  padding-bottom: max(11px, env(safe-area-inset-bottom));
}

.message-form > input {
  min-height: 50px;
  font-size: var(--shedar-font-body);
}

.attach-button,
.message-form button {
  width: 50px;
  min-width: 50px;
  min-height: 50px;
}

/* Tablets and phones: contacts become a swipeable strip above the dialog. */
@media (max-width: 900px) {
  .workspace:has(.chat-shell) {
    min-height: 0;
    overflow: hidden;
  }

  .chat-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: clamp(320px, calc(100dvh - 205px), 820px);
    min-height: 0;
  }

  .chat-people {
    grid-row: 1;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    align-items: stretch;
    gap: 8px;
    padding: 9px;
    display: flex;
    overflow: auto hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    -webkit-overflow-scrolling: touch;
  }

  .chat-people h3 {
    flex: 0 0 auto;
    align-content: center;
    margin: 0 4px;
    font-size: var(--shedar-font-small);
  }

  .chat-people button {
    flex: 0 0 min(210px, 62vw);
    min-height: 56px;
    padding: 8px 10px;
    scroll-snap-align: start;
  }

  .chat-people button > div {
    min-width: 0;
  }

  .chat-people button b,
  .chat-people button small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation {
    grid-row: 2;
    min-height: 0;
  }

  .chat-shell > .conversation:only-child {
    grid-row: 1 / -1;
  }

  .message {
    max-width: min(88%, 680px);
  }
}

@media (max-width: 600px) {
  :root {
    --shedar-font-caption: 12px;
    --shedar-font-small: 14px;
    --shedar-font-body: 16px;
    --shedar-font-strong: 17px;
  }

  .workspace:has(.chat-shell) {
    padding-inline: 9px;
  }

  .chat-shell {
    border-radius: 12px;
    height: clamp(310px, calc(100dvh - 215px), 760px);
  }

  .chat-people h3 {
    display: none;
  }

  .chat-people button {
    flex-basis: min(185px, 72vw);
  }

  .conversation-head {
    min-height: 62px;
    padding: 10px 12px;
  }

  .messages {
    gap: 10px;
    padding: 12px 10px;
  }

  .message {
    max-width: 94%;
  }

  .message p {
    padding: 11px 13px;
  }

  .message-form {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 6px;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .message-form > input,
  .attach-button,
  .message-form button {
    min-height: 48px;
  }

  .attach-button,
  .message-form button {
    width: 48px;
    min-width: 48px;
  }

  .message-menu {
    position: fixed;
    right: 10px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
  }

  .message-menu button {
    min-height: 48px;
    font-size: 15px;
  }
}

/* Native shells use dynamic viewport height so the input stays visible above
   the software keyboard and home indicator on differently sized phones. */
.native-app .chat-shell {
  height: clamp(
    310px,
    calc(100dvh - 245px - env(safe-area-inset-top) - env(safe-area-inset-bottom)),
    820px
  );
  min-height: 0;
}

.native-app .chat-people {
  display: flex;
}

@media (max-width: 900px) and (max-height: 650px) {
  .workspace:has(.chat-shell) .section-head {
    display: none;
  }

  .chat-shell,
  .native-app .chat-shell {
    height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .messages {
    scroll-behavior: auto;
  }
}

/* Mandatory location gate for driver accounts */
#shedar-location-gate {
  z-index: 10000;
  background: color-mix(in srgb, #101215 76%, transparent);
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  place-items: center;
  display: grid;
  position: fixed;
  inset: 0;
  backdrop-filter: blur(8px);
}

.location-gate-card {
  background: var(--color-surface, #fff);
  color: var(--color-text, #17191c);
  text-align: center;
  border-radius: 22px;
  width: min(100%, 520px);
  padding: clamp(24px, 6vw, 42px);
  box-shadow: 0 24px 80px #0006;
}

.location-gate-icon {
  background: var(--color-primary-light, #fff0f0);
  color: var(--red, #df0011);
  border-radius: 50%;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  font-size: 40px;
  font-weight: 900;
  display: grid;
}

.location-gate-card h1 {
  margin: 0 0 12px;
  font-size: clamp(25px, 6vw, 34px);
  line-height: 1.15;
}

.location-gate-card > p:not(.eyebrow) {
  color: var(--color-text-secondary, #555f69);
  margin: 0 auto 22px;
  font-size: var(--shedar-font-body);
  line-height: 1.55;
}

.location-gate-actions {
  display: grid;
  gap: 10px;
}

.location-gate-actions button {
  width: 100%;
}

.location-gate-card small {
  color: var(--color-text-muted, #737b84);
  margin-top: 16px;
  font-size: var(--shedar-font-small);
  line-height: 1.45;
  display: block;
}

.tracking-toggle.mandatory-tracking,
.tracking-toggle.mandatory-tracking:disabled {
  opacity: 1;
  cursor: default;
}

/* Superadministrator and 1C settings extensions */
.user-management-actions {
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  display: flex;
}

.superadmin-badge {
  background: #ede8ff;
  color: #5d3db2;
  border-radius: 99px;
  width: max-content;
  margin-top: 8px;
  padding: 7px 11px;
  font-size: var(--shedar-font-caption);
  font-weight: 800;
}

.danger-button {
  background: #fff7f7 !important;
  border-color: #f0c8c8 !important;
  color: #a61d2d !important;
}

.danger-button:hover:not(:disabled) {
  background: #ffeaea !important;
  border-color: #d99a9f !important;
}

.order-management-actions {
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  display: flex;
}

.orders-table td:last-child {
  min-width: 172px;
}

.waybill-delete-button {
  background: #fff7f7 !important;
}

.route-progress-summary {
  color: var(--color-text-muted, #737b84);
  margin: 12px 0 0;
  font-size: var(--shedar-font-small);
  font-weight: 700;
}

.route-progress-status.en_route {
  color: #1d4ed8;
  background: #dbeafe;
}

.route-progress-status.arrived,
.route-progress-status.loading {
  color: #9a4d00;
  background: #fff1d6;
}

.route-progress-status.completed,
.route-progress-status.delivered {
  color: #087849;
  background: #dff7ea;
}

.route-progress-details {
  border: 1px solid var(--color-border, #e1e4e8);
  background: var(--color-surface-alt, #f7f8f9);
  border-radius: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  display: grid;
}

.route-progress-details div {
  gap: 4px;
  display: grid;
}

.route-progress-details span {
  color: var(--color-text-muted, #737b84);
  font-size: var(--shedar-font-caption);
}

.route-progress-details b {
  font-size: var(--shedar-font-small);
}

.interactive-report {
  cursor: pointer;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.interactive-report:hover,
.interactive-report:focus-visible {
  background: var(--color-primary-light, #fff0f0);
  box-shadow: inset 3px 0 0 var(--color-primary, #d90000);
  outline: none;
}

.driver-work-session-card {
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: clamp(18px, 3vw, 26px);
  display: flex;
}

.driver-work-session-card h2 {
  margin: 2px 0 7px;
  font-size: clamp(20px, 3vw, 27px);
}

.driver-work-session-card p:last-child {
  color: var(--color-text-muted, #737b84);
  margin: 0;
  font-size: var(--shedar-font-small);
}

.driver-work-session-card > button {
  flex: 0 0 auto;
  min-width: 150px;
  min-height: 52px;
  font-size: 16px;
}

.finish-work-button {
  background: #087849 !important;
}

.interactive-stat-card {
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.interactive-stat-card:hover,
.interactive-stat-card:focus-visible,
.selected-stat-card {
  border-color: var(--color-primary, #d90000);
  box-shadow: 0 12px 30px rgba(125, 16, 16, 0.13);
  transform: translateY(-2px);
  outline: none;
}

.enhancement-checkbox {
  align-items: center;
  gap: 10px;
  min-height: 44px;
  display: flex !important;
}

.enhancement-checkbox > span {
  margin: 0 !important;
  order: 2;
}

.enhancement-checkbox input[type="checkbox"] {
  flex: 0 0 22px;
  width: 22px;
  min-height: 22px;
}

.integration-settings-card {
  max-width: 980px;
  margin-top: 22px;
  padding: clamp(20px, 3vw, 30px);
}

.integration-settings-head {
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  display: flex;
}

.integration-settings-head h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 28px);
}

.integration-settings-head > div > p:last-child,
.integration-result {
  color: var(--color-text-muted, #737b84);
  margin: 0;
  font-size: var(--shedar-font-small);
  line-height: 1.5;
}

@media (max-width: 760px) {
  .user-record {
    align-items: flex-start;
  }

  .user-management-actions {
    width: 100%;
    margin: 8px 0 0;
  }

  .user-management-actions button {
    flex: 1;
    min-height: 46px;
  }

  .superadmin-badge {
    margin-top: 8px;
  }

  .order-management-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .orders-table td:last-child {
    min-width: 150px;
  }

  .route-progress-details {
    grid-template-columns: 1fr;
  }

  .driver-work-session-card {
    align-items: stretch;
    flex-direction: column;
  }

  .driver-work-session-card > button {
    width: 100%;
  }

  .integration-settings-head {
    display: block;
  }

  .integration-settings-head > .record-status {
    margin-top: 14px;
  }

  .integration-settings-form {
    grid-template-columns: 1fr;
  }
}
/* Упрощённая навигация: технические индикаторы соединения скрыты. */
.sidebar-online,
.head-actions > .live-pill {
  display: none !important;
}

.interactive-order-row {
  cursor: pointer;
  transition: background-color .18s ease, box-shadow .18s ease;
}

.interactive-order-row:hover,
.interactive-order-row:focus-visible {
  background: rgba(217, 0, 0, .045) !important;
  box-shadow: inset 4px 0 0 #d90000;
  outline: none;
}

.linked-entity-highlight {
  animation: linked-entity-pulse 1s ease-in-out 3;
  box-shadow: 0 0 0 3px rgba(217, 0, 0, .28), 0 18px 45px rgba(15, 23, 42, .16) !important;
}

@keyframes linked-entity-pulse {
  50% { transform: translateY(-2px); box-shadow: 0 0 0 6px rgba(217, 0, 0, .16), 0 20px 50px rgba(15, 23, 42, .18); }
}

.contact-import-preview {
  max-height: min(50vh, 440px);
  overflow: auto;
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 14px;
}

.contact-import-preview > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #dfe3e8);
}

.contact-import-preview > div:last-child { border-bottom: 0; }
.contact-import-preview span { color: var(--muted, #64748b); font-size: .88rem; }

.backup-row .backup-delete-button { margin-left: 8px; }

.telegram-panel {
  display: grid;
  gap: 22px;
  margin-bottom: 24px;
}

.telegram-settings-head { margin-bottom: 0; }
.telegram-settings-form {
  padding-top: 22px;
  border-top: 1px solid var(--line, #dfe3e8);
}
.telegram-settings-form .integration-result { align-self: center; }
.telegram-settings-form .form-actions { flex-wrap: wrap; margin-top: 0; }
.telegram-enable-toggle { padding: 2px 0; }
.telegram-link-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 18px;
  border: 1px solid rgba(34, 158, 217, .18);
  border-radius: 14px;
  background: rgba(34, 158, 217, .08);
}
.telegram-link-box p { margin: 4px 0 0; color: var(--muted, #64748b); }

.shedar-native-chat-hidden { display: none !important; }

.shedar-user-chat {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  min-height: min(70vh, 760px);
  overflow: hidden;
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 20px;
  background: var(--panel, #fff);
}

.shedar-floating-chat {
  position: fixed;
  z-index: 2600;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(720px, calc(100vw - 40px));
  height: min(560px, calc(100dvh - 40px));
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  min-width: 320px;
  min-height: 330px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
  resize: both;
}

.shedar-floating-chat[hidden],
.shedar-chat-launcher[hidden] { display: none !important; }

.shedar-floating-chat[data-dock="right"] { right: 20px; bottom: 20px; left: auto; top: auto; }
.shedar-floating-chat[data-dock="left"] { left: var(--shedar-chat-left-offset, 246px); bottom: 20px; right: auto; top: auto; }

.shedar-floating-chat-head {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid var(--line, #dfe3e8);
  background: var(--panel, #fff);
  cursor: move;
  user-select: none;
}

.shedar-floating-chat-head > span {
  color: var(--muted, #64748b);
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shedar-floating-chat-head > div { display: flex; gap: 5px; }
.shedar-floating-chat-head button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-size: 1.05rem;
  cursor: pointer;
}
.shedar-floating-chat-head button:hover { background: rgba(217, 0, 0, .09); color: #d90000; }
.shedar-floating-chat-head .shedar-chat-close-button {
  display: inline-flex;
  width: auto;
  min-width: 112px;
  gap: 7px;
  padding: 0 11px;
  font-size: .82rem;
  font-weight: 800;
}

.shedar-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2600;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 0 19px;
  border: 0;
  border-radius: 999px;
  background: #d90000;
  color: #fff;
  box-shadow: 0 14px 36px rgba(217, 0, 0, .32);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

/* Чат открывается через пункт меню; плавающая красная кнопка его дублировала. */
.shedar-chat-launcher { display: none !important; }

.shedar-back-notice {
  position: fixed;
  z-index: 20050;
  left: 50%;
  bottom: max(88px, calc(env(safe-area-inset-bottom) + 70px));
  max-width: min(88vw, 360px);
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(22, 27, 33, .94);
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .18s ease, transform .18s ease;
}

.shedar-back-notice.visible { opacity: 1; transform: translate(-50%, 0); }

/* На публичной форме не показываем стандартные данные первого входа. */
.login-help > * { display: none !important; }
.login-help::before {
  content: "Данные для входа выдаёт администратор.";
  display: block;
}

.shedar-floating-chat > .shedar-chat-people,
.shedar-floating-chat > .shedar-chat-conversation { min-height: 0; }

.shedar-chat-people {
  min-width: 0;
  padding: 18px 12px;
  border-right: 1px solid var(--line, #dfe3e8);
  background: rgba(148, 163, 184, .07);
}

.shedar-chat-people h3 { margin: 0 8px 12px; font-size: 1rem; }
.shedar-chat-people-list { display: grid; gap: 6px; max-height: 64vh; overflow: auto; }
.shedar-chat-people-list button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
}
.shedar-chat-people-list button:hover,
.shedar-chat-people-list button.active { background: rgba(217, 0, 0, .10); }
.shedar-chat-people-list button > span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #20242a;
  color: #fff;
  font-weight: 800;
}
.shedar-chat-people-list button div { min-width: 0; display: grid; gap: 2px; }
.shedar-chat-people-list button b,
.shedar-chat-people-list button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shedar-chat-people-list button small { color: var(--muted, #64748b); }

.shedar-chat-conversation { position: relative; min-width: 0; display: grid; grid-template-rows: auto minmax(260px, 1fr) auto; }
.shedar-chat-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line, #dfe3e8); }
.shedar-chat-head > div { display: grid; gap: 2px; }
.shedar-chat-head small { color: var(--muted, #64748b); }
.shedar-open-telegram { margin-left: auto; white-space: nowrap; text-decoration: none; }
.shedar-chat-messages { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 18px 18px 30px; overflow: auto; scroll-padding-bottom: 30px; background: rgba(148, 163, 184, .04); }
.shedar-chat-message { align-self: flex-start; max-width: min(78%, 680px); padding: 10px 13px; border-radius: 16px 16px 16px 4px; background: #fff; border: 1px solid var(--line, #dfe3e8); box-shadow: 0 5px 18px rgba(15, 23, 42, .06); }
.dark .shedar-chat-message { background: #24282e; }
.shedar-chat-message.own { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: #d90000; color: #fff; border-color: #d90000; }
.shedar-chat-message p { margin: 3px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.shedar-chat-message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 5px; }
.shedar-chat-message time { display: block; font-size: .72rem; opacity: .72; text-align: right; }
.shedar-chat-message-status { min-width: 1.35em; font-size: .88rem; font-weight: 800; letter-spacing: -.28em; padding-right: .28em; color: rgba(255, 255, 255, .74); line-height: 1; }
.shedar-chat-message-status.sent { letter-spacing: 0; padding-right: 0; }
.shedar-chat-message-status.read { color: #7cf0a5; opacity: 1; }
.shedar-chat-image-button {
  display: block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
}
.shedar-chat-image-button:focus-visible { outline: 3px solid rgba(255, 255, 255, .78); outline-offset: 3px; }
.shedar-chat-message img { display: block; max-width: min(100%, 420px); max-height: 360px; border-radius: 10px; object-fit: cover; }
.shedar-chat-image-unavailable { display: inline-flex; align-items: center; gap: 7px; padding: 9px 10px; border-radius: 10px; background: rgba(148, 163, 184, .12); color: inherit; font-size: .86rem; }
.shedar-chat-end-marker { display: block; flex: 0 0 1px; width: 1px; height: 1px; }
.shedar-chat-launcher { position: relative; }
.shedar-chat-unread-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #fff; color: #d90000; font-size: .72rem; font-weight: 800; box-shadow: 0 0 0 2px #d90000; }
.shedar-chat-unread-badge[hidden], .nav-badge[hidden] { display: none !important; }
.shedar-chat-sender { display: block; margin-bottom: 4px; color: var(--color-text-secondary, #475467); font-size: .8rem; }
.shedar-chat-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--line, #dfe3e8);
  background: var(--color-surface, #fff);
}
.shedar-chat-form > input {
  box-sizing: border-box;
  display: block;
  align-self: center;
  min-width: 0;
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 0 15px;
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 12px;
  outline: 0;
  background: var(--color-surface-alt, #f7f8fa);
  color: var(--color-text, #17191c);
  font: inherit;
  font-size: 16px;
  line-height: 1.25;
  appearance: none;
}
.shedar-chat-form > input::placeholder {
  color: var(--color-text-muted, #7b8794);
  opacity: 1;
}
.shedar-chat-form > input:focus {
  border-color: rgba(217, 0, 0, .58);
  box-shadow: 0 0 0 3px rgba(217, 0, 0, .11);
}
.shedar-chat-form > button { width: 46px; height: 46px; border: 0; border-radius: 13px; background: #d90000; color: #fff; }
.shedar-chat-photo-draft {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(217, 0, 0, .25);
  border-radius: 13px;
  background: rgba(217, 0, 0, .06);
}
.shedar-chat-photo-draft[hidden] { display: none !important; }
.shedar-chat-photo-draft > img { width: 58px; height: 58px; border-radius: 9px; object-fit: cover; }
.shedar-chat-photo-draft > div { min-width: 0; display: grid; gap: 3px; }
.shedar-chat-photo-draft b,
.shedar-chat-photo-draft small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shedar-chat-photo-draft small { color: var(--muted, #64748b); }
.shedar-chat-photo-draft-remove {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 11px;
  background: var(--panel, #fff);
  color: inherit;
  cursor: pointer;
}
.shedar-chat-photo-draft-remove:hover { color: #d90000; border-color: rgba(217, 0, 0, .35); }
.shedar-chat-photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 6200;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(6, 9, 13, .92);
  backdrop-filter: blur(8px);
}
.shedar-chat-photo-viewer[hidden] { display: none !important; }
.shedar-chat-photo-viewer figure {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(1120px, 100%);
  height: min(860px, 100%);
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 18px;
  background: #101318;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}
.shedar-chat-photo-viewport {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: zoom-in;
}
.shedar-chat-photo-viewport.zoomed { cursor: grab; }
.shedar-chat-photo-viewport.zoomed:active { cursor: grabbing; }
.shedar-chat-photo-viewer img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  transform-origin: center;
  transition: transform .12s ease-out;
  will-change: transform;
  pointer-events: none;
}
.shedar-chat-photo-controls {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 46px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 14px;
  background: rgba(13, 17, 23, .80);
  color: #fff;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}
.shedar-chat-photo-controls button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
}
.shedar-chat-photo-controls button:disabled { opacity: .38; cursor: default; }
.shedar-chat-photo-controls output { min-width: 54px; text-align: center; font-size: .82rem; font-weight: 800; }
.shedar-chat-photo-controls .shedar-chat-photo-reset { width: auto; padding: 0 10px; font-size: .78rem; }
.shedar-chat-photo-viewer figcaption { padding: 11px 60px 12px 16px; color: #fff; font-size: .9rem; }
.shedar-chat-photo-viewer-close {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 14px;
  background: rgba(13, 17, 23, .78);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}
.shedar-chat-photo-open { overflow: hidden; }
.shedar-chat-photo-menu {
  position: absolute;
  left: 14px;
  bottom: 76px;
  z-index: 5;
  display: grid;
  gap: 6px;
  width: min(260px, calc(100% - 28px));
  padding: 8px;
  border: 1px solid var(--line, #dfe3e8);
  border-radius: 16px;
  background: var(--panel, #fff);
  box-shadow: 0 18px 44px rgba(15, 23, 42, .24);
}
.shedar-chat-photo-menu[hidden] { display: none !important; }
.shedar-chat-photo-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  font-weight: 750;
}
.shedar-chat-photo-menu button:hover { background: rgba(217, 0, 0, .09); }
.shedar-chat-photo-menu i { width: 24px; color: #d90000; text-align: center; font-size: 18px; }
.dark .shedar-chat-photo-menu { background: #24282e; }

/* The floating window responds to its own resized width, not only to the
   browser viewport. JavaScript updates data-layout through ResizeObserver. */
.shedar-floating-chat[data-layout="compact"] {
  grid-template-columns: minmax(150px, 34%) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}
.shedar-floating-chat[data-layout="compact"] .shedar-floating-chat-head { grid-column: 1 / -1; grid-row: 1; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-people { grid-column: 1; grid-row: 2; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-conversation { grid-column: 2; grid-row: 2; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-people { padding: 10px 7px; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-people h3 { margin-inline: 6px; font-size: .88rem; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-people-list button {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  padding: 7px;
}
.shedar-floating-chat[data-layout="compact"] .shedar-chat-people-list button > span { width: 34px; height: 34px; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-head { gap: 7px; padding: 10px; }
.shedar-floating-chat[data-layout="compact"] .shedar-open-telegram span { display: none; }
.shedar-floating-chat[data-layout="compact"] .shedar-open-telegram { width: 42px; min-width: 42px; padding-inline: 0; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-messages { padding: 10px; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-message { max-width: 92%; }
.shedar-floating-chat[data-layout="compact"] .shedar-chat-form { gap: 6px; padding-inline: 8px; }

.shedar-floating-chat[data-layout="stacked"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
}
.shedar-floating-chat[data-layout="stacked"] .shedar-floating-chat-head { grid-column: 1; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-people {
  grid-column: 1;
  grid-row: 2;
  min-height: 56px;
  padding: 6px;
  border-right: 0;
  border-bottom: 1px solid var(--line, #dfe3e8);
  overflow: hidden;
}
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-people h3 { display: none; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-people-list {
  display: flex;
  gap: 5px;
  max-height: none;
  overflow: auto hidden;
}
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-people-list button {
  flex: 0 0 min(74%, 190px);
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  padding: 6px;
}
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-people-list button > span { width: 34px; height: 34px; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-conversation { grid-column: 1; grid-row: 3; min-height: 0; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-head { gap: 7px; padding: 8px; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-head .account-avatar { width: 34px; height: 34px; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-head small { display: none; }
.shedar-floating-chat[data-layout="stacked"] .shedar-open-telegram { width: 40px; min-width: 40px; min-height: 40px; margin-left: auto; padding: 0; }
.shedar-floating-chat[data-layout="stacked"] .shedar-open-telegram span { display: none; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-messages { padding: 8px; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-message { max-width: 94%; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-form { grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 5px; padding: 7px; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-form > input,
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-form > button,
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-form > .attach-button { width: 44px; height: 44px; min-height: 44px; }
.shedar-floating-chat[data-layout="stacked"] .shedar-chat-form > input { width: 100%; }

@media (max-width: 760px) {
  .telegram-link-box { align-items: stretch; flex-direction: column; }
  .shedar-user-chat { grid-template-columns: 1fr; min-height: 70dvh; }
  .shedar-floating-chat {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100%;
    height: min(84dvh, 760px);
    min-width: 0;
    min-height: 0;
    border-radius: 20px 20px 0 0;
    resize: none;
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .shedar-floating-chat-head { grid-template-columns: auto minmax(0, 1fr) auto; cursor: default; }
  .shedar-floating-chat-head > span { display: none; }
  .shedar-floating-chat-head button:nth-child(-n + 2) { display: none; }
  .shedar-floating-chat-head .shedar-chat-close-button { min-width: 96px; }
  .shedar-chat-launcher { right: 14px; bottom: 78px; min-height: 48px; }
  .shedar-chat-people { padding: 10px; border-right: 0; border-bottom: 1px solid var(--line, #dfe3e8); }
  .shedar-chat-people h3 { margin-bottom: 8px; }
  .shedar-chat-people-list { display: flex; max-height: none; overflow-x: auto; }
  .shedar-chat-people-list button { flex: 0 0 min(78vw, 270px); }
  .shedar-chat-conversation { min-height: 58dvh; }
  .shedar-floating-chat .shedar-chat-conversation { min-height: 0; }
  .shedar-chat-head { flex-wrap: wrap; }
  .shedar-open-telegram { width: 100%; margin-left: 0; text-align: center; }
  .shedar-chat-messages { padding: 12px; }
  .shedar-chat-message { max-width: 91%; }
  .shedar-chat-photo-viewer { padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .shedar-chat-photo-viewer figure { width: 100%; height: 100%; border-radius: 14px; }
  .shedar-chat-photo-controls { top: max(8px, env(safe-area-inset-top)); left: 10px; transform: none; }
  .shedar-chat-photo-controls .shedar-chat-photo-reset { display: none; }
  .shedar-chat-photo-viewer-close { top: max(8px, env(safe-area-inset-top)); right: 10px; }
  .shedar-chat-photo-draft { grid-template-columns: 50px minmax(0, 1fr) 38px; gap: 8px; }
  .shedar-chat-photo-draft > img { width: 50px; height: 50px; }
  .shedar-chat-photo-draft small { white-space: normal; line-height: 1.25; }
}

/* Mobile refinement v2: compact application chrome, stable touch targets and
   a full-height phone chat that remains usable with the software keyboard. */
.location-permission-link {
  border: 0;
  background: transparent;
  color: var(--color-text-secondary, #475467);
  min-height: 42px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.location-gate-actions > button[hidden] {
  display: none !important;
}

.shedar-chat-open,
.shedar-chat-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.shedar-chat-form input,
.shedar-chat-form button,
.shedar-chat-form .attach-button {
  font-size: 16px;
  touch-action: manipulation;
}

.shedar-chat-message p {
  font-size: 15px;
  line-height: 1.42;
}

.dark .shedar-chat-people,
.dark .shedar-chat-messages {
  background: #181b1f;
}

.dark .shedar-chat-head,
.dark .shedar-chat-form,
.dark .shedar-floating-chat-head {
  background: #202328;
}

@media (max-width: 760px) {
  .office-panel .table-wrap {
    overflow: visible;
  }

  .orders-table,
  .orders-table tbody,
  .orders-table tr,
  .orders-table td {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .orders-table {
    table-layout: fixed;
  }

  .orders-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    clip: rect(0 0 0 0);
    overflow: hidden;
    white-space: nowrap;
  }

  .orders-table tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .orders-table tbody tr {
    border: 1px solid var(--line, #dfe3e8);
    border-radius: 14px;
    padding: 11px 12px;
    background: var(--color-surface, #fff);
    overflow: hidden;
  }

  .orders-table tbody td {
    display: grid;
    grid-template-columns: minmax(88px, .65fr) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-width: 0 !important;
    padding: 8px 0;
    border-bottom: 1px solid var(--line, #edf0f2);
    overflow-wrap: anywhere;
  }

  .orders-table tbody td::before {
    content: attr(data-label);
    color: var(--color-text-muted, #737b84);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1.35;
    text-transform: uppercase;
  }

  .orders-table tbody td:last-child {
    border-bottom: 0;
  }

  .orders-table tbody td:last-child:empty {
    display: none;
  }

  .orders-table tbody td[colspan] {
    display: block;
    padding: 22px 8px;
    border: 0;
    text-align: center;
  }

  .orders-table tbody td[colspan]::before {
    display: none;
  }

  :root {
    --shedar-font-caption: 12px;
    --shedar-font-small: 14px;
    --shedar-font-body: 16px;
    --shedar-font-strong: 17px;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  button,
  input,
  select,
  textarea {
    max-width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .portal-header {
    gap: 8px;
    height: calc(62px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 0;
  }

  .shedar-brand {
    flex: 0 0 88px;
    width: 88px;
    min-width: 0;
  }

  .brand-image {
    width: 88px;
    height: 48px;
  }

  .brand-image img {
    width: 86px;
    max-height: 45px;
  }

  .header-account {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 6px;
    width: auto;
    min-width: 0;
  }

  .header-profile-shortcut {
    flex: 1 1 auto;
    width: auto;
    max-width: 190px;
    height: 44px;
    min-width: 0;
    gap: 7px;
    padding: 4px 8px;
    border-radius: 11px;
  }

  .header-profile-icon {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 12px;
  }

  .header-profile-copy strong {
    font-size: 13px;
  }

  .header-profile-copy small {
    font-size: 11px;
  }

  .update-check-button,
  .theme-toggle,
  .logout-button {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 11px;
  }

  .portal-layout {
    min-height: calc(100dvh - 62px - env(safe-area-inset-top));
  }

  .workspace {
    padding: 20px 12px calc(88px + env(safe-area-inset-bottom));
  }

  .section-head {
    gap: 12px;
    margin-bottom: 17px;
  }

  .section-head h1 {
    font-size: clamp(23px, 7vw, 28px);
    line-height: 1.15;
  }

  .section-head > div > p:last-child {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.45;
  }

  .panel,
  .entity-card,
  .driver-record,
  .waybill-card,
  .stat-card,
  .reports-panel,
  .chat-shell {
    border-radius: 14px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    min-height: 104px;
    padding: 14px;
  }

  .stat-card span,
  .stat-card small {
    overflow-wrap: anywhere;
    font-size: 12px;
  }

  .sidebar {
    height: calc(68px + env(safe-area-inset-bottom));
    padding: 6px 7px env(safe-area-inset-bottom);
  }

  .sidebar-nav {
    justify-content: flex-start;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-link {
    flex: 0 0 68px;
    min-width: 68px;
    min-height: 56px;
    padding: 5px 4px;
    scroll-snap-align: center;
  }

  .sidebar-link .nav-label {
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions > button,
  .form-actions > a {
    flex: 1 1 150px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: calc(94dvh - env(safe-area-inset-top));
    padding: 24px 16px max(18px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
  }

  .location-gate-card {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 24px 18px;
    border-radius: 20px;
    overflow-y: auto;
  }

  .location-gate-icon {
    width: 62px;
    height: 62px;
    margin-bottom: 14px;
    font-size: 29px;
  }

  .location-gate-card h1 {
    font-size: clamp(23px, 7vw, 29px);
  }

  .location-gate-card > p:not(.eyebrow) {
    margin-bottom: 18px;
    font-size: 15px;
  }

  .shedar-floating-chat {
    inset: 0 !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    border: 0;
    border-radius: 0;
    resize: none;
    box-shadow: none;
  }

  .shedar-floating-chat-head {
    grid-column: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 9px 0 15px;
    cursor: default;
  }

  .shedar-floating-chat-head > b {
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .shedar-floating-chat-head > span,
  .shedar-floating-chat-head button:not(:last-child) {
    display: none;
  }

  .shedar-floating-chat-head button:last-child {
    width: auto;
    min-width: 96px;
    height: 40px;
    padding-inline: 10px;
    border-radius: 12px;
    font-size: 13px;
  }

  .shedar-chat-people {
    min-height: 58px;
    padding: 7px 9px;
    border-right: 0;
    border-bottom: 1px solid var(--line, #dfe3e8);
    overflow: hidden;
  }

  .shedar-chat-people h3 {
    display: none;
  }

  .shedar-chat-people-list {
    display: flex;
    gap: 6px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .shedar-chat-people-list::-webkit-scrollbar {
    display: none;
  }

  .shedar-chat-people-list button {
    flex: 0 0 auto;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 7px;
    width: auto;
    max-width: min(72vw, 230px);
    min-height: 44px;
    padding: 5px 9px 5px 6px;
    border: 1px solid transparent;
    border-radius: 12px;
    scroll-snap-align: start;
  }

  .shedar-chat-people-list button.active {
    border-color: rgba(217, 0, 0, .22);
    background: rgba(217, 0, 0, .09);
  }

  .shedar-chat-people-list button > span {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 12px;
  }

  .shedar-chat-people-list button b {
    font-size: 13px;
  }

  .shedar-chat-people-list button small {
    font-size: 11px;
  }

  .shedar-chat-conversation,
  .shedar-floating-chat .shedar-chat-conversation {
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    overflow: hidden;
  }

  .shedar-chat-head {
    flex-wrap: nowrap;
    gap: 9px;
    min-height: 54px;
    padding: 7px 10px;
  }

  .shedar-chat-head .account-avatar {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 12px;
  }

  .shedar-chat-head > div {
    min-width: 0;
  }

  .shedar-chat-head b,
  .shedar-chat-head small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .shedar-chat-head b {
    font-size: 14px;
  }

  .shedar-chat-head small {
    font-size: 11px;
  }

  .shedar-open-telegram {
    display: grid;
    flex: 0 0 40px;
    place-items: center;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    margin-left: auto;
    padding: 0;
    border-radius: 12px;
    font-size: 20px;
    text-decoration: none;
  }

  .shedar-open-telegram > span {
    display: none;
  }

  .shedar-chat-messages {
    gap: 8px;
    min-height: 0;
    padding: 12px 10px max(26px, env(safe-area-inset-bottom));
    scroll-padding-block: 12px max(26px, env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .shedar-chat-message {
    max-width: 86%;
    padding: 9px 11px;
    border-radius: 15px 15px 15px 5px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .06);
  }

  .shedar-chat-message.own {
    border-radius: 15px 15px 5px 15px;
    background: #df0b0b;
    border-color: #df0b0b;
  }

  .shedar-chat-message p {
    margin: 2px 0;
    font-size: 16px;
    line-height: 1.38;
  }

  .shedar-chat-sender {
    margin-bottom: 3px;
    font-size: 12px;
  }

  .shedar-chat-message-meta {
    margin-top: 4px;
  }

  .shedar-chat-message time {
    font-size: 11px;
  }

  .shedar-chat-message img {
    max-height: min(44dvh, 320px);
  }

  .shedar-chat-form {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    gap: 7px;
    padding: 8px 9px max(8px, env(safe-area-inset-bottom));
    background: var(--color-surface, #fff);
  }

  .shedar-chat-form > input,
  .shedar-chat-form > button,
  .shedar-chat-form > .attach-button {
    width: 46px;
    height: 46px;
    min-width: 0;
    min-height: 46px;
    border-radius: 12px;
  }

  .shedar-chat-form > input {
    width: 100%;
    padding-inline: 12px;
  }

  .shedar-chat-photo-menu {
    left: 9px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    width: calc(100% - 18px);
  }

  .shedar-chat-launcher {
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .shedar-brand {
    flex-basis: 72px;
    width: 72px;
  }

  .brand-image,
  .brand-image img {
    width: 70px;
  }

  .header-profile-icon,
  .header-profile-copy small {
    display: none;
  }

  .header-profile-shortcut {
    padding-inline: 7px;
  }

  .update-check-button,
  .theme-toggle,
  .logout-button {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .workspace {
    padding-inline: 9px;
  }

  .shedar-chat-people-list button small {
    display: none;
  }

  .shedar-chat-people-list button {
    max-width: 180px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .shedar-floating-chat {
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: minmax(150px, 30vw) minmax(0, 1fr);
  }

  .shedar-floating-chat-head {
    grid-column: 1 / -1;
  }

  .shedar-chat-people {
    min-height: 0;
    border-right: 1px solid var(--line, #dfe3e8);
    border-bottom: 0;
    overflow-y: auto;
  }

  .shedar-chat-people-list {
    display: grid;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shedar-chat-people-list button {
    width: 100%;
    max-width: none;
  }
}
/* Служебные пояснения о серверном разграничении прав скрыты во всех разделах.
   Элемент остаётся в React-разметке, поэтому переходы между вкладками не ломаются. */
.permission-note {
  display: none !important;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #e00000 !important;
  box-shadow: 0 0 0 3px rgb(224 0 0 / 12%) !important;
}

.portal-shell > .error-banner {
  position: fixed !important;
  z-index: 30000 !important;
  top: max(14px, env(safe-area-inset-top)) !important;
  left: 50% !important;
  width: min(680px, calc(100vw - 28px)) !important;
  margin: 0 !important;
  transform: translateX(-50%) !important;
  box-shadow: 0 14px 40px rgb(0 0 0 / 24%) !important;
}
