:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f5;
  --line: #d9e1e5;
  --text: #18262d;
  --muted: #64747d;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #18794e;
  --warn: #9a6700;
  --radius: 8px;
  --shadow: 0 18px 44px rgba(24, 38, 45, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  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;
  letter-spacing: 0;
}

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

a:focus-visible,
button:focus-visible,
.nav-link:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf2f4;
}

.login-shell {
  width: min(100%, 420px);
}

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

.home-card {
  display: grid;
  gap: 18px;
}

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

.login-brand {
  justify-content: center;
  margin-bottom: 20px;
}

.login-logo {
  display: block;
  width: min(100%, 260px);
  height: auto;
}

.brand-logo {
  display: block;
  width: min(100%, 188px);
  height: auto;
}

.brand-panel {
  display: grid;
  min-height: 132px;
  place-items: center;
  border-radius: 8px;
  background: #2f2067;
  overflow: hidden;
}

.brand-panel img {
  display: block;
  width: min(78%, 150px);
  height: auto;
}

.login-card h1,
.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

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

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

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  color: #32444d;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c8d3d8;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  border-color: var(--brand);
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.link-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 14px;
  font-weight: 700;
  line-height: 1;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-color: var(--line);
  color: #2f454e;
}

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

.ghost-button {
  width: 100%;
  background: #f6f8f9;
  border-color: var(--line);
  color: #33474f;
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--brand-dark);
}

.compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.alert {
  margin: 0 0 16px;
  padding: 11px 12px;
  border: 1px solid #f0c6c0;
  border-radius: 7px;
  background: #fff4f2;
  color: var(--danger);
  font-weight: 700;
}

.app-body {
  background: var(--bg);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

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

.brand small {
  display: block;
  font-size: 12px;
}

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

.nav-link {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 7px;
  color: #3d5058;
  font-weight: 700;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--surface-soft);
  color: var(--brand-dark);
}

.sidebar-footer {
  margin-top: auto;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.dashboard-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  grid-column: 1 / -1;
}

.surface-card,
.content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(24, 38, 45, 0.06);
}

.metric-card {
  display: grid;
  min-height: 126px;
  gap: 10px;
  padding: 18px;
}

.command-card {
  display: grid;
  min-height: 142px;
  gap: 12px;
  padding: 18px;
  align-content: start;
}

.command-card:hover {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 16px 34px rgba(24, 38, 45, 0.09);
}

.command-icon {
  display: inline-grid;
  width: 46px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: #e8f4f2;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}

.command-card strong {
  font-size: 22px;
}

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

.metric-card span {
  color: var(--brand-dark);
  font-weight: 800;
}

.metric-card strong {
  font-size: 22px;
}

.content-panel {
  padding: 18px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

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

.workflow-card {
  min-width: 0;
}

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

.workflow-steps > div {
  display: grid;
  min-height: 92px;
  align-content: center;
  justify-items: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

.workflow-steps p {
  margin: 0;
  font-weight: 800;
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.quick-actions .panel-header {
  margin-bottom: 2px;
}

.quick-actions .primary-button,
.quick-actions .secondary-button {
  width: 100%;
}

.timeline-list > div {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

.timeline-list p {
  margin: 0;
  font-weight: 800;
}

.step-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: #e8f4f2;
  color: var(--brand-dark);
  font-weight: 800;
}

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

.info-tile {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

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

.copy-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.copy-row code {
  flex: 1;
  min-width: 0;
}

.sgp-console {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.sgp-console > .alert,
.sgp-console > .success,
.sgp-hero-panel,
.sgp-callback-panel,
.sgp-api-panel {
  grid-column: 1;
}

.sgp-test-panel {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  gap: 14px;
}

.sgp-status-grid,
.sgp-test-actions {
  display: grid;
  gap: 12px;
}

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

.sgp-test-actions .primary-button,
.sgp-test-actions .secondary-button {
  width: 100%;
}

.test-result {
  display: grid;
  gap: 8px;
  min-height: 156px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

.test-result span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.test-result strong {
  color: var(--text);
}

.test-result p {
  margin: 0;
  color: #33474f;
}

.test-result small {
  color: var(--muted);
}

.test-result.is-ok {
  border-color: #b7e0cb;
  background: #f1fbf6;
}

.test-result.is-error {
  border-color: #f4c7c2;
  background: #fff5f3;
}

code,
.qr-output {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

code {
  overflow-wrap: anywhere;
  color: #233840;
}

.form-actions {
  display: flex;
  align-items: end;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel-wide {
  min-width: 0;
}

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

.gateway-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(24, 38, 45, 0.05);
}

.gateway-toolbar h2,
.gateway-toolbar p {
  margin: 0;
}

.gateway-toolbar h2 {
  font-size: 18px;
}

.gateway-toolbar p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.gateway-board {
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
}

.resource-list,
.gateway-list {
  display: grid;
  gap: 12px;
}

.resource-item,
.gateway-item {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

.gateway-card.is-default {
  border-color: rgba(15, 118, 110, 0.34);
}

.template-card.is-inactive {
  background: #fbfcfc;
}

.template-preview {
  margin: 10px 0 0;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
}

.template-edit-form {
  margin-top: 12px;
}

.resource-header,
.gateway-summary,
.gateway-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gateway-summary {
  justify-content: space-between;
}

.resource-title,
.gateway-summary strong,
.gateway-summary span {
  display: block;
}

.resource-subtitle,
.gateway-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.resource-badges {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gateway-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.gateway-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.gateway-status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.gateway-status-panel span,
.gateway-status-panel strong {
  display: block;
}

.gateway-status-panel span {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.gateway-status-panel strong {
  color: var(--text);
  font-size: 15px;
}

.gateway-status-panel code {
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.gateway-status-success {
  border-color: rgba(15, 118, 110, 0.28);
  background: #f1fbf9;
}

.gateway-status-success code {
  background: #d9f7ef;
  color: #0f766e;
}

.gateway-status-danger {
  border-color: rgba(185, 28, 28, 0.24);
  background: #fff7f6;
}

.gateway-status-danger code {
  background: #fee2e2;
  color: #b91c1c;
}

.gateway-status-info code {
  background: #eef2f6;
  color: var(--brand-dark);
}

.gateway-edit-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.gateway-edit-form .field-grow {
  grid-column: span 2;
}

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

.secret-field-mask {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.resource-details,
.danger-zone {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.resource-details summary,
.danger-zone summary {
  width: fit-content;
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 800;
}

.resource-details[open] summary,
.danger-zone[open] summary {
  margin-bottom: 12px;
}

.danger-zone {
  border-color: #f0c6c0;
}

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

.action-bar,
.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-group-operational {
  padding-right: 4px;
}

.gateway-actions {
  padding-top: 2px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

.data-table th {
  background: #f8fafb;
  color: #485a62;
  font-size: 12px;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.text-clip {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.row-actions form,
.inline-form {
  margin: 0;
}

.status-badge,
.default-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-active,
.status-delivered,
.status-sent,
.status-read,
.status-pill-success {
  background: #e8f5ee;
  color: var(--ok);
}

.status-inactive,
.status-failed,
.status-pill-danger {
  background: #fff2ef;
  color: var(--danger);
}

.status-queued,
.status-processing,
.status-pill-warning {
  background: #fff7df;
  color: var(--warn);
}

.default-pill,
.status-pill-info {
  background: #eaf2ff;
  color: #2457a6;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #32444d;
  font-weight: 700;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.login-remember {
  align-items: flex-start;
  margin-top: -2px;
  font-size: 13px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.messages-layout {
  display: grid;
  gap: 18px;
}

.filters-card {
  padding-bottom: 16px;
}

.filter-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(180px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
}

.messages-panel {
  min-width: 0;
}

.message-list {
  background: #ffffff;
}

.messages-table {
  min-width: 820px;
}

.message-preview {
  max-width: 440px;
  color: #2d4048;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
  min-height: 620px;
}

.chat-sidebar,
.chat-panel {
  min-width: 0;
}

.chat-conversation-list {
  display: grid;
  gap: 8px;
}

.chat-conversation {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: inherit;
  text-decoration: none;
  background: #ffffff;
}

.chat-conversation span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conversation-name {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conversation small {
  color: var(--muted);
}

.chat-conversation.is-selected {
  border-color: var(--brand);
  background: #eef8f5;
}

.chat-thread {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 520px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7faf9;
}

.chat-message-row {
  display: flex;
}

.chat-message-row.outbound {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: min(560px, 78%);
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #24353b;
}

.chat-bubble.outbound {
  border-color: #b9d9cf;
  background: #dff3ed;
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-bubble time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.field-grow {
  grid-column: span 2;
}

.empty-state {
  display: grid;
  min-height: 138px;
  place-items: center;
  border: 1px dashed #cbd6db;
  border-radius: 7px;
  background: #fbfcfc;
  color: var(--muted);
  text-align: center;
}

.qr-panel {
  max-width: 820px;
}

.qr-output {
  min-height: 220px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1f24;
  color: #e7f7f4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .overview-grid,
  .dashboard-board,
  .command-grid,
  .timeline-list,
  .workflow-steps,
  .info-grid,
  .sgp-console,
  .sgp-status-grid,
  .split-layout,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .sgp-test-panel,
  .sgp-console > .alert,
  .sgp-console > .success,
  .sgp-hero-panel,
  .sgp-callback-panel,
  .sgp-api-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .filter-panel,
  .filter-toolbar,
  .gateway-edit-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grow,
  .gateway-edit-form .field-grow {
    grid-column: span 2;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .main-panel {
    padding: 18px;
  }

  .page-header {
    display: block;
  }

  .form-grid,
  .filter-panel,
  .filter-toolbar,
  .gateway-edit-form {
    grid-template-columns: 1fr;
  }

  .field-grow,
  .gateway-edit-form .field-grow {
    grid-column: auto;
  }

  .gateway-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .gateway-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .gateway-status-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .gateway-status-panel code {
    width: fit-content;
  }

  .chat-layout {
    min-height: auto;
  }

  .chat-thread {
    min-height: 420px;
    padding: 12px;
  }

  .chat-bubble {
    max-width: 92%;
  }

  .gateway-toolbar .secondary-button,
  .gateway-actions .secondary-button,
  .gateway-actions .danger-button,
  .danger-zone .secondary-button,
  .danger-zone .danger-button {
    width: 100%;
    min-height: 40px;
  }

  .action-bar,
  .action-group {
    width: 100%;
  }

  .login-card {
    padding: 22px;
  }
}
