/* ============================================
   FINFAMÍLIA — STYLE UNIVERSAL
   Temas: light & dark
   Paleta: preto, roxo, verde-limão
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;600;700;800&display=swap');

/* ---- VARIÁVEIS: TEMA DARK (padrão) ---- */
:root {
  --bg:          #0d0d0f;
  --bg2:         #141418;
  --bg3:         #1c1c22;
  --card:        #18181f;
  --border:      #2a2a35;
  --text:        #e8e8f0;
  --text-muted:  #6b6b80;
  --text-soft:   #a0a0b8;

  --purple:      #7c3aed;
  --purple-light:#a855f7;
  --purple-dim:  #2d1b5e;
  --lime:        #a3e635;
  --lime-dark:   #65a30d;
  --lime-dim:    #1a2e05;
  --red:         #f43f5e;
  --red-dim:     #3b0f1e;
  --green:       #22c55e;
  --green-dim:   #052e16;

  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --radius:      12px;
  --radius-sm:   8px;

  --font-display: 'Syne', sans-serif;
  --font-mono:    'Space Mono', monospace;
}

/* ---- VARIÁVEIS: TEMA LIGHT ---- */
[data-theme="light"] {
  --bg:          #f0eff8;
  --bg2:         #e8e6f5;
  --bg3:         #dddaf0;
  --card:        #ffffff;
  --border:      #d0cce8;
  --text:        #1a1a2e;
  --text-muted:  #8880aa;
  --text-soft:   #5a5575;

  --purple:      #7c3aed;
  --purple-light:#9333ea;
  --purple-dim:  #ede9fe;
  --lime:        #65a30d;
  --lime-dark:   #4d7c0f;
  --lime-dim:    #ecfccb;
  --red:         #e11d48;
  --red-dim:     #ffe4e6;
  --green:       #16a34a;
  --green-dim:   #dcfce7;

  --shadow:      0 4px 24px rgba(100,80,160,0.12);
  --shadow-sm:   0 2px 8px rgba(100,80,160,0.08);
}

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  line-height: 1.6;
}

a { color: var(--purple-light); text-decoration: none; }
a:hover { color: var(--lime); }

img { display: block; max-width: 100%; }

/* ---- LAYOUT ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- TOPBAR / NAV ---- */
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo span {
  color: var(--lime);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.topbar-nav a {
  color: var(--text-soft);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.topbar-nav a:hover,
.topbar-nav a.active {
  color: var(--text);
  background: var(--bg3);
}

.topbar-nav a.active {
  color: var(--lime);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--purple);
}

.avatar-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--purple-dim);
  border: 2px solid var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--purple-light);
}

/* ---- THEME TOGGLE ---- */
.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 52px;
  height: 28px;
  cursor: pointer;
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--purple-light);
  top: 3px;
  left: 4px;
  transition: transform 0.3s, background 0.3s;
}

[data-theme="light"] .theme-toggle::after {
  transform: translateX(24px);
  background: var(--lime-dark);
}

/* ---- CARDS ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover { box-shadow: var(--shadow); }

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.card-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  font-family: var(--font-mono);
}

.card-value.positivo { color: var(--lime); }
.card-value.negativo { color: var(--red); }
.card-value.neutro   { color: var(--purple-light); }

/* ---- STAT CARDS GRID ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ---- BADGE ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-entrada {
  background: var(--lime-dim);
  color: var(--lime);
}

.badge-saida {
  background: var(--red-dim);
  color: var(--red);
}

.badge-purple {
  background: var(--purple-dim);
  color: var(--purple-light);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  letter-spacing: 0.3px;
  text-decoration: none;
}

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

.btn-lime {
  background: var(--lime);
  color: #0d0d0f;
}
.btn-lime:hover { background: #bef264; color: #0d0d0f; }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236b6b80' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ---- FLASH MESSAGES ---- */
.flash {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flash-success { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.flash-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid var(--red); }
.flash-info    { background: var(--purple-dim); color: var(--purple-light); border: 1px solid var(--purple); }

/* ---- TABLE ---- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--bg2);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

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

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg2); color: var(--text); }

/* ---- CUPOM FISCAL ---- */
.cupom {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cupom-header {
  background: var(--purple);
  padding: 20px;
  text-align: center;
}

.cupom-header h2 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.cupom-header p {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  letter-spacing: 1px;
}

.cupom-divider {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 20px;
  letter-spacing: 2px;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  margin: 2px 0;
}

.cupom-body {
  padding: 12px 20px;
  font-family: var(--font-mono);
}

.cupom-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.78rem;
  gap: 12px;
}

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

.cupom-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.cupom-item-desc {
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cupom-item-meta {
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.5px;
}

.cupom-item-valor {
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}

.cupom-item-valor.entrada { color: var(--lime); }
.cupom-item-valor.saida   { color: var(--red); }

.cupom-footer {
  background: var(--bg2);
  padding: 16px 20px;
  font-family: var(--font-mono);
  border-top: 2px dashed var(--border);
}

.cupom-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
  color: var(--text-soft);
}

.cupom-total-row.main {
  font-size: 1rem;
  color: var(--text);
  font-weight: 700;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.cupom-total-row.main .saldo-positivo { color: var(--lime); }
.cupom-total-row.main .saldo-negativo { color: var(--red); }

/* ---- SALDO DOS MEMBROS ---- */
.membros-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.membro-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.membro-item:hover { border-color: var(--purple); }

.membro-info { flex: 1; }

.membro-nome {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.membro-saldo-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.membro-saldo-valor {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
}

/* ---- LOGIN PAGE ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(163,230,53,0.08) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
}

.login-logo h1 span { color: var(--lime); }

.login-logo p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* ---- UPLOAD FOTO ---- */
.foto-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s;
}

.foto-upload:hover { border-color: var(--purple); }

.foto-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--purple);
}

/* ---- PAGE HEADER ---- */
.page-header {
  padding: 28px 0 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.page-title span { color: var(--lime); }

.page-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  padding: 0 24px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ---- GRID LAYOUT DASHBOARD ---- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.dash-grid-wide {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
}

@media (max-width: 900px) {
  .dash-grid,
  .dash-grid-wide {
    grid-template-columns: 1fr;
  }
}

/* ---- CONFIG TYPES ---- */
.tipos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 700px) {
  .tipos-grid { grid-template-columns: 1fr; }
}

.tipo-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
}

.tipo-tag .icone { font-size: 1.1rem; }
.tipo-tag .nome  { flex: 1; font-weight: 600; }

/* ---- UTILS ---- */
.text-muted  { color: var(--text-muted); }
.text-soft   { color: var(--text-soft); }
.text-lime   { color: var(--lime); }
.text-red    { color: var(--red); }
.text-purple { color: var(--purple-light); }
.mono        { font-family: var(--font-mono); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }

/* ---- ANIMATIONS ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.4s ease both; }
.fade-up-1 { animation-delay: 0.05s; }
.fade-up-2 { animation-delay: 0.1s; }
.fade-up-3 { animation-delay: 0.15s; }
.fade-up-4 { animation-delay: 0.2s; }

/* ---- RESPONSIVE NAV ---- */
@media (max-width: 768px) {
  .topbar-nav { display: none; }
  .login-card { padding: 32px 24px; }
}
