:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --surface-3: #eef3ef;
  --text: #101214;
  --muted: #58625d;
  --subtle: #7b847f;
  --border: #dce4de;
  --border-strong: #c5d0c8;
  --green: #10d078;
  --green-strong: #087b49;
  --green-soft: #e3faee;
  --dark: #0c0d0f;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(16, 24, 20, 0.08);
  --radius: 18px;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 86% -10%, rgba(16, 208, 120, 0.18), transparent 26rem),
    linear-gradient(180deg, #fbfdfb 0%, var(--bg) 44%);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--green);
  color: var(--dark);
  font-weight: 760;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  background: #18df85;
  transform: translateY(-1px);
}

.portal-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  gap: 18px;
  padding: 18px;
}

body[data-auth-mode="login"] .portal-shell,
body[data-auth-mode="password"] .portal-shell {
  display: block;
  padding: 0;
}

body[data-auth-mode="login"] .sidebar,
body[data-auth-mode="password"] .sidebar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 18px;
  display: flex;
  height: calc(100vh - 36px);
  flex-direction: column;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0%, rgba(16, 208, 120, 0.2), transparent 18rem), var(--dark);
  box-shadow: 0 24px 70px rgba(17, 19, 21, 0.2);
}

.sidebar-top {
  padding: 4px 8px 22px;
}

.brand,
.auth-copy strong {
  display: block;
  color: var(--text);
  font-size: 34px;
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.045em;
}

.sidebar .brand {
  color: #fff;
}

.sidebar-top span {
  display: inline-flex;
  margin-top: 12px;
  padding: 5px 10px;
  border: 1px solid rgba(16, 208, 120, 0.28);
  border-radius: 999px;
  background: rgba(16, 208, 120, 0.1);
  color: var(--green);
  font-size: 12px;
  font-weight: 760;
}

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

.sidebar a {
  display: flex;
  align-items: center;
  min-height: 43px;
  padding: 0 12px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar a:hover,
.sidebar a.is-active {
  background: var(--green);
  color: var(--dark);
}

.session-card {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.session-card span {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  text-overflow: ellipsis;
}

.session-card button {
  min-height: 38px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.content {
  display: grid;
  align-content: start;
  gap: 18px;
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 10px 0 28px;
}

body[data-auth-mode="login"] .content,
body[data-auth-mode="password"] .content {
  min-height: 100vh;
  place-items: center;
  width: 100%;
  padding: 24px;
}

.auth-panel {
  width: min(100%, 410px);
}

.auth-panel.is-visible {
  display: grid;
  gap: 22px;
}

.auth-copy {
  text-align: center;
}

.auth-copy strong {
  margin-bottom: 28px;
}

.auth-copy h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 780;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.auth-copy span,
.panel-head span,
.page-title span,
.embed span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.auth-panel form,
.panel,
.metrics article,
.app-header {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.auth-panel form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: #33413a;
  font-size: 13px;
  font-weight: 720;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  outline: 0;
  background: #fff;
  color: var(--text);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input,
select {
  min-height: 44px;
  padding: 0 13px;
}

input[readonly] {
  background: var(--surface-2);
  color: #46524b;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 208, 120, 0.16);
}

.auth-panel small {
  color: var(--danger);
  font-size: 13px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 152px;
  padding: 28px;
  background: radial-gradient(circle at 92% 0%, rgba(16, 208, 120, 0.18), transparent 18rem), #fff;
}

.page-title h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 780;
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.page-title span {
  max-width: 660px;
  margin-top: 10px;
}

.account-switcher {
  display: grid;
  width: min(100%, 360px);
  gap: 10px;
}

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

.metrics article {
  padding: 18px;
  background: linear-gradient(180deg, #fff, #f8fbf7);
}

.metrics span,
.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metrics strong,
.status-grid strong {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-size: 30px;
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.04em;
}

.owner-grid,
.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(440px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 22px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 23px;
  font-weight: 780;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.account-list {
  display: grid;
  gap: 9px;
}

.account-item {
  display: grid;
  width: 100%;
  min-height: 64px;
  justify-items: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.account-item:hover,
.account-item.is-selected {
  border-color: rgba(16, 208, 120, 0.7);
  background: var(--green-soft);
}

.account-item span {
  font-weight: 780;
}

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

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

.status-grid div,
.task-list div,
.conversation-list article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.status-grid strong {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
}

.task-list,
.conversation-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-list strong,
.conversation-list strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.task-list span,
.conversation-list span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.settings {
  display: grid;
  gap: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.widget-preview {
  overflow: hidden;
  max-width: 430px;
  margin: 2px auto 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(17, 19, 21, 0.1);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.preview-toolbar button {
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.preview-toolbar div {
  display: flex;
  gap: 10px;
}

.preview-toolbar span {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--dark);
}

.preview-messages {
  display: grid;
  align-content: start;
  min-height: 310px;
  gap: 10px;
  padding: 18px;
}

.preview-botline {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.preview-botline > span {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: visible;
  border-radius: 999px;
  background: linear-gradient(135deg, #f4f7f4, #d8f4e4);
  color: #111315;
}

.preview-botline > span::after {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 208, 120, 0.16);
  content: "";
}

.preview-botline svg {
  width: 22px;
  height: 22px;
}

.preview-botline img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.preview-botline strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.preview-messages p {
  width: fit-content;
  max-width: 88%;
  margin: 0;
  padding: 10px 13px;
  border-radius: 10px;
  background: #e9ebe9;
  color: #202326;
  font-size: 14px;
}

.preview-messages .user {
  justify-self: end;
  border-radius: 999px;
  background: var(--green);
  color: var(--dark);
  font-weight: 700;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 18px 16px;
}

.preview-actions button {
  min-height: 36px;
  font-size: 13px;
}

.preview-input {
  margin: 0 16px 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--subtle);
}

.preview-powered {
  padding: 0 0 14px;
  color: var(--subtle);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
}

.preview-powered strong {
  color: var(--text);
}

pre {
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid #202326;
  border-radius: 14px;
  background: var(--dark);
  color: var(--green);
  font-size: 13px;
  line-height: 1.55;
}

code {
  color: var(--green-strong);
  font-weight: 750;
}

@media (max-width: 1080px) {
  .portal-shell,
  .owner-grid,
  .workspace,
  .metrics {
    grid-template-columns: 1fr;
  }

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

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

  .session-card {
    margin-top: 18px;
  }
}

@media (max-width: 720px) {
  .portal-shell {
    padding: 10px;
  }

  .content {
    padding: 0;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
    padding: 20px;
  }

  .sidebar {
    padding: 16px;
  }

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

  .panel,
  .auth-panel form {
    padding: 18px;
  }

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

  .widget-preview {
    max-width: none;
  }
}
