:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #10b981;
  --secondary-hover: #059669;
  --secondary-light: #d1fae5;
  --dark: #0f172a;
  --dark-surface: #1e293b;
  --slate-500: #64748b;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --warning-light: #fef3c7;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --plate-font: "Courier New", Courier, monospace;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-float: 0 20px 40px -10px rgba(15, 23, 42, 0.25);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 120px 16px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.header-content {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo-wrap {
  width: 44px;
  height: 44px;
  background: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
  border: 1px solid #e2e8f0;
}

.brand-logo-wrap svg,
.brand-logo-wrap img,
.brand-logo-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.brand-text h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--dark);
  line-height: 1.1;
}

.brand-text h1 .brand-highlight {
  color: #2563eb;
}

.brand-text span {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #2563eb;
  letter-spacing: 0.4px;
  display: block;
}

.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--dark);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.info-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #ecfdf5 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.info-banner svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.info-banner p {
  font-size: 0.8125rem;
  color: #1e3a8a;
  line-height: 1.4;
}

.search-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--slate-200);
  margin-bottom: 24px;
}

.search-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.search-card-subtitle {
  font-size: 0.75rem;
  color: var(--slate-500);
  margin-bottom: 16px;
}

/* ========================================================
   COMPONENTE DE PLACA DINÂMICA (MERCOSUL E ANTIGA)
   ======================================================== */
.mercosul-plate-box {
  background: #ffffff;
  border: 3px solid #000000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  margin-bottom: 10px;
  transition: all 0.25s ease;
}

/* Estilo Mercosul (Azul) */
.mercosul-plate-box.theme-mercosul .mercosul-header {
  background: #003399;
  color: #ffffff;
}

/* Estilo Placa Antiga (Cinza Tradicional) */
.mercosul-plate-box.theme-antiga {
  border-color: #475569;
  background: #f1f5f9;
}

.mercosul-plate-box.theme-antiga .mercosul-header {
  background: #64748b;
  color: #f8fafc;
  letter-spacing: 1px;
}

.mercosul-plate-box.theme-antiga .mercosul-body {
  background: #e2e8f0;
}

.mercosul-header {
  background: #003399;
  color: #ffffff;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  transition: background 0.25s ease;
}

.mercosul-header .flag-brasil {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mercosul-body {
  padding: 8px 12px;
  background: #fdfdfd;
  transition: background 0.25s ease;
}

.plate-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--plate-font);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 5px;
  text-align: center;
  text-transform: uppercase;
}

/* Indicador dinâmico de formato detectado */
.plate-format-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.71875rem;
  color: var(--slate-500);
}

.plate-badge-type {
  font-weight: 700;
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.plate-badge-type.badge-mercosul {
  background: #dbeafe;
  color: #1e40af;
}

.plate-badge-type.badge-antiga {
  background: #e2e8f0;
  color: #334155;
}

.plate-badge-type.badge-neutral {
  background: #f1f5f9;
  color: #64748b;
}

.quick-plates {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.quick-plates-label {
  font-size: 0.75rem;
  color: var(--slate-500);
}

.chip-plate {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  color: var(--dark);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.71875rem;
  font-family: var(--plate-font);
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, #0369a1 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.results-counter {
  font-size: 0.75rem;
  background: var(--slate-100);
  color: var(--slate-500);
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}

.toll-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  border: 1.5px solid var(--slate-200);
  display: flex;
  gap: 12px;
  cursor: pointer;
}

.toll-card.selected {
  border-color: var(--primary);
  background: #f0f9ff;
}

.custom-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--slate-500);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.toll-card.selected .custom-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.custom-checkbox svg {
  width: 14px;
  height: 14px;
  color: #ffffff;
  display: none;
}

.toll-card.selected .custom-checkbox svg {
  display: block;
}

.toll-card-info {
  flex: 1;
}

.toll-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}

.concessionaire-name {
  font-size: 0.8125rem;
  font-weight: 700;
}

.toll-amount {
  font-size: 1.05rem;
  font-weight: 800;
}

.portico-location {
  font-size: 0.78125rem;
  color: var(--slate-500);
  margin-bottom: 8px;
}

.toll-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.71875rem;
}

.evasion-warning {
  background: var(--warning-light);
  color: #b45309;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 700;
}

.checkout-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--slate-200);
  padding: 12px 16px calc(12px + var(--safe-bottom)) 16px;
  z-index: 50;
}

.checkout-bar-inner {
  max-width: 480px;
  margin: 0 auto;
}

.summary-breakdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.78125rem;
  color: var(--slate-500);
}

.checkout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.total-value {
  font-size: 1.35rem;
  font-weight: 800;
}

.btn-checkout {
  flex: 1;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ========================================================
   ABAS DE FORMA DE PAGAMENTO (Pix, Crédito, Débito)
   ======================================================== */
.payment-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--slate-100);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--slate-200);
}

.payment-tab-btn {
  background: transparent;
  border: none;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.78125rem;
  font-weight: 700;
  color: var(--slate-500);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.payment-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.payment-tab-btn svg {
  width: 18px;
  height: 18px;
}

/* ========================================================
   FORMULÁRIO DE CARTÃO SIMULADO
   ======================================================== */
.card-preview-box {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  border: 1px solid #334155;
}

.card-preview-chip {
  width: 32px;
  height: 24px;
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  border-radius: 4px;
  margin-bottom: 12px;
}

.card-preview-number {
  font-family: var(--plate-font);
  font-size: 1.05rem;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.card-preview-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  text-transform: uppercase;
  color: #94a3b8;
}

.card-preview-name {
  color: #ffffff;
  font-weight: 700;
}

.card-form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--dark);
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--dark);
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pci-shield-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.6875rem;
  color: #059669;
  background: #ecfdf5;
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.btn-card-pay {
  width: 100%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-card-pay:active {
  transform: scale(0.98);
}

/* Modal e Telas de Status */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(24px + var(--safe-bottom)) 20px;
  box-shadow: var(--shadow-float);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--slate-200);
  border-radius: 9999px;
  margin: 0 auto 16px auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.btn-close {
  background: var(--slate-100);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.pix-timer-box {
  background: var(--slate-100);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pix-countdown {
  font-family: var(--plate-font);
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
}

.qr-code-wrapper {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
}

.qr-code-img {
  width: 190px;
  height: 190px;
  background: #ffffff;
  padding: 8px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.qr-instructions {
  font-size: 0.75rem;
  color: var(--slate-500);
}

.pix-copy-box {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.pix-copy-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--slate-500);
  outline: none;
}

.btn-copy {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-copy.copied {
  background: var(--secondary);
}

.btn-simulate {
  width: 100%;
  background: #ffffff;
  color: #1e293b;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

.receipt-card {
  text-align: center;
  padding: 10px 0;
}

.receipt-icon {
  width: 56px;
  height: 56px;
  background: var(--secondary-light);
  color: var(--secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
}

.receipt-details {
  background: var(--slate-100);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--dark);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 200;
}

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

.offline-banner {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  background: #f59e0b;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  z-index: 60;
}

.ios-guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ios-guide-card {
  background: #ffffff;
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.ios-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  text-align: left;
  font-size: 0.875rem;
}

.ios-step-num {
  width: 28px;
  height: 28px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
