:root {
  --bg: #f4fbf7;
  --bg-2: #eef8f2;
  --surface: #ffffff;
  --surface-2: #f8fcf9;
  --border: #dceee4;
  --text: #1a3d2e;
  --text-soft: #5a7d6a;
  --primary: #5cb88a;
  --primary-dim: #4aa876;
  --primary-soft: #e3f5ec;
  --accent: #f4a261;
  --accent-soft: #fff0e3;
  --sky: #a8d8ea;
  --sky-soft: #e8f6fc;
  --lavender: #d4c1ec;
  --lavender-soft: #f3edfb;
  --success: #5cb88a;
  --success-soft: #e3f5ec;
  --danger: #e76f6f;
  --danger-soft: #fdeeee;
  --warning: #e9b949;
  --warning-soft: #fff8e6;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 4px 24px rgba(42, 92, 68, 0.08);
  --font: 'Outfit', system-ui, sans-serif;
  --nav-h: 64px;
  --top-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100dvh; }
a { color: var(--primary-dim); text-decoration: none; }

/* Auth */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 70% 50% at 20% 0%, rgba(168, 216, 234, 0.45), transparent),
    radial-gradient(ellipse 60% 45% at 100% 100%, rgba(244, 162, 97, 0.2), transparent),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(92, 184, 138, 0.15), transparent),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-logo {
  display: inline-block;
  max-height: 56px;
  width: auto;
  max-width: 220px;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
}
.auth-card h1 { margin: 10px 0 4px; font-size: 20px; font-weight: 800; }
.auth-sub { text-align: center; color: var(--text-soft); font-size: 14px; margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-soft); font-family: inherit; font-weight: 600;
  cursor: pointer; transition: .2s;
}
.auth-tab.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dim); }

/* Shell */
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: 230px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 40;
  box-shadow: 2px 0 16px rgba(42, 92, 68, 0.04);
}
.sidebar-logo { padding: 4px 8px 16px; }
.sidebar-logo img {
  max-height: 44px; width: auto; max-width: 100%; display: block; object-fit: contain;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: var(--radius-sm); color: var(--text-soft); font-weight: 600;
  font-size: 14px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; font-family: inherit; transition: .15s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; display: block; }
.nav-item:hover { background: var(--primary-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dim); }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

.main-wrap { flex: 1; margin-left: 230px; display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  height: var(--top-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 800; color: var(--text); }
.topbar-logo { height: 32px; width: auto; max-width: 140px; object-fit: contain; }
.topbar .crumb { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.content { flex: 1; padding: 20px; max-width: 960px; width: 100%; }

.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--surface); border-top: 1px solid var(--border); z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(42, 92, 68, 0.06);
}
.mobile-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: none; color: var(--text-soft); font-family: inherit;
  font-size: 9px; font-weight: 600; cursor: pointer; padding: 6px 2px;
}
.mobile-nav button svg { width: 16px; height: 16px; display: block; }
.mobile-nav button.active { color: var(--primary-dim); }

/* Components */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head h2 svg { width: 16px; height: 16px; flex-shrink: 0; display: block; }
.card-body { padding: 18px; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-soft);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92, 184, 138, 0.2);
}
.textarea { min-height: 90px; resize: vertical; }
.req { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dim); }
.btn-ghost { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--text); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-instagram {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-icon {
  width: 38px; height: 38px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-icon svg { width: 16px; height: 16px; display: block; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.col-span-2 { grid-column: span 2; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow);
}
.stat-card .lbl { font-size: 12px; color: var(--text-soft); font-weight: 600; text-transform: uppercase; }
.stat-card .val { font-size: 24px; font-weight: 900; color: var(--primary-dim); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
}
.badge svg { width: 12px; height: 12px; flex-shrink: 0; display: block; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; display: block; }
.badge-green { background: var(--success-soft); color: #2d6a4f; }
.badge-amber { background: var(--warning-soft); color: #9a6b00; }
.badge-gray { background: var(--surface-2); color: var(--text-soft); }
.badge-accent { background: var(--accent-soft); color: #c45d00; }
.badge-blue { background: #e3f0ff; color: #1d5a9e; }

.event-actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 16px;
}
.admin-inscritos-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
}
.config-summary {
  margin: 8px 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 13px;
}
.config-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.prova-card {
  display: flex; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.prova-card:last-child { border-bottom: none; }
.prova-card:hover { background: var(--primary-soft); }
.prova-date {
  width: 52px; flex-shrink: 0; text-align: center; background: var(--sky-soft);
  border: 1px solid rgba(168, 216, 234, 0.5); border-radius: var(--radius-sm); padding: 8px 6px;
}
.prova-date .day { font-size: 22px; font-weight: 900; color: var(--primary-dim); line-height: 1; }
.prova-date .mon { font-size: 11px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; }
.prova-info { flex: 1; min-width: 0; }
.prova-info h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.prova-meta { font-size: 13px; color: var(--text-soft); }

.hint-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: var(--primary-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; color: var(--text);
}
.hint-card svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; display: block; }

.page-loader { display: flex; justify-content: center; padding: 40px; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-soft); }
.empty-state h3 { color: var(--text); margin: 0 0 8px; }

.foto-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; }
.foto-preview {
  width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--primary); background: var(--surface-2);
}
.foto-placeholder {
  width: 120px; height: 120px; border-radius: 50%; background: var(--primary-soft);
  border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: 13px; text-align: center; padding: 8px;
}

/* Aniversários */
.aniv-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.aniv-row:last-child { border-bottom: none; }
.membro-row:hover { background: var(--primary-soft); }
.aniv-avatar {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
  background: var(--lavender-soft); border: 2px solid var(--border); flex-shrink: 0;
}
.aniv-avatar-ph {
  width: 52px; height: 52px; border-radius: 50%; background: var(--lavender-soft);
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--primary-dim); flex-shrink: 0; font-size: 18px;
}
.aniv-info { flex: 1; min-width: 0; }
.aniv-info h3 { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.aniv-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); font-weight: 700; }
.cell-strong { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--text-soft); }

.ig-preview-wrap { text-align: center; margin: 12px 0; }
.ig-preview {
  max-width: 100%; width: 360px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(26, 61, 46, 0.35); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90dvh; overflow: auto; box-shadow: var(--shadow);
}
.modal-lg { max-width: 640px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}

#toast-root {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: 14px; font-weight: 600; pointer-events: auto;
}
.toast.err { border-color: var(--danger); }
.toast svg, .toast-ic svg { width: 16px; height: 16px; flex-shrink: 0; display: block; }

.err-box {
  padding: 14px; background: var(--danger-soft); border: 1px solid var(--danger);
  border-radius: var(--radius-sm); color: var(--danger); font-size: 14px;
}
.success-box {
  display: flex; align-items: center; gap: 8px;
  padding: 14px; background: var(--success-soft); border: 1px solid var(--success);
  border-radius: var(--radius-sm); color: #2d6a4f; font-size: 14px; font-weight: 600;
  margin-bottom: 12px;
}
.success-box.hidden { display: none; }
.success-box svg { width: 16px; height: 16px; flex-shrink: 0; }

.section-title {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-soft); margin: 18px 0 10px;
}

.inscritos-list { font-size: 13px; color: var(--text-soft); margin-top: 8px; }
.filter-check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.filter-check input { width: 18px; height: 18px; accent-color: var(--primary); }
.admin-toggle {
  display: flex; padding: 12px 14px; background: var(--surface-2);
  border-radius: var(--radius-sm); margin-bottom: 16px;
}
.admin-toggle input:disabled { opacity: 0.6; cursor: not-allowed; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; padding-bottom: calc(var(--nav-h) + 8px); }
  .mobile-nav { display: flex; }
  .content { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .hide-mobile { display: none !important; }
  .aniv-row { flex-wrap: wrap; }
  .aniv-actions { width: 100%; justify-content: flex-start; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--radius) var(--radius) 0 0; max-height: 92dvh; }
  #toast-root { bottom: calc(var(--nav-h) + 12px); }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}
