/* ═══════════════════════════════════════════════════════════
   VARIÁVEIS & RESET
═══════════════════════════════════════════════════════════ */
:root {
  --bg:            #efefed;
  --surface:       #f7f7f7;
  --surface-strong:#ffffff;
  --line:          #ddd9d2;
  --text:          #4b4b4d;
  --muted:         #7a7a7d;
  --accent:        #f7aa38;
  --accent-dark:   #db9228;
  --positive:      #2f7d4d;
  --negative:      #c6493d;
  --shadow:        0 10px 24px rgba(75,75,77,.10);
  --shadow-modal:  0 24px 64px rgba(40,30,20,.22);
  --radius:        18px;
  --radius-sm:     12px;
  --sidebar-w:     268px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(247,170,56,.18), transparent 28%),
    linear-gradient(180deg, #f8f8f6 0%, var(--bg) 100%);
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════ */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar {
  padding: 28px 18px;
  background: linear-gradient(180deg, #4b4b4d 0%, #38383a 100%);
  color: #f7f7f7;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 50;
}

.sidebar h1 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .72rem;
  opacity: .6;
}

.sidebar-text {
  margin: 8px 0 0;
  color: rgba(247,239,232,.72);
  line-height: 1.6;
  font-size: .88rem;
}

/* Hamburguer — só aparece mobile */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
}

.sidebar-nav { display: grid; gap: 5px; }

.nav-link {
  color: #fff5ee;
  text-decoration: none;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
  transition: background .2s ease, transform .2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .93rem;
}

.nav-link:hover  { background: rgba(255,255,255,.13); transform: translateX(3px); }
.nav-link.active { background: rgba(247,170,56,.25); color: #ffe4a0; font-weight: 600; }

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(247,170,56,.32), rgba(255,255,255,.08));
  border: 1px solid rgba(255,255,255,.12);
}

.sidebar-card span  { color: rgba(255,255,255,.7); display: block; margin-bottom: 5px; font-size: .86rem; }
.sidebar-card strong { font-size: 1.6rem; }

/* ═══════════════════════════════════════════════════════════
   CONTEÚDO / PÁGINAS
═══════════════════════════════════════════════════════════ */
.content {
  padding: 32px;
  min-height: 100vh;
  overflow-x: hidden;
}

.page {
  display: none;
  flex-direction: column;
  gap: 22px;
  animation: fadeIn .22s ease;
}

.page.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(229,216,196,.8);
  flex-wrap: wrap;
}

.page-header h2 { margin: 0; font-size: 1.55rem; }

/* ═══════════════════════════════════════════════════════════
   FILTER BAR
═══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  flex: 1 1 160px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .93rem;
  color: var(--text);
  transition: border-color .15s;
}

.filter-bar input:focus,
.filter-bar select:focus {
  outline: 2px solid rgba(247,170,56,.35);
  border-color: var(--accent);
}

.count-badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: .86rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-card.compact { align-self: start; }

.card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title-row h3 { margin: 0; }
.compact-row { margin-bottom: 12px; }

/* ═══════════════════════════════════════════════════════════
   STATS GRID
═══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  display: grid;
  gap: 8px;
  text-align: center;
  justify-items: center;
  align-content: center;
  min-height: 120px;
}

.stat-card strong {
  font-size: clamp(1rem, 1rem + 1vw, 1.7rem);
  line-height: 1.15;
  word-break: break-word;
}

.stat-card span {
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card.positive strong { color: var(--positive); }
.stat-card.negative strong { color: var(--negative); }
.stat-card.highlight {
  background: linear-gradient(180deg, #fff5e4, #ffe7bf);
}
.stat-card.highlight strong { color: var(--accent-dark); }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD GRIDS
═══════════════════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
}

.summary-list { display: grid; gap: 12px; }

.summary-list div {
  padding: 13px 15px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  text-align: center;
}

.summary-list span  { color: var(--muted); font-size: .86rem; display: block; margin-bottom: 4px; }
.summary-list strong { display: block; font-size: clamp(.95rem, .95rem + .6vw, 1.35rem); line-height: 1.2; }

canvas {
  width: 100%;
  max-width: 100%;
  display: block;
  background: linear-gradient(180deg, #fffaf2 0%, #fff 100%);
  border-radius: var(--radius-sm);
}

.month-badge {
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: .9rem;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   LIST ITEMS
═══════════════════════════════════════════════════════════ */
.list-container { display: grid; gap: 10px; }

.list-item {
  display: grid;
  gap: 8px;
  padding: 15px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  transition: box-shadow .15s;
}

.list-item:hover { box-shadow: 0 4px 16px rgba(75,75,77,.10); }

.list-item-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.list-item h4, .list-item p { margin: 0; }

.list-item p { color: var(--muted); font-size: .88rem; margin-top: 3px; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .8rem;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag.status-ativa    { color: var(--positive); border-color: rgba(47,125,77,.3); }
.tag.status-encerrada { color: var(--negative); border-color: rgba(198,73,61,.3); }
.tag.receita  { color: var(--positive); }
.tag.despesa  { color: var(--negative); }
.tag.isento   { color: #7b5b12; }

.amount { font-size: 1.05rem; font-weight: 700; }
.amount.receita { color: var(--positive); }
.amount.despesa { color: var(--negative); }
.amount.isento  { color: #7b5b12; }

.list-stack          { display: grid; gap: 4px; }
.list-stack strong   { display: block; }
.list-stack span     { color: var(--muted); font-size: .86rem; }

/* Alunos inativos */
.student-inactive { opacity: .82; border-style: dashed; }
.inactive-badge {
  display: inline-block;
  font-size: .78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(198,73,61,.08);
  color: var(--negative);
  border: 1px solid rgba(198,73,61,.25);
}
.inactive-note {
  margin: 0;
  font-size: .87rem;
  color: var(--muted);
  font-style: italic;
}

/* Abas de alunos */
.student-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.student-tab-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.student-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
.form-grid { display: grid; gap: 14px; }

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: .93rem;
}

.form-grid input,
.form-grid select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: .95rem;
  color: var(--text);
  transition: border-color .15s;
}

.form-grid input:focus,
.form-grid select:focus {
  outline: 2px solid rgba(247,170,56,.3);
  border-color: var(--accent);
}

.form-grid select[multiple] { min-height: 155px; }

.helper-text { margin: -4px 0 0; color: var(--muted); font-size: .86rem; }

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ═══════════════════════════════════════════════════════════
   BOTÕES
═══════════════════════════════════════════════════════════ */
.primary-btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s;
  white-space: nowrap;
}
.primary-btn:hover { filter: brightness(1.07); }

.secondary-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  background: var(--surface);
  color: var(--text);
  font-size: .93rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.secondary-btn:hover    { background: var(--surface-strong); }
.secondary-btn:disabled { opacity: .45; cursor: not-allowed; }

.danger-btn {
  border: 1px solid rgba(198,73,61,.3);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  background: rgba(198,73,61,.06);
  color: var(--negative);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.danger-btn:hover { background: rgba(198,73,61,.12); }

/* ═══════════════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════════════ */
.tab-btn { font-size: .88rem; padding: 9px 15px; }

.tab-btn.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: 0;
}

.tab-panel { animation: fadeIn .18s ease; }

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40,30,20,.45);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--surface-strong);
  border-radius: 22px;
  box-shadow: var(--shadow-modal);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .22s ease;
}

.modal-box-wide { max-width: 580px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.modal-header h3 { margin: 0; font-size: 1.18rem; }

.modal-close {
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ═══════════════════════════════════════════════════════════
   PRESENÇA
═══════════════════════════════════════════════════════════ */
.attendance-list   { display: grid; gap: 10px; }

.attendance-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 160px;
  gap: 12px;
  align-items: center;
  padding: 12px 15px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.attendance-row strong { display: block; margin-bottom: 3px; }
.attendance-row span   { color: var(--muted); font-size: .86rem; }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════════════ */
.empty-state {
  padding: 28px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  background: #2e2e30;
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: .93rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  animation: fadeIn .2s ease;
  max-width: 320px;
}
.toast.success { border-left: 4px solid var(--positive); }
.toast.error   { border-left: 4px solid var(--negative); }
.toast[hidden] { display: none; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVO — TABLET (≤ 1080px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    padding: 18px 16px;
    gap: 16px;
  }

  .sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .sidebar-toggle { display: block; }

  /* Nav fica colapsada até clicar */
  .sidebar-nav {
    display: none;
    grid-template-columns: repeat(3, 1fr);
  }
  .sidebar-nav.open { display: grid; }

  .sidebar-card { margin-top: 0; }

  .sidebar-text { display: none; }

  .dashboard-grid { grid-template-columns: 1fr; }

  .content { padding: 20px; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVO — MOBILE (≤ 640px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .content { padding: 14px; }

  .sidebar-nav { grid-template-columns: repeat(2, 1fr); }
  .sidebar-nav.open { display: grid; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }

  .page-header { flex-direction: column; align-items: flex-start; }

  .page-header .button-row { width: 100%; }

  .filter-bar { flex-direction: column; }
  .filter-bar input,
  .filter-bar select { flex: 1 1 100%; }

  .attendance-row { grid-template-columns: 1fr; }

  .action-row { grid-template-columns: 1fr; }

  .dashboard-grid { grid-template-columns: 1fr; }

  .modal-box { padding: 20px; }

  .button-row { gap: 6px; }

  .primary-btn,
  .secondary-btn { font-size: .88rem; padding: 10px 14px; }

  .toast { bottom: 16px; right: 16px; left: 16px; max-width: none; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVO — MOBILE PEQUENO (≤ 400px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar-nav { grid-template-columns: 1fr; }
  .student-tabs { flex-direction: column; }
}
