/* ==========================================================================
   ORBIFY LIFE — HÁBITOS (HABIT TRACKER) SYSTEM
   Estilo Apple Bento Grid + Calendário Interativo + Streaks + Temas Dark/White
   ========================================================================== */

.habits-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  min-height: calc(100vh - 60px);
  background: var(--bg-deep, #0a0b0e);
  color: var(--text-main, #f1f5f9);
  box-sizing: border-box;
  width: 100%;
}

body.dashboard-theme-white .habits-wrapper {
  background: #f8fafc !important;
  color: #0f172a !important;
  --color-life: #15803d !important;
}

/* ==========================================================================
   1. TOOLBAR SUPERIOR (Igual ao padrão Notas / Diário)
   ========================================================================== */
.habits-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card, rgb(21 21 21 / 85%));
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

body.dashboard-theme-white .habits-toolbar {
  background: rgb(252 252 252 / 93%);
  border-color: rgba(0, 0, 0, 0.06);
}

.habits-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.habits-toolbar-title {
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-bright, #ffffff);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

body.dashboard-theme-white .habits-toolbar-title {
  color: #0f172a;
}

.habits-title-icon {
  color: var(--color-life, #a5ff8f);
  font-size: 1rem;
}

body.dashboard-theme-white .habits-title-icon {
  color: #15803d !important;
}

.habits-cal-header-icon {
  color: var(--color-life, #a5ff8f);
  font-size: 0.88rem;
}

body.dashboard-theme-white .habits-cal-header-icon {
  color: #15803d !important;
}

.habits-legend-today-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-life, #a5ff8f);
}

body.dashboard-theme-white .habits-legend-today-dot {
  background: #15803d !important;
}

.habits-today-pct-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.14);
  color: #10b981;
}

body.dashboard-theme-white .habits-today-pct-pill {
  background: rgba(21, 128, 61, 0.12) !important;
  color: #15803d !important;
}

.habits-today-bar-fill {
  height: 100%;
  background: var(--color-life, #a5ff8f);
  border-radius: 999px;
  transition: width 0.3s ease;
}

body.dashboard-theme-white .habits-today-bar-fill {
  background: #15803d !important;
}

.habits-count-pill {
  font-size: 0.75rem;
  font-weight: 400;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary, #94a3b8);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

body.dashboard-theme-white .habits-count-pill {
  background: #f1f5f9;
  color: #475569;
  border-color: rgba(0, 0, 0, 0.08);
}

.habits-search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 200px;
  max-width: 320px;
  flex: 1;
}

.habits-search-icon {
  position: absolute;
  left: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted, #64748b);
  pointer-events: none;
}

.habits-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  padding: 0.45rem 0.85rem 0.45rem 2.2rem;
  font-size: 0.84rem;
  color: var(--text-bright, #ffffff);
  outline: none;
  transition: all 0.18s ease;
  font-family: inherit;
}

.habits-search-input:focus {
  border-color: var(--color-life, #a5ff8f);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(165, 255, 143, 0.12);
}

body.dashboard-theme-white .habits-search-input {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
}

body.dashboard-theme-white .habits-search-input:focus {
  border-color: #15803d;
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.15);
}

.habits-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-new-habit {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 400;
  background: rgba(165, 255, 143, 0.16);
  border: 1px solid rgba(165, 255, 143, 0.35);
  color: var(--color-life, #a5ff8f);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn-new-habit:hover {
  background: rgba(165, 255, 143, 0.25);
  border-color: var(--color-life, #a5ff8f);
  transform: translateY(-1px);
}

body.dashboard-theme-white .btn-new-habit {
  background: #15803d;
  color: #ffffff;
  border-color: #15803d;
}

body.dashboard-theme-white .btn-new-habit:hover {
  background: #166534;
}

/* ==========================================================================
   2. FILTROS RÁPIDOS (TODOS, PENDENTES HOJE, FEITOS HOJE)
   ========================================================================== */
.habits-filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.habits-filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.habits-filter-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-bright, #ffffff);
}

.habits-filter-tab.active {
  background: rgba(165, 255, 143, 0.16);
  border-color: rgba(165, 255, 143, 0.4);
  color: var(--color-life, #a5ff8f);
  font-weight: 400;
}

body.dashboard-theme-white .habits-filter-tab {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.dashboard-theme-white .habits-filter-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}

body.dashboard-theme-white .habits-filter-tab.active {
  color: #143000 !important;
  background: rgba(191, 249, 80, 0.35) !important;
  border: 1px solid rgba(60, 110, 15, 0.45) !important;
  font-weight: 500 !important;
}

/* ==========================================================================
   3. LAYOUT RESPONSIVO DE HÁBITOS (DESKTOP 2 COLUNAS IGUAL AO DIÁRIO)
   ========================================================================== */
.habits-desktop-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.habits-main-stream {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-sizing: border-box;
}

.habits-stream-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.25rem;
  box-sizing: border-box;
}

.habits-calendar-sidebar {
  width: 310px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
}

.habits-calendar-sidebar .habits-calendar-card {
  width: 100%;
}

/* Badge indicadora de data selecionada */
.habits-active-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  font-size: 0.78rem;
  background: rgba(165, 255, 143, 0.12);
  border: 1px solid rgba(165, 255, 143, 0.3);
  color: var(--color-life, #a5ff8f);
  margin-bottom: 0.25rem;
  width: fit-content;
  animation: fadeInBadge 0.2s ease;
}

@keyframes fadeInBadge {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.habits-active-date-badge strong {
  color: var(--text-bright, #ffffff);
}

body.dashboard-theme-white .habits-active-date-badge {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

body.dashboard-theme-white .habits-active-date-badge strong {
  color: #0f172a;
}

.btn-clear-date-filter {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  font-size: 0.75rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  opacity: 0.8;
  transition: all 0.15s ease;
}

.btn-clear-date-filter:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.btn-view-day-details {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: inherit;
  cursor: pointer;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 400;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
  font-family: inherit;
  margin-left: 0.25rem;
}

.btn-view-day-details:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

body.dashboard-theme-white .btn-view-day-details {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #15803d;
}

/* Mensagem de nenhum resultado na busca/filtro */
.habits-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card, rgb(21 21 21 / 85%));
  border: 1px dashed var(--border-subtle);
  border-radius: 18px;
  text-align: center;
  gap: 0.75rem;
}

body.dashboard-theme-white .habits-no-results {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
}

.habits-no-results-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 0.25rem;
}

.habits-no-results-title {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-bright, #ffffff);
  margin: 0;
}

body.dashboard-theme-white .habits-no-results-title {
  color: #0f172a;
}

.habits-no-results-sub {
  font-size: 0.84rem;
  color: var(--text-secondary, #94a3b8);
  max-width: 400px;
  margin: 0;
}

.btn-clear-habits-filters {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-bright, #ffffff);
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 0.5rem;
  font-family: inherit;
}

.btn-clear-habits-filters:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Banner de Progresso de Hoje */
.habits-today-banner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 18px;
  padding: 1.15rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: 100%;
  box-sizing: border-box;
}

body.dashboard-theme-white .habits-today-banner {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.03);
}

.habits-today-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.habits-today-title {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-bright, #ffffff);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

body.dashboard-theme-white .habits-today-title {
  color: #0f172a;
}

.habits-today-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary, #94a3b8);
  margin: 0;
}

body.dashboard-theme-white .habits-today-subtitle {
  color: #64748b;
}

.habits-today-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.habits-progress-circle-wrap {
  width: 48px;
  height: 48px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.habits-progress-percent {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-bright, #ffffff);
}

body.dashboard-theme-white .habits-progress-percent {
  color: #0f172a;
}

/* ==========================================================================
   4. LISTA DE CARDS DE HÁBITOS
   ========================================================================== */
.habits-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.habit-card {
  background: var(--bg-card, rgb(21 21 21 / 85%));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 18px;
  padding: 1.15rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.habit-card:hover {
  border-color: var(--border-hover, rgba(255, 255, 255, 0.16));
  transform: translateY(-2px);
}

.habit-card.is-focused-habit {
  border-color: var(--habit-color, #a855f7) !important;
  box-shadow: 0 0 24px var(--habit-glow, rgba(168, 85, 247, 0.25));
}

body.dashboard-theme-white .habit-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

body.dashboard-theme-white .habit-card:hover {
  border-color: rgba(0, 0, 0, 0.16);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

/* Barra Accent superior colorida */
.habit-card-accent-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--habit-color, #a855f7);
}

.habit-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.habit-card-title-group {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.habit-card-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--habit-color, #a855f7);
  background: var(--habit-bg, rgba(168, 85, 247, 0.14));
  border: 1px solid var(--habit-border, rgba(168, 85, 247, 0.3));
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.habit-card:hover .habit-card-icon-box {
  transform: scale(1.05);
}

.habit-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  flex: 1;
  min-width: 0;
}

.habit-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}

.habit-card-title {
  font-size: 0.98rem;
  font-weight: 400;
  color: var(--text-bright, #ffffff);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
}

body.dashboard-theme-white .habit-card-title {
  color: #0f172a;
}

.habit-card-meta-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-secondary, #94a3b8);
  flex-wrap: nowrap;
  width: 100%;
}

.habit-cat-badge {
  font-size: 0.68rem;
  font-weight: 400;
  padding: 0.12rem 0.48rem;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--habit-bg, rgba(168, 85, 247, 0.12));
  color: var(--habit-color, #a855f7);
  border: 1px solid var(--habit-border, rgba(168, 85, 247, 0.25));
  white-space: nowrap;
  flex-shrink: 0;
}

.habit-freq-badge {
  font-size: 0.68rem;
  font-weight: 400;
  padding: 0.12rem 0.48rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted, #64748b);
  border: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  flex-shrink: 0;
}

body.dashboard-theme-white .habit-freq-badge {
  background: #f1f5f9;
  color: #64748b;
  border-color: rgba(0, 0, 0, 0.06);
}

.habit-card-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.btn-habit-action {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

.btn-habit-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-bright, #ffffff);
}

body.dashboard-theme-white .btn-habit-action:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-habit-action.delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Botão Principal de Check-in Hoje */
.habit-checkin-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.9rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

/* Estado: Pendente hoje */
.habit-checkin-btn.pending {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px dashed var(--border-subtle, rgba(255, 255, 255, 0.15));
  color: var(--text-secondary, #94a3b8);
}

.habit-checkin-btn.pending:hover {
  background: var(--habit-bg, rgba(168, 85, 247, 0.12));
  border-color: var(--habit-color, #a855f7);
  border-style: solid;
  color: var(--text-bright, #ffffff);
  transform: translateY(-1px);
}

body.dashboard-theme-white .habit-checkin-btn.pending {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.14);
  color: #475569;
}

body.dashboard-theme-white .habit-checkin-btn.pending:hover {
  background: var(--habit-bg, rgba(168, 85, 247, 0.12));
  border-color: var(--habit-color, #a855f7);
  color: #0f172a;
}

/* Estado: Concluído hoje */
.habit-checkin-btn.completed {
  background: var(--habit-color, #a855f7);
  border: 1.5px solid var(--habit-color, #a855f7);
  color: #ffffff;
  box-shadow: 0 4px 16px var(--habit-glow, rgba(168, 85, 247, 0.3));
}

.habit-checkin-btn.completed:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.habit-checkin-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.habit-checkin-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.2);
}

.habit-checkin-btn.pending .habit-checkin-icon {
  border: 1.5px solid currentColor;
  background: transparent;
}

/* Linha de Sequência (Streak) e Histórico Recente */
.habit-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
  font-size: 0.76rem;
  flex-wrap: wrap;
}

body.dashboard-theme-white .habit-card-footer {
  border-color: rgba(0, 0, 0, 0.05);
}

.habit-streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 400;
  color: #f59e0b;
}

.habit-streak-badge.has-streak {
  color: #f97316;
}

.habit-streak-fire {
  font-size: 0.9rem;
  animation: habit-fire-pulse 1.8s infinite ease-in-out;
}

@keyframes habit-fire-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Micro Tracker de 7 Dias no Card */
.habit-mini-week-strip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.habit-mini-day-dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted, #64748b);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.habit-mini-day-dot:hover {
  transform: scale(1.12);
}

.habit-mini-day-dot.done {
  background: var(--habit-color, #a855f7);
  border-color: var(--habit-color, #a855f7);
  color: #ffffff;
}

.habit-mini-day-dot.today {
  border-color: var(--color-life, #a5ff8f);
}

body.dashboard-theme-white .habit-mini-day-dot {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.06);
  color: #64748b;
}

/* ==========================================================================
   5. CALENDÁRIO INTERATIVO LATERAL (IDÊNTICO AO DIÁRIO)
   ========================================================================== */
.habits-calendar-card {
  width: 100%;
  background: var(--bg-card, rgb(21 21 21 / 85%));
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  user-select: none;
  box-sizing: border-box;
}

body.dashboard-theme-white .habits-calendar-card {
  background: rgb(252 252 252 / 95%);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

/* Header do Calendário */
.habits-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.25rem;
}

.habits-cal-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-bright, #ffffff);
  letter-spacing: -0.01em;
  margin: 0;
}

body.dashboard-theme-white .habits-cal-title {
  color: #0f172a;
}

.habits-cal-nav-btns {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.habits-cal-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  font-size: 0.72rem;
  transition: all 0.15s ease;
  font-family: inherit;
}

.habits-cal-nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-bright, #ffffff);
}

.habits-cal-nav-btn.btn-today {
  width: auto;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 400;
}

body.dashboard-theme-white .habits-cal-nav-btn {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}

body.dashboard-theme-white .habits-cal-nav-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Filtro compacto de visualização: Geral vs Hábito específico */
.habits-cal-filter-bar {
  margin-bottom: 0.15rem;
}

.habits-cal-select-wrap {
  position: relative;
  width: 100%;
}

.habits-cal-select-filter {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  padding: 0.45rem 1.8rem 0.45rem 0.65rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-bright, #ffffff);
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
  color-scheme: dark;
}

.habits-cal-select-filter:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
}

.habits-cal-select-filter:focus {
  outline: none;
  border-color: var(--color-life, #a5ff8f);
  background: rgba(255, 255, 255, 0.08);
}

/* Opções e Optgroups legíveis com alto contraste no tema escuro/black */
.habits-cal-select-filter option,
.habits-cal-select-filter optgroup {
  background-color: #17181d !important;
  color: #f1f5f9 !important;
  font-size: 0.82rem;
  padding: 0.45rem 0.6rem;
}

.habits-cal-select-filter optgroup {
  font-weight: 400;
  color: #94a3b8 !important;
}

body.dashboard-theme-white .habits-cal-select-filter {
  color-scheme: light;
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

body.dashboard-theme-white .habits-cal-select-filter:hover {
  background: #f1f5f9;
}

body.dashboard-theme-white .habits-cal-select-filter option,
body.dashboard-theme-white .habits-cal-select-filter optgroup {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

body.dashboard-theme-white .habits-cal-select-filter optgroup {
  color: #64748b !important;
}

.habits-cal-select-caret {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--text-muted, #64748b);
  pointer-events: none;
}

/* Dias da Semana no formato compacto (D, S, T, Q, Q, S, S) */
.habits-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted, #64748b);
  padding: 0.15rem 0;
}

body.dashboard-theme-white .habits-cal-weekdays {
  color: #94a3b8;
}

/* Grid de Dias */
.habits-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.habits-cal-day {
  aspect-ratio: 1;
  min-height: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 2px;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.habits-cal-day:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dashboard-theme-white .habits-cal-day:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.habits-cal-day.other-month {
  opacity: 0.32;
}

.habits-cal-day .cal-day-num {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--text-bright, #ffffff);
  line-height: 1;
}

body.dashboard-theme-white .habits-cal-day .cal-day-num {
  color: #0f172a;
}

.habits-cal-day.is-today .cal-day-num {
  color: var(--color-life, #a5ff8f);
  font-weight: 500;
}

body.dashboard-theme-white .habits-cal-day.is-today .cal-day-num {
  color: #15803d;
  font-weight: 500;
}

/* Dia Selecionado */
.habits-cal-day.is-selected {
  background: rgba(165, 255, 143, 0.18) !important;
  border-color: var(--color-life, #a5ff8f) !important;
  box-shadow: 0 0 12px rgba(165, 255, 143, 0.25);
}

body.dashboard-theme-white .habits-cal-day.is-selected {
  background: #f0fdf4 !important;
  border-color: #15803d !important;
  box-shadow: 0 2px 8px rgba(21, 128, 61, 0.2);
}

/* Barra de Carregamento Circular no Calendário (Visão Geral e Foco) */
.habit-cal-progress-ring-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  position: relative;
  flex-shrink: 0;
}

.habit-cal-ring-svg {
  width: 15px;
  height: 15px;
  transform: rotate(-90deg);
  overflow: visible;
}

.habit-cal-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2.2;
}

body.dashboard-theme-white .habit-cal-ring-bg {
  stroke: rgba(0, 0, 0, 0.1);
}

.habit-cal-ring-bar {
  fill: none;
  stroke: var(--color-life, #a5ff8f);
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

body.dashboard-theme-white .habit-cal-ring-bar {
  stroke: #15803d !important;
}

.habit-cal-ring-bar.all-done {
  stroke: var(--color-life, #a5ff8f);
  filter: drop-shadow(0 0 3px rgba(165, 255, 143, 0.7));
}

body.dashboard-theme-white .habit-cal-ring-bar.all-done {
  stroke: #15803d !important;
  filter: drop-shadow(0 0 2px rgba(21, 128, 61, 0.45));
}

.habits-cal-day:hover .habit-cal-ring-bar.all-done {
  filter: drop-shadow(0 0 5px rgba(165, 255, 143, 0.95));
}

/* Dots e Indicadores (Fallback) */
.cal-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  transition: all 0.18s ease;
  box-sizing: border-box;
}

.cal-day-dot.dot-green {
  background: var(--color-life, #a5ff8f);
  border: none;
  box-shadow: 0 0 5px rgba(165, 255, 143, 0.65);
}

.cal-day-dot.dot-partial {
  background: #f59e0b;
  border: none;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.5);
}

.cal-day-dot.dot-hollow {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.cal-day-dot.dot-focus-done {
  border-radius: 50%;
}

.cal-day-dot.dot-focus-hollow {
  background: transparent;
  border: 1.5px dashed;
  border-radius: 50%;
  opacity: 0.45;
}

body.dashboard-theme-white .cal-day-dot.dot-green {
  background: #15803d;
  box-shadow: 0 0 4px rgba(21, 128, 61, 0.4);
}

body.dashboard-theme-white .cal-day-dot.dot-partial {
  background: #d97706;
}

body.dashboard-theme-white .cal-day-dot.dot-hollow {
  border: 1px solid #94a3b8;
}

.habits-cal-day:hover .cal-day-dot.dot-green {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(165, 255, 143, 0.85);
}

.habits-cal-day:hover .cal-day-dot.dot-hollow {
  border-color: rgba(255, 255, 255, 0.6);
}

body.dashboard-theme-white .habits-cal-day:hover .cal-day-dot.dot-hollow {
  border-color: #475569;
}

/* Rodapé e Legenda do Calendário */
.habits-cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
}

body.dashboard-theme-white .habits-cal-footer {
  border-top-color: #e2e8f0;
  color: #64748b;
}

.habits-cal-legend {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-cal-reset-selection {
  background: none;
  border: none;
  color: var(--color-life, #a5ff8f);
  font-size: 0.72rem;
  font-weight: 400;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-cal-reset-selection:hover {
  text-decoration: underline;
  background: rgba(165, 255, 143, 0.1);
}

body.dashboard-theme-white .btn-cal-reset-selection {
  color: #15803d;
}

/* ==========================================================================
   6. MODAL: NOVO / EDITAR HÁBITO
   ========================================================================== */
.habit-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
}

.habit-modal-backdrop.hidden {
  display: none !important;
}

.habit-modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card-modal, #14161d);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 20px;
  padding: 1.4rem 1.6rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}

body.dashboard-theme-white .habit-modal-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.habit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.habit-modal-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-bright, #ffffff);
  margin: 0;
}

body.dashboard-theme-white .habit-modal-title {
  color: #0f172a;
}

.btn-modal-close-habit {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.btn-modal-close-habit:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-bright, #ffffff);
}

body.dashboard-theme-white .btn-modal-close-habit {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

/* Seletor de Cores do Hábito */
.habit-color-palette {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.35rem 0;
}

.habit-color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.habit-color-option:hover {
  transform: scale(1.15);
}

.habit-color-option.selected {
  border-color: #ffffff;
  transform: scale(1.1);
  box-shadow: 0 0 10px currentColor;
}

body.dashboard-theme-white .habit-color-option.selected {
  border-color: #0f172a;
}

.habit-color-option i {
  font-size: 0.65rem;
  color: #ffffff;
  display: none;
}

.habit-color-option.selected i {
  display: block;
}

/* Seletor de Ícones */
.habit-icons-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.45rem;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.35rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: 12px;
}

body.dashboard-theme-white .habit-icons-grid {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

.habit-icon-choice {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s ease;
}

.habit-icon-choice:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-bright, #ffffff);
}

.habit-icon-choice.selected {
  background: var(--color-life, #a5ff8f);
  color: #0a0b0e;
  font-weight: 400;
}

body.dashboard-theme-white .habit-icon-choice.selected {
  background: #15803d;
  color: #ffffff;
}

/* Seletor de Dias da Semana (Frequência) */
.habit-days-picker-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.habit-day-pill-btn {
  flex: 1;
  padding: 0.45rem 0.2rem;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 400;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.habit-day-pill-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.habit-day-pill-btn.selected {
  background: var(--color-life, #a5ff8f);
  border-color: var(--color-life, #a5ff8f);
  color: #0a0b0e;
}

body.dashboard-theme-white .habit-day-pill-btn {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.dashboard-theme-white .habit-day-pill-btn.selected {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
}

/* Modal Detalhes do Dia Selecionado no Calendário */
.habit-day-details-modal {
  width: 100%;
  max-width: 420px;
}

.habit-day-check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  cursor: pointer;
  transition: all 0.15s ease;
}

.habit-day-check-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-hover, rgba(255, 255, 255, 0.12));
}

body.dashboard-theme-white .habit-day-check-item {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.06);
}

body.dashboard-theme-white .habit-day-check-item:hover {
  background: #f1f5f9;
}

/* ==========================================================================
   7. ESTADO VAZIO (EMPTY STATE)
   ========================================================================== */
.habits-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1.5rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.015);
  border: 1.5px dashed var(--border-subtle, rgba(255, 255, 255, 0.08));
  gap: 0.75rem;
}

body.dashboard-theme-white .habits-empty-state {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
}

.habits-empty-icon-box {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: rgba(165, 255, 143, 0.12);
  color: var(--color-life, #a5ff8f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

body.dashboard-theme-white .habits-empty-icon-box {
  background: rgba(21, 128, 61, 0.12);
  color: #15803d;
}

.habits-empty-title {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-bright, #ffffff);
  margin: 0;
}

body.dashboard-theme-white .habits-empty-title {
  color: #0f172a;
}

.habits-empty-desc {
  font-size: 0.86rem;
  color: var(--text-secondary, #94a3b8);
  max-width: 380px;
  line-height: 1.5;
  margin: 0;
}

body.dashboard-theme-white .habits-empty-desc {
  color: #64748b;
}

/* ==========================================================================
   8. RESPONSIVIDADE E ADAPTAÇÃO POR TAMANHO DE TELA
   ========================================================================== */

/* Telas intermediárias, dobráveis (ex: Galaxy Z Fold) e tablets (<= 1024px) */
@media (max-width: 1024px) {
  .habits-wrapper {
    padding: 0.85rem 1rem;
    gap: 0.85rem;
    width: 100%;
    box-sizing: border-box;
  }

  .habits-desktop-layout {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.85rem;
  }

  .habits-main-stream {
    width: 100%;
    flex: none;
  }

  .habits-stream-content {
    width: 100%;
  }

  /* Header original mantido exatamente como estava antes */
  .habits-toolbar {
    width: 100%;
    box-sizing: border-box;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
  }

  .habits-toolbar-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
  }

  .habits-toolbar-title {
    font-size: 1.15rem;
  }

  .habits-search-box {
    flex: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .habits-toolbar-right {
    width: 100%;
  }

  .btn-new-habit {
    width: 100%;
    justify-content: center;
  }

  /* Oculta as tags "Todos", "Pendentes" e "Concluídos" no Z Fold e mobile */
  .habits-filter-tabs {
    display: none !important;
  }

  /* Banner de Progresso */
  .habits-today-banner {
    width: 100%;
    box-sizing: border-box;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    gap: 0.75rem;
  }

  .habits-today-progress-wrap {
    width: 100%;
    justify-content: space-between;
  }

  /* ITENS EM 2 COLUNAS NO Z FOLD */
  .habits-cards-grid {
    width: 100%;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.85rem;
  }

  .habit-card {
    width: 100%;
    box-sizing: border-box;
    padding: 0.95rem 1rem;
    gap: 0.65rem;
  }

  .habit-card-icon-box {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .habit-card-title {
    font-size: 0.88rem;
  }

  .habit-checkin-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
  }

  /* Rodapé do card na mesma linha (fogo + número e mini tracker) */
  .habit-card-footer {
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    gap: 0.35rem !important;
  }

  /* Remove a palavra 'dias' para manter fogo e número compactos na mesma linha */
  .habit-streak-label {
    display: none !important;
  }

  .habit-streak-badge {
    flex-shrink: 0 !important;
    gap: 0.25rem !important;
    font-size: 0.8rem !important;
  }

  .habit-mini-week-strip {
    flex-shrink: 0 !important;
    gap: 0.22rem !important;
  }

  .habit-mini-day-dot {
    width: 19px;
    height: 19px;
    font-size: 0.55rem;
  }

  /* Calendário Lateral com espaçamento e respiro nos dias */
  .habits-calendar-sidebar {
    width: 100%;
    position: static;
  }

  .habits-calendar-sidebar .habits-calendar-card {
    width: 100% !important;
    padding: 0.85rem 1rem !important;
    gap: 0.55rem !important;
    border-radius: 16px !important;
  }

  .habits-calendar-sidebar .habits-cal-weekdays {
    padding: 0.3rem 0 !important;
    margin-bottom: 2px !important;
  }

  .habits-calendar-sidebar .habits-cal-grid {
    gap: 6px 4px !important;
  }

  .habits-calendar-sidebar .habits-cal-day {
    aspect-ratio: auto !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 3px 0 !important;
    gap: 3.5px !important;
    border-radius: 9px !important;
  }

  .habits-calendar-sidebar .habits-cal-day .cal-day-num {
    font-size: 0.78rem !important;
  }

  .habits-calendar-sidebar .habits-cal-nav-btn.btn-today {
    width: auto !important;
    padding: 0 0.65rem !important;
    font-size: 0.72rem !important;
  }
}

/* Celulares compactos (<= 580px): 1 Coluna */
@media (max-width: 580px) {
  .habits-cards-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Telas mobile compactas (<= 480px) */
@media (max-width: 480px) {
  .habits-wrapper {
    padding: 0.65rem 0.75rem;
    gap: 0.65rem;
  }

  .habit-card {
    padding: 0.95rem;
    gap: 0.75rem;
  }

  .habit-card-footer {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: space-between;
  }

  .habit-mini-day-dot {
    width: 20px;
    height: 20px;
    font-size: 0.55rem;
  }

  .habit-streak-badge {
    font-size: 0.72rem;
  }

  .habits-calendar-card {
    padding: 0.75rem 0.85rem;
  }
}
