/* ==========================================================================
   TreeMind OS — Componentes
   Blocos reutilizáveis. Nenhum componente conhece a view em que vive.
   ========================================================================== */

/* ==========================================================================
   Card
   ========================================================================== */

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--sp-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), border-color var(--t-fast),
    transform var(--t-fast), box-shadow var(--t-fast);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card--interactive:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.card__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}

.card__subtitle {
  margin-top: 1px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.card__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

.card__body {
  flex: 1;
  min-height: 0;
}

.card__foot {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Stat card (linha de indicadores)
   ========================================================================== */

.stat {
  position: relative;
  overflow: hidden;
  padding: var(--sp-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast),
    transform var(--t-fast), box-shadow var(--t-fast);
}

.stat:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.stat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.stat__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--stat-soft, var(--blue-soft));
  color: var(--stat-color, var(--blue));
}

.stat__icon svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.stat__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat__value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat__caption {
  margin-top: 2px;
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.stat__spark {
  height: 30px;
  margin-top: auto;
}

/* ==========================================================================
   Barra de progresso
   ========================================================================== */

.progress {
  height: 5px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress--thin {
  height: 4px;
}

.progress__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--progress-color, var(--blue));
  /* A largura real entra via style inline no JS; a transição anima o preenchimento. */
  transition: width 700ms var(--ease);
}

/* ==========================================================================
   Botões
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast),
    color var(--t-fast), transform var(--t-fast);
}

.btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn--primary {
  background: var(--brand-accent);
  color: #fff;
  font-weight: var(--fw-semibold);
}

.btn--primary:hover {
  background: #7d75ff;
}

.btn--secondary {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn--ghost {
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn--link {
  height: auto;
  padding: 0;
  color: var(--brand-accent);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.btn--link:hover {
  color: #8d86ff;
}

.btn--sm {
  height: 28px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
}

.btn--block {
  width: 100%;
}

/* Botão só de ícone. */
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast),
    border-color var(--t-fast);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.icon-btn--bare {
  border-color: transparent;
  background: transparent;
}

.icon-btn--sm {
  width: 28px;
  height: 28px;
}

.icon-btn--sm svg {
  width: 14px;
  height: 14px;
}

.icon-btn__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border: 2px solid var(--bg-primary);
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: var(--fw-bold);
  line-height: 11px;
  text-align: center;
}

/* ==========================================================================
   Campos de formulário
   ========================================================================== */

.field {
  margin-bottom: var(--sp-4);
}

.field__label {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}

.input,
.textarea,
.select {
  width: 100%;
  height: 38px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.textarea {
  height: auto;
  min-height: 86px;
  padding: var(--sp-3);
  resize: vertical;
  line-height: 1.55;
}

.select {
  appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f7d91' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.16);
}

.input.is-invalid,
.textarea.is-invalid,
.select.is-invalid {
  border-color: var(--red);
}

.field__error {
  display: none;
  margin-top: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--red);
}

.field__error.is-visible {
  display: block;
}

/* --- Busca ------------------------------------------------------------- */

.search {
  position: relative;
  width: 240px;
}

.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 34px;
  padding: 0 var(--sp-3) 0 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
    background var(--t-fast);
}

.search input::placeholder {
  color: var(--text-muted);
}

.search input:focus {
  background: var(--bg-secondary);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.14);
}

/* ==========================================================================
   Checkbox customizado
   ========================================================================== */

.check {
  position: relative;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: transparent;
  transition: background var(--t-fast), border-color var(--t-fast),
    transform var(--t-fast);
}

.check svg {
  width: 11px;
  height: 11px;
  stroke-width: 3;
  color: #fff;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.check:hover {
  border-color: var(--brand-accent);
}

.check:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.check[aria-checked="true"] {
  background: var(--green);
  border-color: var(--green);
}

.check[aria-checked="true"] svg {
  opacity: 1;
  transform: scale(1);
}

/* ==========================================================================
   Tags / badges
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--tag-soft, var(--blue-soft));
  color: var(--tag-color, var(--blue));
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.badge-new {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--brand-accent);
  color: #fff;
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--dot-color, var(--blue));
}

/* ==========================================================================
   Avatar
   ========================================================================== */

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--brand-accent), var(--brand-primary));
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
}

.avatar--sm {
  width: 26px;
  height: 26px;
  font-size: var(--fs-xs);
}

.avatar--lg {
  width: 40px;
  height: 40px;
  font-size: var(--fs-md);
}

/* ==========================================================================
   Segmented control (filtros)
   ========================================================================== */

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.segmented__item {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}

.segmented__item:hover {
  color: var(--text-primary);
}

.segmented__item.is-active {
  background: var(--brand-primary);
  color: var(--text-primary);
}

.segmented__item:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ==========================================================================
   Lista de tarefas
   ========================================================================== */

.task-list {
  display: flex;
  flex-direction: column;
}

.task {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}

.task:last-child {
  border-bottom: none;
}

.task:hover {
  background: rgba(255, 255, 255, 0.03);
}

.task__main {
  flex: 1;
  min-width: 0;
}

.task__name {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--t-fast);
}

.task__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 4px;
}

.task__time {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.task.is-done .task__name {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ==========================================================================
   Eventos do calendário
   ========================================================================== */

.event {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast);
}

.event:hover {
  background: rgba(255, 255, 255, 0.03);
}

.event__time {
  width: 42px;
  flex-shrink: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.event__bar {
  width: 3px;
  align-self: stretch;
  min-height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--event-color, var(--blue));
}

.event__main {
  flex: 1;
  min-width: 0;
}

.event__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event__sub {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.event__duration {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ==========================================================================
   Hábitos
   ========================================================================== */

.habit {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-color);
}

.habit:last-child {
  border-bottom: none;
}

.habit__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--habit-soft, var(--green-soft));
  color: var(--habit-color, var(--green));
}

.habit__icon svg {
  width: 15px;
  height: 15px;
}

.habit__main {
  flex: 1;
  min-width: 0;
}

.habit__name {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
}

.habit__streak {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.habit__streak svg {
  width: 11px;
  height: 11px;
  color: var(--orange);
}

.habit__week {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.habit-day {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 9px;
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  transition: background var(--t-fast), border-color var(--t-fast),
    color var(--t-fast), transform var(--t-fast);
}

.habit-day:hover {
  border-color: var(--border-strong);
  transform: scale(1.12);
}

.habit-day:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.habit-day[data-state="done"] {
  background: var(--habit-color, var(--green));
  border-color: var(--habit-color, var(--green));
  color: #04121a;
}

.habit-day[data-state="pending"] {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* "Não planejado": visualmente recuado, mas ainda clicável. */
.habit-day[data-state="off"] {
  background: rgba(255, 255, 255, 0.02);
  border-style: dashed;
  opacity: 0.5;
}

/* ==========================================================================
   Insights da IA
   ========================================================================== */

.insight {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.insight:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.insight__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--insight-soft, var(--purple-soft));
  color: var(--insight-color, var(--purple));
}

.insight__icon svg {
  width: 14px;
  height: 14px;
}

.insight__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}

.insight__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.insight__text {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

.insight__action {
  margin-top: var(--sp-2);
}

/* ==========================================================================
   Projetos
   ========================================================================== */

.project {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast),
    transform var(--t-fast);
}

.project:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateX(2px);
}

.project:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.project__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--project-soft, var(--blue-soft));
  color: var(--project-color, var(--blue));
}

.project__icon svg {
  width: 16px;
  height: 16px;
}

.project__main {
  flex: 1;
  min-width: 0;
}

.project__name {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}

.project__desc {
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project__progress {
  width: 110px;
  flex-shrink: 0;
}

.project__pct {
  margin-bottom: 5px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-align: right;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Ações rápidas que aparecem no hover. */
.project__quick {
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.project:hover .project__quick,
.project:focus-within .project__quick {
  opacity: 1;
  transform: translateX(0);
}

.project--new {
  justify-content: center;
  border-style: dashed;
  background: transparent;
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.project--new:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}

/* Card de projeto (grid da view Projetos). */
.project-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.project-card__stats {
  display: flex;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ==========================================================================
   Acesso rápido
   ========================================================================== */

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}

.quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-align: center;
  transition: background var(--t-fast), border-color var(--t-fast),
    color var(--t-fast), transform var(--t-fast);
}

.quick svg {
  width: 19px;
  height: 19px;
  color: var(--quick-color, var(--brand-accent));
  transition: transform var(--t-fast);
}

.quick:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.quick:hover svg {
  transform: scale(1.12);
}

.quick:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ==========================================================================
   Finanças
   ========================================================================== */

.balance {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--green);
}

.trend svg {
  width: 13px;
  height: 13px;
}

.trend--down {
  color: var(--red);
}

.money-split {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
}

.money-box {
  padding: var(--sp-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.money-box__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.money-box__label svg {
  width: 12px;
  height: 12px;
}

.money-box__value {
  margin-top: 4px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

/* Donut + lista de categorias lado a lado. Empilha no mobile. */
.donut-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}

.donut-row .cat-list {
  flex: 1;
  min-width: 0;
}

.donut-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
  margin: 0 auto;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center__value {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.donut-center__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast), opacity var(--t-fast);
}

.cat:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cat.is-dimmed {
  opacity: 0.35;
}

.cat__name {
  flex: 1;
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat__pct {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cat__value {
  width: 58px;
  text-align: right;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Gráficos
   ========================================================================== */

.chart-box {
  position: relative;
  height: 250px;
}

.chart-box--sm {
  height: 190px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: opacity var(--t-fast);
}

.legend-item:hover {
  color: var(--text-primary);
}

.legend-item.is-off {
  opacity: 0.38;
  text-decoration: line-through;
}

.legend-item:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Tabela
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.table th {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--fs-base);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.num--pos {
  color: var(--green);
}

.num--neg {
  color: var(--red);
}

/* ==========================================================================
   Dropdown
   ========================================================================== */

.dropdown {
  position: relative;
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  padding: var(--sp-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--t-fast), transform var(--t-fast),
    visibility var(--t-fast);
  z-index: 40;
}

.dropdown__menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown__menu--left {
  right: auto;
  left: 0;
}

.dropdown__menu--wide {
  width: 320px;
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}

.dropdown__item svg {
  width: 14px;
  height: 14px;
}

.dropdown__item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.dropdown__item.is-active {
  color: var(--brand-accent);
  font-weight: var(--fw-medium);
}

.dropdown__item:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.dropdown__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.dropdown__divider {
  height: 1px;
  margin: var(--sp-1) 0;
  background: var(--border-color);
}

/* --- Notificações ------------------------------------------------------ */

.notif {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}

.notif:hover {
  background: rgba(255, 255, 255, 0.04);
}

.notif__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--notif-soft, var(--blue-soft));
  color: var(--notif-color, var(--blue));
}

.notif__icon svg {
  width: 14px;
  height: 14px;
}

.notif__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.notif__text {
  margin-top: 1px;
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--text-muted);
}

.notif__time {
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-muted);
}

.notif.is-unread .notif__title::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--brand-accent);
  vertical-align: middle;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(3, 9, 17, 0.72);
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
  z-index: var(--z-modal);
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform var(--t-slow), opacity var(--t-slow);
}

.overlay.is-open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal--wide {
  max-width: 580px;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-color);
}

.modal__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}

.modal__subtitle {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.modal__close {
  margin-left: auto;
}

.modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-5);
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-color);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

/* ==========================================================================
   Painel lateral (IA)
   ========================================================================== */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--t-slow);
  z-index: var(--z-panel);
}

.panel.is-open {
  transform: translateX(0);
}

.panel__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-4);
}

.panel__foot {
  flex-shrink: 0;
  padding: var(--sp-4);
  border-top: 1px solid var(--border-color);
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 9, 17, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
  z-index: calc(var(--z-panel) - 1);
}

.panel-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Chat (IA Assistant)
   ========================================================================== */

.chat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.msg {
  display: flex;
  gap: var(--sp-3);
  max-width: 90%;
}

.msg--user {
  flex-direction: row-reverse;
  margin-left: auto;
}

.msg__bubble {
  padding: var(--sp-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: var(--fs-base);
  line-height: 1.55;
}

.msg--user .msg__bubble {
  background: var(--brand-primary);
  border-color: transparent;
}

.msg__avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
}

.msg__avatar svg {
  width: 14px;
  height: 14px;
}

.msg--user .msg__avatar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 50%;
}

.msg__actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color);
}

.chat-input {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
}

.chat-input .textarea {
  min-height: 38px;
  max-height: 110px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.suggestion {
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: background var(--t-fast), border-color var(--t-fast),
    color var(--t-fast);
}

.suggestion:hover {
  background: var(--bg-card-hover);
  border-color: var(--brand-accent);
  color: var(--text-primary);
}

/* Indicador de "digitando". */
.typing {
  display: flex;
  gap: 4px;
  padding: var(--sp-3);
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 260px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  pointer-events: auto;
  animation: toast-in 250ms var(--ease);
}

.toast.is-leaving {
  animation: toast-out 200ms var(--ease) forwards;
}

.toast__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--toast-soft, var(--green-soft));
  color: var(--toast-color, var(--green));
}

.toast__icon svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ==========================================================================
   Estados: vazio, erro, skeleton
   ========================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.empty__icon svg {
  width: 20px;
  height: 20px;
}

.empty__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}

.empty__text {
  max-width: 280px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.state-error .empty__icon {
  background: var(--red-soft);
  color: var(--red);
}

.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ==========================================================================
   Splash de carregamento
   ========================================================================== */

.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-primary);
  z-index: 100;
  transition: opacity var(--t-slow), visibility var(--t-slow);
}

.splash.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.splash__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
}

.splash__logo {
  width: 56px;
  height: 56px;
  animation: pulse 1.6s infinite var(--ease);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.65;
    transform: scale(0.94);
  }
}

.splash__name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}

.splash__bar {
  width: 140px;
  height: 2px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.splash__bar::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-accent);
  animation: slide 1.1s infinite var(--ease);
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(350%);
  }
}

/* ==========================================================================
   Login
   ========================================================================== */

.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: var(--bg-primary);
  z-index: 95;
  transition: opacity var(--t-slow), visibility var(--t-slow);
}

.login.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.login::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 400px at 50% 0%, rgba(29, 50, 84, 0.6), transparent 70%),
    radial-gradient(500px 300px at 50% 100%, rgba(108, 99, 255, 0.08), transparent 70%);
}

.login__card {
  position: relative;
  width: 100%;
  max-width: 372px;
  padding: var(--sp-8) var(--sp-6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}

.login__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  text-align: center;
}

.login__logo {
  width: 44px;
  height: 44px;
}

.login__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.login__sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.login__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-inline input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-accent);
  cursor: pointer;
}

.login__divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.login__divider::before,
.login__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* ==========================================================================
   View transition
   ========================================================================== */

.view {
  animation: view-in 250ms var(--ease);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Itens escondidos pelo filtro de busca do header. */
[data-filter-hidden="true"] {
  display: none !important;
}

/* ==========================================================================
   Notas
   ========================================================================== */

.note {
  cursor: pointer;
}

.note__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-2);
}

.note__excerpt {
  flex: 1;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ==========================================================================
   Objetivos
   ========================================================================== */

.goal__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.goal__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-color);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.goal__meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.goal__meta svg {
  width: 12px;
  height: 12px;
}

/* ==========================================================================
   Grade semanal do calendário
   ========================================================================== */

.week-grid {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
}

.week-grid__head {
  padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-align: center;
  color: var(--text-secondary);
}

.week-grid__head.is-today {
  color: var(--brand-accent);
}

.week-grid__hour {
  padding: var(--sp-2);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.week-grid__cell {
  min-height: 42px;
  padding: 3px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  transition: background var(--t-fast);
}

.week-grid__cell:hover {
  background: rgba(255, 255, 255, 0.03);
}

.week-event {
  height: 100%;
  min-height: 34px;
  padding: 4px 6px;
  border-left: 2px solid var(--event-color, var(--blue));
  border-radius: var(--radius-sm);
  background: var(--event-soft, var(--blue-soft));
  font-size: 10px;
  font-weight: var(--fw-medium);
  line-height: 1.3;
  cursor: pointer;
  overflow: hidden;
  transition: filter var(--t-fast);
}

.week-event:hover {
  filter: brightness(1.25);
}

/* ==========================================================================
   Utilitários
   ========================================================================== */

.u-flex { display: flex; }
.u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-1 { gap: var(--sp-1); }
.u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); }
.u-gap-4 { gap: var(--sp-4); }
.u-mt-2 { margin-top: var(--sp-2); }
.u-mt-3 { margin-top: var(--sp-3); }
.u-mt-4 { margin-top: var(--sp-4); }
.u-mb-3 { margin-bottom: var(--sp-3); }
.u-mb-4 { margin-bottom: var(--sp-4); }
.u-ml-auto { margin-left: auto; }
.u-text-muted { color: var(--text-muted); }
.u-text-sm { font-size: var(--fs-sm); }
.u-text-xs { font-size: var(--fs-xs); }
.u-full { width: 100%; }
