:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #d9dee7;
  --line-strong: #c5ccd8;
  --text: #1d2430;
  --muted: #667085;
  --soft: #eef2f6;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --warn: #b54708;
  --warn-bg: #fff6e6;
  --ok: #067647;
  --ok-bg: #eaf7ef;
  --shadow: 0 10px 28px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

button.danger {
  color: var(--danger);
  border-color: #f0b8b3;
}

.hidden {
  display: none !important;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
}

textarea {
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.4;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(100%, 390px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel label {
  display: grid;
  gap: 5px;
}

.auth-panel label span {
  color: var(--muted);
  font-size: 12px;
}

.auth-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  min-height: 74px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand.compact {
  margin-bottom: 4px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #17324d;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

p {
  margin: 0;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.metrics {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.userbar {
  flex: 0 1 380px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.topbar-link.current {
  color: var(--text);
}

.metric {
  min-width: 84px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.metric strong {
  display: block;
  font-size: 18px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.settings-band {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.settings-form {
  display: grid;
  grid-template-columns: 150px 155px minmax(170px, 220px) minmax(260px, 1fr) 110px 120px;
  align-items: end;
  gap: 10px;
}

.settings-form label {
  display: grid;
  gap: 4px;
}

.settings-form span {
  color: var(--muted);
  font-size: 12px;
}

.settings-form .wide {
  grid-column: span 2;
}

.settings-form.mobile-handoff input[name="fallbackSmartQueueName"] {
  background: #f1f4f8;
  color: var(--muted);
}

.settings-workspace {
  flex: 1;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.settings-panel {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-title-row.flat {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-title-row.flat,
.title-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title-row.flat h2 {
  margin: 0;
  font-size: 18px;
}

.title-actions button {
  min-height: 30px;
  font-size: 13px;
}

.settings-form-page {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 18px;
}

.settings-form-page .wide {
  grid-column: 1 / -1;
}

.settings-form-page .settings-submit {
  grid-column: 1 / -1;
}

.billing-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 18px;
}

.billing-form .settings-submit {
  grid-column: 1 / -1;
}

.behavior-map {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.behavior-map h3 {
  margin: 8px 0 0;
  font-size: 15px;
}

.behavior-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.behavior-summary p,
.behavior-card p {
  margin: 6px 0 0;
  color: var(--text);
  line-height: 1.4;
}

.behavior-summary small,
.behavior-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

.behavior-grid,
.behavior-modules,
.behavior-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.behavior-kv,
.behavior-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.behavior-kv {
  display: grid;
  gap: 4px;
}

.behavior-kv span {
  color: var(--muted);
  font-size: 12px;
}

.behavior-kv strong,
.behavior-card strong {
  overflow-wrap: anywhere;
}

.behavior-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.behavior-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f8fafc;
}

.behavior-badge.ok,
.behavior-summary.ok {
  color: #066341;
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.behavior-badge.warning,
.behavior-summary.warning {
  color: #8a4b00;
  background: #fffbeb;
  border-color: #fde68a;
}

.behavior-badge.danger,
.behavior-summary.danger {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.behavior-source-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.behavior-source-refs span {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 11px;
}

.behavior-steps {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.behavior-step {
  display: grid;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.behavior-step span {
  line-height: 1.35;
}

.behavior-prompt {
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
}

.package-editor {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.package-editor .section-title-row.flat {
  border-bottom: 0;
  padding-bottom: 0;
}

.package-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px;
}

#packageDraftEditor {
  width: calc(100% - 36px);
  min-height: 420px;
  margin: 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  background: #ffffff;
}

#packageEditorOutput {
  margin: 0 18px 18px;
}

.usage-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 18px 0;
}

.usage-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.usage-card span,
.usage-card small,
.usage-breakdown-row small,
.usage-table small {
  color: var(--muted);
}

.usage-card strong {
  font-size: 22px;
  line-height: 1.1;
}

.usage-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 18px 18px;
}

.usage-breakdown-row {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.usage-table-wrap {
  max-height: 520px;
  overflow: auto;
  padding: 0 18px 18px;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.usage-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.usage-table th,
.usage-table td {
  padding: 10px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.usage-table td {
  min-width: 0;
}

.usage-table td > span,
.usage-table td > small,
.usage-table td > strong {
  display: block;
  overflow-wrap: anywhere;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.workspace {
  flex: 1;
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "workspace-nav details"
    "kanban details";
  gap: 14px;
  padding: 14px 18px 18px;
  overflow: hidden;
  align-items: stretch;
}

.workspace > * {
  min-height: 0;
}

body.dental-ui .workspace {
  grid-template-areas:
    "workspace-nav details"
    "kanban details";
}

body.dental-ui.workspace-schedule .workspace {
  grid-template-areas:
    "workspace-nav details"
    "calendar details";
}

.workspace-nav {
  grid-area: workspace-nav;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workspace-mode {
  display: flex;
  gap: 6px;
  align-items: center;
}

.workspace-mode button,
.workspace-mode a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.workspace-mode button.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.test-steps {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.test-steps span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid #d9e8e5;
  border-radius: 999px;
  background: #f2fbf9;
  color: #31534f;
  font-size: 12px;
  white-space: nowrap;
}

.workspace-context {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: right;
}

.workspace-context strong,
.workspace-context span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-context span {
  color: var(--muted);
  font-size: 12px;
}

.calendar-panel {
  grid-area: calendar;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  max-height: 100%;
}

.calendar-head {
  min-height: 54px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.calendar-head h2 {
  margin: 0;
  font-size: 16px;
}

.calendar-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.calendar-summary {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.calendar-summary span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.legend-dot.free {
  background: #dff8f2;
  border-color: #91d3c8;
}

.legend-dot.booked {
  background: #d9dee7;
}

.legend-dot.current {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
}

.legend-dot.robot {
  background: #eaf7ef;
  border-color: #83c79e;
}

.confirmed-appointments {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.confirmed-appointments h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.confirmed-appointments .admin-task-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 126px;
  overflow: hidden;
}

.calendar-grid {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(164px, 1fr);
  gap: 1px;
  overflow: auto;
  background: var(--line);
}

.calendar-day {
  min-width: 154px;
  background: #fbfcfe;
}

.calendar-day h3 {
  margin: 0;
  padding: 8px 10px;
  color: #344054;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.slot-list {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.slot,
.slot-picks button {
  width: 100%;
  min-height: 58px;
  padding: 7px 8px;
  display: grid;
  justify-items: start;
  gap: 2px;
  text-align: left;
  border-radius: 6px;
  line-height: 1.2;
}

.slot strong,
.slot-picks strong {
  font-size: 13px;
}

.slot span,
.slot small,
.slot-picks span {
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot.free {
  border-color: #b7ded8;
  background: #f2fbf9;
}

.slot.booked {
  border-color: var(--line);
  background: #eef2f6;
  color: var(--muted);
  cursor: help;
}

.slot.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.slot.robot-confirmed {
  border-color: #83c79e;
  background: #eaf7ef;
}

.slot.loading,
.slot-picks button.loading {
  opacity: 0.68;
  cursor: progress;
}

.slot.loading::after,
.slot-picks button.loading::after {
  content: "Записываю...";
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.kanban {
  grid-area: kanban;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 286px;
  gap: 12px;
  padding-bottom: 8px;
  align-items: stretch;
}

.column {
  min-height: 360px;
  max-height: calc(100vh - 124px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.column-header {
  min-height: 44px;
  padding: 10px 10px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.column-header h2 {
  margin: 0;
  font-size: 14px;
}

.count {
  min-width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
}

.column-body {
  display: grid;
  gap: 8px;
  padding: 8px;
  align-content: start;
  overflow: auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(29, 36, 48, 0.03);
}

.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.trip-id {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.card-meta {
  display: grid;
  gap: 3px;
  color: #3d4654;
  font-size: 12px;
  line-height: 1.35;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--soft);
  color: #344054;
  font-size: 11px;
  line-height: 1;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.card-actions select {
  grid-column: 1 / -1;
}

.details {
  grid-area: details;
  min-height: 0;
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.details-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.slot-picks {
  display: grid;
  gap: 8px;
}

.slot-picks button {
  border-color: #b7ded8;
  background: #f2fbf9;
}

.details-empty {
  padding: 18px;
  color: var(--muted);
}

.details-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
}

.details-head h2 {
  margin: 0;
  font-size: 18px;
}

.details-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.details-tabs button {
  min-width: 0;
  min-height: 30px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.details-tabs button.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.details-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.details-section h3 {
  margin: 0;
  font-size: 13px;
  color: #344054;
}

.section-title-row,
.history-title {
  padding: 12px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title-row h3,
.history-title h3 {
  margin: 0;
  font-size: 13px;
  color: #344054;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.kv {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 12px;
}

.compact-kv {
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 7px 10px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-actions .full {
  grid-column: 1 / -1;
}

.full {
  width: 100%;
}

.details-form-grid {
  display: grid;
  gap: 8px;
}

.compact-field {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.compact-field span {
  color: var(--muted);
  font-size: 12px;
}

.driver-phone-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.compact-slots {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dialog-section {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.dialog-chat {
  max-height: 360px;
  overflow: auto;
  padding: 0 14px 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.call-list {
  display: grid;
  gap: 10px;
}

.call-panel {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.call-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.call-row span,
.call-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-row small,
.call-row time {
  color: var(--muted);
}

.call-row small {
  grid-column: 1 / -1;
}

.call-row time {
  grid-column: 1 / 3;
}

.download-link {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.download-link.disabled {
  pointer-events: none;
  color: var(--muted);
  background: #eef2f6;
}

.call-record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.call-dialog {
  max-height: 280px;
  padding: 0;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
}

.chat-message {
  max-width: 88%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  display: grid;
  gap: 5px;
}

.chat-message.bot {
  justify-self: start;
  border-color: #b7ded8;
  background: #f2fbf9;
}

.chat-message.driver {
  justify-self: end;
  border-color: #bed0f5;
  background: #f4f7ff;
}

.chat-message.operator {
  justify-self: start;
  border-color: #e0c48a;
  background: #fff8e8;
}

.chat-message.system {
  justify-self: center;
  max-width: 100%;
  border-color: #d8dee8;
  background: #f8fafc;
}

.chat-message-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.chat-message strong {
  font-size: 12px;
}

.chat-message time {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.chat-message p {
  color: #1d2430;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.history {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.event {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfe;
  display: grid;
  gap: 4px;
}

.event strong {
  font-size: 12px;
}

.event time {
  color: var(--muted);
  font-size: 11px;
}

.event pre {
  margin: 0;
  max-height: 116px;
  overflow: auto;
  color: #344054;
  font-size: 11px;
  white-space: pre-wrap;
}

.admin-task-list {
  display: grid;
  gap: 8px;
}

.admin-task {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.admin-task div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-task p {
  margin: 6px 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.admin-task span,
.admin-task small {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #1d2430;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 20;
}

@media (max-width: 1180px) {
  body {
    min-width: 0;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .metrics {
    grid-auto-flow: row;
    grid-template-columns: repeat(5, minmax(90px, 1fr));
    width: 100%;
  }

  .userbar {
    flex-wrap: wrap;
  }

  .settings-form,
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "workspace-nav"
      "calendar"
      "kanban"
      "details";
    height: auto;
    overflow: visible;
  }

  .behavior-grid,
  .behavior-modules,
  .behavior-card-grid {
    grid-template-columns: 1fr;
  }

  .behavior-summary {
    display: grid;
  }

  body.dental-ui .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "workspace-nav"
      "calendar"
      "kanban"
      "details";
  }

  body.dental-ui.workspace-schedule .workspace {
    grid-template-areas:
      "workspace-nav"
      "calendar"
      "details";
  }

  .workspace-nav {
    grid-template-columns: 1fr;
  }

  .workspace-context {
    text-align: left;
  }

  .kanban {
    grid-auto-columns: minmax(260px, 82vw);
  }

  .column,
  .details {
    max-height: none;
  }
}
