:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f0f5f7;
  --text: #152022;
  --muted: #657478;
  --border: #dfe7ea;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #047857;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

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

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

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

.sidebar {
  background: #102124;
  color: #e9f4f2;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-weight: 750;
  letter-spacing: 0;
  font-size: 22px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #15b8a6, #2563eb);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

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

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #b8c9cc;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.nav small {
  color: #6ee7d8;
}

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

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

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  max-width: 760px;
}

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

.button,
button.button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.blue {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

.button.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button.small {
  padding: 7px 10px;
  font-size: 12px;
}

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

.grid > *,
.split > *,
.panel,
.panel-body,
.field,
.table-wrap {
  min-width: 0;
}

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

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

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 18px;
}

.metric {
  padding: 18px;
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
}

.metric .value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 8px;
}

.metric .hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #e8f5f2;
  color: var(--ok);
}

.status.warn {
  background: #fff7ed;
  color: var(--warn);
}

.status.danger {
  background: #fef2f2;
  color: var(--danger);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

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

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

.field label {
  font-size: 13px;
  font-weight: 700;
}

.input,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}

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

.builder-field {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 140px 76px 38px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdfe;
}

.builder-field > label {
  white-space: nowrap;
}

.builder-field [data-field-options] {
  grid-column: 1 / 4;
}

.builder-field .remove-field {
  grid-column: 4;
  grid-row: 1;
  width: 38px;
  height: 38px;
  padding: 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.chat-demo,
.widget-preview {
  background: #f8fbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.chat-log {
  height: 320px;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 88%;
  border-radius: 12px;
  padding: 10px 12px;
  background: #e8f5f2;
  align-self: flex-start;
  font-size: 14px;
}

.bubble.user {
  background: #2563eb;
  color: #fff;
  align-self: flex-end;
}

.chat-send {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.chat-send input {
  flex: 1;
}

.public-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, .12), transparent 34%), var(--bg);
}

.public-form {
  width: min(720px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.public-form h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.public-form .step {
  display: none;
}

.public-form .step.active {
  display: block;
}

.form-progress {
  height: 6px;
  border-radius: 999px;
  background: #e5edf0;
  overflow: hidden;
  margin: 18px 0;
}

.form-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.notice {
  padding: 12px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 8px;
  margin-bottom: 14px;
}

.notice.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h1 {
  margin: 10px 0 8px;
  font-size: 26px;
  line-height: 1.15;
}

.login-brand {
  color: var(--text);
  margin-bottom: 14px;
}

.user-box {
  display: grid;
  gap: 7px;
  margin-top: 22px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  color: #d8e7e5;
  font-size: 13px;
}

.user-box span {
  color: #9bb1b4;
  word-break: break-word;
}

.user-box .button {
  width: 100%;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .14);
  color: #fff;
}

.footer-note {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
}

.codebox {
  background: #0f172a;
  color: #dbeafe;
  padding: 14px;
  border-radius: 8px;
  max-width: 100%;
  overflow: auto;
}

.hidden-hp {
  position: absolute;
  left: -10000px;
  opacity: 0;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .split {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

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

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

  .topbar h1 {
    font-size: 25px;
  }
}
