:root {
  color-scheme: light;
  --bg: #f3f7fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --line: #dce6f4;
  --text: #172033;
  --muted: #65758b;
  --blue: #1769ff;
  --blue-dark: #0b50d5;
  --green: #16a36a;
  --red: #d9304f;
  --orange: #f59e0b;
  --shadow: 0 20px 60px rgba(36, 60, 99, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(23, 105, 255, 0.16), transparent 26%),
    radial-gradient(circle at 82% 0%, rgba(22, 163, 106, 0.13), transparent 24%),
    linear-gradient(135deg, #f7fbff 0%, #eef4fb 45%, #f8fbff 100%);
  color: var(--text);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
textarea:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.68;
  animation: floatGlow 12s ease-in-out infinite alternate;
}

.ambient-one {
  width: 360px;
  height: 360px;
  left: -130px;
  top: 80px;
  background: rgba(23, 105, 255, 0.14);
}

.ambient-two {
  width: 300px;
  height: 300px;
  right: -120px;
  bottom: 60px;
  background: rgba(22, 163, 106, 0.12);
  animation-delay: -3s;
}

@keyframes floatGlow {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(24px, -18px, 0) scale(1.06);
  }
}

.app-shell {
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

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

.login-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid rgba(220, 230, 244, 0.95);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), #12b886);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 14px 30px rgba(23, 105, 255, 0.26);
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.login-brand h1 {
  margin: 2px 0 0;
  font-size: 30px;
  line-height: 1.15;
}

.login-copy {
  margin: 24px 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-form,
.settings-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: #34425b;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: 0;
  padding: 12px 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(23, 105, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(23, 105, 255, 0.12);
}

.login-form button,
.primary-button,
.secondary-button,
.ghost-button,
.reply-form button,
.public-actions a,
.doc-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.login-form button,
.primary-button,
.reply-form button,
.public-actions a:first-child {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 28px rgba(23, 105, 255, 0.22);
}

.login-form button:hover,
.primary-button:hover,
.reply-form button:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.secondary-button,
.public-actions a,
.doc-link {
  border: 1px solid var(--line);
  background: #fff;
  color: #1f3352;
}

.secondary-button:hover,
.public-actions a:hover,
.doc-link:hover {
  border-color: rgba(23, 105, 255, 0.4);
  transform: translateY(-1px);
}

.ghost-button {
  width: 100%;
  margin-top: auto;
  border: 1px solid rgba(220, 230, 244, 0.75);
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
}

.status-line {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dashboard-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-right: 1px solid rgba(220, 230, 244, 0.85);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  padding: 24px;
}

.sidebar-brand strong {
  display: block;
  font-size: 18px;
}

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

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tabs button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  border-radius: 12px;
  background: transparent;
  color: #516177;
  padding: 0 14px;
  text-align: left;
  font-weight: 800;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-tabs button:hover,
.nav-tabs button.is-active {
  background: #edf4ff;
  color: var(--blue);
}

#unreadBadge:not(:empty) {
  min-width: 22px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  padding: 3px 7px;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.metric-grid article,
.setup-card,
.conversation-list,
.chat-panel,
.customer-panel,
.table-wrap,
.settings-form {
  border: 1px solid rgba(220, 230, 244, 0.92);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 40px rgba(36, 60, 99, 0.08);
}

.metric-grid article {
  padding: 20px;
}

.metric-grid span {
  color: var(--muted);
  font-weight: 700;
}

.metric-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.setup-card {
  padding: 22px;
}

.setup-card h3,
.panel-heading h3,
.chat-header h3,
.customer-panel h3 {
  margin: 0;
  font-size: 18px;
}

.setup-card p,
.panel-heading p,
.chat-header p {
  color: var(--muted);
  line-height: 1.65;
}

dl {
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
}

dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  color: #23314a;
}

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

.panel-heading.compact {
  margin: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f6f9fd;
  color: #526071;
  font-size: 13px;
}

td {
  color: #2c3952;
}

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

.page-cell img,
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  object-fit: cover;
  background: #dfe8f6;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  background: #e8f8ef;
  color: #0b7c4b;
}

.pill.warn {
  background: #fff5db;
  color: #936006;
}

.pill.off {
  background: #f2f5f9;
  color: #6a788c;
}

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

.tiny-button {
  border-radius: 9px;
  background: #edf4ff;
  color: var(--blue);
  padding: 7px 10px;
  font-weight: 800;
}

.tiny-danger {
  background: #fff0f3;
  color: var(--red);
}

.inbox-view {
  display: grid;
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr) minmax(230px, 290px);
  gap: 14px;
  min-height: calc(100vh - 150px);
}

.conversation-list,
.chat-panel,
.customer-panel {
  min-height: 620px;
  overflow: hidden;
}

.conversation-scroll {
  max-height: calc(100vh - 245px);
  overflow: auto;
  padding: 10px;
}

.conversation-item {
  width: 100%;
  display: grid;
  gap: 7px;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  padding: 12px;
  text-align: left;
  transition: background 0.2s ease, transform 0.2s ease;
}

.conversation-item:hover,
.conversation-item.is-selected {
  background: #edf4ff;
}

.conversation-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

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

.conversation-item small,
.conversation-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.unread-dot {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.message-thread {
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.6), rgba(255, 255, 255, 0));
}

.message {
  max-width: min(72%, 620px);
  display: grid;
  gap: 5px;
}

.message p {
  margin: 0;
  border-radius: 16px;
  padding: 11px 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.message.inbound {
  align-self: flex-start;
}

.message.inbound p {
  background: #eef4fb;
}

.message.outbound {
  align-self: flex-end;
  text-align: right;
}

.message.outbound p {
  background: var(--blue);
  color: #fff;
}

.reply-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.customer-panel {
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.settings-form {
  max-width: 780px;
  padding: 22px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.switch-row input {
  width: 22px;
  height: 22px;
}

.secondary-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.public-page,
.doc-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.public-shell,
.doc-shell {
  width: min(760px, 100%);
}

.public-card,
.doc-shell {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  padding: 34px;
}

.public-card h1,
.doc-shell h1 {
  margin: 18px 0 10px;
  font-size: 34px;
}

.public-card p,
.doc-shell p {
  color: var(--muted);
  line-height: 1.75;
}

.public-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.doc-shell h2 {
  margin: 28px 0 6px;
  font-size: 20px;
}

.doc-link {
  margin-top: 24px;
}

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

  .inbox-view {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .customer-panel {
    grid-column: 1 / -1;
    min-height: 0;
  }
}

@media (max-width: 860px) {
  .dashboard-view {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    gap: 16px;
  }

  .nav-tabs {
    display: flex;
    overflow: auto;
    padding-bottom: 4px;
  }

  .nav-tabs button {
    white-space: nowrap;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > * {
    flex: 1;
  }

  .metric-grid,
  .setup-grid,
  .inbox-view {
    grid-template-columns: 1fr;
  }

  .conversation-list,
  .chat-panel,
  .customer-panel {
    min-height: 0;
  }

  .conversation-scroll {
    max-height: 340px;
  }

  .chat-panel {
    min-height: 600px;
  }

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

@media (max-width: 540px) {
  .login-card,
  .public-card,
  .doc-shell {
    padding: 24px;
    border-radius: 18px;
  }

  .metric-grid strong {
    font-size: 28px;
  }

  .chat-header {
    display: grid;
  }

  .message {
    max-width: 88%;
  }
}
