:root {
  --ink: #14213d;
  --muted: #64748b;
  --line: #dbe4f0;
  --soft: #f6f8fc;
  --white: #ffffff;
  --purple: #6d28d9;
  --purple-dark: #4c1d95;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #16a34a;
  --red: #dc2626;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f8fbff 0%, #f5f2ff 52%, #eef6ff 100%);
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.15fr);
  gap: 28px;
  padding: 32px;
}

.customer-chat-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #f7f9fd;
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 32px;
  border-right: 1px solid rgba(109, 40, 217, 0.16);
}

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

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--plugin-primary, var(--purple)), var(--plugin-accent, var(--blue)));
  box-shadow: 0 16px 40px rgba(37, 99, 235, 0.22);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle,
.small,
.muted {
  color: var(--muted);
}

.brand-copy h1 {
  margin: 0 0 14px;
  font-size: 44px;
  line-height: 1.04;
  letter-spacing: 0;
}

.brand-copy p {
  max-width: 520px;
  margin: 0;
  color: #475569;
  line-height: 1.8;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 16px;
  border: 1px solid rgba(219, 228, 240, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
}

.chat-wrap {
  align-self: center;
  width: min(100%, 760px);
  margin: 0 auto;
  border: 1px solid rgba(109, 40, 217, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 24px 80px rgba(76, 29, 149, 0.16);
}

.front-messages {
  height: min(66vh, 640px);
  overflow: auto;
  padding: 14px 18px 22px;
  background: #ffffff;
}

.front-message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 12px 0;
}

.front-message-row.customer {
  justify-content: flex-end;
}

.front-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: #7c73d8;
  font-weight: 800;
}

.front-message {
  width: fit-content;
  max-width: min(620px, 62vw);
  padding: 9px 13px;
  border-radius: 16px;
  color: #1f2937;
  line-height: 1.45;
  white-space: pre-wrap;
}

.front-message.agent {
  border-top-left-radius: 6px;
  background: var(--plugin-agent, #ede9fe);
}

.front-message.customer {
  border-top-right-radius: 6px;
  color: white;
  background: linear-gradient(135deg, var(--plugin-customer, var(--blue)), var(--plugin-primary, var(--purple)));
}

.front-meta {
  margin-top: 5px;
  color: #94a3b8;
  font-size: 11px;
}

.front-message-row.customer .front-meta {
  text-align: right;
}

.front-composer {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: white;
}

.front-composer textarea {
  min-height: 46px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.front-composer textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  color: white;
  background: linear-gradient(135deg, var(--plugin-primary, var(--purple-dark)), var(--plugin-primary, var(--purple)) 48%, var(--plugin-accent, var(--blue)));
}

.agent-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #0f172a;
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.messages {
  height: min(62vh, 520px);
  overflow: auto;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.message {
  width: fit-content;
  max-width: min(58ch, 68%);
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.agent {
  color: #1e1b4b;
  background: var(--plugin-agent, #ede9fe);
}

.message.customer {
  margin-left: auto;
  color: white;
  background: linear-gradient(135deg, var(--plugin-customer, var(--blue)), var(--plugin-primary, var(--purple)));
}

.message .meta {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.message.agent .meta {
  color: #6b7280;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer textarea {
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  outline: none;
}

.composer textarea:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.primary {
  min-width: 92px;
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--purple), var(--blue));
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: #f7f9fd;
}

.sidebar {
  padding: 24px;
  color: white;
  background: linear-gradient(180deg, #34146f 0%, #4c1d95 52%, #1e40af 100%);
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav a {
  padding: 12px 13px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.14);
}

.main {
  padding: 26px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.cols-2 {
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
}

.grid.cols-2.wide-left {
  grid-template-columns: minmax(620px, 1.25fr) minmax(360px, 0.75fr);
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.06);
}

.card-head,
.card-body {
  padding: 18px;
}

.card-head {
  border-bottom: 1px solid var(--line);
}

.split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-head h2,
.card-head h3 {
  margin: 0;
}

.metric {
  padding: 20px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

.table th,
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

.table th {
  color: #475569;
  background: #f8fafc;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: #475569;
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  background: white;
}

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

.inline-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.2fr) auto;
  gap: 10px;
  width: min(100%, 620px);
}

.inline-form.agent-form {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) auto;
}

.inline-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.compact {
  min-height: 42px;
  padding: 0 16px;
}

.ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--ink);
  background: white;
}

.danger {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: white;
  font-weight: 800;
  background: #dc2626;
}

.lock-notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: #92400e;
  background: #fffbeb;
  font-weight: 700;
}

.readonly-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.readonly-summary div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.readonly-summary .wide {
  grid-column: 1 / -1;
}

.readonly-summary span,
.readonly-summary strong,
.readonly-summary p {
  display: block;
}

.readonly-summary span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.readonly-summary strong,
.readonly-summary p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.field input:disabled,
.field textarea:disabled,
.field select:disabled {
  color: #64748b;
  background: #f1f5f9;
  cursor: not-allowed;
}

.mini-chat {
  height: auto;
  max-height: 48vh;
  min-height: 180px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.line-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px 0;
}

.line-card,
.conversation-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  background: white;
}

.line-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
}

.line-card.active,
.conversation-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.line-card strong,
.line-card small,
.conversation-item span,
.seat-check span {
  display: block;
}

.line-card small,
.conversation-item small,
.seat-check small {
  margin-top: 4px;
  color: var(--muted);
}

.line-card em {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: #1e40af;
  background: var(--blue-soft);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.dns-pill.connected,
.dns-status.connected {
  color: #166534;
  background: #dcfce7;
}

.dns-pill.pending,
.dns-status.pending,
.dns-pill.checking,
.dns-status.checking {
  color: #92400e;
  background: #fef3c7;
}

.dns-pill.error,
.dns-status.error {
  color: #991b1b;
  background: #fee2e2;
}

.dns-panel {
  display: grid;
  gap: 10px;
}

.dns-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dns-panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.dns-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.conversation-board {
  display: grid;
  grid-template-columns: minmax(300px, 0.38fr) minmax(460px, 0.62fr);
  min-height: 0;
}

.plugin-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.8fr);
  gap: 16px;
  padding: 18px;
}

.plugin-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.plugin-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  background: white;
}

.plugin-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.plugin-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
}

.plugin-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plugin-card strong,
.plugin-card small {
  display: block;
}

.plugin-card small {
  margin-top: 4px;
  color: var(--muted);
}

.plugin-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.plugin-preview .messages {
  height: 220px;
}

.plugin-form {
  display: grid;
  align-content: start;
}

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

.color-grid label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 14px;
  font-weight: 700;
}

.color-grid input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: white;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

.conversation-item {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  line-height: 1.35;
}

.conversation-top {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-text {
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item b {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--red);
  font-size: 12px;
}

.conversation-detail {
  padding: 10px;
}

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

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.seat-checks {
  display: grid;
  gap: 10px;
}

.seat-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seat-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--purple);
}

.inbox {
  height: calc(100vh - 102px);
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.inbox-list {
  display: grid;
  grid-template-rows: auto auto 1fr;
  border-right: 1px solid var(--line);
  background: #fbfcff;
  min-width: 0;
}

.inbox-filter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.inbox-filter button {
  border: 0;
  border-radius: 6px;
  padding: 6px 4px;
  color: #64748b;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.inbox-filter button.active {
  color: var(--blue);
  background: #eaf2ff;
}

.inbox-search {
  margin: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #94a3b8;
  background: white;
  font-size: 13px;
}

.inbox-scroll {
  overflow: auto;
  padding: 4px 8px 10px;
}

.inbox-item {
  position: relative;
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 7px;
  padding: 7px 8px;
  text-align: left;
  background: transparent;
}

.inbox-item.active,
.inbox-item:hover {
  background: #eef4ff;
}

.inbox-avatar,
.inbox-message-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: #7c73d8;
  font-weight: 800;
}

.inbox-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.inbox-name {
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-meta,
.inbox-preview,
.inbox-time {
  color: #94a3b8;
  font-size: 12px;
}

.inbox-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-item b {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: #ef4444;
  font-size: 11px;
}

.inbox-chat {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: white;
}

.inbox-chat-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

.inbox-chat-head strong,
.inbox-chat-head span {
  display: block;
}

.inbox-chat-head strong {
  color: #334155;
  font-size: 15px;
}

.inbox-chat-head span {
  color: #94a3b8;
  font-size: 12px;
}

.inbox-tools {
  display: flex;
  gap: 8px;
}

.inbox-tools button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  color: #64748b;
  background: #f8fafc;
  font-size: 12px;
}

.inbox-messages {
  overflow: auto;
  padding: 14px 18px 20px;
  background: #ffffff;
}

.inbox-message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 8px 0;
}

.inbox-message-row.agent {
  justify-content: flex-end;
}

.inbox-message {
  width: fit-content;
  max-width: min(680px, 62vw);
  padding: 8px 12px;
  border-radius: 16px;
  color: #334155;
  line-height: 1.45;
  white-space: pre-wrap;
}

.inbox-message.customer {
  border-top-left-radius: 6px;
  background: #eaf0fa;
}

.inbox-message.agent {
  border-top-right-radius: 6px;
  background: #eef2f7;
}

.inbox-message-meta {
  margin-top: 4px;
  color: #94a3b8;
  font-size: 11px;
}

.inbox-message-row.agent .inbox-message-meta {
  text-align: right;
}

.inbox-composer {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: white;
}

.inbox-composer textarea {
  min-height: 46px;
  max-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

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

.login-card {
  width: min(100%, 440px);
  border: 1px solid rgba(109, 40, 217, 0.18);
  border-radius: 8px;
  padding: 26px;
  background: white;
  box-shadow: 0 24px 70px rgba(76, 29, 149, 0.14);
}

.login-form {
  margin-top: 26px;
}

.domain-box {
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.dns-code {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  color: #dbeafe;
  background: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  overflow: auto;
}

@media (max-width: 920px) {
  .shell,
  .admin-shell,
  .grid.cols-2,
  .grid.cols-2.wide-left,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .split-head,
  .conversation-board,
  .plugin-layout {
    grid-template-columns: 1fr;
  }

  .split-head {
    display: grid;
  }

  .inline-form,
  .inline-form.agent-form,
  .line-list,
  .plugin-list,
  .color-grid {
    grid-template-columns: 1fr;
  }

  .conversation-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .shell {
    padding: 18px;
  }

  .brand-panel {
    padding: 10px 0;
    border-right: 0;
  }

  .brand-copy h1 {
    font-size: 32px;
  }

  .messages {
    height: 52vh;
  }

  .sidebar {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .status-row {
    grid-template-columns: 1fr;
  }

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

  .primary {
    min-height: 44px;
  }

  .main {
    padding: 16px;
  }
}
