:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --ink: #10202b;
  --muted: #667789;
  --line: #d9e3ea;
  --navy: #092d44;
  --teal: #10c7a7;
  --teal-dark: #087c70;
  --coral: #ff7a45;
  --danger: #d94141;
  --shadow: 0 18px 50px rgba(9, 45, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

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

.auth-shell {
  display: grid;
  place-items: center;
  width: 100%;
  overflow-x: hidden;
  padding: 32px;
  background:
    radial-gradient(circle at 15% 10%, rgba(16, 199, 167, 0.16), transparent 32%),
    radial-gradient(circle at 85% 90%, rgba(255, 122, 69, 0.12), transparent 30%),
    #f7fafc;
}

.auth-shell .main {
  width: min(1080px, calc(100vw - 64px));
  max-width: 100%;
  min-width: 0;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.7fr);
  gap: 28px;
  align-items: stretch;
  min-width: 0;
}

.login-copy,
.auth-card,
.surface,
.metric-card,
.danger-zone {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-copy {
  padding: 44px;
  color: white;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(9, 45, 68, 0.96), rgba(8, 124, 112, 0.88)),
    #092d44;
}

.login-copy h1 {
  max-width: 560px;
  margin: 18px 0;
  font-size: clamp(38px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.login-copy p {
  max-width: 540px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 18px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.auth-card {
  padding: 34px;
}

.auth-card h2 {
  margin: 0 0 24px;
  font-size: 34px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--navy));
  font-weight: 950;
}

.brand-mark.large {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  font-size: 28px;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-content: start;
  gap: 14px;
  min-height: 100vh;
  overflow-y: auto;
  padding: 24px;
  color: white;
  background: #092d44;
}

.customer-shell .sidebar {
  background: linear-gradient(180deg, #092d44, #087c70);
}

.customer-shell .brand-mark {
  background: linear-gradient(135deg, var(--coral), var(--teal-dark));
}

.brand-name {
  margin-top: 2px;
  font-size: 21px;
  font-weight: 950;
}

.brand-caption {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 800;
}

.sidebar nav {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-top: 30px;
}

.nav-item,
.logout {
  display: block;
  padding: 14px 15px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

.nav-item.active,
.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.logout {
  grid-column: 1 / -1;
  margin-top: 26px;
  color: #ffd9c9;
}

.main {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  padding: 28px;
}

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

.topbar h1 {
  margin: 3px 0 0;
  font-size: clamp(30px, 4vw, 46px);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--coral);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-pill {
  display: grid;
  gap: 2px;
  min-width: 180px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.user-pill span {
  font-weight: 950;
}

.user-pill strong {
  color: var(--muted);
  font-size: 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 22px;
}

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

.metric-card strong {
  font-size: 38px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

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

.panel-grid > *,
.docs-grid > * {
  min-width: 0;
}

.docs-hero {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.docs-hero > div {
  min-width: 0;
}

.api-info-panel {
  margin-bottom: 18px;
}

.api-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.api-info-grid > div {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfe;
}

.api-info-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.api-info-grid strong {
  font-size: 18px;
}

.api-info-grid code,
.api-info-grid small {
  overflow-wrap: anywhere;
}

.code-samples {
  display: grid;
  gap: 14px;
}

.code-samples article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #092d44;
}

.sample-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  color: white;
  background: var(--teal-dark);
}

.sample-head strong {
  overflow-wrap: anywhere;
}

.code-samples pre {
  margin: 0;
  border-radius: 0;
}

.code-samples pre code {
  width: 100%;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.surface,
.danger-zone {
  min-width: 0;
  max-width: 100%;
  padding: 24px;
}

.surface.narrow,
.danger-zone {
  max-width: 820px;
}

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

.section-head form {
  display: inline-flex;
}

.section-head.compact {
  margin-bottom: 10px;
}

.section-head h2,
.surface h2,
.danger-zone h2 {
  margin: 0;
  font-size: 25px;
}

.muted {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.roadmap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.roadmap span {
  padding: 9px 13px;
  border: 1px solid rgba(16, 199, 167, 0.25);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(16, 199, 167, 0.08);
  font-size: 13px;
  font-weight: 900;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 3px;
  color: var(--muted);
}

.actions {
  text-align: right;
}

.actions form {
  display: inline-flex;
  justify-content: flex-end;
}

.status {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.status.active,
.status.ready,
.status.connected {
  color: #086858;
  background: rgba(16, 199, 167, 0.13);
}

.status.passive,
.status.paused,
.status.pending_payment,
.status.pending,
.status.trial,
.status.draft,
.status.new,
.status.contacted,
.status.not_configured,
.status.queued,
.status.simulated,
.status.waiting_qr,
.status.starting,
.status.not_started {
  color: #8a4b16;
  background: rgba(255, 122, 69, 0.15);
}

.status.blocked,
.status.cancelled,
.status.expired,
.status.failed,
.status.disconnected,
.status.bridge_unavailable {
  color: #9f2929;
  background: rgba(217, 65, 65, 0.11);
}

.status.sent,
.status.received {
  color: #086858;
  background: rgba(16, 199, 167, 0.13);
}

.status.open,
.status.waiting_admin,
.status.waiting_customer {
  color: #8a4b16;
  background: rgba(255, 122, 69, 0.15);
}

.status.resolved {
  color: #086858;
  background: rgba(16, 199, 167, 0.13);
}

.status.converted {
  color: #086858;
  background: rgba(16, 199, 167, 0.13);
}

.status.closed {
  color: #596673;
  background: rgba(102, 119, 137, 0.13);
}

.setup-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 20px;
}

.setup-step {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fbfdfe;
  font-size: 13px;
  font-weight: 950;
}

.setup-step.done {
  border-color: rgba(16, 199, 167, 0.28);
  color: #086858;
  background: rgba(16, 199, 167, 0.1);
}

.setup-step.pending {
  border-color: rgba(255, 122, 69, 0.22);
  color: #8a4b16;
  background: rgba(255, 122, 69, 0.09);
}

.assistant-box {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(16, 199, 167, 0.24);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 199, 167, 0.09), rgba(255, 255, 255, 0.9));
}

.assistant-box strong {
  color: var(--teal-dark);
}

.assistant-box p {
  margin: 0;
  color: var(--ink);
  line-height: 1.65;
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(16, 199, 167, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(16, 199, 167, 0.08), rgba(255, 122, 69, 0.06)),
    #fff;
}

.qr-image {
  width: min(280px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 14px;
  background: white;
  box-shadow: 0 12px 30px rgba(9, 45, 68, 0.12);
}

.qr-box p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

.wa-console {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.wa-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.wa-action-grid form {
  min-width: 0;
}

.wa-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid rgba(16, 199, 167, 0.22);
  border-radius: 14px;
  color: var(--teal-dark);
  background: #f7fcfb;
  font-size: 14px;
  font-weight: 950;
  text-align: center;
}

.wa-action:hover {
  border-color: rgba(16, 199, 167, 0.45);
  background: rgba(16, 199, 167, 0.09);
}

.wa-auth-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  border: 1px solid rgba(16, 199, 167, 0.32);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(16, 199, 167, 0.07);
}

.wa-auth-strip > div {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border-right: 1px solid rgba(16, 199, 167, 0.18);
}

.wa-auth-strip > div:last-child {
  border-right: 0;
}

.wa-auth-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.wa-auth-strip code {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.wa-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.mini-stat {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfe;
}

.mini-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.mini-stat strong {
  color: var(--navy);
  font-size: 28px;
  line-height: 1;
}

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

.inline-actions form {
  display: inline-flex;
}

.compact-form {
  margin-top: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: #1c2c38;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fbfdfe;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(16, 199, 167, 0.14);
}

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

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

.span-2 {
  grid-column: 1 / -1;
}

.stacked-form {
  margin-top: 18px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 2px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--teal-dark);
}

.form-grid label:has(input[type="password"]) {
  grid-column: span 1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

button,
.link-button,
.secondary,
.primary,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 950;
}

.primary {
  color: white;
  background: var(--teal-dark);
}

.primary:hover {
  background: #07675f;
}

.secondary {
  color: var(--navy);
  background: #edf4f7;
}

.secondary.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.danger {
  color: white;
  background: var(--danger);
}

.danger.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

button:disabled,
.wa-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.danger-zone {
  margin-top: 18px;
  border-color: rgba(217, 65, 65, 0.28);
}

.danger-zone p {
  color: var(--muted);
}

.notice {
  margin: 0 0 18px;
  padding: 13px 15px;
  border-radius: 12px;
  font-weight: 850;
}

.notice-form {
  margin-top: 12px;
}

.notice-form button {
  width: auto;
}

.notice.success {
  color: #086858;
  background: rgba(16, 199, 167, 0.12);
}

.notice.error {
  color: #9f2929;
  background: rgba(217, 65, 65, 0.11);
}

.secret-code {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  overflow-x: auto;
  border-radius: 12px;
  color: #072233;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 900;
  white-space: nowrap;
}

code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
}

pre {
  overflow-x: hidden;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 14px 0 0;
  padding: 16px;
  border-radius: 14px;
  color: #e8fbf7;
  background: #092d44;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}

pre code {
  display: block;
  width: 100%;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.profile-list {
  display: grid;
  gap: 10px;
  margin: 0 0 24px;
}

.profile-list div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.profile-list dt {
  color: var(--muted);
  font-weight: 900;
}

.profile-list dd {
  margin: 0;
  font-weight: 950;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.profile-list code {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 920px) {
  .login-panel,
  .app-shell,
  .metrics-grid,
  .docs-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
  }

  .logout {
    margin-top: 0;
  }

  .topbar,
  .section-head,
  .docs-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  .profile-list div {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 560px) {
  .main,
  .auth-shell {
    padding: 16px;
  }

  .auth-shell .main {
    width: min(100%, calc(100vw - 24px)) !important;
    max-width: 100% !important;
    padding: 0 !important;
    overflow: visible;
  }

  body.auth-shell {
    display: block;
    width: 100%;
    padding: 12px;
    overflow-x: hidden;
  }

  body.auth-shell .surface,
  body.auth-shell .docs-grid,
  body.auth-shell .docs-hero {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  body.auth-shell .login-panel,
  body.auth-shell .login-copy,
  body.auth-shell .auth-card {
    width: 100%;
    max-width: calc(100vw - 24px);
    min-width: 0;
    overflow: hidden;
  }

  body.auth-shell .login-copy *,
  body.auth-shell .auth-card * {
    max-width: 100%;
    min-width: 0;
  }

  body.auth-shell .docs-hero h2,
  body.auth-shell .surface h2 {
    font-size: 24px;
    line-height: 1.25;
  }

  body.auth-shell .muted {
    width: 100%;
    max-width: 100%;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
  }

  body.auth-shell .profile-list code {
    display: block;
    width: 100%;
    white-space: normal;
    font-size: 13px;
    line-height: 1.5;
  }

  .login-copy,
  .auth-card,
  .surface,
  .danger-zone {
    padding: 18px;
    border-radius: 16px;
  }

  .login-copy h1 {
    max-width: 100%;
    font-size: 28px;
    line-height: 1.08;
    word-break: break-word;
  }

  .login-copy p {
    max-width: 100%;
    font-size: 15px;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: none;
  }

  pre {
    margin-left: -2px;
    padding: 13px;
    font-size: 13px;
    overflow-x: hidden;
    white-space: pre-wrap;
  }

  pre code {
    width: 100%;
    min-width: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
