:root {
  --bg: #0f1117;
  --bg-elev: #151824;
  --card: #1a1d27;
  --card-hover: #222636;
  --border: #262a38;
  --text: #e6e9f2;
  --text-dim: #8a90a3;
  --text-muted: #5c6275;
  --accent: #4f8ef7;
  --accent-hover: #6ba0ff;
  --pix: #4f8ef7;
  --credit: #22c55e;
  --warn: #facc15;
  --danger: #ef4444;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select {
  font: inherit;
  color: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* =========================================================================
   LOGIN
   ========================================================================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 80% -10%, rgba(79, 142, 247, 0.14), transparent),
    radial-gradient(700px 400px at -10% 110%, rgba(79, 142, 247, 0.10), transparent),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.35s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 6px;
}

.login-logo .dot {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #3a6fd1);
  display: grid; place-items: center;
  font-weight: 700; color: white;
  box-shadow: 0 4px 12px rgba(79, 142, 247, 0.4);
}

.login-logo .name {
  font-size: 20px; font-weight: 600; letter-spacing: -0.02em;
}

.login-card h1 {
  font-size: 22px; margin-top: 14px; text-align: center; font-weight: 600;
}

.login-card p.subtitle {
  text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 22px;
}

.form-field {
  margin-bottom: 14px;
  position: relative;
}

.form-field label {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 6px; letter-spacing: 0.02em;
}

.form-field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.form-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #10121b;
}

.form-field .toggle-pw {
  position: absolute; right: 10px; top: 32px;
  padding: 6px 8px; color: var(--text-dim); font-size: 12px; border-radius: 6px;
}
.form-field .toggle-pw:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.btn-primary {
  width: 100%;
  padding: 12px 14px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  font-weight: 600;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: 0.6; cursor: progress; }

.error-msg {
  margin-top: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
}
.error-msg.show { display: block; animation: fadeUp 0.2s; }

.hint {
  margin-top: 18px; text-align: center; font-size: 12px; color: var(--text-muted);
}

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-header .inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  gap: 12px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 17px;
}

.brand .dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #3a6fd1);
  display: grid; place-items: center; color: white; font-weight: 700; font-size: 12px;
}

.user-area { display: flex; align-items: center; gap: 12px; }
.user-area .who { font-size: 13px; color: var(--text-dim); }
.user-area .who strong { color: var(--text); font-weight: 600; }

.btn-ghost {
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--border); color: var(--text-dim);
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.app-main {
  max-width: 1280px; margin: 0 auto;
  padding: 24px;
}

/* =========================================================================
   SUMMARY CARDS
   ========================================================================= */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  animation: fadeUp 0.3s ease;
}

.summary-card .label {
  font-size: 12px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.summary-card .value {
  font-size: 26px; font-weight: 600; letter-spacing: -0.01em;
}

.summary-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* =========================================================================
   FILTERS
   ========================================================================= */
.filters {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filter-field {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 140px;
}

.filter-field label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em;
}

.filter-field input, .filter-field select {
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  min-width: 0;
}

.filter-field input:focus, .filter-field select:focus {
  outline: none; border-color: var(--accent);
}

.filter-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.btn-refresh {
  padding: 9px 16px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.15s;
}
.btn-refresh:hover { background: var(--accent-hover); }
.btn-refresh.loading { opacity: 0.7; cursor: progress; }

.autorefresh-info {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.autorefresh-info .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--credit);
  box-shadow: 0 0 8px var(--credit);
  animation: pulse 2s ease-in-out infinite;
}

/* =========================================================================
   TABLE
   ========================================================================= */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s;
  animation: fadeUp 0.22s ease backwards;
}
tbody tr:hover { background: var(--card-hover); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.badge-pix { background: rgba(79, 142, 247, 0.14); color: var(--pix); }
.badge-credit { background: rgba(34, 197, 94, 0.14); color: var(--credit); }
.badge-other { background: rgba(138, 144, 163, 0.14); color: var(--text-dim); }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.status-confirmed .dot { background: var(--credit); box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.status-pending .dot { background: var(--warn); box-shadow: 0 0 6px rgba(250,204,21,0.6); }
.status-other .dot { background: var(--text-muted); }

.value-cell { font-weight: 600; font-variant-numeric: tabular-nums; }

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state h3 { color: var(--text); font-weight: 500; margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

.warn-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  background: rgba(250, 204, 21, 0.10);
  border: 1px solid rgba(250, 204, 21, 0.35);
  color: #fde68a;
  border-radius: 10px;
  font-size: 13px;
}

/* =========================================================================
   ADMIN
   ========================================================================= */
.admin-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}
.admin-section h2 {
  font-size: 16px; margin-bottom: 14px; font-weight: 600;
}

.admin-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.admin-form .form-field { margin-bottom: 0; }
.admin-form input {
  padding: 10px 12px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.admin-form .checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }

.btn-danger {
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  background: rgba(239,68,68,0.15); color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.35);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.toast {
  position: fixed; right: 20px; bottom: 20px;
  background: var(--card); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 13px;
  display: none;
  animation: fadeUp 0.2s;
}
.toast.show { display: block; }
.toast.error { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.toast.success { border-color: rgba(34,197,94,0.4); color: #86efac; }

/* =========================================================================
   ANIMATIONS & RESPONSIVE
   ========================================================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.6; }
}

@media (max-width: 640px) {
  .app-header .inner { padding: 12px 16px; }
  .app-main { padding: 16px; }
  .user-area .who { display: none; }
  .summary-card .value { font-size: 22px; }
  thead th, tbody td { padding: 10px 12px; font-size: 13px; }
  .filter-field { min-width: 0; flex: 1 1 140px; }
}
