:root {
  --bg: #ededed;
  --surface: #ffffff;
  --blue: #009ee3;
  --blue-dark: #0073a8;
  --action: #3483fa;
  --action-dark: #2968c8;
  --green: #00a650;
  --red: #f23d4f;
  --text: rgba(0, 0, 0, .9);
  --text-dim: rgba(0, 0, 0, .45);
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

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

body {
  font-family: 'Proxima Nova', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.device {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- Telas ---------- */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn .25s ease;
  padding-bottom: 20px;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Cabeçalho azul estilo Mercado Pago */
.screen-header {
  background: linear-gradient(90deg, var(--blue) 0%, var(--action) 100%);
  color: #fff;
  text-align: center;
  padding: 18px 20px 22px;
  margin-bottom: 20px;
}
.screen-header h1 { font-size: 1.15rem; font-weight: 600; margin-top: 6px; }

.logo {
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: rgba(255, 255, 255, .85);
}
.logo span { color: #fff; }

.valor-resumo { color: rgba(255, 255, 255, .95); font-weight: 700; font-size: 1rem; margin-top: 6px; }

.hint { text-align: center; color: var(--text-dim); margin-top: 12px; padding: 0 20px; }
.hint.strong { color: var(--text); font-weight: 600; font-size: 1.05rem; }

/* ---------- Valor ---------- */
.valor-display {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  padding: 26px 16px;
  margin: 0 20px 18px;
  font-size: 2.4rem;
  font-weight: 300;
  color: var(--text);
}
.valor-display span { font-weight: 600; }

/* ---------- Teclado ---------- */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 20px 16px;
}

.keypad button {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 400;
  padding: 15px 0;
  cursor: pointer;
  transition: background .12s, transform .08s;
  user-select: none;
}

.keypad button:active { background: #f0f0f0; transform: scale(.96); }
.keypad .key-alt { font-size: .95rem; color: var(--text-dim); }

/* ---------- Botões ---------- */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 15px;
  margin: 0 20px;
  cursor: pointer;
  transition: background .12s, transform .08s;
}
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:disabled { background: #e0e0e0; color: var(--text-dim); cursor: default; box-shadow: none; }
.btn-primary:not(:disabled):active, .btn-secondary:active { transform: scale(.98); filter: brightness(1.05); }
.btn-secondary { background: transparent; color: var(--action); margin-top: 10px; }

.btn-group { display: flex; flex-direction: column; }

/* ---------- Tipo ---------- */
.tipo-opcoes { display: flex; flex-direction: column; gap: 12px; flex: 1; padding: 0 20px; }

.btn-tipo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 22px 20px;
  cursor: pointer;
  text-align: left;
  transition: transform .08s, box-shadow .15s;
}
.btn-tipo:active { transform: scale(.98); box-shadow: 0 0 0 2px var(--action); }
.tipo-icone { font-size: 1.7rem; }
.tipo-label { font-size: 1.25rem; font-weight: 600; }
.tipo-sub { color: var(--text-dim); font-size: .85rem; }

/* ---------- NFC ---------- */
.nfc-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nfc-icon { font-size: 4.5rem; z-index: 2; animation: nfcPulse 1.6s ease-in-out infinite; }

@keyframes nfcPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.nfc-waves { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.wave {
  position: absolute;
  border: 2px solid var(--blue);
  border-radius: 50%;
  opacity: 0;
  animation: wave 2.4s ease-out infinite;
}
.w1 { width: 130px; height: 130px; }
.w2 { width: 130px; height: 130px; animation-delay: .8s; }
.w3 { width: 130px; height: 130px; animation-delay: 1.6s; }

@keyframes wave {
  0%   { transform: scale(1); opacity: .7; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ---------- Spinner ---------- */
.spinner-area { flex: 1; display: flex; align-items: center; justify-content: center; }
.spinner {
  width: 72px; height: 72px;
  border: 6px solid #d6eaf8;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Resultado ---------- */
.resultado-area { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 0 20px; }
.resultado-icon {
  width: 110px; height: 110px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3.4rem; font-weight: 800;
  color: #fff;
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.resultado-icon.ok  { background: var(--green); }
.resultado-icon.err { background: var(--red); }
.resultado-titulo { font-size: 1.4rem; font-weight: 600; }
.resultado-titulo.ok { color: var(--green); }
.resultado-titulo.err { color: var(--red); }
.resultado-detalhe { color: var(--text-dim); font-size: 1rem; text-align: center; }

@keyframes pop {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- Modal senha ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 420px;
  padding: 24px 0 20px;
  animation: slideUp .25s ease;
}
.modal h2 { text-align: center; font-size: 1.1rem; font-weight: 600; margin-bottom: 18px; padding: 0 20px; }

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.senha-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 20px; }
.senha-dots span {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid #c8c8c8;
  transition: background .1s, border-color .1s;
}
.senha-dots span.filled { background: var(--action); border-color: var(--action); }

.modal .keypad { margin-bottom: 8px; }

/* ---------- Link dev ---------- */
.dev-link {
  position: fixed;
  bottom: 12px; right: 12px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  font-size: 1.2rem;
  opacity: .7;
  z-index: 5;
}

/* ---------- Painel do operador ---------- */
.operador .device { max-width: 640px; }
.panel-header {
  padding: 24px 20px 16px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--action) 100%);
  color: #fff;
}
.panel-header h1 { font-size: 1.3rem; font-weight: 600; }
.panel-header p { color: rgba(255, 255, 255, .8); margin-top: 4px; font-size: .85rem; }

.estado-atual {
  margin: 14px 20px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.estado-atual .label { color: var(--text-dim); font-size: .8rem; }
.estado-atual .valor { font-weight: 700; color: var(--blue-dark); font-size: 1rem; }

.panel-section { padding: 4px 20px; }
.panel-section h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin: 14px 0 10px; }

.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

.panel-btn {
  background: var(--surface);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  color: var(--text);
  padding: 13px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, transform .08s;
}
.panel-btn:hover { border-color: var(--action); color: var(--action); }
.panel-btn:active { transform: scale(.97); }
.panel-btn.ok { border-color: var(--green); color: var(--green); }
.panel-btn.err { border-color: var(--red); color: var(--red); }

.panel-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px;
  font-size: .9rem;
  margin-bottom: 10px;
}

.log {
  margin: 10px 20px 30px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  padding: 14px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: .78rem;
  max-height: 220px;
  overflow-y: auto;
  color: var(--text-dim);
}
.log div { padding: 2px 0; }
.log .t { color: #c0c0c0; margin-right: 8px; }
.log .cmd { color: var(--action); }
.log .st { color: var(--green); }
