:root {
  --primary: #C62828;
  --primary-dark: #9A1B1B;
  --primary-light: #FFEBEE;
  --secondary: #2E7D32;
  --secondary-light: #E8F5E9;
  --gold: #E6A122;
  --gold-light: #FFF8E7;
  --dark-bg: #141416;
  --dark-surface: #1E1F24;
  --body-bg: #F5F2EB;
  --surface: #FFFFFF;
  --text-main: #1F2421;
  --text-muted: #6B7280;
  --border: #E5E0D8;
  --border-focus: #C62828;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --app-max-width: 460px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #24252A;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* App Viewport Container */
#app-container {
  width: 100%;
  max-width: var(--app-max-width);
  height: 100vh;
  max-height: 920px;
  background-color: var(--body-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

@media (max-width: 480px) {
  body {
    background-color: var(--body-bg);
  }
  #app-container {
    height: 100vh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (min-width: 481px) {
  #app-container {
    border-radius: 36px;
    border: 8px solid #2B2C32;
  }
}

/* Top App Bar */
.top-bar {
  background: linear-gradient(135deg, #18191D 0%, #26272E 100%);
  color: #FFFFFF;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  z-index: 100;
  flex-shrink: 0;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-back {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #FFF;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-back:hover {
  background: var(--primary);
}

.brand-logo-img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
}

.brand-title-group h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title-group h1 span {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 700;
}

/* Header Status Badge */
.header-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(46, 125, 50, 0.2);
  border: 1px solid rgba(46, 125, 50, 0.5);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #81C784;
}

.status-dot {
  width: 7px;
  height: 7px;
  background-color: #4CAF50;
  border-radius: 50%;
  box-shadow: 0 0 6px #4CAF50;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Screen Content Area */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 80px 16px;
  position: relative;
  scroll-behavior: smooth;
}

.screen {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Screen Header */
.screen-header {
  margin-bottom: 16px;
}

.screen-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.screen-title {
  font-size: 22px;
  font-weight: 800;
  color: #111;
  line-height: 1.2;
}

.screen-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Card Styles */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #333;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input, .form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #111;
  background-color: #FFF;
  transition: all 0.2s;
  font-family: inherit;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #FFF;
  box-shadow: 0 4px 10px rgba(198, 40, 40, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-dark {
  background: #1C1D22;
  color: #FFF;
}

.btn-dark:hover {
  background: #000;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-main);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: #EEE;
}

.btn-green {
  background: var(--secondary);
  color: #FFF;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  width: auto;
}

/* Chips / Filter Pills */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

/* Scanner Frame */
.scanner-viewport {
  width: 100%;
  height: 280px;
  background: #111;
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #FFF;
  margin-bottom: 16px;
  border: 2px solid #333;
}

.scanner-reticle {
  width: 180px;
  height: 180px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-light);
  box-shadow: 0 0 10px #FF5252;
  animation: scanAnim 2.5s infinite linear;
}

@keyframes scanAnim {
  0% { top: 0; }
  50% { top: 178px; }
  100% { top: 0; }
}

.scanner-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--primary);
  border-style: solid;
}
.c-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.c-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; }
.c-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; }
.c-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }

/* Saldo Badge & Hero */
.saldo-hero {
  background: linear-gradient(135deg, #1C1D22 0%, #2A2B34 100%);
  color: #FFF;
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  border-top: 4px solid var(--primary);
  box-shadow: var(--shadow-md);
}

.saldo-hero .client-name {
  font-size: 18px;
  font-weight: 800;
  color: #FFF;
}

.saldo-hero .saldo-amount {
  font-size: 38px;
  font-weight: 900;
  color: var(--gold);
  margin: 6px 0;
  letter-spacing: -0.5px;
}

.saldo-hero .saldo-sub {
  font-size: 12px;
  color: #BBB;
}

/* Grid & Tables */
.menu-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.menu-item-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.menu-item-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.menu-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.menu-item-text h3 {
  font-size: 15px;
  font-weight: 700;
  color: #222;
}

.menu-item-text p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Table Style */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  background: #F3EFE8;
  color: #333;
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: #333;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: #FAF7F2;
}

.badge-pts-plus {
  color: var(--secondary);
  font-weight: 800;
}

.badge-pts-minus {
  color: var(--primary);
  font-weight: 800;
}

.link-action {
  color: #1976D2;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* Rewards Grid (Screen 05) */
.rewards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.reward-card-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.reward-card-btn:hover, .reward-card-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.reward-icon-box {
  font-size: 26px;
}

.reward-name {
  font-size: 11px;
  font-weight: 700;
  color: #222;
  line-height: 1.2;
}

.reward-pts-badge {
  font-size: 10px;
  font-weight: 800;
  color: var(--primary);
}

/* Signature Canvas */
.signature-box {
  background: #FFF;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  width: 100%;
  height: 130px;
  position: relative;
  cursor: crosshair;
  margin-bottom: 8px;
}

.signature-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.signature-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Ranking Chart (Screen 13) */
.ranking-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.ranking-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.ranking-badge {
  background: var(--primary);
  color: #FFF;
  font-weight: 800;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 8px;
}

.ranking-name {
  font-weight: 700;
  font-size: 13px;
  color: #222;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #EAE6DF;
  border-radius: 5px;
  overflow: hidden;
  margin: 6px 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--gold) 100%);
  border-radius: 5px;
}

.ranking-stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Bottom Tab Navigation */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #1C1D22;
  border-top: 1px solid #33343C;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #888;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  width: 20%;
  height: 100%;
  gap: 4px;
  transition: all 0.2s;
  font-family: inherit;
}

.nav-tab .tab-icon {
  font-size: 18px;
}

.nav-tab.active, .nav-tab:hover {
  color: var(--gold);
}
.nav-tab.active .tab-icon {
  transform: scale(1.15);
  color: var(--primary);
}

/* Google Wallet Pass Replica Modal */
.wallet-modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(5px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-in-out;
}

.wallet-card-modal {
  width: 100%;
  max-width: 380px;
  background: #141416;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6);
  border: 1px solid #333;
}

.wallet-pass-card {
  background: #C62828;
  border-radius: 16px;
  color: #FFF;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  position: relative;
}

.pass-top-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.2);
}

.pass-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gold);
}

.pass-issuer {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pass-program {
  font-size: 14px;
  font-weight: 900;
  color: #FFF;
}

.pass-hero-img-wrap {
  width: 100%;
  height: 110px;
  overflow: hidden;
  background: #18191D;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pass-hero-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.pass-balance-section {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.pass-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
}

.pass-points {
  font-size: 24px;
  font-weight: 900;
  color: #FFF;
}

.pass-equiv {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
}

.pass-details-row {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
}

.pass-val {
  font-size: 13px;
  font-weight: 700;
  color: #FFF;
  margin-top: 2px;
}

.pass-barcode-box {
  background: #FFF;
  margin: 8px 12px 12px;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

/* Real Camera Viewport Overrides */
#qr-reader {
  width: 100% !important;
  border: none !important;
  background: #000 !important;
}
#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: var(--radius-md) !important;
}
#qr-reader__scan_region {
  background: transparent !important;
}
#qr-reader__dashboard {
  display: none !important;
}
#qr-reader__status_span {
  display: none !important;
}

