:root {
  color-scheme: light;
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --text: #15202b;
  --muted: #667585;
  --line: #dfe7ee;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --accent: #f2b84b;
  --danger: #c63d3d;
  --shadow: 0 22px 55px rgba(22, 38, 54, 0.14);
  --soft-shadow: 0 12px 28px rgba(22, 38, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.phone {
  width: min(100%, 460px);
  min-height: min(940px, calc(100vh - 36px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 30px 24px 22px;
  background: #142532;
  color: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: 0;
  line-height: 1.12;
}

.app-header p {
  margin-top: 7px;
  color: #bfdbfe;
  font-size: 0.95rem;
  font-weight: 700;
}

.badge {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.11);
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 800;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 18px 20px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.tab-button {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  font-size: 0.85rem;
}

.tab-button.active {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.view-section {
  display: block;
}

.calculator,
.page-content {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.field,
.field-group {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field span,
.field-group legend,
.switch-card span,
.result-panel span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.1rem;
  outline: 0;
}

.field textarea {
  padding: 14px 16px;
  min-height: 80px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 800;
}

.segmented input:checked + span {
  background: var(--brand);
  color: #ffffff;
}

.switch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.switch-card {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  cursor: pointer;
  box-shadow: var(--soft-shadow);
}

.switch-card input {
  width: 42px;
  height: 24px;
  accent-color: var(--brand);
}

.switch-card strong {
  color: var(--text);
  font-size: 1rem;
}

.result-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.result-panel strong {
  color: var(--brand-dark);
  font-size: 1.45rem;
  white-space: nowrap;
}

.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-button,
.secondary-button {
  height: 56px;
  border: 0;
  border-radius: 18px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  background: var(--surface-soft);
  color: var(--brand);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  border-color: var(--brand);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
}

.section-title h2 {
  font-size: 1.2rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-strip div {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--soft-shadow);
}

.summary-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-strip strong {
  color: var(--text);
  font-size: 1.2rem;
}

.summary-strip small {
  color: var(--muted);
  font-size: 0.78rem;
}

#agenda-ganho-card {
  background: #142532;
  border-color: #142532;
  color: white;
}
#agenda-ganho-card span,
#agenda-ganho-card strong {
  color: white;
}

.form-stack {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
}

.agenda-list,
.historic-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.agenda-card,
.historic-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
}

.agenda-card .remove-button,
.historic-card .remove-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
}

.agenda-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.1rem;
}

.agenda-card-header span:first-child {
  color: var(--brand-dark);
}

.agenda-card p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.historic-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.historic-card-details {
  display: grid;
  gap: 4px;
}
.historic-card-details small {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
}
.historic-card-details strong {
  font-size: 1.2rem;
}

.historic-card-valor {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--brand);
}

.remove-button {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(198, 61, 61, 0.2);
  border-radius: 14px;
  background: #fff0f0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.empty-state {
  padding: 24px 18px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.dashboard-card {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.dashboard-card small {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.dashboard-card strong {
  font-size: 1.5rem;
  color: var(--brand);
}

.dashboard-card span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--soft-shadow);
}

.metric-card small {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-card strong {
  font-size: 1.15rem;
  color: var(--text);
}

.metric-card span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

#melhor-dia-nome {
  color: var(--brand-dark);
}

@media (max-width: 460px) {
  .app-shell {
    display: block;
    padding: 0;
  }

  .phone {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .app-header {
    padding-top: 26px;
  }

  .splash,
  .onboarding-container {
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 380px) {
  .dashboard-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .tab-button {
    font-size: 0.75rem;
  }
}

/* NOVOS ESTILOS - ALERTA E AGENDA INTELIGENTE */
.alertas-container {
  display: grid;
  gap: 10px;
  padding: 0 20px;
}

.alerta {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.alerta.info {
  background-color: #eff6ff;
  color: #1d4ed8;
}

.alerta.success {
  background-color: #f0fdf4;
  color: #166534;
}

.alerta.warning {
  background-color: #fffbeb;
  color: #b45309;
}

#agenda-grupos {
  display: grid;
  gap: 24px;
}

.agenda-group .section-title {
  margin-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* --- ESTILOS DA TELA DE CAPA (SPLASH SCREEN) --- */
.splash {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100%, 460px);
  height: min(100vh, 940px);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #142532;
  display: grid;
  place-items: center;
  z-index: 100;
  transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
  opacity: 1;
  visibility: visible;
}

.splash.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  color: #ffffff;
}

.splash-logo {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px
}

.splash-content h1 {
  font-size: 2.5rem;
  letter-spacing: 0;
  line-height: 1.1;
  margin-bottom: 12px;
}

.splash-content p {
  font-size: 1.1rem;
  font-weight: 700;
  color: #bfdbfe;
}

/* --- ONBOARDING STYLES --- */
.onboarding-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100%, 460px);
  height: min(100vh, 940px);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 99;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
  background: linear-gradient(170deg, #081C3A 0%, #0E4CB5 100%);
}

.onboarding-container.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* TELA 1 - CAPA: imagem de fundo com overlay */
.onboarding-cover-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.onboarding-scene {
  width: 100%;
  height: 100%;
  display: block;
}

.onboarding-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(6, 18, 45, 0.50) 0%,
    rgba(6, 18, 45, 0.20) 35%,
    rgba(6, 18, 45, 0.65) 70%,
    rgba(6, 18, 45, 0.92) 100%
  );
}

.onboarding-cover-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 52px 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
  text-align: center;
}

.onboarding-cover-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
  justify-content: flex-start;
}

.onboarding-logo-box {
  width: 64px;
  height: 64px;
  background: #2563eb;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.5);
}

.onboarding-cover-title {
  font-size: 2.6rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.onboarding-cover-sub {
  font-size: 1rem;
  color: #c7deff;
  line-height: 1.5;
  margin: 0;
}

.onboarding-card {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.onboarding-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.onboarding-card p {
  color: #c7deff;
  font-size: 0.97rem;
  margin-bottom: 20px;
}

.onboarding-button {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 16px;
  background: #2563eb;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.2s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.onboarding-button:hover {
  background: #1d4ed8;
  transform: scale(1.02);
}

.onboarding-button:active {
  transform: scale(0.98);
}

/* TELA 2 - CONTRA-CAPA: white/light theme */
.onboarding-light {
  background: #f5f7fa;
  color: #15202b;
}

.onboarding-content-light {
  width: 100%;
  max-width: 460px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-grow: 1;
  justify-content: center;
}

.onboarding-name-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 36px 28px 28px;
  box-shadow: 0 8px 40px rgba(22, 38, 54, 0.10);
  text-align: left;
}

.onboarding-name-title {
  font-size: 2rem;
  font-weight: 800;
  color: #15202b;
  margin-bottom: 8px;
}

.onboarding-name-desc {
  font-size: 1.05rem;
  font-weight: 600;
  color: #15202b;
  margin-bottom: 4px;
}

.onboarding-name-sub {
  font-size: 0.92rem;
  color: #667585;
  margin-bottom: 28px;
}

.onboarding-input-group {
  position: relative;
  margin-bottom: 16px;
}

.onboarding-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: #667585;
  pointer-events: none;
}

.onboarding-input-light {
  width: 100%;
  min-height: 54px;
  padding: 0 16px 0 46px;
  border: 1.5px solid #dfe7ee;
  border-radius: 14px;
  background: #f5f7fa;
  color: #15202b;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.onboarding-input-light::placeholder {
  color: #a0aeba;
}

.onboarding-input-light:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #fff;
}

.onboarding-button-primary {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 14px;
  background: #2563eb;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.2s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 24px;
  font-family: inherit;
}

.onboarding-button-primary:hover {
  background: #1d4ed8;
  transform: scale(1.02);
}

.onboarding-button-primary:active {
  transform: scale(0.98);
}

.btn-arrow {
  font-size: 1.3rem;
  line-height: 1;
}

.onboarding-security-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f0faf4;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.security-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: #22c55e;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  margin-top: 1px;
}

.security-text strong {
  font-size: 0.92rem;
  color: #15202b;
  display: block;
  margin-bottom: 3px;
}

.security-text p {
  font-size: 0.82rem;
  color: #667585;
  margin: 0;
}

.onboarding-terms {
  font-size: 0.78rem;
  color: #a0aeba;
  text-align: center;
  margin: 0;
}

.onboarding-terms a {
  color: #2563eb;
  text-decoration: none;
}

.onboarding-terms a:hover {
  text-decoration: underline;
}

/* --- BACK BUTTON --- */
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.back-btn:hover { transform: scale(1.1); }
.back-btn:active { transform: scale(0.93); }

/* Botão no onboarding claro (tela 2) */
.back-btn-onboarding {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  background: #e2e8f0;
  color: #15202b;
}

.back-btn-onboarding:hover { background: #cbd5e1; }

/* Botão no header do app (fundo escuro) */
.back-btn-app {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.30);
}

/* --- PROFILE BUTTON --- */
.profile-button {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.11);
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
}

/* --- User Greeting --- */
#user-greeting h1 {
  font-size: 1.4rem;
}
#user-greeting p {
  font-size: 0.9rem;
  font-weight: 400;
}

