:root {
  --primary: #0075eb;
  --primary-hover: #005ec2;
  --success: #10b981;
  --success-hover: #059669;
  --bg-main: #0b0f19;
  --bg-card: rgba(22, 29, 47, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 20px 35px -10px rgba(0, 0, 0, 0.5);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-main: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-border: rgba(0, 0, 0, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 30px -10px rgba(0, 0, 0, 0.1);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
}

.app-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
}

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

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 117, 235, 0.3);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(0, 117, 235, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
}

.btn-install {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.hidden {
  display: none !important;
}

/* Main Views */
.view {
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}

.view.active {
  display: block;
  opacity: 1;
}

/* Upload Dropzone */
.dropzone {
  position: relative;
  background: var(--bg-card);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(0, 117, 235, 0.05);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 117, 235, 0.12);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.dropzone h2 {
  font-size: 18px;
  font-weight: 600;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.2s;
}

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

.privacy-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  max-width: 320px;
  line-height: 1.4;
}

/* Text Paste Drawer */
.text-paste-details {
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.text-paste-details summary {
  cursor: pointer;
  font-weight: 600;
}

.paste-box {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paste-box textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  resize: vertical;
}

/* Loading View */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  gap: 16px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(0, 117, 235, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: var(--text-muted);
  font-size: 15px;
}

/* Result Card */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 16px;
}

.payee-label, .amount-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: block;
}

.payee-name {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.3;
}

.recipient-name {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.amount-badge {
  text-align: right;
  flex-shrink: 0;
}

.amount-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--success);
  display: block;
}

.due-badge {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  margin-top: 4px;
}

/* QR Code */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.qr-svg-wrapper {
  background: white;
  padding: 14px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 240px;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-svg-wrapper svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-caption {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 117, 235, 0.25);
  transition: background 0.15s, transform 0.15s;
}

.btn-primary-action:hover {
  background: var(--primary-hover);
}

.btn-primary-action:active {
  transform: scale(0.98);
}

.btn-sub-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-sub-action:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Transfer Details Grid */
.details-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  gap: 8px;
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

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

.detail-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monospace {
  font-family: var(--font-mono);
}

.detail-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-copy:hover {
  background: var(--primary);
  color: white;
}

.btn-copy.copied {
  background: var(--success);
  color: white;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
