:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --panel-strong: #f3f7f6;
  --text: #101828;
  --muted: #667085;
  --border: #d7dde6;
  --border-strong: #b8c2cf;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.08);
  --soft-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
  --radius: 8px;
  font-family: Inter, "SF Pro Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.12;
}

.page-subtitle {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.admin-link,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.admin-link {
  border-color: var(--border);
  background: var(--panel);
  color: var(--text);
}

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

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

.button.secondary {
  border-color: var(--border-strong);
  background: var(--panel);
  color: var(--text);
}

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

.button.ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
}

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

.input:disabled,
.select:disabled,
.textarea:disabled {
  border-color: var(--border);
  background: #eef2f6;
  color: #98a2b3;
  cursor: not-allowed;
}

.shell,
.admin-grid {
  display: grid;
  gap: 18px;
}

.customer-layout {
  grid-template-columns: minmax(0, 1.42fr) minmax(300px, 0.58fr);
  align-items: start;
}

.admin-grid {
  grid-template-columns: minmax(0, 0.85fr) minmax(360px, 1.15fr);
  margin-top: 18px;
}

.editor-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
}

.order-workspace {
  grid-template-columns: minmax(0, 1.65fr) minmax(380px, 0.75fr);
  align-items: start;
}

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

.customer-page {
  width: min(1120px, calc(100% - 32px));
}

.admin-page {
  width: min(1360px, calc(100% - 32px));
}

.customer-page .panel {
  box-shadow: var(--soft-shadow);
}

.customer-topbar {
  align-items: center;
  padding: 6px 0 8px;
}

.language-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(56px, 1fr));
  gap: 2px;
  min-width: 128px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.language-button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.language-button.active {
  background: var(--primary);
  color: #fff;
}

.customer-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 3px;
  width: min(100%, 540px);
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.customer-tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.customer-tab-button.active {
  background: var(--primary);
  color: #fff;
}

.customer-tab-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 2px;
}

.order-panel {
  border-top: 4px solid var(--primary);
}

.panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.panel p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.side-stack {
  display: grid;
  gap: 18px;
}

.compact-panel {
  padding: 20px;
}

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

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

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

.generate-form {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.check-field {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 760;
}

.field .field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.55;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.session-help {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
}

.session-help a {
  color: var(--primary);
  font-size: 12px;
  font-weight: 760;
}

.field .optional-badge,
.field .required-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field .required-badge {
  border-color: #9fd3b2;
  background: #ecfdf3;
  color: var(--green);
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
}

.input,
.select {
  min-height: 42px;
  padding: 0 12px;
}

.textarea {
  min-height: 118px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.notice,
.status-box,
.output-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--muted);
}

.notice,
.status-box {
  padding: 12px;
  line-height: 1.55;
  white-space: pre-line;
}

.output-box {
  min-height: 92px;
  max-height: 280px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.5;
}

.success {
  border-color: #9fd3b2;
  background: #f0fdf4;
  color: #166534;
}

.warning {
  border-color: #f0d28a;
  background: #fffbeb;
  color: #92400e;
}

.danger-text {
  border-color: #f0aaa4;
  background: #fff1f2;
  color: #991b1b;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.Unused,
.status-pill.Success {
  border-color: #9fd3b2;
  background: #ecfdf3;
  color: var(--green);
}

.status-pill.Processing {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.status-pill.Failed,
.status-pill.Revoked {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--red);
}

.status-pill.neutral {
  color: var(--muted);
}

.customer-page .compact-panel {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.flow-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.flow-list li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.flow-list span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: #e8f3f1;
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
}

.flow-list p {
  margin: 0;
  color: var(--text);
  font-weight: 720;
}

.notice-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.6;
}

.notice-list li::marker {
  color: var(--primary);
  font-weight: 850;
}

.button.caution-action {
  display: flex;
  width: fit-content;
  min-height: 38px;
  margin-top: 14px;
  padding: 0 13px 0 15px;
  gap: 8px;
  border-color: #99d6cd;
  background: #eefaf7;
  color: var(--primary-strong);
  text-decoration: none;
  box-shadow: inset 0 -1px 0 rgba(15, 118, 110, 0.08);
}

.notice-list .button.caution-action {
  margin-top: 2px;
}

.button.caution-action::after {
  content: "\2197";
  font-size: 12px;
  line-height: 1;
  transform: translateY(1px);
}

.button.caution-action:hover {
  border-color: #5fb8ac;
  background: #ddf5ef;
  color: var(--primary-strong);
  text-decoration: none;
}

.button.caution-action:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 2px;
}

.refresh-panel {
  margin-top: 18px;
  border-top: 4px solid #2563eb;
}

.plus-panel {
  border-top-color: var(--blue);
}

.card-channel-layout {
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.5fr);
}

.card-channel-form-panel {
  min-height: 320px;
  overflow: hidden;
  border-top-color: var(--blue);
  padding: 0;
}

.card-channel-form-panel .panel-head {
  margin: 0;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: #fbfdff;
}

.card-channel-form-panel .panel-head h2 {
  font-size: 22px;
}

.card-channel-form {
  max-width: none;
  gap: 0;
}

.card-form-section {
  display: grid;
  gap: 14px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.card-form-section:first-child {
  border-top: 0;
}

.card-verification-section {
  gap: 12px;
  border-bottom: 1px solid #dbeafe;
  background: linear-gradient(90deg, #f2f7ff 0%, #fbfdff 74%);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.section-label > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: #e8f1ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.section-label strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
}

.card-verification-section .section-label > span {
  background: var(--blue);
  color: #fff;
}

.card-field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.55fr);
  gap: 14px;
  align-items: start;
}

.account-email-field {
  min-width: 0;
}

.optional-session-fields {
  background: #fcfcfd;
}

.optional-session-fields .session-help {
  justify-content: flex-start;
  text-align: left;
}

.optional-session-fields .textarea {
  min-height: 96px;
}

.card-submit-row {
  display: flex;
  justify-content: flex-end;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.card-submit-row .button {
  min-width: 168px;
}

.card-channel-layout .compact-panel {
  border-left: 3px solid #dbeafe;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.05);
}

.card-channel-layout .flow-list li {
  grid-template-columns: 36px minmax(0, 1fr);
}

.card-channel-layout .flow-list span {
  width: 36px;
  height: 36px;
  background: #eff6ff;
  color: var(--blue);
}

.refresh-form {
  gap: 12px;
}

.refresh-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.refresh-result {
  min-height: 42px;
  max-height: 220px;
  margin: 0;
  padding: 11px 12px;
  overflow: auto;
  white-space: pre-line;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.admin-console.hidden,
.hidden {
  display: none;
}

.admin-topbar {
  align-items: center;
}

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

.login-panel {
  max-width: 560px;
}

.login-form {
  margin-top: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 82px;
  border-left: 3px solid var(--primary);
  background: var(--panel-soft);
  padding: 12px;
}

.metric b {
  display: block;
  font-size: 26px;
  line-height: 1.05;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

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

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

.order-workspace > .table-panel,
.order-workspace > .editor-panel {
  margin-top: 0;
}

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #fff;
}

.orders-table {
  min-width: 620px;
}

.orders-table th:first-child,
.orders-table td:first-child {
  min-width: 220px;
  word-break: break-word;
}

.orders-table th:last-child,
.orders-table td:last-child {
  width: 84px;
  text-align: right;
}

.orders-table td:last-child .small-button {
  min-width: 58px;
}

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

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
  font-weight: 800;
}

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

td .mini {
  color: var(--muted);
  font-size: 12px;
}

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

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

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

@media (max-width: 980px) {
  .customer-layout,
  .card-channel-layout,
  .admin-grid,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .editor-panel {
    margin-top: 0;
  }
}

@media (max-width: 700px) {
  .page {
    width: min(100% - 24px, 1180px);
    padding-top: 22px;
  }

  .topbar,
  .panel-head {
    flex-direction: column;
  }

  .customer-topbar {
    align-items: stretch;
  }

  .language-toggle {
    width: 100%;
  }

  .customer-tabs {
    width: 100%;
  }

  .inline-control,
  .inline-form,
  .login-form,
  .split-actions,
  .refresh-actions {
    grid-template-columns: 1fr;
  }

  .label-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-help {
    justify-content: flex-start;
    text-align: left;
  }

  .wide-mobile,
  .inline-control .button {
    width: 100%;
  }

  .button.caution-action.wide-mobile {
    width: 100%;
  }

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

  .panel {
    padding: 18px;
  }

  .card-channel-form-panel {
    padding: 0;
  }

  .card-channel-form-panel .panel-head {
    padding: 18px;
  }

  .card-form-section {
    padding: 18px;
  }

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

  .card-submit-row {
    padding: 18px;
  }

  .card-submit-row .button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .customer-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .customer-tab-button {
    padding-inline: 6px;
    font-size: 12px;
  }

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

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