:root {
  --bg: #f3efe6;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-strong: #fffaf2;
  --ink: #172321;
  --muted: #62716d;
  --line: rgba(23, 35, 33, 0.12);
  --brand: #0e7c66;
  --brand-deep: #0a5445;
  --accent: #c78c2a;
  --danger: #b44f32;
  --shadow: 0 20px 60px rgba(18, 34, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(circle at top left, rgba(14, 124, 102, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(199, 140, 42, 0.14), transparent 24%),
    linear-gradient(180deg, #f8f4ec 0%, #efe7da 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

.sidebar {
  padding: 28px 22px;
  background: linear-gradient(180deg, rgba(10, 84, 69, 0.96), rgba(12, 54, 53, 0.94));
  color: #f5efe5;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-logo {
  width: min(100%, 236px);
  height: auto;
  display: block;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand h1,
.topbar h2,
.section-head h3,
.auth-card h1,
.user-card h4 {
  margin: 0;
  font-family: "Rockwell", "Georgia", serif;
  letter-spacing: 0.02em;
}

.brand p,
.sidebar-foot,
.top-user span,
.metric-card span,
.section-head .eyebrow,
.eyebrow,
.detail-list span,
.bubble span {
  color: rgba(245, 239, 229, 0.76);
}

.brand p {
  margin: 0;
  line-height: 1.45;
  max-width: 18ch;
}

.brand-kicker,
.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  margin-bottom: 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  transition: transform 140ms ease, background 140ms ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 250, 242, 0.16);
  transform: translateX(4px);
}

.sidebar-foot {
  margin-top: auto;
  font-size: 0.9rem;
}

.content {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar .eyebrow,
.metric-card span,
.section-head .eyebrow,
.detail-list span,
.bubble span {
  color: var(--muted);
}

.top-user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.top-user span {
  display: block;
  color: var(--muted);
}

.flash {
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.flash.ok {
  background: rgba(14, 124, 102, 0.12);
  border-color: rgba(14, 124, 102, 0.2);
}

.flash.error {
  background: rgba(180, 79, 50, 0.11);
  border-color: rgba(180, 79, 50, 0.2);
}

.metric-grid,
.split-grid {
  display: grid;
  gap: 18px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 22px;
}

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

.admin-grid {
  align-items: start;
}

.detail-grid {
  margin-bottom: 22px;
}

.metric-card,
.panel-card,
.auth-card,
.user-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.metric-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.metric-card.accent {
  background:
    linear-gradient(135deg, rgba(255, 250, 242, 0.92), rgba(249, 240, 221, 0.88));
}

.panel-card {
  padding: 22px;
  margin-bottom: 22px;
}

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

.filters,
.permission-grid,
.table-actions,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-pill,
.mini-btn,
button,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font: inherit;
  transition: transform 140ms ease, opacity 140ms ease;
}

.filter-pill {
  position: relative;
}

.notify-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e03131;
  box-shadow: 0 0 0 2px var(--panel, #fff);
}

.row-id {
  position: relative;
  display: inline-block;
  padding-right: 12px;
}

.row-id .notify-dot {
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
}

.label-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.label-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.label-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.label-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.label-checkbox input {
  cursor: pointer;
}

.filter-pill,
.mini-btn,
.ghost-btn {
  padding: 10px 14px;
  background: rgba(14, 124, 102, 0.08);
  border: 1px solid rgba(14, 124, 102, 0.16);
  color: var(--ink);
}

.filter-pill.active,
button,
.mini-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.filter-pill.active,
button {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
}

button {
  padding: 12px 18px;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
}

.mini-btn.danger {
  background: rgba(180, 79, 50, 0.12);
  border-color: rgba(180, 79, 50, 0.24);
}

.table-wrap {
  overflow-x: auto;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  background: rgba(14, 124, 102, 0.06);
  color: var(--muted);
}

.search-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.search-grid {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}

.search-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-actions .ghost-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.search-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.data-table tr.row-clickable {
  cursor: pointer;
}

.data-table tr.row-clickable:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}

.data-table td span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.message-preview {
  min-width: 280px;
  max-width: 360px;
}

.owner-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.owner-stack span {
  margin-top: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
}

.status-badge.open {
  background: rgba(14, 124, 102, 0.12);
  border-color: rgba(14, 124, 102, 0.22);
}

.status-badge.waiting_human {
  background: rgba(199, 140, 42, 0.18);
  border-color: rgba(199, 140, 42, 0.28);
}

.status-badge.handoff_human {
  background: rgba(14, 124, 102, 0.12);
  border-color: rgba(14, 124, 102, 0.22);
}

.status-badge.closed {
  background: rgba(98, 113, 109, 0.12);
  border-color: rgba(98, 113, 109, 0.22);
}

.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-queue-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-queue-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 4px 14px;
  background: rgba(255, 255, 255, 0.6);
}

.agent-queue-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.agent-queue-card summary::-webkit-details-marker {
  display: none;
}

.agent-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 12px;
}

.agent-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}

.agent-queue-item:hover {
  background: rgba(14, 124, 102, 0.12);
}

.agent-queue-item-time {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.chart-row {
  display: grid;
  grid-template-columns: 68px 1fr 44px;
  gap: 12px;
  align-items: center;
}

.chart-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(14, 124, 102, 0.08);
  overflow: hidden;
}

.chart-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.reason-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reason-list li,
.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.detail-list {
  display: flex;
  flex-direction: column;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 6px;
}

.bubble {
  max-width: 78%;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
}

.transcript-divider {
  align-self: center;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(23, 35, 33, 0.06);
}

.bubble.in {
  align-self: flex-start;
  border-top-left-radius: 8px;
}

.bubble.out {
  align-self: flex-end;
  background: rgba(14, 124, 102, 0.14);
  border-top-right-radius: 8px;
}

.bubble p {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.deleted-text em {
  color: var(--muted);
}

.edited-tag {
  color: var(--muted);
  font-size: 0.78rem;
}

.message-manage-actions {
  margin-top: 8px;
}

.edit-message-form {
  margin-top: 8px;
}

.edit-message-form[hidden] {
  display: none;
}

.chat-media-image {
  display: block;
  max-width: 260px;
  max-height: 260px;
  border-radius: 12px;
  margin-top: 8px;
  object-fit: cover;
}

.chat-media-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(14, 124, 102, 0.1);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.reply-quote {
  margin-top: 4px;
  padding: 6px 10px;
  border-left: 3px solid rgba(14, 124, 102, 0.5);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  font-size: 0.85em;
  opacity: 0.85;
}

.reply-btn {
  margin-top: 8px;
}

.reply-preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(14, 124, 102, 0.1);
  border-left: 3px solid rgba(14, 124, 102, 0.5);
  font-size: 0.9em;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.inline-queue-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-queue-form select {
  width: auto;
  min-height: 46px;
}

.inline-queue-label {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.inline-note {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.inline-note.emphasis {
  background: rgba(14, 124, 102, 0.1);
  border-color: rgba(14, 124, 102, 0.22);
  color: var(--ink);
}

.info-banner {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}

.info-banner.success {
  background: rgba(14, 124, 102, 0.1);
  border-color: rgba(14, 124, 102, 0.2);
}

.info-banner.warning {
  background: rgba(199, 140, 42, 0.14);
  border-color: rgba(199, 140, 42, 0.24);
}

.info-banner.neutral {
  background: rgba(98, 113, 109, 0.1);
  border-color: rgba(98, 113, 109, 0.22);
}

.live-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.reception-watch-hidden {
  display: none;
}

.live-strip-minimal {
  justify-content: flex-end;
}

.live-strip h3 {
  margin: 0;
}

.live-strip-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(14, 124, 102, 0.1);
  border: 1px solid rgba(14, 124, 102, 0.18);
  color: var(--ink);
}

.live-indicator::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 6px rgba(14, 124, 102, 0.12);
}

.live-strip.has-update .live-indicator {
  background: rgba(199, 140, 42, 0.14);
  border-color: rgba(199, 140, 42, 0.22);
}

.live-strip.has-update .live-indicator::before {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(199, 140, 42, 0.14);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stack-form.compact {
  gap: 12px;
}

.stack-form label,
.field-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.8);
}

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

.quick-reply-anchor {
  position: relative;
}

.quick-reply-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quick-reply-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  min-height: auto;
}

.quick-reply-option strong {
  color: var(--brand-deep, #0e7c66);
  white-space: nowrap;
}

.quick-reply-option span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-reply-option.active,
.quick-reply-option:hover {
  background: rgba(14, 124, 102, 0.12);
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.check-item.mini {
  padding: 10px 12px;
}

.check-item input {
  width: auto;
  margin: 0;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-card {
  padding: 18px;
}

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

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 520px);
  padding: 28px;
}

.auth-card-wide {
  width: min(100%, 620px);
}

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

  .sidebar {
    padding: 22px 20px 18px;
    gap: 18px;
  }

  .brand {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .brand p {
    max-width: none;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-foot {
    display: none;
  }

  .top-user {
    width: 100%;
    justify-content: space-between;
  }

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

  .live-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-grid {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
  }
}

@media (max-width: 760px) {
  .sidebar {
    padding: 16px 14px 14px;
  }

  .brand {
    gap: 12px;
  }

  .brand-logo {
    width: min(100%, 180px);
  }

  .brand-copy {
    gap: 6px;
  }

  .content {
    padding: 14px;
  }

  .topbar,
  .section-head,
  .user-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    margin-bottom: 16px;
  }

  .topbar > *,
  .section-head > *,
  .user-header > * {
    width: 100%;
  }

  .topbar h2,
  .section-head h3,
  .auth-card h1 {
    line-height: 1.15;
  }

  .top-user {
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .top-user form,
  .top-user button {
    width: 100%;
  }

  .metric-card,
  .panel-card,
  .auth-card,
  .user-card {
    border-radius: 20px;
  }

  .metric-card,
  .panel-card,
  .user-card {
    padding: 16px;
  }

  .panel-card {
    margin-bottom: 16px;
  }

  .flash,
  .info-banner,
  .search-toolbar {
    border-radius: 16px;
    padding: 14px;
  }

  .filters,
  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }

  .nav-link,
  .filter-pill {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .search-toolbar {
    gap: 12px;
  }

  .bubble {
    max-width: 100%;
    border-radius: 18px;
    padding: 12px 14px;
  }

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

  .search-actions,
  .table-actions,
  .detail-actions,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-actions > *,
  .table-actions > *,
  .detail-actions > *,
  .inline-form > * {
    width: 100%;
  }

  .search-actions .ghost-btn,
  .table-actions .mini-btn,
  .table-actions .ghost-btn,
  .detail-actions .mini-btn,
  .detail-actions .ghost-btn,
  .detail-actions button,
  .inline-form button {
    width: 100%;
  }

  .detail-list div {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .live-strip-side {
    width: 100%;
  }

  .live-indicator {
    width: 100%;
    justify-content: center;
  }

  .check-item {
    align-items: flex-start;
  }

  .auth-body {
    padding: 16px;
  }

  .auth-card,
  .auth-card-wide {
    width: 100%;
    padding: 20px 16px;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
  }

  .data-table td {
    display: grid;
    grid-template-columns: minmax(104px, 118px) minmax(0, 1fr);
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
  }

  .data-table td:first-child {
    border-top: 0;
    padding-top: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .data-table td[colspan] {
    display: block;
    padding: 0;
    border-top: 0;
  }

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

  .message-preview {
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 12px;
  }

  .brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-logo {
    width: min(100%, 160px);
  }

  .chart-row {
    grid-template-columns: 58px 1fr 36px;
    gap: 10px;
  }

  .data-table td {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .data-table td::before {
    margin-bottom: 2px;
  }
}
