:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #f2f4f7;
  --text-dim: #9aa3b2;
  --primary: #32bf84;
  --primary-dark: #23935f;
  --danger: #e5534b;
  --warning: #d9a441;
  --radius: 16px;
  --radius-sm: 10px;
  --max-width: 460px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

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

.app.admin-app {
  max-width: 720px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
}

.topbar h1 {
  font-size: 19px;
  margin: 0;
  font-weight: 700;
}

.topbar .subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

.content {
  flex: 1;
  padding: 8px 20px 100px;
}

.center-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #06110a;
}

.brand .name {
  font-size: 20px;
  font-weight: 800;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}

.hero-card {
  background: linear-gradient(160deg, #17301f, var(--surface) 65%);
  border: 1px solid #22452c;
}

.hero-amount {
  font-size: 32px;
  font-weight: 800;
  margin: 4px 0 14px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-box .label {
  font-size: 12px;
  color: var(--text-dim);
}

.stat-box .value {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-pending { background: rgba(217, 164, 65, 0.15); color: var(--warning); }
.badge-finished { background: rgba(50, 191, 132, 0.15); color: var(--primary); }
.badge-blocked { background: rgba(229, 83, 75, 0.15); color: var(--danger); }
.badge-active { background: rgba(50, 191, 132, 0.15); color: var(--primary); }
.badge-partial { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-reversed { background: rgba(229, 83, 75, 0.15); color: var(--danger); }

.finished-banner {
  text-align: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #06170e;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px;
}

.qr-box img {
  width: 190px;
  height: 190px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
}

.pix-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  gap: 10px;
}

.pix-key-row code {
  word-break: break-all;
  color: var(--text);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.history-item:last-child { border-bottom: none; }

.history-item .amount { font-weight: 700; font-size: 15px; }
.history-item .date { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.history-item .notes { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

.history-item.is-reversed .amount { text-decoration: line-through; color: var(--text-dim); }

form.stacked { display: flex; flex-direction: column; gap: 14px; }

label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}

input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.field { margin-bottom: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #06170e;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
}

.btn:hover { background: var(--primary-dark); color: #fff; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(229, 83, 75, 0.15);
  color: var(--danger);
  border: 1px solid rgba(229, 83, 75, 0.4);
}

.btn-sm { padding: 9px 12px; font-size: 13px; width: auto; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.link-row {
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-dim);
}

.link-row a { color: var(--primary); text-decoration: none; font-weight: 600; }

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}

.alert-error { background: rgba(229, 83, 75, 0.12); color: #ff8f88; border: 1px solid rgba(229, 83, 75, 0.35); }
.alert-success { background: rgba(50, 191, 132, 0.12); color: #7fe0b3; border: 1px solid rgba(50, 191, 132, 0.35); }
.alert-info { background: rgba(217, 164, 65, 0.12); color: #f0c579; border: 1px solid rgba(217, 164, 65, 0.35); }

.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  gap: 6px;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
}

.bottom-nav a.active { color: var(--primary); background: rgba(50, 191, 132, 0.1); }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 22px 0 10px;
}

table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.simple th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.search-bar { margin-bottom: 16px; }
.search-bar form { display: flex; gap: 8px; }
.search-bar input { flex: 1; }

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.user-row:last-child { border-bottom: none; }
.user-row .name { font-weight: 700; font-size: 15px; }
.user-row .meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.user-row .right { text-align: right; }

/* Tabela de usuarios do admin: tabela normal em telas largas, vira lista de
   cards empilhados no celular (cada <td> mostra seu rotulo via data-label). */
.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th, .user-table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.user-table th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.user-table td.name-cell { font-weight: 700; font-size: 15px; }
.user-table td.name-cell a { color: var(--text); text-decoration: none; }
.user-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

@media (max-width: 640px) {
  .user-table thead { display: none; }
  .user-table, .user-table tbody, .user-table tr, .user-table td { display: block; width: 100%; }
  .user-table { border: none; }
  .user-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--surface-2);
  }
  .user-table td {
    border-bottom: none;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .user-table td.name-cell {
    justify-content: flex-start;
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }
  .user-table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
  }
  .user-table td.name-cell::before { content: none; }
  .user-table td .btn-sm { width: 100%; }
}

.small-text { font-size: 12px; color: var(--text-dim); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

@media (min-width: 500px) {
  .app.admin-app .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
