:root {
  --navy: #1E3A7B;
  --navy-dark: #15295A;
  --navy-soft: #EEF2FF;
  --gold: #EAB308;
  --gold-soft: #FEF9C3;
  --bg: #F2F4F8;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --green: #059669;
  --green-soft: #ECFDF5;
  --amber: #D97706;
  --amber-soft: #FFFBEB;
  --red: #DC2626;
  --red-soft: #FEF2F2;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* --- Login --- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 22px;
  padding: 30px 24px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.login-logo-wrap {
  width: 82px;
  height: 82px;
  margin: 0 auto 12px;
  background: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30, 58, 123, 0.14);
  border: 1px solid var(--border);
}
.login-logo { width: 66px; height: auto; }
.login-title { margin: 0; font-size: 22px; color: var(--navy); font-weight: 800; }
.login-sub { margin: 4px 0 20px; font-size: 14px; color: var(--muted); font-weight: 500; }
.login-form { text-align: left; }
.login-hint { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.login-hint-badge {
  margin: 10px 0 0;
  font-size: 12px;
  background: var(--gold-soft);
  color: #854D0E;
  padding: 7px 10px;
  border-radius: 10px;
}

/* --- App Shell --- */
.app-shell {
  min-height: 100dvh;
  padding-bottom: calc(84px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.topbar-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 34px; height: 32px; object-fit: contain; }
.brand-title { font-size: 16px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.btn-icon-top {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.main-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 14px 28px;
}

/* --- Month Nav --- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.nav-arrow {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--navy);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.month-picker-wrap {
  position: relative;
  padding: 6px 16px;
  border-radius: 12px;
  cursor: pointer;
}
.month-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-transform: capitalize;
}
.month-input-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* --- Hero Card --- */
.hero-card {
  background: linear-gradient(145deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  border-radius: 20px;
  padding: 18px 18px 16px;
  box-shadow: 0 10px 26px rgba(30, 58, 123, 0.24);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3.5px;
  background: var(--gold);
}
.hero-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.hero-label { font-size: 12px; opacity: 0.85; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.hero-tag {
  background: var(--gold);
  color: #1E293B;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}
.hero-amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-top: 2px;
}
.hero-pill-hours {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 8px 14px;
  text-align: right;
  min-width: 78px;
}
.hero-hours-val { font-size: 20px; font-weight: 800; line-height: 1.1; }
.hero-hours-sub { font-size: 11px; opacity: 0.85; }

.status-segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 12px;
  margin-top: 14px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 7px 6px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
}
.seg-btn.active { background: #fff; color: var(--navy); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.seg-btn.active[data-status="enviado"] { color: var(--amber); }
.seg-btn.active[data-status="pago"] { color: var(--green); }
.hero-dates { font-size: 11.5px; opacity: 0.82; margin-top: 8px; min-height: 14px; }

/* --- Auto-Send Banner --- */
.auto-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 12px;
}
.auto-banner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.auto-banner-info { display: flex; align-items: flex-start; gap: 10px; }
.auto-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0; background: #94A3B8;
}
.auto-dot.on { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.auto-dot.warn { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.auto-title { font-size: 13px; font-weight: 700; color: var(--text); }
.auto-desc { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #CBD5E1; border-radius: 999px; transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; height: 20px; width: 20px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* --- Action Buttons --- */
.action-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 16px; font-size: 15px; }
.btn-grow { flex: 1; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-outline-navy { background: var(--card); color: var(--navy); border-color: #CBD5E1; }
.btn-whatsapp { background: var(--green); color: #fff; }
.btn-ghost { background: #F1F5F9; color: var(--text); }
.btn-danger-ghost { background: var(--red-soft); color: var(--red); }
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* --- Section Bar & Aulas List --- */
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 8px;
}
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.link-btn { background: none; border: none; color: var(--navy); font-size: 13px; font-weight: 700; cursor: pointer; padding: 4px; }

.aulas-list { display: flex; flex-direction: column; gap: 9px; }

.aula-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px 13px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.aula-card.cancelada { opacity: 0.58; background: #F8FAFC; }
.aula-card.cancelada .aula-date,
.aula-card.cancelada .aula-tema,
.aula-card.cancelada .aula-val { text-decoration: line-through; }

.aula-chk {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}
.aula-body { flex: 1; min-width: 0; cursor: pointer; }
.aula-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.aula-date { font-size: 14.5px; font-weight: 800; color: var(--text); }
.aula-val { font-size: 15px; font-weight: 800; color: var(--navy); white-space: nowrap; }
.aula-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-turma { background: var(--navy-soft); color: var(--navy); }
.badge-horas { background: #F1F5F9; color: #334155; }
.badge-agendada { background: var(--amber-soft); color: var(--amber); }
.badge-cancelada { background: var(--red-soft); color: var(--red); }
.badge-pago { background: var(--green-soft); color: var(--green); }
.badge-enviado { background: var(--amber-soft); color: var(--amber); }
.badge-aberto { background: #F1F5F9; color: #475569; }
.aula-tema { font-size: 13.5px; color: #334155; margin-top: 5px; word-break: break-word; }

.empty-state {
  background: var(--card);
  border: 1px dashed #CBD5E1;
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state strong { color: var(--text); display: block; margin-bottom: 4px; }

/* --- Cards / Forms --- */
.page-h2 { margin: 2px 0 12px; font-size: 20px; font-weight: 800; color: var(--navy); }
.panel-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-accent {
  border-left: 4px solid var(--gold);
  box-shadow: 0 3px 12px rgba(30, 58, 123, 0.08);
}
.muted-inline { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.preset-span-2 { grid-column: span 2; }
.badge-simult { background: var(--gold-soft); color: #854D0E; }
.avisos-box {
  background: var(--amber-soft);
  color: #92400E;
  border: 1px solid #FDE68A;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12px;
  margin-bottom: 8px;
}
.card-h3 { margin: 0 0 8px; font-size: 15.5px; font-weight: 800; color: var(--text); }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.muted-sm { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.sub-heading { font-size: 13px; font-weight: 700; color: var(--navy); margin: 12px 0 6px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.field-label { display: block; font-size: 12.5px; font-weight: 700; color: #334155; margin: 10px 0 4px; }
.field-note { font-size: 11.5px; color: var(--navy); font-weight: 600; margin-top: 3px; text-transform: capitalize; }
.input, .select-compact {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 11px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.input:focus { outline: 2px solid var(--navy); border-color: var(--navy); }
.input-lg { padding: 12px 14px; font-size: 16px; }
.select-compact { width: auto; min-width: 100px; font-weight: 700; color: var(--navy); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stack-btns { display: flex; flex-direction: column; gap: 8px; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.inline-add .input { flex: 1; }

.check-row {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 10px 0; cursor: pointer;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--navy); }
.check-highlight {
  background: var(--green-soft);
  padding: 10px 12px;
  border-radius: 11px;
  color: #065F46;
}

.alert-error {
  background: var(--red-soft);
  color: var(--red);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
}

/* --- Histórico --- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 15px; padding: 14px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 21px; font-weight: 800; margin-top: 3px; }
.kpi-val.navy { color: var(--navy); }
.kpi-val.amber { color: var(--amber); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-svg { width: 100%; height: 175px; display: block; }
.chart-bar { cursor: pointer; transition: opacity 0.15s; }
.chart-bar:hover { opacity: 0.8; }

.simple-list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: #F8FAFC; border-radius: 11px; cursor: pointer;
}
.list-row-main { font-weight: 700; font-size: 14px; color: var(--text); }
.list-row-sub { font-size: 12px; color: var(--muted); }
.list-row-right { text-align: right; }

/* --- Excel & Backup --- */
.file-input { display: none; }
.abas-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.aba-item {
  border: 1px solid var(--border);
  background: #F8FAFC;
  border-radius: 12px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.aba-item.selected { border-color: var(--navy); background: var(--navy-soft); }
.preview-summary {
  background: var(--navy-soft);
  color: var(--navy-dark);
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.preview-table-wrap {
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 12px;
}
.preview-table { width: 100%; border-collapse: collapse; }
.preview-table th, .preview-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.preview-table th { background: #F1F5F9; position: sticky; top: 0; }
.storage-pill {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  background: #F8FAFC;
  padding: 8px 10px;
  border-radius: 10px;
}

/* --- Chips Turmas / Logs --- */
.chips-manage, .chips-select { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip-btn {
  border: 1px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.chip-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--navy-soft); color: var(--navy);
  padding: 6px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
}
.chip-tag.archived { background: #F1F5F9; color: var(--muted); text-decoration: line-through; }
.chip-tag button { border: none; background: none; color: inherit; cursor: pointer; font-weight: 800; padding: 0 2px; }

.logs-list { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.log-item { padding: 8px 10px; border-radius: 10px; background: #F8FAFC; border-left: 3px solid var(--navy); }
.log-item.erro { border-left-color: var(--red); background: var(--red-soft); }
.log-item.sucesso { border-left-color: var(--green); background: var(--green-soft); }

/* --- FAB & Tabbar --- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(74px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2.5px solid var(--gold);
  background: var(--navy);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  font-weight: 500;
  box-shadow: 0 8px 22px rgba(30, 58, 123, 0.35);
  cursor: pointer;
  z-index: 40;
}

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  z-index: 35;
}
.tab-btn {
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 2px;
  cursor: pointer;
}
.tab-btn.active { color: var(--navy); }
.tab-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Modals (Bottom Sheet on iPhone) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
}
.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
}
@media (min-width: 640px) {
  .modal-sheet { border-radius: 20px; }
}
.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; color: var(--navy); }
.modal-close { border: none; background: #F1F5F9; width: 32px; height: 32px; border-radius: 50%; font-size: 20px; cursor: pointer; color: #334155; }
.modal-body { padding: 14px 18px 20px; overflow-y: auto; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}
.preset-chip {
  border: 1.5px solid var(--border);
  background: #F8FAFC;
  border-radius: 12px;
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
}
.preset-chip small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.preset-chip.active { border-color: var(--navy); background: var(--navy-soft); color: var(--navy); }
.preset-chip.active small { color: var(--navy); }

.turn-card {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 10px 12px 12px;
  margin: 10px 0;
}
.turn-card-head { font-size: 12px; font-weight: 800; color: var(--navy); text-transform: uppercase; letter-spacing: 0.4px; }
.box-soft { background: #F8FAFC; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.subtotal-box {
  background: var(--navy-soft);
  border-radius: 11px;
  padding: 8px 12px;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.subtotal-label { font-size: 11px; color: var(--navy); font-weight: 700; }
.subtotal-val { font-size: 18px; font-weight: 800; color: var(--navy); }

.modal-footer-btns { display: flex; gap: 10px; margin-top: 16px; }
.msg-preview {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  margin: 6px 0 0;
  color: var(--text);
}

.sub-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #0F172A;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  z-index: 90;
  max-width: 90vw;
  text-align: center;
}
