/* ============================================================
   BillsApp — Compact Payment Terminal UI
   Theme: IntaSend (#1B4FBB primary, #F4A726 accent)
   Font: Inter
   Approach: single centered card, action-first
   ============================================================ */

/* ---- Variables ---- */
:root {
  --blue:       #1B4FBB;
  --blue-dark:  #1540A0;
  --blue-light: #EEF3FF;
  --gold:       #F4A726;
  --green:      #059669;
  --green-bg:   #D1FAE5;
  --red:        #DC2626;
  --red-bg:     #FEE2E2;
  --amber:      #D97706;
  --amber-bg:   #FEF3C7;
  --purple:     #7C3AED;
  --purple-bg:  #EDE9FE;

  --ok:         #10B981;
  --ok-bg:      #ECFDF5;
  --fail:       #EF4444;
  --fail-bg:    #FEF2F2;
  --warn:       #F59E0B;
  --warn-bg:    #FFFBEB;

  --text:       #111827;
  --text-2:     #374151;
  --muted:      #6B7280;
  --border:     #E5E7EB;
  --bg:         #ECEEF2;
  --white:      #FFFFFF;

  --r:    10px;
  --r-lg: 18px;
  --shadow: 0 4px 24px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --trans: 150ms ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ============================================================
   SHELL & CARD
   ============================================================ */
.shell {
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 12px 40px;
}

.card {
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}

/* ============================================================
   CARD HEADER
   ============================================================ */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo-icon { display: flex; align-items: center; flex-shrink: 0; }
.logo-text { letter-spacing: -.01em; }

.header-nav { display: flex; align-items: center; gap: 4px; }
.header-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
}
.header-link:hover { background: var(--blue-light); color: var(--blue); text-decoration: none; }
.header-link--muted { color: var(--muted); font-size: .78rem; }
.header-link--muted:hover { background: #F3F4F6; color: var(--text); }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flashes { border-bottom: 1px solid var(--border); }
.flash {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: .85rem;
  font-weight: 500;
}
.flash--success { background: var(--ok-bg); color: #065F46; }
.flash--error   { background: var(--fail-bg); color: #991B1B; }
.flash--warning { background: var(--warn-bg); color: #92400E; }
.flash--info    { background: var(--blue-light); color: var(--blue-dark); }
.flash-icon { font-size: .9rem; flex-shrink: 0; }
.flash-close {
  margin-left: auto;
  opacity: .6;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  background: none; border: none;
}
.flash-close:hover { opacity: 1; }

/* ============================================================
   CARD BODY & FOOTER
   ============================================================ */
.card-body { padding: 24px 20px; }
.card-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--muted);
  text-align: center;
}
.card-foot a { color: var(--muted); text-decoration: underline; }
.foot-sep { margin: 0 6px; }

/* ============================================================
   HOME — SERVICE TILES
   ============================================================ */
.home { }
.home-prompt {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 14px;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 16px;
  border-radius: var(--r);
  text-decoration: none;
  transition: transform var(--trans), box-shadow var(--trans), filter var(--trans);
  cursor: pointer;
  border: 1.5px solid transparent;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.1);
  text-decoration: none;
  filter: brightness(.97);
}
.tile:active { transform: translateY(0); }

.tile--kplc      { background: var(--amber-bg); color: var(--amber); border-color: #FDE68A; }
.tile--safaricom { background: var(--green-bg);  color: var(--green); border-color: #A7F3D0; }
.tile--airtel    { background: var(--red-bg);    color: var(--red);   border-color: #FECACA; }
.tile--bills     { background: var(--blue-light); color: var(--blue); border-color: #BFDBFE; }

.tile-icon { display: flex; }
.tile-label {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.tile-sub {
  font-size: .75rem;
  color: var(--muted);
}

.home-signin {
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
  padding-top: 4px;
}
.home-signin a { color: var(--blue); font-weight: 500; }

/* ============================================================
   PAGE LAYOUT (transactions, auth, history)
   ============================================================ */
.page-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.page-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-2);
  flex-shrink: 0;
  transition: background var(--trans);
}
.back-btn:hover { background: #F3F4F6; text-decoration: none; }

/* ============================================================
   STEP INDICATOR
   ============================================================ */
.steps {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 0;
  margin-bottom: 22px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.step {
  flex: 1;
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.step--active { color: var(--blue); }
.step--done   { color: var(--ok); }
.step-sep {
  width: 16px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* ============================================================
   FORM FIELDS
   ============================================================ */
.field,
.form-group { margin-bottom: 16px; }
.field-label,
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
.required { color: var(--red); margin-left: 2px; }

.field-input,
.form-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: .92rem;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
  -webkit-appearance: none;
}
.field-input::placeholder,
.form-input::placeholder { color: #C4C9D4; }
.field-input:focus,
.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(27,79,187,.12);
}
.input-error { border-color: var(--fail) !important; }
.field-input.otp-input,
.form-input.otp-input {
  text-align: center;
  letter-spacing: .3em;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 14px;
}

/* Input with prefix (+254) */
.input-group {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color var(--trans), box-shadow var(--trans);
}
.input-group:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(27,79,187,.12);
}
.input-prefix {
  padding: 10px 10px;
  background: #F9FAFB;
  border-right: 1.5px solid var(--border);
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.input-group .form-input {
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.input-group .form-input:focus { border: none; box-shadow: none; }

.field-hint,
.form-hint  { display: block; font-size: .73rem; color: var(--muted); margin-top: 4px; }
.field-error,
.form-error { display: block; font-size: .73rem; color: var(--fail); margin-top: 4px; font-weight: 500; }
.form-note  { font-size: .75rem; color: var(--muted); margin: 8px 0 14px; }

/* Live fee hint inside amount field area */
#amount-fee { font-size: .73rem; color: var(--blue); font-weight: 600; margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  background: var(--blue);
  color: var(--white);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: .92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans);
  text-decoration: none;
  text-align: center;
}
.btn-primary:hover { background: var(--blue-dark); text-decoration: none; }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-pay { background: #0E3D96; }
.btn-pay:hover { background: #0B3080; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  background: var(--white);
  color: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans);
  text-decoration: none;
  text-align: center;
}
.btn-outline:hover { background: var(--blue-light); text-decoration: none; }
.btn-outline.btn-block { display: flex !important; width: 100%; }

.btn-ghost {
  display: block;
  text-align: center;
  padding: 10px;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 500;
  border-radius: var(--r);
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
}
.btn-ghost:hover { background: #F3F4F6; color: var(--text); text-decoration: none; }

.btn-block { display: flex !important; width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .8rem; border-radius: 8px; }

.btn-primary + .btn-ghost,
.btn-outline + .btn-ghost,
.btn-primary + .btn-outline,
.btn-outline + .btn-primary { margin-top: 8px; }

/* Icon button */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text-2);
  transition: background var(--trans);
  text-decoration: none;
}
.icon-btn:hover { background: #F3F4F6; text-decoration: none; }

/* Mode toggle (single/batch) */
.mode-toggle {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
  flex-shrink: 0;
}
.mode-btn {
  padding: 5px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
}
.mode-btn:hover { text-decoration: none; background: #F3F4F6; }
.mode-btn--active { background: var(--blue); color: var(--white); }
.mode-btn--active:hover { background: var(--blue-dark); }

/* Add row in batch */
.add-row-btn {
  font-size: .82rem;
  color: var(--blue);
  font-weight: 600;
  padding: 6px 0;
  margin-bottom: 12px;
  cursor: pointer;
  border: none;
  background: none;
}
.add-row-btn:hover { text-decoration: underline; }

.batch-row { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.batch-row-label { font-size: .73rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 10px; }

/* ============================================================
   DETAIL LIST (preview & result)
   ============================================================ */
.detail-list {
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--muted); font-weight: 500; flex-shrink: 0; }
.detail-row dd { text-align: right; font-weight: 600; word-break: break-all; }
.detail-row--total { background: #F9FAFB; }
.detail-row--total dt,
.detail-row--total dd { font-weight: 700; font-size: .92rem; color: var(--text); }

/* ============================================================
   FEE BOX (preview)
   ============================================================ */
.fee-box {
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
}
.fee-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.fee-row:last-child { border-bottom: none; }
.fee-row--total {
  background: var(--blue-light);
  font-weight: 700;
  font-size: .92rem;
  color: var(--blue-dark);
}

.stk-notice {
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
}
.stk-notice strong { color: var(--text); }

/* ============================================================
   PROCESSING PAGE
   ============================================================ */
.processing-page { text-align: center; }
.pulse-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 18px;
  width: 80px;
  height: 80px;
}
.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--blue);
  opacity: .3;
  animation: pulse 2s ease-out infinite;
}
.pulse-ring--delay { animation-delay: 1s; }
@keyframes pulse {
  0%   { transform: scale(.7); opacity: .4; }
  100% { transform: scale(1.4); opacity: 0; }
}
.pulse-icon { position: relative; z-index: 1; }

.proc-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.proc-sub   { font-size: .85rem; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.proc-sub strong { color: var(--text); }

.proc-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 20px;
}
.proc-meta-sep { color: var(--border); }
.proc-meta-item { }

.poll-track {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.poll-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 99px;
  width: 0%;
  transition: width 800ms ease;
}
.poll-text {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.refresh-wrap { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.refresh-msg  { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }

/* ============================================================
   RESULT PAGE
   ============================================================ */
.result-page { }
.result-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
.result-icon--ok   { background: var(--ok); }
.result-icon--fail { background: var(--fail); }
.result-icon--wait { background: var(--warn); }

.result-title {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.result-error {
  text-align: center;
  font-size: .83rem;
  color: var(--fail);
  margin-bottom: 16px;
  padding: 10px;
  background: var(--fail-bg);
  border-radius: var(--r);
}
.result-pending {
  text-align: center;
  font-size: .83rem;
  color: var(--warn);
  margin-bottom: 16px;
}

/* KPLC token */
.token-box {
  background: #FFFBEB;
  border: 2px dashed #FDE68A;
  border-radius: var(--r);
  text-align: center;
  padding: 18px 14px;
  margin-bottom: 16px;
}
.token-label {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--amber);
  margin-bottom: 8px;
}
.token-digits {
  font-family: 'SF Mono', 'Courier New', monospace;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--text);
  margin-bottom: 10px;
  word-break: break-all;
  line-height: 1.3;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: var(--amber-bg);
  color: var(--amber);
  border: 1.5px solid #FDE68A;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans);
  margin-bottom: 8px;
}
.copy-btn:hover { background: #FEF0C7; }
.token-hint { font-size: .72rem; color: var(--muted); }

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.status-pill--completed  { background: var(--ok-bg); color: #065F46; }
.status-pill--failed     { background: var(--fail-bg); color: #991B1B; }
.status-pill--pending,
.status-pill--stk_sent,
.status-pill--paid,
.status-pill--processing { background: var(--warn-bg); color: #92400E; }

.result-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page { }
.auth-sub {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
.auth-divider {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
  margin: 14px 0;
  position: relative;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

.auth-perks {
  list-style: none;
  margin-top: 18px;
  padding: 14px;
  background: #F9FAFB;
  border-radius: var(--r);
}
.auth-perks li {
  font-size: .78rem;
  color: var(--muted);
  padding: 3px 0;
}

.otp-timer {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
  margin: 12px 0;
}

/* ============================================================
   HISTORY PAGE
   ============================================================ */
.history-page { }
.history-user {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 14px;
  margin-top: -8px;
}
.history-new-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* Transaction list rows */
.txn-list { border-radius: var(--r); border: 1.5px solid var(--border); overflow: hidden; }
.txn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background var(--trans);
}
.txn-row:last-child { border-bottom: none; }
.txn-row:hover { background: #F9FAFB; text-decoration: none; }
.txn-row-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.txn-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }

.txn-type-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.txn-type-dot--kplc             { background: var(--amber); }
.txn-type-dot--airtime_safaricom { background: var(--green); }
.txn-type-dot--airtime_airtel   { background: var(--red); }
.txn-type-dot--bill_payment     { background: var(--blue); }

.txn-row-title { font-size: .85rem; font-weight: 600; }
.txn-row-meta  { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.txn-row-amount { font-size: .88rem; font-weight: 700; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.page-link {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  border: 1.5px solid var(--border);
  transition: background var(--trans);
  text-decoration: none;
}
.page-link:hover { background: var(--blue-light); text-decoration: none; }
.page-link--active { background: var(--blue); color: var(--white); border-color: var(--blue); }
.page-ellipsis { padding: 5px 4px; font-size: .8rem; color: var(--muted); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
}
.empty-state p { font-size: .85rem; margin-bottom: 14px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.mono { font-family: 'SF Mono', 'Courier New', monospace; font-size: .88em; letter-spacing: .02em; }

/* ============================================================
   MOBILE — already mobile-first; these are max-width tweaks
   ============================================================ */
@media (max-width: 460px) {
  .shell { padding: 0; align-items: flex-start; }
  .card { border-radius: 0; box-shadow: none; min-height: 100dvh; }
  .token-digits { font-size: 1.3rem; letter-spacing: .1em; }
}

@media (min-width: 461px) {
  .shell { align-items: center; padding: 32px 12px 48px; }
}
