:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
  --bg: #081016;
  --text: #eff8f6;
  --panel: rgba(18, 33, 41, 0.78);
  --line: rgba(164, 216, 205, 0.16);
  --muted: #91aaa6;
  --accent: #53e0b2;
  --danger: #ff7f7f;
  --input-bg: #071219;
  --step-bg: rgba(6, 19, 24, 0.62);
  --step-idle: rgba(6, 19, 24, 0.4);
  --pre-bg: #03090d;
  --pre-text: #b8d5cf;
  --btn-bg: rgba(7, 18, 25, 0.8);
  --btn-text: #dce9e6;
  --grad1: rgba(48, 163, 137, 0.2);
  --grad2: rgba(45, 99, 140, 0.25);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef8f5;
  --text: #0d2820;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(20, 100, 75, 0.18);
  --muted: #518078;
  --accent: #0aab72;
  --danger: #cc3333;
  --input-bg: #f4faf8;
  --step-bg: rgba(235, 250, 246, 0.9);
  --step-idle: rgba(228, 246, 242, 0.7);
  --pre-bg: #e8f5f1;
  --pre-text: #205040;
  --btn-bg: rgba(235, 248, 244, 0.95);
  --btn-text: #164438;
  --grad1: rgba(48, 163, 137, 0.08);
  --grad2: rgba(45, 99, 140, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, var(--grad1), transparent 36%),
    radial-gradient(circle at 90% 5%, var(--grad2), transparent 32%),
    var(--bg);
  transition: background 0.3s, color 0.3s;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.toggle-bar {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.toggle-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 700px;
  margin-bottom: 12px;
  font-size: clamp(22px, 3.5vw, 38px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.subtitle {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ── Status card ─────────────────────────────────────────────────────────── */

.status-card,
.panel,
.metric {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 170px;
  padding: 14px 16px;
  border-radius: 14px;
}

.status-card small,
.status-card strong {
  display: block;
  font-size: 12px;
}

.status-card small {
  color: var(--muted);
  margin-bottom: 3px;
}

.status-card strong {
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #71817e;
  flex-shrink: 0;
}

.status-dot.ok {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(83, 224, 178, 0.7);
}

.status-dot.error {
  background: var(--danger);
}

/* ── Panel ───────────────────────────────────────────────────────────────── */

.panel {
  padding: 24px;
  border-radius: 20px;
}

.flow-panel {
  margin-bottom: 14px;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

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

.toolbar button,
.secondary-action {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 700;
  font-size: 13px;
  transition: border-color 0.2s;
}

.toolbar .primary-action {
  border-color: transparent;
  background: var(--accent);
  color: #05241a;
}

.danger-action {
  color: #ff9999 !important;
}

[data-theme="light"] .danger-action {
  color: #bb2222 !important;
}

/* ── Progress stepper ────────────────────────────────────────────────────── */

.progress-line {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 0 4px;
}

.progress-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.progress-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
  z-index: 0;
  transition: background 0.4s;
}

.progress-item.done:not(:last-child)::after {
  background: var(--accent);
}

.step-num {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg);
  position: relative;
  z-index: 1;
  transition: all 0.3s;
  color: var(--muted);
}

.step-label {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  transition: color 0.3s;
}

.progress-item.active .step-num {
  border-color: var(--accent);
  color: var(--accent);
}

.progress-item.active .step-label {
  color: var(--text);
  font-weight: 600;
}

.progress-item.done .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: #05241a;
}

.progress-item.done .step-label {
  color: var(--accent);
}

/* ── Flow grid ───────────────────────────────────────────────────────────── */

.label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#hotelId {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

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

.flow-step {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--step-bg);
}

.flow-step h3 {
  margin: 0;
  font-size: 15px;
}

.flow-step label {
  color: var(--muted);
  font-size: 12px;
}

.flow-step small {
  color: var(--muted);
  font-size: 12px;
}

.flow-step input,
.flow-step select {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.2s;
}

.flow-step input:focus,
.flow-step select:focus {
  border-color: var(--accent);
}

.flow-step button,
#runButton {
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--accent);
  color: #05241a;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  transition: opacity 0.2s;
}

.flow-step .secondary-action {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--btn-text);
}

.flow-step button:disabled,
#runButton:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.step-number {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
}

.token-preview {
  min-height: 40px;
  padding: 10px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.identity-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* ── Summary metrics ─────────────────────────────────────────────────────── */

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

.metric {
  padding: 18px 20px;
  border-radius: 16px;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 18px;
}

/* ── Section heading ─────────────────────────────────────────────────────── */

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.hotel-name {
  color: var(--muted);
  font-size: 13px;
}

/* ── Machine grid ────────────────────────────────────────────────────────── */

.empty-state {
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

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

.machine-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--step-bg);
}

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

.machine-card h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.machine-card header span {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(83, 224, 178, 0.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.data-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.data-list div {
  min-width: 0;
}

.data-list dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.data-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

/* ── Raw output ──────────────────────────────────────────────────────────── */

.raw-panel {
  margin-top: 14px;
}

.raw-panel summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

pre {
  overflow: auto;
  margin: 18px 0 0;
  padding: 18px;
  border-radius: 12px;
  background: var(--pre-bg);
  color: var(--pre-text);
  font-size: 12px;
  line-height: 1.65;
}

.error-text {
  color: var(--danger);
}

/* ── Payment and operation flow ─────────────────────────────────────────── */

.operation-panel {
  margin-top: 14px;
}

.operation-badge {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.notice-box {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  background: var(--step-idle);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.notice-box strong {
  flex-shrink: 0;
  color: var(--text);
}

.operation-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

.operation-card,
.monitor-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--step-bg);
}

.operation-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.operation-card h3,
.monitor-card h3 {
  margin: 0;
  font-size: 15px;
}

.operation-card label {
  color: var(--muted);
  font-size: 12px;
}

.operation-card input,
.operation-card select {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}

.operation-card input:focus,
.operation-card select:focus {
  border-color: var(--accent);
}

.operation-card code {
  color: var(--accent);
}

.inline-status,
.generated-url,
.monitor-result {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.ok-status {
  color: var(--accent);
}

.operation-actions,
.monitor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.operation-actions button,
.monitor-actions button {
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--accent);
  color: #05241a;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}

.operation-actions .secondary-action,
.monitor-actions .secondary-action {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--btn-text);
}

.operation-actions button:disabled,
.monitor-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.monitor-card {
  display: grid;
  grid-template-columns: 1.3fr auto;
  gap: 14px;
  margin-top: 12px;
  align-items: start;
}

.monitor-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.monitor-result {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.monitor-result div {
  min-width: 0;
}

.monitor-result span,
.monitor-result strong {
  display: block;
}

.monitor-result span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.monitor-result strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-right {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .summary-grid,
  .machine-grid,
  .flow-grid {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .monitor-result {
    grid-template-columns: 1fr 1fr;
  }

  .progress-line {
    gap: 0;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 24px, 1120px);
    padding-top: 32px;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .summary-grid,
  .machine-grid,
  .flow-grid,
  .operation-grid {
    grid-template-columns: 1fr;
  }

  .operation-wide {
    grid-column: auto;
  }

  .notice-box,
  .monitor-card {
    display: flex;
    flex-direction: column;
  }

  .monitor-result {
    display: grid;
    grid-template-columns: 1fr;
  }

  .progress-line {
    gap: 0;
  }

  .step-label {
    font-size: 11px;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar button {
    flex: 1 1 100%;
  }
}
