:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #eef4f7;
  --line: #dce3ea;
  --text: #17202a;
  --muted: #667085;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --teal: #0f766e;
  --amber: #d97706;
  --rose: #e11d48;
  --shadow: 0 18px 50px rgba(18, 38, 63, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.hidden {
  display: none !important;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  display: inline-block;
  flex: 0 0 auto;
}

.brand-dot.amber {
  background: linear-gradient(135deg, var(--amber), var(--rose));
}

.primary,
.login-form button,
.primary-link {
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary:hover,
.login-form button:hover,
.primary-link:hover {
  background: var(--blue-dark);
}

.secondary-link,
.ghost,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost:hover,
.secondary-link:hover,
.icon-button:hover {
  border-color: #b8c4d3;
  background: #f9fafb;
}

.small {
  min-height: 34px;
  padding: 0 12px;
}

.site-body {
  background:
    linear-gradient(180deg, #eef6f4 0%, #f7f8fb 48%, #fff 100%);
}

.site-nav {
  width: min(1120px, calc(100% - 40px));
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: #101828;
}

.site-nav nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: #435166;
  font-size: 14px;
}

.site-nav nav a:hover {
  color: var(--blue);
}

.site-hero {
  width: min(1120px, calc(100% - 40px));
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 52px;
  padding: 34px 0 84px;
}

.site-hero-copy {
  max-width: 610px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--teal);
  font-weight: 800;
}

.site-hero h1 {
  margin: 0;
  font-size: 54px;
  line-height: 1.08;
  max-width: 620px;
}

.site-hero p {
  color: #4b5563;
  font-size: 17px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.site-hero-panel {
  min-height: 430px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 15% 10%, rgba(15, 118, 110, 0.22), transparent 30%),
    linear-gradient(145deg, #102033, #1c3b55 45%, #294b3e);
  box-shadow: var(--shadow);
  padding: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-chat {
  width: min(330px, 100%);
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.24);
}

.mini-chat-head {
  height: 52px;
  background: #0f766e;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  font-weight: 700;
}

.mini-chat-head span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
}

.mini-message {
  max-width: 78%;
  margin: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.6;
  font-size: 14px;
}

.mini-message.left {
  background: #eef2f7;
}

.mini-message.right {
  margin-left: auto;
  background: #dbeafe;
  color: #123c7c;
}

.site-band {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto 32px;
  padding: 38px 0;
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 34px;
  border-top: 1px solid rgba(102, 112, 133, 0.18);
}

.site-band.alt {
  align-items: start;
  padding-bottom: 90px;
}

.site-band h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.site-band p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.feature-grid article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.feature-grid strong,
.feature-grid span {
  display: block;
}

.feature-grid span {
  color: var(--muted);
  line-height: 1.7;
  margin-top: 8px;
  font-size: 14px;
}

.embed-code {
  margin: 0;
  padding: 18px;
  background: #121826;
  color: #d7e3f2;
  border-radius: 8px;
  overflow: auto;
}

.app-body {
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.1), transparent 28%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

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

.login-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label,
.field,
.faq-form label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  color: var(--text);
  min-height: 40px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

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

.form-error {
  min-height: 20px;
  color: var(--rose);
  margin: 0;
  font-size: 13px;
}

.workspace {
  height: 100vh;
  min-height: 620px;
  display: grid;
  grid-template-columns: 300px minmax(440px, 1fr) 300px;
  background: var(--bg);
}

.conversation-pane,
.customer-pane,
.chat-pane {
  min-height: 0;
  background: #fff;
}

.conversation-pane {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}

.customer-pane {
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr;
}

.pane-top,
.customer-pane header,
.chat-head {
  min-height: 68px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pane-top strong,
.pane-top span {
  display: block;
}

.pane-top span {
  color: var(--teal);
  font-size: 13px;
  margin-top: 4px;
}

.presence-select {
  width: 78px;
  min-height: 34px;
  padding: 6px 8px;
  flex: 0 0 auto;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 18px;
}

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

.conversation-search {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.conversation-search input {
  min-height: 36px;
}

.status-tabs button,
.admin-nav button {
  border: 0;
  background: transparent;
  color: #475467;
  border-radius: 6px;
  min-height: 36px;
  font-weight: 700;
}

.status-tabs button.active {
  background: #e8f0ff;
  color: var(--blue);
}

.conversation-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.conversation-item {
  width: 100%;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  display: grid;
  gap: 8px;
}

.conversation-item:hover,
.conversation-item.active {
  background: #f8fafc;
  border-color: var(--line);
}

.conversation-item.active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.conversation-item.unread {
  border-color: #bfdbfe;
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--rose);
}

.conversation-item.unread:hover,
.conversation-item.unread.active {
  background: #eaf2ff;
}

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

.conversation-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-flags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.conversation-item p {
  margin: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0 6px;
}

.unread-pill,
.read-pill {
  min-height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.unread-pill {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #fecaca;
}

.read-pill {
  color: #667085;
  background: #f2f4f7;
  border: 1px solid #eaecf0;
}

.meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.meta-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitor-line {
  color: #475467;
}

.tag-line {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-line span {
  min-height: 22px;
  border-radius: 999px;
  background: #eef4f7;
  color: #475467;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.chat-pane {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.chat-head h1,
.customer-pane h2,
.section-head h1 {
  margin: 0;
  font-size: 18px;
}

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

.chat-head h1 {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  color: #075985;
  background: #e0f2fe;
  margin-top: 6px;
}

.status-pill.ai {
  color: #065f46;
  background: #d1fae5;
}

.status-pill.queued {
  color: #92400e;
  background: #fef3c7;
}

.status-pill.offline {
  color: #9f1239;
  background: #ffe4e6;
}

.status-pill.human {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-pill.ended,
.status-pill.muted {
  color: #475467;
  background: #eef2f7;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.message-stream {
  overflow: auto;
  padding: 22px;
  background:
    linear-gradient(180deg, #f8fafc 0%, #f3f6fb 100%);
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.empty-state div {
  display: grid;
  gap: 6px;
  text-align: center;
}

.empty-state strong {
  color: #344054;
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

.message-row.incoming {
  justify-content: flex-start;
}

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

.message-row.system {
  justify-content: center;
}

.message-bubble {
  max-width: min(68%, 620px);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.65;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.04);
  overflow-wrap: anywhere;
}

.message-row.outgoing .message-bubble {
  background: #dbeafe;
  color: #123c7c;
  border-color: #bfdbfe;
}

.message-row.outgoing.ai .message-bubble {
  background: #ecfdf5;
  color: #075046;
  border-color: #c7f2df;
}

.message-row.system .message-bubble {
  max-width: 82%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.chat-attachment {
  display: grid;
  gap: 8px;
}

.chat-attachment img {
  max-width: 260px;
  max-height: 280px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
}

.chat-file-link {
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.chat-file-meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.contact-card {
  display: grid;
  gap: 10px;
}

.contact-card p {
  margin: 0;
  white-space: pre-wrap;
}

.contact-qr {
  width: 190px;
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.contact-phone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.message-author {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.message-time {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

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

.composer textarea {
  min-height: 48px;
  max-height: 120px;
  resize: none;
}

.composer button {
  min-width: 78px;
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  font-weight: 800;
}

.quick-replies {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0;
  border-top: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
}

.quick-replies button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  min-height: 32px;
  border-radius: 6px;
  padding: 0 10px;
  font-weight: 700;
}

.quick-replies button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.info-list {
  margin: 0;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  overflow: auto;
}

.info-list div {
  display: grid;
  gap: 5px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

.info-list dd {
  margin: 0;
  color: #263445;
  overflow-wrap: anywhere;
}

.customer-form {
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
  overflow: auto;
}

.customer-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.customer-form .wide,
.customer-summary,
.customer-form button,
.customer-form .save-toast {
  grid-column: 1 / -1;
}

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

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.summary-row strong {
  color: #344054;
  font-weight: 800;
  overflow-wrap: anywhere;
  text-align: right;
}

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

.admin-nav {
  background: #101828;
  color: #fff;
  padding: 20px 14px;
  display: grid;
  grid-template-rows: auto repeat(5, auto) 1fr auto;
  gap: 8px;
}

.admin-nav .brand-mark {
  color: #fff;
  margin-bottom: 18px;
  padding: 0 8px;
}

.admin-nav button {
  color: #d0d5dd;
  text-align: left;
  padding: 0 12px;
}

.admin-nav button.active,
.admin-nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.logout-button {
  grid-row: -1;
}

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

.admin-section {
  display: grid;
  gap: 22px;
}

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

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

.settings-grid {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 18px;
}

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

.save-toast {
  min-height: 22px;
  margin: 0;
  color: var(--teal);
  font-weight: 700;
}

.embed-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.embed-panel strong,
.embed-panel span {
  display: block;
}

.embed-panel span {
  color: var(--muted);
  margin-top: 6px;
}

.embed-panel pre {
  margin: 0;
  padding: 14px;
  background: #121826;
  color: #d7e3f2;
  border-radius: 8px;
  overflow: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 8px;
}

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

.stat-card strong {
  font-size: 28px;
}

.inline-form {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 120px auto auto;
  gap: 10px;
  align-items: center;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
}

tr:last-child td {
  border-bottom: 0;
}

tr.record-unread td {
  background: #fff8f6;
}

tr.record-unread:hover td {
  background: #fff1ed;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  min-height: 28px;
  font-weight: 700;
}

.danger {
  color: var(--rose);
}

.faq-form {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.faq-list {
  display: grid;
  gap: 12px;
}

.faq-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.faq-item strong,
.faq-item p {
  margin: 0;
}

.faq-item p {
  color: var(--muted);
  line-height: 1.7;
  margin-top: 6px;
}

.records-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.record-detail {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 420px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-detail > span {
  color: var(--muted);
}

.record-detail-head {
  display: grid;
  gap: 4px;
}

.record-detail-head > span,
.record-source {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.record-source {
  display: block;
  margin-top: 4px;
  line-height: 1.35;
}

.visitor-meta-panel {
  border: 1px solid #dbe7ff;
  border-radius: 8px;
  background: #f7fbff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.visitor-meta-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

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

.visitor-meta-grid div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

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

.visitor-meta-grid strong {
  color: #344054;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.record-message {
  width: fit-content;
  max-width: 74%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.04);
}

.record-message.visitor {
  align-self: flex-start;
}

.record-message.service {
  align-self: flex-end;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.record-message.system {
  align-self: center;
  max-width: 84%;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.record-message strong {
  display: block;
  color: #344054;
}

.record-message p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.record-message.service p {
  color: #123c7c;
}

@media (max-width: 980px) {
  .site-hero,
  .site-band {
    grid-template-columns: 1fr;
  }

  .site-hero h1 {
    font-size: 42px;
  }

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

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

  .customer-pane {
    display: none;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    position: sticky;
    top: 0;
    z-index: 2;
    grid-template-columns: 1fr repeat(6, auto);
    grid-template-rows: auto;
    align-items: center;
    overflow-x: auto;
  }

  .admin-nav .brand-mark {
    margin: 0;
  }

  .records-layout,
  .settings-grid,
  .stats-grid,
  .visitor-meta-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .site-nav {
    height: auto;
    padding: 18px 0;
    align-items: flex-start;
    gap: 14px;
  }

  .site-nav,
  .site-nav nav,
  .hero-actions,
  .section-head {
    flex-direction: column;
  }

  .site-nav nav {
    align-items: flex-start;
    gap: 12px;
  }

  .site-hero {
    min-height: auto;
    padding-top: 20px;
  }

  .site-hero h1 {
    font-size: 34px;
  }

  .workspace {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .conversation-pane {
    min-height: 360px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-pane {
    min-height: 620px;
  }

  .message-bubble {
    max-width: 86%;
  }

  .admin-content {
    padding: 18px;
  }

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

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

/* Agent desktop workspace */
.agent-page {
  height: 100vh;
  overflow: hidden;
  background: #eef3f9;
}

.agent-page .agent-workspace {
  --agent-blue: #2563eb;
  --agent-blue-deep: #1d4ed8;
  --agent-blue-soft: #eaf2ff;
  --agent-text: #13233c;
  --agent-muted: #6f7f95;
  --agent-line: #dbe5f2;
  --agent-card: rgba(255, 255, 255, 0.94);
  --agent-shadow: 0 18px 48px rgba(22, 42, 77, 0.09);
  width: 100%;
  height: 100vh;
  min-height: 720px;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  grid-template-columns: 1fr;
  color: var(--agent-text);
  background:
    linear-gradient(180deg, rgba(247, 250, 255, 0.96), rgba(237, 243, 251, 0.98));
}

.agent-topbar {
  height: 58px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid #dce5f0;
  box-shadow: 0 8px 24px rgba(20, 40, 70, 0.05);
  z-index: 3;
}

.agent-brand,
.agent-top-actions,
.agent-user-chip,
.chat-identity,
.presence-control,
.search-field,
.composer-tools,
.send-group {
  display: flex;
  align-items: center;
}

.agent-brand {
  gap: 10px;
  min-width: 0;
}

.agent-brand strong {
  font-size: 16px;
  white-space: nowrap;
}

.agent-brand-icon {
  width: 30px;
  height: 30px;
  color: var(--agent-blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.agent-brand-icon svg,
.top-icon-button svg,
.logout-icon svg,
.icon-button svg,
.filter-button svg,
.search-field svg,
.customer-pane h2 svg,
.composer-tools svg,
.send-group svg,
.topbar-chevron svg {
  width: 18px;
  height: 18px;
  display: block;
}

.topbar-chevron,
.top-icon-button,
.logout-icon,
.icon-button,
.filter-button,
.composer-tools button,
.send-more {
  border: 0;
  background: transparent;
  color: #223451;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar-chevron {
  width: 26px;
  height: 26px;
  border-left: 1px solid #e2e8f2;
  margin-left: 6px;
}

.agent-top-actions {
  gap: 14px;
  min-width: 0;
}

.top-icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.top-icon-button:hover,
.logout-icon:hover,
.icon-button:hover,
.filter-button:hover,
.composer-tools button:hover,
.send-more:hover {
  background: #eef4ff;
  color: var(--agent-blue);
}

.agent-user-chip {
  gap: 9px;
  padding: 5px 8px 5px 6px;
  border-radius: 999px;
  background: #f4f7fb;
  border: 1px solid #e1e8f2;
  min-width: 0;
}

.agent-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(135deg, #7c6cff, #2f6df6);
}

.agent-user-chip div {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.agent-user-chip strong,
.agent-user-chip span {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-user-chip strong {
  font-size: 13px;
  line-height: 1.2;
}

.agent-user-chip span {
  color: #32c46d;
  font-size: 12px;
}

.logout-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.agent-layout {
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(290px, 330px) minmax(520px, 1fr) minmax(340px, 392px);
  gap: 16px;
}

.agent-page .agent-card {
  min-width: 0;
  min-height: 0;
  background: var(--agent-card);
  border: 1px solid #e0e8f3;
  border-radius: 10px;
  box-shadow: var(--agent-shadow);
  overflow: hidden;
}

.agent-page .conversation-pane {
  border-right: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.agent-page .pane-top {
  min-height: 62px;
  padding: 13px 14px;
  border-bottom: 0;
}

.agent-page .pane-top span {
  margin-top: 0;
  color: inherit;
  font-size: inherit;
}

.presence-control {
  gap: 8px;
  width: 104px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: #f9fbff;
  border: 1px solid var(--agent-line);
}

.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: #25c967;
  box-shadow: 0 0 0 4px rgba(37, 201, 103, 0.12);
  flex: 0 0 auto;
}

.agent-page .presence-select {
  width: 70px;
  min-height: 30px;
  padding: 0 18px 0 0;
  border: 0;
  background: transparent;
  color: #223451;
  box-shadow: none;
  font-size: 13px;
  font-weight: 800;
}

.agent-page .icon-button,
.agent-page .filter-button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--agent-line);
  background: #fff;
}

.agent-page .conversation-search {
  padding: 0 14px 12px;
  border-bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 9px;
}

.search-field {
  min-width: 0;
  height: 36px;
  gap: 7px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--agent-line);
  background: #f9fbff;
  color: #8996a9;
}

.search-field input {
  min-width: 0;
  width: 100%;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: #1a2b45;
  box-shadow: none;
  font-size: 13px;
}

.search-field input:focus {
  box-shadow: none;
}

.agent-page .status-tabs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 12px;
  border-bottom: 1px solid #edf1f7;
}

.agent-page .status-tabs button {
  min-width: 0;
  min-height: 36px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #4f5f75;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
}

.agent-page .status-tabs button span {
  flex: 0 0 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.agent-page .status-tabs button.active {
  color: var(--agent-blue);
  background: #edf4ff;
  border-color: #cfe0ff;
}

.tab-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #e1e9f5;
  color: #405069;
}

.status-tabs button.active .tab-count {
  color: #fff;
  background: var(--agent-blue);
}

.agent-page .conversation-list {
  min-height: 0;
  padding: 0 8px 10px;
  overflow: auto;
}

.agent-page .conversation-item {
  width: 100%;
  min-height: 92px;
  margin: 0;
  padding: 12px 10px 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  text-align: left;
  position: relative;
}

.agent-page .conversation-item + .conversation-item {
  border-top-color: #edf1f6;
}

.agent-page .conversation-item:hover,
.agent-page .conversation-item.active {
  background: #f4f8ff;
  border-color: #dbe8ff;
}

.agent-page .conversation-item.active {
  box-shadow: inset 3px 0 0 var(--agent-blue);
}

.agent-page .conversation-item.unread {
  background: #eef5ff;
  border-color: #cfe0ff;
  box-shadow: inset 3px 0 0 var(--agent-blue);
}

.agent-page .conversation-item.visitor-only {
  background: #fbfdff;
}

.conversation-avatar,
.chat-avatar,
.customer-profile-avatar,
.message-side-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #6c5cf7, #1f6feb);
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.12);
}

.conversation-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  align-self: start;
  font-size: 14px;
}

.conversation-text {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.agent-page .conversation-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.agent-page .conversation-main strong {
  color: #1f2f48;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-page .conversation-main time {
  color: #78869a;
  font-size: 12px;
  white-space: nowrap;
}

.agent-page .conversation-item p {
  margin: 0;
  color: #66768d;
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta,
.conversation-extra {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.conversation-meta {
  color: #6f7f95;
  font-size: 12px;
}

.conversation-extra {
  color: #8794a7;
  font-size: 12px;
}

.conversation-extra span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-extra em {
  min-width: 0;
  max-width: 70px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #edf2f8;
  color: #506078;
  font-style: normal;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-status {
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: #1d4ed8;
  background: #e7f0ff;
  font-weight: 800;
}

.conversation-status.ai {
  color: #0f766e;
  background: #e1f7ef;
}

.conversation-status.queued {
  color: #9a5b00;
  background: #fff3d7;
}

.conversation-status.offline {
  color: #b42318;
  background: #ffe9e7;
}

.conversation-status.ended {
  color: #667085;
  background: #eff2f6;
}

.agent-page .badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  background: #ef4444;
  color: #fff;
  box-shadow: 0 5px 12px rgba(239, 68, 68, 0.22);
}

.agent-page .chat-pane {
  display: grid;
  grid-template-rows: 84px minmax(0, 1fr) auto 100px;
}

.agent-page .chat-head {
  min-height: 84px;
  padding: 16px 22px;
  border-bottom: 1px solid #edf1f7;
}

.chat-identity {
  min-width: 0;
  gap: 12px;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex: 0 0 auto;
  font-size: 18px;
}

.chat-identity h1 {
  max-width: min(58vw, 640px);
  margin: 0;
  color: #162741;
  font-size: 16px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-page .status-pill {
  min-height: 22px;
  margin-top: 6px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
}

.agent-page .head-actions {
  gap: 10px;
}

.agent-page .head-actions .small {
  min-width: 78px;
  min-height: 38px;
  border-radius: 8px;
  font-weight: 800;
}

.agent-page .head-actions .primary {
  background: linear-gradient(135deg, #2e73ff, #1d55d7);
  box-shadow: 0 9px 20px rgba(37, 99, 235, 0.18);
}

.agent-page .head-actions .ghost {
  border: 1px solid #d6e1ef;
  background: #f8fbff;
  color: #3260a2;
}

.agent-page .message-stream {
  overflow: auto;
  padding: 24px 26px;
  background:
    radial-gradient(circle at 50% 0%, rgba(219, 231, 247, 0.8), transparent 28%),
    linear-gradient(180deg, #f7faff 0%, #f2f6fb 100%);
}

.agent-page .empty-state.compact {
  min-height: 170px;
  height: 170px;
}

.agent-page .message-row {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.agent-page .message-row.incoming {
  justify-content: flex-start;
}

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

.agent-page .message-row.system {
  justify-content: center;
}

.message-side-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  font-size: 12px;
  background: linear-gradient(135deg, #8ea8d8, #366eea);
}

.message-row.incoming .message-side-avatar {
  color: var(--agent-blue);
  background: #eef5ff;
  border: 1px solid #d8e6fb;
  box-shadow: none;
}

.agent-page .message-bubble {
  max-width: min(68%, 620px, calc(100% - 46px));
  padding: 11px 13px;
  border-radius: 8px;
  line-height: 1.65;
  color: #23334d;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e1e8f2;
  box-shadow: 0 10px 28px rgba(31, 56, 92, 0.08);
}

.agent-page .message-row.outgoing .message-bubble {
  color: #0f3f86;
  background: linear-gradient(180deg, #eaf3ff, #dfeaff);
  border-color: #c8dcff;
}

.agent-page .message-row.outgoing.ai .message-bubble {
  color: #075046;
  background: #e9fbf3;
  border-color: #c7f2df;
}

.agent-page .message-row.system .message-bubble {
  max-width: 76%;
  padding: 8px 18px;
  color: #78869a;
  background: rgba(224, 231, 240, 0.86);
  border: 0;
  box-shadow: none;
}

.agent-page .message-author {
  margin-bottom: 4px;
  color: #62728a;
  font-size: 12px;
  font-weight: 800;
}

.agent-page .message-time {
  margin-top: 5px;
  color: #7a889b;
  font-size: 11px;
}

.agent-page .quick-replies {
  min-height: 52px;
  padding: 10px 16px 8px;
  border-top: 1px solid #edf1f7;
  background: rgba(255, 255, 255, 0.94);
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.agent-page .quick-replies button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  color: #27446e;
  background: #fff;
  font-weight: 800;
  box-shadow: 0 7px 16px rgba(31, 56, 92, 0.05);
}

.agent-page .quick-replies button:hover {
  color: var(--agent-blue);
  border-color: #bfd4ff;
  background: #f6f9ff;
}

.agent-page .composer {
  min-height: 100px;
  padding: 12px 16px 14px;
  border-top: 1px solid #edf1f7;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(34px, auto) 34px;
  gap: 8px;
  background: #fff;
}

.agent-page .composer textarea {
  width: 100%;
  min-height: 34px;
  max-height: 88px;
  padding: 6px 0;
  border: 0;
  resize: none;
  color: #253550;
  background: transparent;
  box-shadow: none;
}

.agent-page .composer textarea:focus {
  box-shadow: none;
}

.composer-bar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-tools {
  gap: 14px;
  min-width: 0;
}

.agent-page .composer-tools button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 7px;
  color: #607188;
}

.send-group {
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.22);
}

.agent-page .composer .send-group button {
  height: 38px;
  border-radius: 0;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #2d73ff, #1d55d7);
  font-weight: 900;
}

.agent-page .composer #agentSend {
  min-width: 92px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.agent-page .composer #agentSend svg {
  width: 16px;
  height: 16px;
}

.agent-page .composer .send-more {
  min-width: 32px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.agent-page .customer-pane {
  border-left: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.agent-page .customer-pane header {
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 0;
}

.agent-page .customer-pane h2 {
  margin: 0;
  color: #172741;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
}

.agent-page .customer-pane h2 svg {
  color: var(--agent-blue);
}

.customer-scroll {
  min-height: 0;
  padding: 0 16px 16px;
  overflow: auto;
}

.agent-page .customer-summary {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  border: 0;
  background: transparent;
}

.customer-profile {
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfdff, #f7fbff);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
}

.customer-profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 18px;
}

.customer-profile-main {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: start;
}

.customer-profile-main strong,
.customer-profile-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-profile-main strong {
  color: #172741;
  font-size: 14px;
}

.customer-profile-main span {
  color: #66768d;
  font-size: 12px;
}

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

.agent-page .summary-row {
  min-width: 0;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid #e7edf5;
  border-radius: 8px;
  background: #fff;
  display: grid;
  align-content: center;
  gap: 4px;
}

.agent-page .summary-row span,
.agent-page .summary-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-page .summary-row span {
  color: #7a889b;
  font-size: 12px;
}

.agent-page .summary-row strong {
  color: #273852;
  font-size: 13px;
}

.customer-tabs {
  margin-top: 16px;
  border-bottom: 1px solid #e6edf6;
  display: flex;
  gap: 22px;
}

.customer-tabs button {
  min-height: 40px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #62728a;
  font-weight: 800;
}

.customer-tabs button.active {
  color: var(--agent-blue);
  border-bottom-color: var(--agent-blue);
}

.agent-page .customer-form {
  margin-top: 14px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  overflow: visible;
}

.agent-page .customer-form label {
  min-width: 0;
  color: #405069;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  gap: 7px;
}

.agent-page .customer-form label.full,
.agent-page .customer-form label:nth-last-of-type(-n + 2),
.agent-page .customer-form button,
.agent-page .customer-toast,
.agent-page .save-toast {
  grid-column: 1 / -1;
}

.agent-page .customer-form input,
.agent-page .customer-form select,
.agent-page .customer-form textarea {
  min-width: 0;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #dfe7f2;
  background: #fff;
  color: #20324d;
}

.agent-page .customer-form input,
.agent-page .customer-form select {
  min-height: 38px;
  padding: 0 12px;
}

.agent-page .customer-form textarea {
  min-height: 76px;
  resize: vertical;
  padding: 10px 12px;
}

.agent-page .customer-form input:focus,
.agent-page .customer-form select:focus,
.agent-page .customer-form textarea:focus {
  border-color: #b7ccff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.agent-page .customer-form button[type="submit"] {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #2d73ff, #1d55d7);
  font-weight: 900;
  box-shadow: 0 9px 22px rgba(37, 99, 235, 0.2);
}

.agent-page .customer-toast,
.agent-page .save-toast {
  min-height: 18px;
  color: #13a35a;
  font-size: 12px;
  margin: 0;
}

.agent-page ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.agent-page ::-webkit-scrollbar-thumb {
  background: #c9d4e4;
  border-radius: 999px;
}

.agent-page ::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1280px) {
  .agent-layout {
    grid-template-columns: 300px minmax(480px, 1fr) 340px;
    padding: 14px;
    gap: 12px;
  }

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

@media (max-width: 1080px) {
  .agent-layout {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .agent-page .customer-pane {
    display: none;
  }
}

/* Admin console */
.admin-page {
  min-height: 100vh;
  background: #f3f7fc;
}

.admin-page .admin-console {
  --admin-blue: #2563eb;
  --admin-blue-deep: #1d4ed8;
  --admin-navy: #061f3d;
  --admin-navy-deep: #03162d;
  --admin-text: #14233b;
  --admin-muted: #718096;
  --admin-line: #dce6f3;
  --admin-card: rgba(255, 255, 255, 0.96);
  --admin-shadow: 0 16px 42px rgba(28, 50, 84, 0.08);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  color: var(--admin-text);
  background:
    linear-gradient(180deg, #f8fbff 0%, #f1f6fc 100%);
}

.admin-page .admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px 16px;
  color: #dce9ff;
  background:
    linear-gradient(180deg, #061f3d 0%, #082b52 54%, #061b35 100%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  overflow: hidden;
}

.admin-brand,
.admin-menu button,
.admin-profile,
.card-title,
.card-actions,
.switch-field,
.admin-save-button,
.admin-logout {
  display: flex;
  align-items: center;
}

.admin-brand {
  gap: 12px;
  padding: 2px 8px;
  min-width: 0;
}

.admin-brand strong {
  color: #fff;
  font-size: 18px;
  letter-spacing: 0;
  white-space: nowrap;
}

.admin-brand-icon {
  width: 34px;
  height: 34px;
  color: #3b82f6;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.admin-brand-icon svg,
.admin-menu svg,
.admin-save-button svg,
.admin-logout svg,
.card-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.admin-menu {
  display: grid;
  align-content: start;
  gap: 10px;
}

.admin-page .admin-menu button {
  width: 100%;
  min-height: 46px;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #d3def1;
  font-size: 15px;
  font-weight: 800;
  text-align: left;
}

.admin-page .admin-menu button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.admin-page .admin-menu button.active {
  color: #fff;
  background: linear-gradient(135deg, #2f7cff, #1357ef);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28);
}

.admin-profile {
  min-width: 0;
  gap: 10px;
  padding: 16px 8px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #95d5ff, #5b7cff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.admin-profile div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

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

.admin-profile strong {
  color: #fff;
  font-size: 14px;
}

.admin-profile span {
  color: #52df83;
  font-size: 12px;
}

.admin-logout {
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #dce9ff;
  background: transparent;
  justify-content: center;
  flex: 0 0 auto;
}

.admin-logout:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.admin-page .admin-content {
  min-width: 0;
  height: 100vh;
  padding: 26px 28px 34px;
  overflow: auto;
}

.admin-page .admin-section {
  display: grid;
  gap: 16px;
}

.admin-page-head {
  min-height: 56px;
  padding: 0 0 8px;
  align-items: flex-start;
}

.admin-page-head h1 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  line-height: 1.25;
}

.admin-page-head p {
  margin: 8px 0 0;
  color: #7b8798;
  line-height: 1.5;
}

.admin-save-button {
  min-width: 138px;
  min-height: 44px;
  gap: 8px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2f7cff, #1456e8);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.admin-page .admin-card {
  min-width: 0;
  background: var(--admin-card);
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
}

.admin-page .settings-grid {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.admin-page .config-card {
  padding: 22px 24px 20px;
  display: grid;
  gap: 16px;
}

.card-title {
  min-width: 0;
  gap: 12px;
}

.card-icon {
  width: 28px;
  height: 28px;
  color: var(--admin-blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.card-title h2 {
  margin: 0;
  color: #172033;
  font-size: 19px;
  line-height: 1.25;
}

.card-title p {
  margin: 5px 0 0;
  color: #8a96a8;
  font-size: 13px;
}

.card-fields {
  min-width: 0;
  display: grid;
  gap: 16px 34px;
}

.card-fields.two-columns {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.admin-page .field {
  min-width: 0;
  color: #344258;
  font-size: 14px;
  font-weight: 800;
}

.admin-page .field.wide,
.admin-page .wide {
  grid-column: 1 / -1;
}

.admin-page input,
.admin-page textarea,
.admin-page select {
  min-width: 0;
  width: 100%;
  border: 1px solid #d8e2ef;
  border-radius: 7px;
  background: #fff;
  color: #1f2d43;
  box-shadow: inset 0 1px 1px rgba(20, 40, 70, 0.02);
}

.admin-page input,
.admin-page select {
  min-height: 40px;
  padding: 0 12px;
}

.admin-page textarea {
  min-height: 76px;
  padding: 10px 12px;
  resize: vertical;
}

.admin-page input:focus,
.admin-page textarea:focus,
.admin-page select:focus {
  border-color: #9fc0ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field-note {
  color: #8a96a8;
  font-size: 12px;
  font-weight: 500;
}

.weekday-picker {
  min-width: 0;
  min-height: 40px;
  padding: 5px 10px;
  border: 1px solid #d8e2ef;
  border-radius: 7px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.weekday-picker button {
  width: 36px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid #d8e2ef;
  border-radius: 6px;
  color: #607086;
  background: #f5f8fc;
  font-weight: 900;
}

.weekday-picker button.active {
  color: #fff;
  border-color: var(--admin-blue);
  background: linear-gradient(135deg, #2f7cff, #1456e8);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.2);
}

.weekday-picker button:hover {
  border-color: #aac5ff;
  color: var(--admin-blue);
}

.weekday-picker button.active:hover {
  color: #fff;
}

.switch-field {
  min-height: 40px;
  justify-content: flex-start;
  gap: 14px;
  align-content: center;
}

.switch-field > span {
  color: #344258;
}

.admin-page .switch-select {
  width: 86px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: #1456e8;
  background: #edf4ff;
  border-color: #bcd2ff;
  font-weight: 900;
  flex: 0 0 auto;
}

.color-field input[type="color"] {
  height: 40px;
  padding: 5px;
}

.admin-page .embed-panel {
  padding: 22px 24px;
  display: grid;
  gap: 14px;
}

.admin-page .embed-panel pre {
  max-height: 180px;
  margin: 0;
  padding: 16px;
  color: #d7e4f7;
  background: #0f1d33;
  border-radius: 8px;
  border: 1px solid #1d3150;
  overflow: auto;
}

.card-actions {
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.admin-page .save-toast {
  min-height: 20px;
  margin: 0;
  color: #0f9f5c;
  font-weight: 800;
}

.admin-page .primary,
.admin-page .ghost {
  border-radius: 7px;
  font-weight: 900;
}

.admin-page .ghost {
  border-color: #d8e2ef;
  color: #284160;
  background: #fff;
}

.admin-page .ghost:hover {
  color: var(--admin-blue);
  border-color: #bcd2ff;
  background: #f6f9ff;
}

.admin-page .inline-form {
  padding: 16px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 120px auto auto;
  gap: 10px;
  align-items: center;
}

.admin-page .table-wrap {
  border-radius: 8px;
  overflow: auto;
}

.admin-page table {
  min-width: 720px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.admin-page th,
.admin-page td {
  padding: 14px 16px;
  border-bottom: 1px solid #edf1f7;
  white-space: nowrap;
}

.admin-page th {
  color: #7b8798;
  background: #f8fbff;
  font-size: 13px;
  font-weight: 900;
}

.admin-page td {
  color: #26364f;
  background: #fff;
}

.admin-page tr:last-child td {
  border-bottom: 0;
}

.admin-page tr.record-unread td {
  background: #fff8f8;
}

.admin-page tr:hover td {
  background: #f8fbff;
}

.admin-page .table-empty {
  height: 180px;
  color: #7b8798;
  text-align: center;
}

.admin-page .table-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-page .text-button {
  color: var(--admin-blue);
  font-weight: 900;
}

.admin-page .danger {
  color: #e11d48;
}

.admin-page .faq-form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.admin-page .faq-list {
  display: grid;
  gap: 12px;
}

.admin-page .faq-item {
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--admin-shadow);
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.admin-page .faq-item strong,
.admin-page .faq-item p {
  margin: 0;
}

.admin-page .faq-item p {
  margin-top: 8px;
  color: #66768c;
  line-height: 1.7;
}

.admin-page .stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.admin-page .stat-card {
  min-height: 116px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--admin-shadow);
  padding: 18px;
  display: grid;
  align-content: space-between;
  gap: 14px;
}

.admin-page .stat-card span {
  color: #7b8798;
  font-size: 13px;
  font-weight: 800;
}

.admin-page .stat-card strong {
  color: #15243d;
  font-size: 30px;
  line-height: 1;
}

.admin-page .records-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.admin-page .profiles-layout {
  grid-template-columns: minmax(620px, 1fr) minmax(420px, 0.78fr);
}

.admin-page .profiles-layout table {
  min-width: 980px;
}

.admin-page .profile-charts {
  display: grid;
  gap: 16px;
}

.admin-page .profile-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.admin-page .profile-metric-card {
  min-height: 104px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--admin-shadow);
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.admin-page .profile-metric-card span,
.admin-page .profile-metric-card em {
  color: #7b8798;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.admin-page .profile-metric-card strong {
  color: #15243d;
  font-size: 28px;
  line-height: 1;
}

.admin-page .profile-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 14px;
}

.admin-page .profile-chart-card {
  min-height: 230px;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.admin-page .profile-chart-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-page .profile-chart-card header strong {
  color: #15243d;
  font-size: 15px;
}

.admin-page .profile-chart-card header span {
  color: #7b8798;
  font-size: 12px;
  font-weight: 800;
}

.admin-page .profile-bars {
  display: grid;
  gap: 12px;
}

.admin-page .profile-bar-row {
  display: grid;
  grid-template-columns: minmax(78px, 0.9fr) minmax(90px, 1.4fr) 38px 42px;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.admin-page .profile-bar-row > span,
.admin-page .profile-bar-row em {
  color: #66768c;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-page .profile-bar-row strong {
  color: #273852;
  font-size: 13px;
  text-align: right;
}

.admin-page .profile-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #eef3fa;
  overflow: hidden;
}

.admin-page .profile-bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7cff, #5fb5ff);
}

.admin-page .profile-bar-track i.hot,
.admin-page .profile-bar-track i.withContact {
  background: linear-gradient(90deg, #ef4444, #fb7185);
}

.admin-page .profile-bar-track i.warm,
.admin-page .profile-bar-track i.conversation {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.admin-page .profile-bar-track i.cold,
.admin-page .profile-bar-track i.visitor {
  background: linear-gradient(90deg, #3b82f6, #93c5fd);
}

.admin-page .profile-split {
  display: grid;
  gap: 12px;
}

.admin-page .profile-split-item {
  position: relative;
  min-height: 64px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}

.admin-page .profile-split-item span,
.admin-page .profile-split-item em {
  position: relative;
  z-index: 1;
  color: #66768c;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.admin-page .profile-split-item strong {
  position: relative;
  z-index: 1;
  color: #15243d;
  font-size: 22px;
  text-align: right;
}

.admin-page .profile-split-item i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, #2f7cff, #5fb5ff);
}

.admin-page .profile-split-item.noContact i,
.admin-page .profile-split-item.visitor i {
  background: linear-gradient(90deg, #94a3b8, #cbd5e1);
}

.admin-page .records-pagination {
  min-height: 58px;
  padding: 12px 14px;
  border-top: 1px solid #edf1f7;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pagination-summary {
  color: #66768c;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.pagination-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination-actions button,
.pagination-ellipsis {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
}

.pagination-actions button {
  border: 1px solid #d8e2ef;
  color: #284160;
  background: #fff;
}

.pagination-actions button:hover {
  color: var(--admin-blue);
  border-color: #bcd2ff;
  background: #f6f9ff;
}

.pagination-actions button.active {
  color: #fff;
  border-color: var(--admin-blue);
  background: linear-gradient(135deg, #2f7cff, #1456e8);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.pagination-actions button:disabled {
  color: #a7b1c0;
  background: #f4f7fb;
  border-color: #e3eaf3;
  box-shadow: none;
}

.pagination-ellipsis {
  min-width: 22px;
  padding: 0 2px;
  color: #8a96a8;
}

.admin-page .record-detail {
  min-height: 520px;
  max-height: calc(100vh - 138px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.admin-page .record-detail > span,
.admin-page .record-source {
  color: #7b8798;
}

.admin-page .record-detail-head {
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f7;
}

.admin-page .visitor-meta-panel {
  border: 1px solid #dbe8ff;
  border-radius: 8px;
  background: #f7fbff;
  padding: 14px;
}

.admin-page .visitor-meta-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-page .visitor-meta-grid strong {
  color: #273852;
}

.admin-page .profile-lead {
  min-width: 64px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
}

.admin-page .profile-lead.hot {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #ffd6d2;
}

.admin-page .profile-lead.warm {
  color: #9a5b00;
  background: #fff7e6;
  border: 1px solid #ffe0a3;
}

.admin-page .profile-lead.cold {
  color: #2f5d8a;
  background: #eef6ff;
  border: 1px solid #d5e9ff;
}

.admin-page .profile-summary-row {
  padding: 12px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #66768c;
  font-size: 13px;
  line-height: 1.5;
}

.admin-page .profile-recent-list {
  display: grid;
  gap: 8px;
}

.admin-page .profile-recent-list div {
  padding: 10px 12px;
  border: 1px solid #e0e8f3;
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 4px;
}

.admin-page .profile-recent-list strong {
  color: #273852;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.admin-page .profile-recent-list span {
  color: #7b8798;
  font-size: 12px;
}

.admin-page .record-message {
  border-color: #e0e8f3;
  box-shadow: 0 10px 22px rgba(26, 48, 80, 0.06);
}

.admin-page .record-message.service {
  color: #0f3f86;
  background: #eaf3ff;
  border-color: #c8dcff;
}

.admin-page .record-message.visitor {
  background: #fff;
}

.admin-page .record-message.system {
  color: #66768c;
  background: #eef2f7;
  border: 0;
  box-shadow: none;
}

.admin-page ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.admin-page ::-webkit-scrollbar-thumb {
  background: #c7d4e5;
  border-radius: 999px;
}

.admin-page ::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1180px) {
  .admin-page .admin-console {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .card-fields.two-columns,
  .admin-page .records-layout {
    grid-template-columns: 1fr;
  }

  .admin-page .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-page .stats-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .admin-page .profile-metrics,
  .admin-page .profile-chart-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .admin-page .admin-console {
    grid-template-columns: 1fr;
  }

  .admin-page .admin-sidebar {
    position: static;
    height: auto;
    padding: 14px;
    gap: 14px;
  }

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

  .admin-page .admin-content {
    height: auto;
    min-height: 100vh;
    padding: 18px;
  }

  .admin-page-head,
  .card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-page .records-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination-summary {
    white-space: normal;
  }

  .admin-save-button,
  .admin-page .inline-form {
    width: 100%;
  }

  .admin-page .inline-form,
  .admin-page .stats-grid,
  .admin-page .profile-metrics,
  .admin-page .profile-chart-grid {
    grid-template-columns: 1fr;
  }

  .admin-page .profile-bar-row {
    grid-template-columns: minmax(76px, 1fr) minmax(88px, 1.4fr) 36px;
  }

  .admin-page .profile-bar-row em {
    display: none;
  }
}
