:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #152033;
  --muted: #64748b;
  --line: #dce4ef;
  --line-strong: #c8d4e3;
  --accent: #0f8b7d;
  --accent-dark: #0b6d62;
  --accent-soft: #e8f6f3;
  --blue: #2563eb;
  --violet: #7c3aed;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 44%, #eef3f8 100%);
}

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

button {
  min-height: 40px;
  width: fit-content;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #16a394);
  box-shadow: 0 8px 18px rgba(15, 139, 125, 0.18);
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 139, 125, 0.22);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
  box-shadow: none;
}

button.secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}

button.secondary:hover {
  color: var(--accent-dark);
  border-color: rgba(15, 139, 125, 0.42);
  background: var(--accent-soft);
}

.link-button {
  color: var(--accent-dark);
  background: transparent;
  box-shadow: none;
  padding: 0 6px;
}

.link-button:hover {
  box-shadow: none;
  background: transparent;
  color: #064e47;
}

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

.admin-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  color: #eaf3ff;
  background:
    linear-gradient(180deg, rgba(17, 29, 48, 0.98), rgba(13, 27, 43, 0.98)),
    #111d30;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
  padding: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #073f3a;
  background: linear-gradient(135deg, #dffcf6, #b7f4ea);
  box-shadow: 0 12px 28px rgba(20, 184, 166, 0.18);
  font-weight: 900;
  letter-spacing: 0.02em;
}

.brand strong,
.brand span,
.admin-nav a {
  display: block;
}

.brand strong {
  color: #ffffff;
  font-size: 15px;
}

.brand span {
  margin-top: 2px;
  color: rgba(226, 236, 247, 0.7);
  font-size: 12px;
}

.admin-nav nav {
  display: grid;
  gap: 6px;
}

.admin-nav a {
  position: relative;
  border-radius: 8px;
  padding: 12px 12px 12px 38px;
  color: rgba(226, 236, 247, 0.82);
  text-decoration: none;
  font-weight: 750;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.admin-nav a::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(190, 217, 231, 0.72);
  border-radius: 50%;
  transform: translateY(-50%);
}

.admin-nav a:hover,
.admin-nav a.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.admin-nav a.active::before {
  border-color: #7ef4e7;
  background: #7ef4e7;
  box-shadow: 0 0 0 4px rgba(126, 244, 231, 0.14);
}

.admin-main {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 30px;
  display: grid;
  gap: 22px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(220, 228, 239, 0.84);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.88)),
    var(--panel);
  box-shadow: var(--shadow-soft);
}

header p {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

header h1 {
  margin: 0;
  color: #111827;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

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

.login-status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.login-status.signed-in {
  color: var(--accent-dark);
  border-color: rgba(15, 139, 125, 0.24);
  background: var(--accent-soft);
}

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

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

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

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

.account-section {
  display: grid;
}

.account-card {
  width: min(760px, 100%);
}

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

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

.card,
.stat {
  border: 1px solid rgba(220, 228, 239, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.card {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.card h2 {
  margin: 0;
  color: #111827;
  font-size: 19px;
  letter-spacing: 0;
}

.card p,
.hint {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.75;
}

.stat {
  position: relative;
  min-height: 126px;
  padding: 20px;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 18px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 139, 125, 0.16), rgba(37, 99, 235, 0.12));
}

.stat span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 14px;
  color: #0f172a;
  font-size: 34px;
  line-height: 1;
}

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

.field label {
  color: #334155;
  font-size: 14px;
  font-weight: 850;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--ink);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input {
  height: 44px;
  padding: 0 13px;
}

select {
  height: 44px;
  padding: 0 13px;
}

textarea {
  min-height: 112px;
  padding: 12px 13px;
  resize: vertical;
  line-height: 1.6;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(15, 139, 125, 0.78);
  box-shadow: 0 0 0 4px rgba(15, 139, 125, 0.12);
  background: #fcfffe;
}

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

.inline-input {
  width: min(180px, 100%);
}

.split-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

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

.color-choice {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  box-shadow: none;
}

.color-choice::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.color-choice.active {
  border-color: rgba(15, 139, 125, 0.58);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(15, 139, 125, 0.1);
}

.check-row {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-weight: 800;
  line-height: 1.4;
}

.check-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  box-shadow: none;
  accent-color: var(--accent);
}

.feedback {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.feedback.ok {
  color: var(--accent-dark);
}

.feedback.error {
  color: var(--danger);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: var(--panel-soft);
  color: #334155;
  line-height: 1.6;
}

.visitor-board {
  display: grid;
  grid-template-columns: minmax(260px, 0.36fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.visitor-list {
  display: grid;
  gap: 10px;
}

.visitor-item {
  width: 100%;
  min-height: auto;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--panel-soft);
  box-shadow: none;
  text-align: left;
}

.visitor-item:hover {
  border-color: rgba(15, 139, 125, 0.36);
  background: #f2fbf8;
  box-shadow: none;
}

.visitor-item span,
.visitor-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.visitor-item small,
.visitor-item em,
.visitor-detail-head span {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.5;
}

.visitor-item small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.lead-badge,
.muted-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.lead-badge {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.muted-badge {
  color: var(--muted);
  background: #eef2f7;
}

.visitor-detail {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.visitor-detail-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.visitor-detail-head strong {
  display: block;
  color: #111827;
  font-size: 17px;
}

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

.contact-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--panel-soft);
}

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

.contact-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contact-grid strong {
  margin-top: 5px;
  color: var(--ink);
  word-break: break-word;
}

.visitor-messages {
  display: grid;
  gap: 10px;
}

.visitor-message {
  display: grid;
  gap: 6px;
}

.visitor-message span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.visitor-message p {
  width: fit-content;
  max-width: 86%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
  color: #334155;
  line-height: 1.65;
  white-space: pre-wrap;
}

.visitor-message.from-user {
  justify-items: end;
}

.visitor-message.from-user p {
  color: #03211e;
  border-color: rgba(15, 139, 125, 0.18);
  background: var(--accent-soft);
}

#widgetCode {
  min-height: 98px;
  color: #dff7ff;
  background: #0f172a;
  border-color: #1e293b;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.widget-preview {
  width: 100%;
  min-height: 420px;
  max-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(135deg, rgba(15, 139, 125, 0.08), rgba(37, 99, 235, 0.06)),
    #eef2f7;
}

.widget-preview iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

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

  .admin-nav {
    position: static;
    height: auto;
    padding: 16px;
  }

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

  .admin-main {
    padding: 18px;
  }

  header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .two,
  .three,
  .visitor-board,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .account-card {
    width: 100%;
  }
}

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

  .inline-actions,
  .color-row,
  .split-field {
    align-items: stretch;
    flex-direction: column;
  }

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

  button,
  .link-button {
    width: 100%;
    justify-content: center;
  }

  .check-row {
    width: 100%;
  }
}
