/* ── Variables (Claymorphism) ──────────────────────────── */
:root {
  --bg: #d8dcf0;
  --bg-soft: #dfe3f6;
  --surface: #fafbff;
  --surface-hover: #f3f5fc;
  --border: rgba(99, 102, 241, 0.1);
  --text: #1a1d23;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-hover: #4f46e5;
  --success: #10b981;
  --success-light: #34d399;
  --success-soft: rgba(16, 185, 129, 0.14);
  --radius: 22px;
  --radius-sm: 16px;
  --clay-outer: 8px 8px 20px rgba(99, 102, 241, 0.16), -6px -6px 16px rgba(255, 255, 255, 0.95);
  --clay-inner: inset 2px 2px 6px rgba(255, 255, 255, 0.98), inset -2px -3px 7px rgba(99, 102, 241, 0.08);
  --clay: var(--clay-outer), var(--clay-inner);
  --clay-hover: 10px 10px 24px rgba(99, 102, 241, 0.2), -8px -8px 20px rgba(255, 255, 255, 0.96), inset 2px 2px 6px rgba(255, 255, 255, 0.98), inset -2px -3px 7px rgba(99, 102, 241, 0.08);
  --clay-inset: inset 5px 5px 12px rgba(99, 102, 241, 0.12), inset -5px -5px 12px rgba(255, 255, 255, 0.98);
  --clay-accent: 6px 6px 14px rgba(79, 70, 229, 0.38), -3px -3px 10px rgba(255, 255, 255, 0.18), inset 2px 2px 6px rgba(255, 255, 255, 0.32), inset -2px -4px 8px rgba(55, 48, 163, 0.28);
  --shadow: var(--clay-outer);
  --shadow-hover: var(--clay-hover);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --modal-shadow: 12px 12px 28px rgba(99, 102, 241, 0.18), -8px -8px 24px rgba(255, 255, 255, 0.95), inset 2px 2px 6px rgba(255, 255, 255, 0.9), inset -1px -1px 4px rgba(99, 102, 241, 0.06);
  --modal-shadow-mobile: 0 -10px 32px rgba(99, 102, 241, 0.14), -6px -6px 20px rgba(255, 255, 255, 0.92), inset 2px 2px 6px rgba(255, 255, 255, 0.9), inset -1px -1px 4px rgba(99, 102, 241, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1d2e;
  --bg-soft: #1f2337;
  --surface: #262a3d;
  --surface-hover: #2e3349;
  --border: rgba(129, 140, 248, 0.12);
  --text: #eef0f8;
  --text-muted: #9ca3b8;
  --accent: #818cf8;
  --accent-light: #9599fa;
  --accent-soft: rgba(129, 140, 248, 0.18);
  --accent-hover: #6366f1;
  --success: #34d399;
  --success-light: #6ee7b7;
  --success-soft: rgba(52, 211, 153, 0.15);
  --clay-outer: 8px 8px 20px rgba(0, 0, 0, 0.35), -4px -4px 12px rgba(255, 255, 255, 0.04);
  --clay-inner: inset 2px 2px 6px rgba(255, 255, 255, 0.06), inset -2px -3px 8px rgba(0, 0, 0, 0.25);
  --clay-hover: 10px 10px 24px rgba(0, 0, 0, 0.4), -4px -4px 14px rgba(255, 255, 255, 0.05), inset 2px 2px 6px rgba(255, 255, 255, 0.06), inset -2px -3px 8px rgba(0, 0, 0, 0.25);
  --clay-inset: inset 5px 5px 12px rgba(0, 0, 0, 0.35), inset -3px -3px 10px rgba(255, 255, 255, 0.04);
  --clay-accent: 6px 6px 16px rgba(0, 0, 0, 0.45), inset 2px 2px 6px rgba(255, 255, 255, 0.12), inset -2px -4px 8px rgba(0, 0, 0, 0.3);
  --modal-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 8px 28px rgba(99, 102, 241, 0.22), inset 2px 2px 6px rgba(255, 255, 255, 0.05), inset -2px -3px 8px rgba(0, 0, 0, 0.35);
  --modal-shadow-mobile: 0 -14px 44px rgba(0, 0, 0, 0.68), 0 -6px 28px rgba(99, 102, 241, 0.32), inset 2px 2px 6px rgba(255, 255, 255, 0.05), inset -2px -3px 8px rgba(0, 0, 0, 0.35);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(145deg, var(--bg) 0%, var(--bg-soft) 50%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── App Shell ──────────────────────────────────────────── */
.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.header .nav {
  flex: 0 0 auto;
  margin-left: auto;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header__actions .btn--icon,
.header__actions .btn--logout {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
  background: transparent;
  box-shadow: none;
}

.header__actions .btn--icon:hover,
.header__actions .btn--logout:hover {
  background: rgba(99, 102, 241, 0.12);
  box-shadow: none;
}

html[data-theme="dark"] .header__actions .btn--icon:hover,
html[data-theme="dark"] .header__actions .btn--logout:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn--icon {
  padding: 6px 10px;
  color: var(--text-muted);
}

.btn--icon:hover {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

/* ── Login ──────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card__brand {
  justify-content: center;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand__logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(99, 102, 241, 0.28));
}

.brand__logo--lg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 2px 5px rgba(99, 102, 241, 0.32));
}

.brand__title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__brand .brand__title {
  font-size: 1.1rem;
}

.login-form__submit {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

.login-error {
  color: #ef4444;
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.login-status {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.login-status:empty {
  display: none;
  margin: 0;
}

.header__brand {
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 5px;
  border-radius: 18px;
  box-shadow: var(--clay);
  border: none;
  width: fit-content;
  max-width: 100%;
}

.sync-status {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

.sync-status--local { color: var(--text-muted); background: var(--surface); }
.sync-status--ok { color: var(--success); background: var(--success-soft); }
.sync-status--error { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.sync-status--saving { color: var(--accent); background: var(--accent-soft); }

.nav__btn {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav__btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.8), inset -1px -1px 3px rgba(99, 102, 241, 0.06);
}

.nav__btn--active {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--clay-accent);
}

.nav__btn--active:hover {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent-hover) 100%);
  color: #fff;
}

/* ── View Transitions ───────────────────────────────────── */
.view {
  animation: viewEnter 0.38s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view--exit {
  animation: viewExit 0.28s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes viewExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--clay);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition), background 0.3s ease;
}

.card--clickable {
  cursor: pointer;
}

.card--clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--clay-hover);
}

.card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.card__title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Grid Layouts ───────────────────────────────────────── */
.grid {
  display: grid;
  gap: 16px;
}

.grid--2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid--days { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

/* ── Section Headers ────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-header__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.section-header--center {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.section-header--center .btn {
  align-self: center;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  touch-action: manipulation;
}

.btn--primary {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--clay-accent);
  border: none;
}

.btn--primary:hover {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent-hover) 100%);
  transform: translateY(-1px);
  box-shadow: 6px 8px 16px rgba(79, 70, 229, 0.42), -3px -3px 10px rgba(255, 255, 255, 0.2), inset 2px 2px 6px rgba(255, 255, 255, 0.32), inset -2px -4px 8px rgba(55, 48, 163, 0.28);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border: none;
  padding: 8px 14px;
  box-shadow: var(--clay);
}

.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--accent);
  box-shadow: var(--clay-hover);
}

.btn--logout {
  color: #ef4444;
  padding: 6px 10px;
  box-shadow: var(--clay);
}

.btn--logout:hover {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.08);
  box-shadow: 6px 6px 14px rgba(239, 68, 68, 0.15), -6px -6px 14px rgba(255, 255, 255, 0.9), inset 2px 2px 5px rgba(255, 255, 255, 0.9), inset -2px -2px 5px rgba(239, 68, 68, 0.08);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.btn__icon {
  font-size: 18px;
}

/* ── Focus Badge ────────────────────────────────────────── */
.focus-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 24px;
}

.focus-badge__icon {
  font-size: 1.1rem;
}

/* ── Day Cards ──────────────────────────────────────────── */
.day-card {
  text-align: center;
  padding: 20px 12px;
  position: relative;
  overflow: hidden;
}

.day-card__body {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: -4px;
  transition: transform var(--transition), background var(--transition);
}

.day-card__body:hover {
  transform: translateY(-2px);
  background: var(--surface-hover);
}

.day-card__name {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.day-card__date {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 4px 0;
  letter-spacing: -0.02em;
}

.day-card__theme {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-card__progress {
  margin-top: 10px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.day-card__progress-bar {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width var(--transition);
}

.day-card--today {
  box-shadow: var(--clay-hover), 0 0 0 2px rgba(99, 102, 241, 0.35);
}

.day-card--today .day-card__name {
  color: var(--accent);
}

.day-card__actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.day-card__actions .btn {
  flex: 1;
  justify-content: center;
  font-size: 0.6875rem;
  padding: 5px 6px;
}

.day-card__count {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.theme-line {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity var(--transition-fast);
}

.theme-line:hover { opacity: 0.7; }

.theme-line--empty {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9375rem;
  margin-bottom: 12px;
}

.focus-line {
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.focus-line:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.analysis-report {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.analysis-report__header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 4px;
}

.analysis-report__range {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

.analysis-report__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.analysis-report__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 88px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--clay);
}

.analysis-report__stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.analysis-report__stat-value {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.analysis-report__stat-pct {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
}

.analysis-report__section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analysis-report__section + .analysis-report__section {
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.analysis-report__section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.analysis-report__section-title .material-symbols-outlined {
  font-size: 17px;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

.analysis-report__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-report__row {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--clay);
}

.analysis-report__row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.analysis-report__row-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.analysis-report__row-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.analysis-report__progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.analysis-report__progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  transition: width 0.3s ease;
}

.card--analysis {
  padding: 20px 18px;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 300;
  padding: 11px 20px;
  border-radius: 999px;
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--clay-accent);
  animation: copyToastIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.copy-toast--error {
  background: linear-gradient(160deg, #f87171 0%, #ef4444 100%);
}

@keyframes copyToastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.nav-arrows {
  display: flex;
  gap: 4px;
}

.nav-arrows--center {
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.nav-arrows__label {
  font-size: 0.875rem;
  color: var(--text-muted);
  min-width: 80px;
  text-align: center;
}

/* Navegación mes a mes (Análisis, Calendario) */
.month-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.month-nav__title {
  text-align: center;
  flex: 0 1 auto;
  min-width: 0;
}

.month-nav__title .section-header__title {
  margin: 0;
  white-space: nowrap;
}

.nav-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 6px;
  cursor: pointer;
  color: var(--accent);
  border-radius: 50%;
  transition: color var(--transition-fast), background var(--transition-fast);
  touch-action: manipulation;
}

.nav-arrow-btn:hover {
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.nav-arrow-btn .material-symbols-outlined {
  font-size: 34px;
  line-height: 1;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.task-item--habit .task-item__text {
  font-weight: 500;
}

.back-btn {
  margin-bottom: 16px;
  padding-left: 0;
}

.card__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.breadcrumb__link {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.breadcrumb__link:hover {
  background: var(--accent-soft);
}

.breadcrumb__sep {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.breadcrumb__current {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Week cards ─────────────────────────────────────────── */
.week-card__num {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}

.week-card__range {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.week-card__focus {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.week-card__stats {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.week-card--current {
  box-shadow: var(--clay-hover), 0 0 0 2px rgba(99, 102, 241, 0.35);
}

/* ── Daily log ──────────────────────────────────────────── */
.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.log-item:last-child { border-bottom: none; }

.log-item__text { flex: 1; font-size: 0.9375rem; }

.log-item__kcal {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.log-summary {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Analysis ───────────────────────────────────────────── */
.analysis-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--surface);
  padding: 5px;
  border-radius: 18px;
  width: fit-content;
  box-shadow: var(--clay);
}

.analysis-tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.analysis-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.45); }

.analysis-tab--active {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--clay-accent);
}

.analysis-json {
  width: 100%;
  min-height: 180px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.insights-list {
  list-style: none;
  margin-top: 12px;
}

.insights-list li {
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 8px;
  color: var(--accent);
}

/* ── Guide ──────────────────────────────────────────────── */
.guide-card {
  text-align: center;
  padding: 32px 24px;
}

.guide-card__icon {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.guide-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.guide-card__text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* ── Task List ──────────────────────────────────────────── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--clay);
  transition: all var(--transition-fast);
  animation: taskSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  flex-wrap: nowrap;
}

.task-item--editable {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.task-item--editable:active,
.task-item--floating {
  cursor: grabbing;
}

.task-item--floating {
  position: fixed;
  z-index: 200;
  margin: 0;
  opacity: 1;
  pointer-events: none;
  cursor: grabbing;
  will-change: left, top;
  transition: none;
  animation: none !important;
  box-shadow:
    0 14px 28px rgba(99, 102, 241, 0.18),
    0 6px 12px rgba(0, 0, 0, 0.06),
    inset 2px 2px 6px rgba(255, 255, 255, 0.95),
    inset -2px -3px 7px rgba(99, 102, 241, 0.06);
}

.task-item__placeholder {
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.16);
  flex-shrink: 0;
  transition: height 0.15s ease;
}

.task-list--reordering .task-item:not(.task-item--floating) {
  transition: transform 0.28s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow var(--transition-fast);
}

.task-list--reordering .task-item:not(.task-item--floating):hover {
  transform: none;
  box-shadow: var(--clay);
}

.task-item--editable:hover {
  transform: none;
  box-shadow: var(--clay);
}

.task-item__pin {
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
  color: var(--text-muted);
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.task-item:hover {
  box-shadow: var(--clay-hover);
  transform: translateY(-1px);
}

.task-item--done {
  opacity: 0.55;
}

.task-item--done .task-item__text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-item:nth-child(1) { animation-delay: 0.04s; }
.task-item:nth-child(2) { animation-delay: 0.08s; }
.task-item:nth-child(3) { animation-delay: 0.12s; }
.task-item:nth-child(4) { animation-delay: 0.16s; }
.task-item:nth-child(5) { animation-delay: 0.20s; }
.task-item:nth-child(n+6) { animation-delay: 0.24s; }

@keyframes taskSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.task-item__check {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  box-shadow: var(--clay-inset);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  font-size: 0.75rem;
  color: transparent;
}

.task-item__check:hover {
  box-shadow: inset 4px 4px 10px rgba(99, 102, 241, 0.14), inset -4px -4px 10px rgba(255, 255, 255, 0.96);
}

.task-item--done .task-item__check {
  background: linear-gradient(160deg, var(--success-light) 0%, var(--success) 100%);
  box-shadow: 4px 4px 10px rgba(16, 185, 129, 0.35), inset 2px 2px 4px rgba(255, 255, 255, 0.35), inset -2px -3px 6px rgba(5, 150, 105, 0.3);
  color: #fff;
}

.task-item__time {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 48px;
  font-variant-numeric: tabular-nums;
}

.task-item__text {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
}

.task-item__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.task-item__move {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
  box-shadow: none;
}

.task-item__move .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.task-item__move:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}

.task-item__from {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 6px;
}

.task-item__delete {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 1;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.task-item__delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.btn--edit-active {
  background: linear-gradient(160deg, rgba(129, 140, 248, 0.35) 0%, rgba(99, 102, 241, 0.25) 100%);
  color: var(--accent);
  box-shadow: var(--clay-accent);
}

.month-focus {
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 20px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.month-focus:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.modal-hint {
  font-size: 0.9375rem;
  margin-bottom: 16px;
  color: var(--text-muted);
}

/* ── Metrics ────────────────────────────────────────────── */
.metric-card {
  position: relative;
  padding: 14px 16px;
}

.metric-card--clickable {
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric-card--clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--clay-hover);
}

.metric-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.metric-card__name {
  font-size: 0.9375rem;
  font-weight: 600;
}

.metric-card .btn--sm {
  padding: 4px 10px;
  font-size: 0.75rem;
  min-height: 32px;
}

.metric-card__hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.metric-card__summary {
  min-width: 0;
}

.metric-card__latest {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.metric-card__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.metric-card__empty {
  margin: 0;
  font-size: 0.875rem;
}

.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-delta .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 20;
}

.metric-delta--up { color: var(--success); }
.metric-delta--down { color: #ef4444; }
.metric-delta--flat { color: var(--text-muted); }
.metric-delta--none { color: var(--text-muted); font-weight: 500; font-size: 0.6875rem; }

.metrics-grid {
  gap: 10px;
}

.metric-card__unit {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.metric-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  animation: taskSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.metric-entry:last-child {
  border-bottom: none;
}

.metric-entry__month {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.metric-entry__row-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.metric-entry__value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-entry__delta-wrap .metric-delta {
  font-size: 0.75rem;
}

.metric-entry__delta {
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 8px;
}

.metric-entry__delta--up { color: var(--success); }
.metric-entry__delta--down { color: #ef4444; }

.metric-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-top: 8px;
  padding-bottom: 14px;
}

.metric-chart--compact {
  height: 44px;
}

.metric-chart--full {
  height: 110px;
  margin-top: 20px;
}

.metric-chart__bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  border-radius: 6px 6px 3px 3px;
  min-height: 4px;
  transition: height var(--transition), opacity var(--transition-fast);
  position: relative;
  opacity: 0.88;
}

.metric-chart__bar:hover {
  opacity: 1;
}

.metric-chart__bar-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.metric-line-chart {
  display: block;
  width: 100%;
  height: 100px;
  margin-bottom: 8px;
}

.metric-line-chart__area {
  fill: rgba(99, 102, 241, 0.12);
}

.metric-line-chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric-line-chart__dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2;
}

.metric-detail-chart {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.metric-donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 12px 8px 8px;
}

.metric-donut__wrap {
  position: relative;
  width: min(240px, 88vw);
  aspect-ratio: 1;
}

.metric-donut__svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 14px rgba(99, 102, 241, 0.18));
}

.metric-donut__segment {
  transition: opacity var(--transition-fast);
}

.metric-donut__segment:hover {
  opacity: 0.85;
}

.metric-donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  pointer-events: none;
}

.metric-donut__value {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.metric-donut__label {
  margin-top: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-donut__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.metric-donut__legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-donut__swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--surface);
}

.metric-detail-list {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Selector de mes (modal metas) */
.month-picker {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--clay-inset);
  border: 1px solid var(--border);
}

.month-picker__head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.month-picker__year {
  font-size: 1rem;
  font-weight: 600;
  min-width: 4ch;
  text-align: center;
}

.month-picker__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.month-picker__month {
  border: none;
  border-radius: 14px;
  padding: 11px 6px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  box-shadow: var(--clay);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.month-picker__month:hover {
  color: var(--accent);
  box-shadow: var(--clay-hover);
}

.month-picker__month--active {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--clay-accent);
}

.month-picker__year-btn .material-symbols-outlined {
  font-size: 28px;
}

/* Selector de hora (modal tareas) */
.time-range-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-range-picker__field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--clay);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.time-range-picker__field:hover {
  box-shadow: var(--clay-hover);
}

.time-range-picker__field--active {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: var(--clay-accent);
}

.time-range-picker__field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.time-range-picker__field-value {
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.time-picker {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--clay-inset);
  border: 1px solid var(--border);
}

.time-picker--inline {
  margin-top: 4px;
}

.time-picker__preview {
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--clay);
  color: var(--text);
}

.time-picker__section {
  margin-bottom: 10px;
}

.time-picker__section:last-of-type {
  margin-bottom: 0;
}

.time-picker__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.time-picker__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.time-picker__grid--period {
  grid-template-columns: repeat(2, 1fr);
}

.time-picker__cell {
  border: none;
  border-radius: 12px;
  padding: 9px 4px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface);
  box-shadow: var(--clay);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.time-picker__cell:hover {
  color: var(--accent);
  box-shadow: var(--clay-hover);
}

.time-picker__cell--active {
  background: linear-gradient(160deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--clay-accent);
}

.time-picker__clear {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

/* ── Empty State ────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty--compact {
  padding: 20px 16px;
}

.card .empty--compact {
  padding: 12px 8px;
}

.empty__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty__text {
  font-size: 0.9375rem;
  line-height: 1.5;
}

.empty__hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  opacity: 0.85;
  margin-top: 4px;
}

/* ── Back Button ────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

/* ── Form Elements ──────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--clay-inset);
  transition: box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  box-shadow: inset 5px 5px 14px rgba(99, 102, 241, 0.12), inset -5px -5px 14px rgba(255, 255, 255, 0.98), 0 0 0 3px var(--accent-soft);
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--modal-shadow);
  animation: modalEnter 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal__title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition-fast);
  line-height: 1;
}

.modal__close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal__body {
  padding: 20px 24px 10px;
}

.modal__footer {
  padding: 0 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal__footer .btn {
  justify-content: center;
  text-align: center;
}

.modal .form-group:last-child {
  margin-bottom: 10px;
}

.modal--confirm {
  position: relative;
  text-align: center;
}

.modal--confirm .modal__header {
  justify-content: center;
  padding: 20px 48px 0;
}

.modal--confirm .modal__title {
  width: 100%;
  text-align: center;
}

.modal--confirm .modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.modal--confirm .modal__footer {
  justify-content: center;
}

.confirm-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 4px 8px 0;
}

.confirm-dialog__icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, rgba(129, 140, 248, 0.22) 0%, rgba(99, 102, 241, 0.14) 100%);
  border: 1px solid var(--border);
  box-shadow: var(--clay);
}

.confirm-dialog__icon .material-symbols-outlined {
  font-size: 30px;
  color: var(--accent);
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.confirm-dialog__message {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 30ch;
}

/* ── Stats Row ──────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-pill {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: none;
  box-shadow: var(--clay);
  text-align: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-pill:hover {
  transform: translateY(-2px);
}

.stat-pill__value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-pill__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Responsive ─────────────────────────────────────────── */

/* Tablet */
@media (max-width: 768px) {
  .grid--2 {
    grid-template-columns: 1fr;
  }

  .section-header {
    gap: 10px;
  }

  .card {
    padding: 20px;
  }
}

/* Móvil */
@media (max-width: 640px) {
  :root {
    --radius: 20px;
    --radius-sm: 14px;
    --clay-outer: 5px 5px 14px rgba(99, 102, 241, 0.11), -5px -5px 14px rgba(255, 255, 255, 0.9);
    --clay-inner: inset 2px 2px 5px rgba(255, 255, 255, 0.92), inset -2px -2px 6px rgba(99, 102, 241, 0.06);
    --clay-hover: 7px 7px 16px rgba(99, 102, 241, 0.13), -7px -7px 16px rgba(255, 255, 255, 0.92), inset 2px 2px 5px rgba(255, 255, 255, 0.92), inset -2px -2px 6px rgba(99, 102, 241, 0.06);
  }

  html {
    font-size: 15px;
  }

  body {
    -webkit-tap-highlight-color: transparent;
  }

  .app {
    padding: 0 14px calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .login-screen {
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    min-height: 100dvh;
  }

  .login-card {
    padding: 22px 18px;
  }

  /* Header morado — solo móvil */
  .header {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    margin: 0 -14px 20px;
    padding: max(14px, env(safe-area-inset-top)) 14px 18px;
    gap: 8px;
    background: linear-gradient(155deg, var(--accent-light) 0%, var(--accent) 48%, var(--accent-hover) 100%);
    border-radius: 0 0 32px 32px;
    box-shadow: 0 12px 28px rgba(79, 70, 229, 0.28);
    z-index: 5;
  }

  .header__brand {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
  }

  .header__actions {
    display: contents;
    margin-left: 0;
  }

  .header__action--theme {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .header__action--logout {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .header__brand .brand__title {
    font-size: 1.05rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  }

  .header .brand__logo {
    --logo-pavilion: rgba(255, 255, 255, 0.82);
    --logo-pavilion-stroke: rgba(255, 255, 255, 0.45);
    --logo-crown: #fff;
    --logo-crown-stroke: rgba(255, 255, 255, 0.7);
    --logo-shine: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  }

  .header__actions .btn--icon,
  .header__actions .btn--logout {
    min-height: 40px;
  }

  .header__actions .btn--icon {
    color: #fff;
  }

  .header__actions .btn--icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
  }

  .header__actions .btn--logout {
    color: #fecaca;
  }

  .header__actions .btn--logout:hover {
    color: #fee2e2;
    background: rgba(255, 255, 255, 0.15);
  }

  html[data-theme="dark"] .header {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48);
  }

  .header .nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    margin-left: 0;
    width: auto;
    z-index: 50;
    justify-content: space-between;
    gap: 4px;
    padding: 6px;
    border-radius: 20px;
    box-shadow:
      0 12px 36px rgba(0, 0, 0, 0.16),
      0 6px 16px rgba(99, 102, 241, 0.14),
      var(--clay-outer);
    border: 1px solid rgba(99, 102, 241, 0.1);
  }

  html[data-theme="dark"] .header .nav {
    box-shadow:
      0 12px 36px rgba(0, 0, 0, 0.5),
      0 6px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(129, 140, 248, 0.14);
  }

  .nav__btn {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 14px 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 14px;
  }

  /* Vistas */
  .section-header {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 16px;
  }

  .section-header__title {
    font-size: 1.2rem;
  }

  .section-header .btn,
  .section-header .nav-arrows {
    align-self: flex-start;
  }

  .section-header--center,
  .section-header--center .btn {
    align-self: center;
  }

  .month-nav {
    margin-bottom: 16px;
    gap: 8px;
  }

  .month-nav__title .section-header__title {
    font-size: 1.2rem;
  }

  .nav-arrow-btn {
    flex-shrink: 0;
  }

  .nav-arrow-btn .material-symbols-outlined {
    font-size: 36px;
  }

  .page-title {
    font-size: 1rem;
    margin-bottom: 6px;
    text-align: center;
  }

  .theme-line {
    font-size: 1.35rem;
    margin-bottom: 12px;
    text-align: center;
  }

  .theme-line--empty {
    text-align: center;
    font-size: 0.875rem;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius);
  }

  .grid {
    gap: 12px;
  }

  .grid--days {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .day-card {
    padding: 14px 8px;
  }

  .day-card__date {
    font-size: 1.4rem;
  }

  .day-card__name {
    font-size: 0.6875rem;
  }

  .day-card__theme {
    font-size: 0.6875rem;
  }

  /* Tareas */
  .task-item {
    padding: 12px 12px;
    gap: 8px;
  }

  .task-item__text {
    font-size: 0.875rem;
  }

  .task-item__time {
    min-width: 40px;
    font-size: 0.75rem;
  }

  /* Botones de acción */
  .action-row {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
  }

  .action-row .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
  }

  .header__actions .btn {
    min-height: 40px;
    height: 40px;
    width: 40px;
    flex: none;
  }

  .btn--sm {
    min-height: 40px;
  }

  /* Navegación semana/mes */
  .nav-arrows {
    flex-wrap: wrap;
    width: 100%;
    gap: 6px;
  }

  .nav-arrows--center {
    flex-direction: column;
    gap: 8px;
  }

  .nav-arrows__label {
    order: -1;
    font-size: 0.8125rem;
  }

  .back-btn {
    margin-bottom: 12px;
    min-height: 44px;
  }

  /* Análisis */
  .analysis-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .analysis-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 0.75rem;
  }

  .card--analysis {
    padding: 16px 14px;
  }

  .analysis-report__range {
    font-size: 1rem;
  }

  .analysis-report__stat {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }

  .analysis-report__row {
    padding: 12px 14px;
  }

  /* Modales tipo bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 90dvh;
    overflow-y: auto;
    margin-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: var(--modal-shadow-mobile);
  }

  .modal__header,
  .modal__body,
  .modal__footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .modal__body {
    padding-bottom: 8px;
  }

  .modal__footer {
    flex-wrap: wrap;
  }

  .modal__footer .btn {
    flex: 1;
  }

  /* Métricas */
  .metric-card {
    padding: 11px 12px;
  }

  .metric-card__latest {
    font-size: 1.1rem;
  }

  .metric-card__header {
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 6px;
  }

  .metric-card .btn--sm {
    min-height: 30px;
    padding: 3px 8px;
  }

  .metric-chart--compact {
    height: 36px;
    margin-top: 6px;
    padding-bottom: 12px;
  }

  .metrics-grid {
    gap: 8px;
  }

  .section-header--center {
    margin-bottom: 14px;
    gap: 10px;
  }

  .empty {
    padding: 32px 16px;
  }

  .empty--compact {
    padding: 16px 12px;
  }

  .focus-line,
  .month-focus {
    font-size: 0.9375rem;
    padding: 14px 16px;
  }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
  .nav__btn {
    font-size: 0.875rem;
    padding: 13px 8px;
    min-height: 46px;
  }

  .grid--days {
    grid-template-columns: repeat(3, 1fr);
  }

  .header .nav {
    left: 8px;
    right: 8px;
  }

  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .header {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }
}
