:root {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-ring: rgba(37, 99, 235, 0.16);

  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08);
  --shadow-shell: 0 20px 50px -12px rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* Mobile-first App Shell */
.app-shell {
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 520px) {
  body {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(circle at 20% 15%, rgba(37, 99, 235, 0.07), transparent 45%),
      radial-gradient(circle at 80% 85%, rgba(5, 150, 105, 0.06), transparent 45%),
      var(--bg-page);
  }

  .app-shell {
    min-height: 760px;
    max-height: 90dvh;
    border-radius: 26px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: var(--shadow-shell);
    overflow: hidden;
  }
}

/* Topbar */
.topbar {
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
  background: var(--bg-muted);
}

.icon-btn:active {
  transform: scale(0.95);
}

.topbar-title-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.qris-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.qris-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

/* Views */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: fadeSlideIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Amount Hero */
.amount-hero {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-md);
}

.amount-hero-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.amount-hero-value {
  font-size: clamp(26px, 8vw, 32px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.amount-hero-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: #93c5fd;
  font-weight: 500;
}

/* Sections */
.section-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Preset Grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.preset-card {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-height: 58px;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.preset-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.preset-card:active {
  transform: scale(0.98);
}

.preset-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.preset-rp {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-card.is-selected .preset-rp {
  color: var(--accent);
}

.preset-num {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.preset-card.is-selected .preset-num {
  color: var(--accent-hover);
}

.preset-badge {
  position: absolute;
  top: -8px;
  right: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* Custom Input */
.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.input-group.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.input-prefix {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}

.amount-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.amount-input::placeholder {
  color: #94a3b8;
  font-weight: 600;
}

.clear-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-muted);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.clear-btn:hover {
  background: var(--border);
}

.helper-text {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.helper-text.is-error {
  color: var(--danger);
  font-weight: 600;
}

/* Method Card */
.method-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.method-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.method-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.method-info {
  flex: 1;
  min-width: 0;
}

.method-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.method-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.method-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Sticky Bottom Bar */
.bottom-bar {
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.bottom-summary {
  display: flex;
  flex-direction: column;
  min-width: 108px;
}

.bottom-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.bottom-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  flex: 1;
  height: 50px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  box-shadow: 0 6px 16px -4px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-primary:disabled {
  background: #cbd5e1;
  color: #f8fafc;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
  flex: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* VIEW 2: QRIS PAYMENT */
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  border: 1px solid rgba(217, 119, 6, 0.22);
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
}

.status-banner.is-urgent {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.25);
  color: #991b1b;
}

.status-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-banner.is-urgent .pulse-dot {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(1.3);
  }
}

.countdown-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* QRIS Card */
.qris-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qris-card-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-strong);
}

.qris-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qris-logo-svg {
  height: 26px;
  width: auto;
}

.qris-std {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.merchant-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.merchant-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.merchant-nmid {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.qr-frame-wrap {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.qr-frame {
  padding: 12px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qr-canvas,
.qr-image {
  display: block;
  width: 224px;
  height: 224px;
  border-radius: 8px;
  object-fit: contain;
}

.qris-amount-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qris-amount-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.qris-amount-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.qris-amount-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qris-amount-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.chip-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chip-copy-btn:hover {
  background: var(--accent-soft);
}

.qris-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.qris-order-label {
  color: var(--text-muted);
}

.qris-order-id {
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.qris-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-secondary,
.btn-outline {
  height: 44px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-secondary {
  border: none;
  background: var(--text-primary);
  color: #ffffff;
}

.btn-secondary:hover {
  background: #1e293b;
}

.btn-outline {
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-subtle);
}

.btn-secondary:active,
.btn-outline:active {
  transform: scale(0.98);
}

/* Guide Accordion */
.guide-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  padding: 14px;
}

.guide-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.guide-summary::-webkit-details-marker {
  display: none;
}

.guide-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.guide-card[open] .guide-chevron {
  transform: rotate(180deg);
}

.guide-steps {
  margin: 12px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Demo / Sandbox Panel */
.demo-panel {
  border: 1px dashed #93c5fd;
  background: #f8faff;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.demo-panel-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-hover);
}

.demo-panel-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.demo-panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.demo-btn {
  height: 38px;
  border-radius: 10px;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.demo-btn-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.demo-btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.22);
}

/* VIEW 3: RESULT */
.result-scroll {
  justify-content: center;
}

.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.result-icon.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.result-icon.is-expired {
  background: var(--danger-soft);
  color: var(--danger);
}

.result-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.result-subtitle {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.result-amount {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 6px 0;
  font-variant-numeric: tabular-nums;
}

.result-details {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 10px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.detail-row span {
  color: var(--text-muted);
}

.detail-row strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  white-space: nowrap;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
