/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --navy:        #1B3A6B;
  --navy-light:  #244d8f;
  --teal:        #0097A7;
  --teal-light:  #00b8cc;
  --teal-bg:     #e6f7f9;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --amber:       #d97706;
  --amber-bg:    #fffbeb;
  --white:       #ffffff;
  --surface:     #f8fafc;
  --border:      #e2e8f0;
  --border-soft: #f1f5f9;
  --text-main:   #0f172a;
  --text-mid:    #475569;
  --text-soft:   #94a3b8;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 16px rgba(27,58,107,.10), 0 1px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(27,58,107,.14), 0 2px 8px rgba(0,0,0,.06);
  --radius:      14px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --font:        'Poppins', sans-serif;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  background: linear-gradient(135deg, #e8eef8 0%, #eaf6f8 50%, #e8eef8 100%);
  background-attachment: fixed;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle grid texture on background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(27,58,107,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27,58,107,.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* ── Page layout ──────────────────────────────────────────────────────────── */
.page-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  border: 1px solid rgba(27,58,107,.08);
}

.card-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 20px 24px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  /* filter: brightness(0) invert(1); */
  opacity: 1;
}

.card-header-title {
  flex: 1;
}

.card-header-title h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: .01em;
  line-height: 1.3;
}

.card-header-title p {
  font-size: 11.5px;
  font-weight: 400;
  color: rgba(255,255,255,.65);
  margin-top: 1px;
}

.flow-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 3px 10px;
  margin-left: auto;
}

.card-body {
  padding: 24px;
}

/* ── Step indicator ───────────────────────────────────────────────────────── */
.step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: background .3s, color .3s;
}

.step-dot.active {
  background: var(--teal);
  color: var(--white);
  box-shadow: 0 0 0 3px rgba(0,151,167,.18);
}

.step-dot.done {
  background: var(--navy);
  color: var(--white);
}

.step-dot.done::after {
  content: '✓';
  font-size: 11px;
}

.step-dot.done span { display: none; }

.step-connector {
  height: 2px;
  width: 32px;
  background: var(--border);
  flex-shrink: 0;
  transition: background .3s;
}

.step-connector.done {
  background: var(--navy);
}

/* ── Section heading ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ── Init / Loading ───────────────────────────────────────────────────────── */
.init-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0 8px;
  text-align: center;
}

.init-text {
  font-size: 13.5px;
  color: var(--text-mid);
  font-weight: 400;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────────────────────────── */
.error-icon { font-size: 32px; }

.error-msg {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
  text-align: center;
}

/* ── Bill card ────────────────────────────────────────────────────────────── */
.bill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.bill-card-header {
  background: linear-gradient(135deg, var(--teal-bg), #d0f0f4);
  border-bottom: 1px solid rgba(0,151,167,.15);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bill-card-header .bill-icon {
  width: 28px;
  height: 28px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  flex-shrink: 0;
}

.bill-card-header .bill-service {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

.bill-card-header .bill-service-sub {
  font-size: 11px;
  color: var(--teal);
  font-weight: 500;
}

.bill-rows {
  padding: 4px 0;
}

.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.bill-row:last-child { border-bottom: none; }

.bill-row-label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.bill-row-value {
  font-size: 13.5px;
  color: var(--text-main);
  font-weight: 500;
  text-align: right;
  max-width: 60%;
}

.bill-row-value.amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.bill-row-value .currency {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  margin-right: 3px;
}

/* ── Params summary (redirect mode header) ────────────────────────────────── */
.params-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.params-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.params-row:last-child { border-bottom: none; }

.params-label {
  font-size: 11.5px;
  color: var(--text-soft);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.params-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

/* ── Bank list ────────────────────────────────────────────────────────────── */
.bank-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
  margin: 0 0 8px;
}

.scroll-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.scrollable-list {
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.scrollable-list::-webkit-scrollbar { width: 4px; }
.scrollable-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}

.item:last-child { border-bottom: none; }
.item:hover { background: var(--surface); }
.item.selected { background: #eaf6f8; border-left: 3px solid var(--teal); }
.item.selected .label { color: var(--teal); font-weight: 600; }

.item .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item .label {
  font-size: 13.5px;
  color: var(--text-main);
  font-weight: 400;
}

.list-icon {
  width: 38px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-icon img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.list-icon-placeholder {
  width: 38px;
  height: 24px;
  background: var(--border-soft);
  border-radius: 4px;
  flex-shrink: 0;
}

.chev {
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1;
  transition: transform .15s;
}

.item:hover .chev { transform: translateX(2px); }

/* ── Inactive bank items ──────────────────────────────────────────────────── */
.item.inactive {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.item.inactive .label {
  color: var(--text-soft);
}

.item.inactive:hover {
  background: transparent;
}

.coming-soon-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid rgba(217,119,6,.25);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.bank-divider {
  padding: 6px 14px 5px;
  background: var(--border-soft);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}

/* ── Loading hint ─────────────────────────────────────────────────────────── */
.loading-hint {
  font-size: 12.5px;
  color: var(--text-mid);
  padding: 8px 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Inline API error ─────────────────────────────────────────────────────── */
.api-error {
  background: var(--red-bg);
  border: 1px solid rgba(220,38,38,.2);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--red);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ── Awaiting panel ───────────────────────────────────────────────────────── */
.awaiting-panel {
  text-align: center;
  padding: 4px 0 8px;
}

.awaiting-bank-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.awaiting-bank-logo img {
  height: 36px;
  object-fit: contain;
}

.awaiting-instruction {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 20px;
}

.awaiting-instruction strong {
  color: var(--navy);
  font-weight: 600;
}

.countdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 16px 0;
}

.countdown-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
}

.countdown-timer {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 4px;
}

.status-pill.pending  { background: var(--amber-bg);  color: var(--amber); }
.status-pill.checking { background: var(--teal-bg);   color: var(--teal); }
.status-pill.approved { background: var(--green-bg);  color: var(--green); }
.status-pill.declined { background: var(--red-bg);    color: var(--red); }

.status-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Terminal status ──────────────────────────────────────────────────────── */
.terminal-status {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  margin-top: 8px;
}

.terminal-status.authorized {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(22,163,74,.2);
}

.terminal-status.declined {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.2);
}

/* ── Complete step ────────────────────────────────────────────────────────── */
.complete-wrap {
  text-align: center;
  padding: 8px 0 4px;
}

.complete-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--green-bg);
  border: 2px solid rgba(22,163,74,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 30px;
  animation: pop .4s ease-out;
}

@keyframes pop {
  0%   { transform: scale(.6); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1);  opacity: 1; }
}

.complete-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 6px;
}

.complete-subtitle {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 20px;
}

.complete-subtitle strong {
  color: var(--navy);
  font-weight: 600;
}

.txn-ref {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.txn-ref-label {
  font-size: 11.5px;
  color: var(--text-soft);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.txn-ref-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  font-family: 'Courier New', monospace;
}

/* ── Confirm failure banner ───────────────────────────────────────────────── */
.confirm-warning {
  background: var(--amber-bg);
  border: 1px solid rgba(217,119,6,.25);
  border-radius: var(--radius-xs);
  padding: 9px 13px;
  font-size: 12px;
  color: var(--amber);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ── Action buttons ───────────────────────────────────────────────────────── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.actions.row {
  flex-direction: row;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: all .18s;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

.btn.primary {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0,151,167,.3);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,151,167,.4);
}

.btn.primary:active:not(:disabled) { transform: translateY(0); }

.btn.secondary {
  background: var(--white);
  color: var(--text-mid);
  border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--text-soft);
}

.btn.danger {
  background: var(--white);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.25);
}

.btn.danger:hover:not(:disabled) {
  background: var(--red-bg);
}

.btn.navy {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(27,58,107,.3);
}

/* Legacy aliases used in existing templates */
.btn.approve  { background: linear-gradient(135deg, var(--teal), var(--teal-light)); color: var(--white); box-shadow: 0 2px 8px rgba(0,151,167,.3); border: none; }
.btn.approve:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,151,167,.4); }
.btn.decline  { background: var(--white); color: var(--text-mid); border: 1px solid var(--border); }
.btn.decline:hover:not(:disabled) { background: var(--surface); }
.btn.back     { background: transparent; color: var(--text-mid); font-size: 12.5px; font-weight: 500; padding: 6px 0; }

/* ── Debug panel ──────────────────────────────────────────────────────────── */
.debug-panel {
  margin-top: 24px;
  border: 1px solid rgba(27,58,107,.15);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-family: 'Courier New', 'Consolas', monospace;
}

.debug-panel-header {
  background: var(--navy);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.debug-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-family: var(--font);
}

.debug-status-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--font);
}

.debug-status-badge.ok  { background: rgba(22,163,74,.25);  color: #86efac; }
.debug-status-badge.err { background: rgba(220,38,38,.25);  color: #fca5a5; }
.debug-status-badge.pending { background: rgba(148,163,184,.2); color: rgba(255,255,255,.6); }

.debug-section {
  background: #0f172a;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.debug-section:last-child { border-bottom: none; }

.debug-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(148,163,184,.8);
  margin-bottom: 6px;
  font-family: var(--font);
}

.debug-endpoint {
  font-size: 12.5px;
  color: #7dd3fc;
}

.debug-method {
  color: #86efac;
  font-weight: 700;
  margin-right: 6px;
}

.debug-code pre {
  font-size: 11.5px;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.debug-code pre::-webkit-scrollbar { width: 3px; }
.debug-code pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }

/* ── Manual entry form ────────────────────────────────────────────────────── */
.field-group { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-main);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,151,167,.1);
}

/* ── Field hints ─────────────────────────────────────────────────────────── */
.field-hint-error {
  font-size: 11.5px;
  color: var(--red);
  margin-top: 5px;
  display: block;
}

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── Utilities ────────────────────────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.small-text { font-size: 11px; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.card-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.card-footer-text {
  font-size: 11px;
  color: var(--text-soft);
}

.card-footer-logo {
  height: 14px;
  opacity: .6;
}

/* ── Responsive tweaks ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card { border-radius: var(--radius) var(--radius) 0 0; }
  .page-wrap { padding: 0; justify-content: flex-end; }
  .card { max-width: 100%; }
}