* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f6f7f9;
  color: #15171c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: #155eef;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d9dde5;
  display: flex;
  height: 56px;
  justify-content: space-between;
  padding: 0 24px;
}

.brand {
  color: #15171c;
  font-size: 18px;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.nav a {
  color: #4a5363;
  font-size: 14px;
}

.shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 24px 48px;
}

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

.page-head h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0 0 6px;
}

.page-head p {
  color: #5d6678;
  margin: 0;
}

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

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

.panel {
  background: #ffffff;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  padding: 18px;
}

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

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

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

.field {
  margin-bottom: 16px;
}

.field label {
  color: #374151;
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 6px;
}

.label-row {
  align-items: center;
  display: flex !important;
  justify-content: space-between;
}

.stream-dot {
  background: #98a2b3;
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.stream-dot[data-state="open"] {
  background: #12b76a;
}

.stream-dot[data-state="error"] {
  background: #f04438;
}

select,
input[type="number"],
input[type="password"],
input[type="text"],
textarea {
  background: #ffffff;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  color: #111827;
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

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

.button {
  align-items: center;
  background: #ffffff;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  color: #111827;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
}

.button.primary {
  background: #155eef;
  border-color: #155eef;
  color: #ffffff;
}

.button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button.danger {
  background: #b42318;
  border-color: #b42318;
  color: #ffffff;
}

.field-error,
.message-error {
  color: #b42318;
}

.message-success {
  color: #027a48;
}

.messages {
  margin-bottom: 16px;
}

.message {
  background: #ffffff;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  padding: 12px 14px;
}

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

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

td,
th {
  border-bottom: 1px solid #e4e7ec;
  font-size: 13px;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #5d6678;
  font-weight: 650;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  background: #101828;
  border-radius: 6px;
  color: #eef2f6;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.summary-strip div {
  background: #ffffff;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  min-width: 0;
  padding: 14px;
}

.summary-strip span {
  color: #667085;
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.summary-strip strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.status {
  background: #eef4ff;
  border-radius: 999px;
  color: #155eef;
  display: inline-block;
  font-size: 12px;
  padding: 3px 8px;
}

.empty {
  color: #667085;
  margin: 0;
}

.muted {
  color: #667085;
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.status-ok {
  background: #ecfdf3;
  color: #027a48;
}

.status-muted {
  background: #f2f4f7;
  color: #475467;
}

.dashboard-panel {
  margin-top: 18px;
}

.portal-shell {
  max-width: 460px;
}

.portal-login-form {
  margin-top: 16px;
}

.recharge-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 520px) minmax(280px, 1fr);
}

.card-recharge-form {
  margin-top: 16px;
}

.link-button {
  background: transparent;
  border: 0;
  color: #155eef;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 0;
}

.modal-backdrop {
  align-items: center;
  background: rgba(17, 24, 39, 0.46);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(17, 24, 39, 0.22);
  max-width: 560px;
  padding: 18px;
  width: min(100%, 560px);
}

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

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

.icon-close {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  color: #344054;
  cursor: pointer;
  display: inline-flex;
  font-size: 20px;
  height: 34px;
  justify-content: center;
  line-height: 1;
  width: 34px;
}

.step-list {
  color: #344054;
  margin: 0;
  padding-left: 20px;
}

.step-list li {
  line-height: 1.6;
  margin-bottom: 8px;
}

.modal-note {
  background: #fff8e6;
  border: 1px solid #fedf89;
  border-radius: 6px;
  color: #7a4b00;
  margin: 12px 0 0;
  padding: 10px 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.result-card {
  border: 1px solid #d9dde5;
  border-radius: 8px;
  padding: 14px;
}

.result-card strong {
  display: block;
  margin-bottom: 10px;
}

.result-summary {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.result-summary strong {
  margin-bottom: 4px;
}

.result-summary p {
  color: #475467;
  margin: 0;
}

.result-dot {
  border-radius: 50%;
  flex: 0 0 auto;
  height: 12px;
  margin-top: 5px;
  width: 12px;
}

.result-dot-ok {
  background: #12b76a;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.14);
}

.result-dot-error {
  background: #f04438;
  box-shadow: 0 0 0 4px rgba(240, 68, 56, 0.14);
}

.result-dot-pending {
  background: #f79009;
  box-shadow: 0 0 0 4px rgba(247, 144, 9, 0.16);
}

.result-card-ok {
  background: #ecfdf3;
  border-color: #abefc6;
}

.result-card-error {
  background: #fff1f3;
  border-color: #fecdca;
}

.result-card-pending {
  background: #fff8e6;
  border-color: #fedf89;
}

.quota-form {
  display: grid;
  gap: 8px;
  min-width: 180px;
}

.quota-form input[type="number"] {
  min-height: 34px;
}

.checkline {
  align-items: center;
  color: #344054;
  display: inline-flex;
  font-size: 13px;
  gap: 6px;
}

.confirm-bar {
  margin-top: 18px;
}

.response-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  margin-top: 18px;
}

.result-list {
  margin: 0;
}

.result-list.compact div {
  grid-template-columns: 86px minmax(0, 1fr);
  padding: 8px 0;
}

.result-list div {
  border-bottom: 1px solid #e4e7ec;
  display: grid;
  gap: 12px;
  grid-template-columns: 120px minmax(0, 1fr);
  padding: 10px 0;
}

.result-list div:first-child {
  padding-top: 0;
}

.result-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.result-list dt {
  color: #667085;
  font-size: 13px;
}

.result-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.result-detail-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.result-detail-grid div {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(152, 162, 179, 0.28);
  border-radius: 6px;
  min-width: 0;
  padding: 10px;
}

.result-detail-grid dt {
  color: #667085;
  font-size: 12px;
  margin-bottom: 4px;
}

.result-detail-grid dd {
  color: #111827;
  font-weight: 650;
  margin: 0;
  overflow-wrap: anywhere;
}

.result-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.stage-pill,
.status-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  padding: 6px 9px;
}

.stage-done,
.status-used {
  background: #ecfdf3;
  color: #027a48;
}

.stage-pending,
.status-confirmed,
.status-sending,
.status-draft {
  background: #fff8e6;
  color: #93370d;
}

.stage-error,
.status-disabled,
.status-failed,
.status-invalid,
.status-not-found {
  background: #fff1f3;
  color: #b42318;
}

.status-unused {
  background: #eef4ff;
  color: #155eef;
}

.status-processing {
  background: #fff8e6;
  color: #93370d;
}

.query-results {
  display: grid;
  gap: 12px;
}

.query-card {
  border: 1px solid #d9dde5;
  border-radius: 8px;
  padding: 14px;
}

.query-card-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.query-card-head strong {
  display: block;
  overflow-wrap: anywhere;
}

.query-summary {
  color: #344054;
  margin: 10px 0 12px;
}

.query-detail-grid {
  margin-bottom: 12px;
}

.query-table-wrap {
  margin-top: 10px;
}

@media (max-width: 860px) {
  .topbar,
  .page-head {
    align-items: stretch;
    flex-direction: column;
    height: auto;
  }

  .topbar {
    gap: 10px;
    padding: 14px 18px;
  }

  .shell {
    padding: 22px 16px 36px;
  }

  .work-grid,
  .preview-grid,
  .response-grid,
  .recharge-grid,
  .result-detail-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }
}
