/* =========================================================================
   RajBill Digitizer — Design tokens (v2)
   Palette: Indigo #4F46E5 · Slate BG #F8FAFC · Surface #FFFFFF
            Emerald (credit/success) #059669 · Rose (debit/error) #E11D48
            Amber (warning) #D97706 · Slate text #0F172A / #64748B
   Type: Sora (display/headings) · Inter (body) · JetBrains Mono (numbers/data)
   Layout: mobile-first, top navbar collapsing into a hamburger menu on mobile
   ========================================================================= */

:root {
  --indigo: #4F46E5;
  --indigo-dark: #4338CA;
  --indigo-light: #EEF2FF;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --emerald: #059669;
  --emerald-light: #ECFDF5;
  --rose: #E11D48;
  --rose-light: #FFF1F2;
  --amber: #D97706;
  --amber-light: #FFFBEB;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.mono, .money, input[type="number"], .gstin, code {
  font-family: 'JetBrains Mono', monospace;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------- topnav */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--indigo);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif; font-weight: 800; font-size: 14px;
}
.brand-name { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px; color: var(--text); }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text); margin: 0 auto; transition: 0.2s; }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-links a:hover { background: var(--indigo-light); color: var(--indigo); }
.nav-links a.active { background: var(--indigo-light); color: var(--indigo); }
.nav-divider { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }

.wallet-chip {
  display: flex; align-items: baseline; gap: 4px;
  background: var(--indigo-light);
  border-radius: 999px;
  padding: 7px 14px;
}
.wallet-value { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--indigo); font-size: 14px; }
.wallet-unit { font-size: 11px; color: var(--indigo); opacity: 0.75; }
.logout-link { color: var(--rose) !important; }
.logout-link:hover { background: var(--rose-light) !important; }

/* ---------------------------------------------------------------- content */
.content { max-width: 1160px; margin: 0 auto; padding: 32px 20px 60px; }

/* ---------------------------------------------------------------- flash */
.flash-stack { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 10px; font-size: 14px; border-left: 4px solid; }
.flash-success { background: var(--emerald-light); border-color: var(--emerald); color: #065F46; }
.flash-error { background: var(--rose-light); border-color: var(--rose); color: #9F1239; }
.flash-warning { background: var(--amber-light); border-color: var(--amber); color: #92400E; }
.flash-info { background: var(--indigo-light); border-color: var(--indigo); color: var(--indigo-dark); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-done { background: var(--emerald-light); color: var(--emerald); }
.badge-processing { background: var(--amber-light); color: var(--amber); }
.badge-failed, .badge-insufficient_credits { background: var(--rose-light); color: var(--rose); }

/* ---------------------------------------------------------------- forms */
.page-header { margin-bottom: 28px; }
.page-header p { color: var(--text-muted); margin-top: 6px; font-size: 15px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: #fff;
  color: var(--text);
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: 'Inter', sans-serif;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); box-shadow: 0 4px 14px rgba(79,70,229,0.3); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--indigo); color: var(--indigo); }
.btn-danger { background: var(--rose); color: #fff; }
.btn-danger:hover { background: #BE123C; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------------------------------------------------------------- auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 26px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-switch a { color: var(--indigo); font-weight: 600; }

/* ---------------------------------------------------------------- landing */
.hero {
  min-height: calc(100vh - 65px);
  background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 60px 20px;
}
.hero-inner { max-width: 620px; margin: 0 auto; text-align: center; }
.hero .eyebrow {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,0.12);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 20px;
}
.hero h1 { font-size: 40px; line-height: 1.15; margin-bottom: 18px; color: #fff; }
.hero p.lede { font-size: 16px; color: rgba(255,255,255,0.85); margin-bottom: 30px; line-height: 1.65; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 44px; }
.hero-feature { background: rgba(255,255,255,0.08); border-radius: 12px; padding: 16px; font-size: 13px; }
.hero-feature .icon { font-size: 22px; margin-bottom: 6px; }

/* ---------------------------------------------------------------- dashboard */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-box .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-box .value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; color: var(--text); margin-top: 4px; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: #FAFBFF;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.upload-zone.dragover { border-color: var(--indigo); background: var(--indigo-light); }
.upload-zone .icon { font-size: 34px; margin-bottom: 8px; }
.upload-zone .hint { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
#file-name-display { font-family: 'JetBrains Mono', monospace; font-size: 13px; margin-top: 12px; color: var(--emerald); }

.capture-options { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.combine-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--indigo-light);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}
.combine-toggle input { width: 16px; height: 16px; accent-color: var(--indigo); }

/* ------------------------------------------------------------ multi-upload preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 12px;
  margin-top: 20px;
  text-align: left;
}
.preview-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.preview-item img {
  display: block;
  width: 100%;
  height: 88px;
  object-fit: cover;
  background: var(--bg);
}
.preview-pdf-icon {
  width: 100%;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: var(--indigo-light);
}
.preview-filename {
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 4px 6px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.preview-remove-btn:hover { background: var(--rose); }

/* ---------------------------------------------------------------- processing modal */
.processing-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.processing-modal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.processing-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 18px;
  border-radius: 999px;
  border: 4px solid var(--indigo-light);
  border-top-color: var(--indigo);
  animation: rajbill-spin 0.8s linear infinite;
}
@keyframes rajbill-spin { to { transform: rotate(360deg); } }
.processing-title { font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.processing-file {
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 16px;
  margin-bottom: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.processing-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--indigo-light);
  overflow: hidden;
  margin-bottom: 10px;
}
.processing-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--indigo);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.processing-count { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.processing-note { font-size: 11.5px; color: var(--text-muted); }
.job-progress-mini { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ---------------------------------------------------------------- job detail: original preview gallery */
.original-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.original-gallery-item {
  display: block;
  position: relative;
}
.original-gallery-item img {
  max-width: 220px;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}
.original-gallery-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.data-table th {
  text-align: left; background: var(--text); color: #fff;
  padding: 10px 14px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: var(--indigo-light); }
table.data-table td.money { text-align: right; }

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

.topup-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.topup-option { border: 1.5px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; background: #fff; }
.topup-option:hover { border-color: var(--indigo); background: var(--indigo-light); }
.topup-option .credits { font-family: 'JetBrains Mono', monospace; font-size: 20px; font-weight: 700; color: var(--text); }
.topup-option .label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.info-note { font-size: 12.5px; color: var(--text-muted); background: var(--bg); border-radius: 8px; padding: 10px 14px; margin-top: 12px; }

.voucher-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; background: var(--surface); }
.stat-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill-done { background: var(--emerald-light); color: var(--emerald); }
.pill-processing { background: var(--amber-light); color: var(--amber); }
.pill-failed, .pill-insufficient_credits { background: var(--rose-light); color: var(--rose); }

.footer-note { color: var(--text-muted); font-size: 12.5px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }

@media (max-width: 860px) {
  .hamburger { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 60px; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px 20px;
    box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 14px; }
  .nav-divider { display: none; }
  .wallet-chip { justify-content: center; margin: 8px 0; }
  .stat-row, .form-row, .topup-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
  .hero-features { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 96px; }
  .bottom-nav { display: flex; }
}

/* ---------------------------------------------------------- mobile bottom nav */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  align-items: stretch;
  justify-content: space-around;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 2px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.bottom-nav-item.active { color: var(--indigo); }
.bottom-nav-icon {
  font-size: 19px;
  line-height: 1;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
}
.bottom-nav-item.active .bottom-nav-icon { background: var(--indigo-light); }

:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
