:root {
  --ink: #14212e;
  --muted: #627282;
  --muted-strong: #445465;
  --canvas: #f3f6f8;
  --shell: #eef3f6;
  --paper: #ffffff;
  --panel: #fbfcfd;
  --panel-alt: #f8fafc;
  --line: #d7e0e7;
  --line-strong: #c2d0da;
  --accent: #0f766e;
  --accent-strong: #0a5c56;
  --accent-soft: #daf1ee;
  --accent-ghost: #eef8f6;
  --nav-bg: #0f1a24;
  --nav-line: rgba(255, 255, 255, 0.08);
  --warning: #b45309;
  --warning-soft: #fff2dd;
  --error: #b42318;
  --error-soft: #ffe7e5;
  --success: #166534;
  --success-soft: #e4f7ea;
  --info: #0f5ea8;
  --info-soft: #e6f0fb;
  --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 28px 64px rgba(15, 23, 42, 0.14);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --mono: "IBM Plex Mono", "Fira Code", monospace;
  --sans: "Manrope", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.09), transparent 24%),
    linear-gradient(180deg, #f9fbfc 0%, var(--canvas) 100%);
  color: var(--ink);
  font-family: var(--sans);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell--public {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(20, 33, 46, 0.98), rgba(12, 23, 33, 0.98)),
    var(--nav-bg);
  color: #f8f5ef;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-inline-end: 1px solid var(--nav-line);
}

.brand {
  display: grid;
  gap: 6px;
}

.brand--shell {
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.brand__copy {
  display: grid;
  gap: 4px;
}

.brand__eyebrow,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.sidebar .brand__eyebrow,
.sidebar .brand__workspace {
  color: rgba(241, 245, 249, 0.68);
}

.brand__workspace {
  font-family: var(--mono);
  font-size: 12px;
}

.sidebar__workspace-card {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar__workspace-card span,
.sidebar__workspace-card small {
  color: rgba(241, 245, 249, 0.68);
  font-size: 12px;
}

.sidebar__workspace-card strong {
  font-size: 15px;
}

.sidebar__nav {
  display: grid;
  gap: 18px;
}

.sidebar__group {
  display: grid;
  gap: 8px;
}

.sidebar__group-label {
  padding-inline: 12px;
  color: rgba(241, 245, 249, 0.46);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar__nav-link {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 14px;
  color: rgba(248, 250, 252, 0.88);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar__nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar__nav-link--active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.24), rgba(20, 184, 166, 0.08));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.22);
}

.sidebar__dropdown {
  display: grid;
  gap: 8px;
}

.sidebar__dropdown-toggle {
  cursor: pointer;
  list-style: none;
  justify-content: space-between;
}

.sidebar__dropdown-toggle::-webkit-details-marker {
  display: none;
}

.sidebar__dropdown-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  opacity: 0.74;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.sidebar__dropdown[open] .sidebar__dropdown-toggle::after {
  transform: rotate(225deg);
}

.sidebar__submenu {
  display: grid;
  gap: 6px;
  padding-inline-start: 14px;
}

.sidebar__submenu-link {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 12px;
  border-inline-start: 2px solid rgba(148, 163, 184, 0.22);
  border-radius: 0 12px 12px 0;
  color: rgba(248, 250, 252, 0.74);
  font-size: 13px;
  font-weight: 700;
}

.sidebar__submenu-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.sidebar__submenu-link--active {
  border-inline-start-color: #2dd4bf;
  background: rgba(15, 118, 110, 0.22);
  color: #fff;
}

.sidebar__logout {
  margin-top: auto;
}

.main-content {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

.main-content--public {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
}

.main-stage {
  display: grid;
  gap: 24px;
  width: 100%;
  max-width: 1600px;
}

.main-content--public .main-stage {
  justify-items: center;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(215, 224, 231, 0.95);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  flex-wrap: wrap;
}

.top-header__identity {
  display: grid;
  gap: 4px;
}

.top-header__label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.top-header__identity strong {
  font-size: 18px;
}

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

.top-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-header__search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.top-header__search-box {
  position: relative;
  min-width: min(380px, 100%);
  width: 380px;
}

.top-header__search-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.top-header__search input {
  width: 100%;
}

.top-header__search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid rgba(215, 224, 231, 0.98);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.99);
  box-shadow: var(--shadow-lg);
}

.top-header__search-heading {
  padding: 6px 12px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-header__search-option,
.top-header__search-empty {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
}

.top-header__search-option {
  color: inherit;
  text-decoration: none;
}

.top-header__search-option--button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.top-header__search-option:hover,
.top-header__search-option:focus-visible,
.top-header__search-option--active {
  background: var(--accent-ghost);
  outline: none;
}

.top-header__search-option strong {
  font-size: 14px;
}

.top-header__search-option span,
.top-header__search-empty {
  color: var(--muted);
  font-size: 12px;
}

.top-header__search-empty {
  padding-block: 12px;
}

.top-header__control {
  min-width: 160px;
}

.top-header__summary {
  min-width: 190px;
}

.top-header__logout {
  margin: 0;
}

.page-shell {
  display: grid;
  gap: 20px;
}

.page-shell--wide {
  gap: 20px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  padding: 4px 2px;
}

.page-header h1 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  max-width: 860px;
  line-height: 1.55;
}

.page-actions,
.inline-actions,
.chat-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.contacts-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 252, 253, 0.98));
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.18), transparent 42%);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel__header h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

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

.metric-grid,
.card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric-card,
.card-link {
  background: linear-gradient(180deg, var(--paper), var(--panel-alt));
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 20px;
  padding: 18px 18px 20px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.metric-card span,
.card-link__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.metric-card strong,
.card-link strong {
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.split-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

.stack-grid {
  display: grid;
  gap: 18px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: white;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.18);
}

.button--ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.button--block {
  width: 100%;
}

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

.stack-form,
.stack-list {
  display: grid;
  gap: 14px;
}

.inline-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.stack-form label,
.status-select {
  display: grid;
  gap: 8px;
}

.stack-form span,
.status-select span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.02);
}

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
.sidebar__nav-link:focus-visible,
.settings-nav__link:focus-visible {
  outline: 0;
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 18px;
}

.table-link {
  color: var(--accent-strong);
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  text-align: left;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(215, 224, 231, 0.8);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-alt);
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.03);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(20, 33, 46, 0.08);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.status-pill--neutral {
  background: rgba(255, 255, 255, 0.16);
}

.flash,
.notice {
  border-radius: 18px;
  padding: 15px 18px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}

.flash--success,
.notice--success {
  background: var(--success-soft);
  border-color: rgba(22, 101, 52, 0.18);
}

.flash--error {
  background: var(--error-soft);
  border-color: rgba(180, 35, 24, 0.16);
}

.flash--warning,
.notice--warning {
  background: var(--warning-soft);
  border-color: rgba(180, 83, 9, 0.18);
}

.flash--info {
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.16);
}

.auth-card {
  width: 100%;
  max-width: 520px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  border: 1px solid rgba(215, 224, 231, 0.9);
  box-shadow: var(--shadow);
  padding: 32px;
  display: grid;
  gap: 26px;
}

.auth-card--wide {
  max-width: 680px;
}

.auth-card__header h1 {
  margin: 8px 0;
  font-size: 36px;
}

.auth-card__header p {
  margin: 0;
  color: var(--muted);
}

.auth-card__footer {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.auth-card__footer a {
  color: var(--accent-strong);
  font-weight: 800;
}

.domain-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.domain-input:focus-within {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.domain-input input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.domain-input input:focus {
  box-shadow: none;
}

.domain-input strong {
  padding: 0 14px;
  color: var(--muted);
  white-space: nowrap;
}

.helpdesk-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 190px);
  max-height: calc(100vh - 190px);
}

.conversation-panel,
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 12px;
  overflow: auto;
}

.conversation-item {
  display: grid;
  align-content: start;
  align-self: start;
  gap: 8px;
  min-height: 130px;
  padding: 14px;
  border: 1px solid rgba(222, 207, 185, 0.8);
  border-radius: 18px;
  background: var(--paper);
  min-width: 0;
}

.conversation-item--active {
  border-color: rgba(15, 118, 110, 0.5);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.3);
}

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

.conversation-item__name {
  font-size: 15px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item__meta,
.conversation-item__assignment,
.conversation-item__reroute,
.conversation-item__queue,
.conversation-item__preview,
.chat-subtitle,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.conversation-item__top .status-pill {
  flex-shrink: 0;
}

.conversation-item__meta,
.conversation-item__assignment {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item__preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  word-break: break-word;
}

.conversation-item__queue {
  color: var(--warning);
  font-family: var(--mono);
}

.conversation-item__reroute {
  color: var(--warning);
  font-family: var(--mono);
  font-weight: 700;
}

.routing-summary {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.92);
}

.routing-summary span {
  color: var(--muted);
  font-size: 13px;
}

.routing-summary strong {
  font-size: 18px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(222, 207, 185, 0.8);
  flex-shrink: 0;
}

.chat-header h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.chat-actions .button {
  min-height: 44px;
}

.chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px 2px 140px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.message-bubble {
  max-width: min(720px, 88%);
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(18, 33, 42, 0.07);
}

.message-bubble--inbound {
  background: #fff;
  border: 1px solid rgba(222, 207, 185, 0.9);
  justify-self: start;
}

.message-bubble--outbound {
  background: var(--accent-soft);
  border: 1px solid rgba(15, 118, 110, 0.16);
  justify-self: end;
}

.message-bubble--system {
  background: rgba(18, 33, 42, 0.08);
  border: 1px solid rgba(18, 33, 42, 0.1);
  justify-self: center;
}

.message-bubble__meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.message-bubble__body {
  line-height: 1.55;
}

.message-attachment {
  display: grid;
  gap: 10px;
}

.message-attachment img,
.message-attachment video {
  max-width: min(100%, 420px);
  border-radius: 16px;
  display: block;
  background: rgba(18, 33, 42, 0.06);
}

.message-attachment audio {
  width: min(100%, 420px);
}

.attachment-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(222, 207, 185, 0.9);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.9);
}

.attachment-card span {
  color: var(--muted);
  font-size: 13px;
}

.chat-footer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  border-top: 1px solid rgba(222, 207, 185, 0.8);
  padding-top: 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(255, 250, 242, 0.98));
  backdrop-filter: blur(8px);
}

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

.message-form__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.message-form textarea {
  min-height: 54px;
  max-height: 180px;
  resize: vertical;
}

.file-field {
  display: grid;
  gap: 8px;
}

.file-field--inline {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf9;
  cursor: pointer;
}

.file-field--inline span {
  color: var(--ink);
  font-size: 14px;
}

.file-field--inline input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.message-form__attachment-name {
  color: var(--muted);
  font-size: 13px;
}

.message-form__options {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.message-form__voice-button {
  min-height: 42px;
  padding: 0 14px;
}

.message-form__voice-button--recording {
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid rgba(180, 35, 24, 0.24);
}

.message-form__voice-state {
  color: var(--muted);
  font-size: 13px;
}

.message-form__voice-state--error {
  color: var(--error);
}

.readout {
  background: linear-gradient(180deg, var(--paper), var(--panel-alt));
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.readout span {
  color: var(--muted);
  font-size: 13px;
}

.readout strong {
  font-family: var(--mono);
  font-size: 14px;
  word-break: break-word;
  line-height: 1.6;
}

.readout--compact {
  padding: 12px 14px;
  min-height: 48px;
  align-content: center;
}

.document-modal-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.document-builder {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 20px;
  background: rgba(248, 250, 252, 0.72);
}

.document-builder__header,
.document-builder__footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.document-builder__header h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.document-builder__header p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.document-items {
  display: grid;
  gap: 14px;
}

.document-line {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 18px;
  background: var(--paper);
}

.document-line__grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 2.1fr) minmax(120px, 0.65fr) minmax(140px, 0.85fr) minmax(150px, 0.9fr) 110px;
  align-items: end;
}

.document-line__field {
  display: grid;
  gap: 8px;
}

.document-line__field span {
  font-size: 14px;
  color: var(--muted);
}

.document-line__field--action .button {
  min-width: 0;
}

.document-line__new-product {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.document-line-summary-list {
  display: grid;
  gap: 8px;
  min-width: 260px;
}

.document-line-summary {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.92);
}

.document-line-summary span {
  color: var(--muted);
  font-size: 13px;
}

.modal {
  z-index: 2000;
}

.modal-backdrop {
  z-index: 1990;
}

.modal .modal-dialog {
  position: relative;
  z-index: 2001;
}

.modal .modal-content {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal .modal-header {
  border-bottom-color: rgba(215, 224, 231, 0.92);
}

.modal .modal-footer {
  border-top-color: rgba(215, 224, 231, 0.92);
}

.settings-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.settings-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(215, 224, 231, 0.92);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--muted-strong);
  font-weight: 700;
}

.settings-nav__link--active {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: var(--accent);
  color: #fff;
}

.template-editor {
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 14px;
  background: #fff;
  padding: 0;
}

.template-editor[open] {
  box-shadow: var(--shadow-sm);
}

.template-editor__summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 14px 16px;
}

.template-editor__summary span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.template-editor__summary strong,
.template-editor__summary small {
  overflow-wrap: anywhere;
}

.template-editor__summary small {
  color: var(--muted);
}

.template-editor .stack-form,
.template-editor__delete {
  border-top: 1px solid rgba(215, 224, 231, 0.92);
  padding: 16px;
}

.permissions-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.floor-pulse-grid {
  align-items: start;
}

.status-pill--available {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill--active {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill--inactive {
  background: rgba(18, 33, 42, 0.08);
  color: var(--muted);
}

.status-pill--busy {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-pill--idle {
  background: rgba(11, 95, 255, 0.1);
  color: #0b5fff;
}

.status-pill--offline {
  background: rgba(18, 33, 42, 0.08);
  color: var(--muted);
}

.floor-agent-table td strong {
  font-size: 15px;
}

.permission-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid rgba(215, 224, 231, 0.92);
  border-radius: 18px;
  padding: 14px;
  background: linear-gradient(180deg, var(--paper), var(--panel-alt));
}

.permission-chip small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

.empty-state {
  padding: 22px;
  border: 1px dashed rgba(98, 114, 130, 0.34);
  border-radius: 18px;
  text-align: center;
  background: rgba(248, 250, 252, 0.6);
}

.empty-state--full {
  min-height: 320px;
  display: grid;
  place-items: center;
}

.card-link {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card-link:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.22);
  box-shadow: var(--shadow);
}

[dir="rtl"] .sidebar {
  border-inline-end: 0;
  border-inline-start: 1px solid var(--nav-line);
}

[dir="rtl"] th,
[dir="rtl"] td,
[dir="rtl"] .page-header,
[dir="rtl"] .panel__header,
[dir="rtl"] .chat-header,
[dir="rtl"] .document-builder__header,
[dir="rtl"] .document-builder__footer {
  text-align: right;
}

[dir="rtl"] .sidebar__group-label,
[dir="rtl"] .brand__eyebrow,
[dir="rtl"] .eyebrow,
[dir="rtl"] .top-header__label,
[dir="rtl"] th,
[dir="rtl"] .metric-card span,
[dir="rtl"] .card-link__label {
  letter-spacing: 0.04em;
}

@media (max-width: 1100px) {
  .sidebar {
    width: auto;
  }

  .helpdesk-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .main-content {
    padding: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .domain-input {
    grid-template-columns: 1fr;
  }

  .domain-input strong {
    padding: 0 14px 12px;
  }

  .page-header,
  .chat-header {
    flex-direction: column;
    align-items: stretch;
  }

  .top-header {
    flex-direction: column;
    align-items: stretch;
  }

  .top-header__actions {
    justify-content: flex-start;
  }

  .top-header__search {
    width: 100%;
  }

  .top-header__search-box {
    width: 100%;
    min-width: 0;
  }

  .top-header__search input {
    flex: 1 1 220px;
  }

  .contacts-header-actions {
    justify-content: flex-start;
  }

  .sidebar__workspace-card {
    display: none;
  }

  .helpdesk-grid {
    grid-template-columns: 1fr;
    min-height: auto;
    max-height: none;
  }

  .conversation-panel,
  .chat-panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .chat-thread {
    max-height: 52vh;
    padding-bottom: 20px;
  }

  .chat-footer {
    position: static;
    backdrop-filter: none;
  }

  .message-form__composer {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .document-modal-grid,
  .document-line__grid,
  .document-line__new-product {
    grid-template-columns: 1fr;
  }

}
