: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;
}

.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);
}

.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));
}

.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;
}

.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;
}

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

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

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

.label-row a {
  color: var(--primary);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
}

.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;
}

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

.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;
}

.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;
}

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,
  .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%;
  }

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

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

  .label-row a {
    text-align: left;
  }

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

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

  .panel {
    padding: 18px;
  }
}

@media (max-width: 430px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

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