/* ========== VARIABLES ========== */
:root {
  --bg-primary: #1a1d23;
  --bg-secondary: #22262e;
  --bg-tertiary: #2c313b;
  --bg-hover: #343a46;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0ad;
  --text-muted: #6b7280;
  --accent: #7c6ff7;
  --accent-bright: #9b8fff;
  --accent-dim: #5a4fc0;
  --border: #363b47;
  --border-glow: #4a5060;
  --green: #34d399;
  --red: #f87171;
  --gold: #d4a843;
  --gold-bright: #f0c850;
  --gold-dim: #8a7030;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== LOGIN SCREEN ========== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 360px;
  width: 100%;
}
.login-logo { display: block; margin-bottom: 16px; }
.login-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #333;
  border: none;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.google-btn:hover { box-shadow: 0 2px 12px rgba(124, 111, 247, 0.3); }
.login-error { color: var(--red); font-size: 0.8rem; margin-top: 16px; min-height: 1.2em; }

.login-or {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  margin: 18px 0 12px;
  text-transform: uppercase;
  position: relative;
}
.login-or::before,
.login-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 28%;
  height: 1px;
  background: var(--border);
}
.login-or::before { left: 12%; }
.login-or::after { right: 12%; }

.btn-readonly {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 22px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-readonly:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-dim);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: 4px;
}
.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(248, 113, 113, 0.08);
}

.readonly-banner {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  text-align: center;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  margin: 8px 16px 0;
  font-weight: 500;
}
.readonly-banner.hidden { display: none; }
.readonly-banner a {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}
.readonly-banner a:hover { color: var(--accent-bright); }

/* Read-only hides every edit affordance */
body.read-only .edit-only { display: none !important; }

/* ========== SYNC INDICATOR ========== */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  padding: 6px 16px 0;
  max-width: 960px;
  margin: 0 auto;
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.4s, box-shadow 0.4s;
}
.sync-indicator.synced .sync-dot {
  background: #3fb950;
  box-shadow: 0 0 6px rgba(63,185,80,0.5);
}
.sync-indicator.error .sync-dot {
  background: #da3633;
  box-shadow: 0 0 6px rgba(218,54,51,0.4);
}
.sync-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 600;
}
.sync-indicator.synced .sync-label { color: #3fb950; }
.sync-indicator.error .sync-label { color: #da3633; }

/* ========== HEADER ========== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 960px;
  margin: 0 auto;
  gap: 12px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent);
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(124,111,247,0.35);
}
.logo-icon svg {
  width: 18px;
  height: 18px;
}
.logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.lang-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.admin-link {
  color: var(--text-muted);
  font-size: 1rem;
  text-decoration: none;
  transition: color 0.15s;
}
.admin-link:hover {
  color: var(--text-primary);
}
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--accent);
  color: #fff;
}

/* ========== TAB CONTENT ========== */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 20px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== MONTH NAV ========== */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}
.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.nav-btn:hover { border-color: var(--border-glow); color: var(--text-secondary); }
.month-label {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
  color: var(--text-primary);
}

/* ========== MONTH PROGRESS ========== */
.month-progress {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 24px 16px;
  margin-bottom: 18px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.month-progress.coin-1 {
  border-color: var(--gold-dim);
  box-shadow: 0 0 16px rgba(212,168,67,0.10);
}
.month-progress.coin-2 {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(212,168,67,0.22);
}
.month-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.month-progress-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.coin-icon {
  width: 18px;
  height: 18px;
  background: radial-gradient(circle at 38% 32%, var(--gold-bright), var(--gold), var(--gold-dim));
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  display: inline-block;
  box-shadow: 0 0 10px rgba(212,168,67,0.3);
}
.month-progress-coins {
  display: flex;
  gap: 6px;
}
.coin-slot {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
}
.coin-slot:not(.earned) .coin-icon {
  background: var(--bg-tertiary);
  border-color: var(--border);
  box-shadow: none;
  opacity: 0.45;
}
.month-progress-bar {
  position: relative;
  height: 28px;
  background: var(--bg-primary);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.month-progress-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 999px;
  transition: width 0.5s ease;
  box-shadow: 0 0 12px rgba(212,168,67,0.25);
}
.month-progress-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.month-progress-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.month-stat {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
.month-stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.month-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.month-stat.done { border-left: 3px solid #22c55e; }
.month-stat.skipped { border-left: 3px solid #f59e0b; }
.month-stat.vacation { border-left: 3px solid #14b8a6; }
.month-stat.unmarked { border-left: 3px solid var(--text-muted); }
.month-progress-rutilio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.month-progress-rutilio[data-mood="eat"] {
  border-color: var(--gold-dim);
  background: linear-gradient(90deg, rgba(212,168,67,0.08), transparent 60%);
}
.month-progress-rutilio[data-mood="feast"] {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(212,168,67,0.16), transparent 70%);
  box-shadow: inset 0 0 18px rgba(212,168,67,0.12);
}
.month-progress-rutilio-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 42px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.month-progress-rutilio-avatar svg { width: 100%; height: 100%; }
.month-progress-rutilio-quote {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
  font-style: italic;
}
.month-progress-rutilio-quote strong {
  color: #6bba62;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.month-progress-rutilio[data-mood="eat"] .month-progress-rutilio-quote strong,
.month-progress-rutilio[data-mood="feast"] .month-progress-rutilio-quote strong {
  color: var(--gold);
}
.donut-legend-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.month-progress-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 0 4px;
  font-style: italic;
}

/* ========== LEGEND ========== */
.calendar-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.legend-category-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  cursor: pointer;
  user-select: none;
  text-align: left;
}
.legend-category-header:hover .legend-category-chevron { opacity: 0.7; }
.legend-category-header:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 2px;
}
.legend-category-chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
  width: 10px;
}
.legend-category.collapsed .legend-category-chevron {
  transform: rotate(-90deg);
}
.legend-category-count {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
}
.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 4px 0 6px 16px;
}
.legend-category.collapsed .legend-items {
  display: none;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-label { font-weight: 500; }

/* ========== CALENDAR WEEKDAYS ========== */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 3px;
}
.weekday {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ========== CALENDAR GRID ========== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

/* ========== DAY CELL ========== */
.day-cell {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 95px;
  padding: 7px;
  position: relative;
  cursor: default;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
}
.day-cell:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-glow);
}
.day-cell.empty {
  background: var(--bg-primary);
  border-color: transparent;
  opacity: 0.3;
}
.day-cell.today {
  border-color: var(--gold-dim);
  box-shadow: inset 0 0 0 1px rgba(212,168,67,0.15);
}
.day-cell.has-vacation {
  background:
    repeating-linear-gradient(135deg,
      rgba(20,184,166,0.10) 0,
      rgba(20,184,166,0.10) 8px,
      rgba(20,184,166,0.22) 8px,
      rgba(20,184,166,0.22) 16px);
  border-color: rgba(20,184,166,0.55);
}
.day-cell.has-vacation::after {
  content: '🧳';
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 1.05rem;
  opacity: 0.95;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55));
}
.day-cell.has-vacation .day-check {
  opacity: 0.55;
}
.day-cell.vacation-preview {
  background-color: rgba(20,184,166,0.28);
  border-color: rgba(20,184,166,0.65);
}
.day-cell.vacation-preview-remove {
  background-color: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.6);
}
.day-cell.vacation-anchor {
  border-color: #14b8a6;
  box-shadow: 0 0 0 2px rgba(20,184,166,0.5), inset 0 0 0 1px rgba(20,184,166,0.35);
}
.day-cell.vacation-anchor.vacation-preview-remove {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239,68,68,0.5), inset 0 0 0 1px rgba(239,68,68,0.35);
}
.day-number {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 5px;
}
.day-cell.today .day-number { color: var(--gold); }

/* ========== DAY CHECKS ========== */
.day-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}
.day-check {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 2px solid var(--check-color, var(--border));
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text-secondary);
  padding: 0;
}
.day-check:hover { transform: scale(1.1); }
.day-check.done {
  background: var(--check-color);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

/* ========== ALL DAY ROUTINES TABLE ========== */
.allday-section {
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
/* Header: title left, day labels right */
.allday-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 14px 6px;
  gap: 8px;
}
.allday-header-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
  min-width: 0;
}
.allday-week-labels {
  display: flex;
  gap: 3px;
}
.allday-day-label {
  width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.allday-day-name {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.allday-day-num {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}
.allday-day-label.today .allday-day-name,
.allday-day-label.today .allday-day-num {
  color: var(--gold);
}
/* Routine rows */
.allday-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
}
.allday-row:hover { background: var(--bg-tertiary); }
.allday-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.allday-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.allday-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.allday-info-btn {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  font-style: italic;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: Georgia, serif;
}
.allday-info-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}
.allday-media-btn {
  font-style: normal;
  font-family: inherit;
  font-size: 0.55rem;
  padding-left: 1px;
}
.allday-media-btn:hover { color: #f87171; border-color: #f87171; }
.allday-popover.media-popover {
  min-width: 340px;
  max-width: 380px;
}
.media-popover-body {
  padding: 12px;
  max-height: 75vh;
}
.media-embed-yt {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #000;
}
.media-embed-ig {
  width: 100%;
  height: 540px;
  border-radius: var(--radius);
  background: #000;
}
.media-embed-link {
  display: block;
  word-break: break-all;
  font-size: 0.78rem;
  color: var(--accent-bright);
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}
.media-embed-link:hover { border-color: var(--accent); }
.media-embed-sep { height: 10px; }
/* 7-day week checks */
.allday-week-checks {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.allday-check {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 2px solid var(--check-color, var(--border));
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: #fff;
}
.allday-check.is-today {
  border-color: var(--gold-dim);
  box-shadow: inset 0 0 0 1px rgba(212,168,67,0.2);
}
.allday-check:hover { transform: scale(1.08); }
.allday-check.done { background: var(--check-color); }
.allday-check.skip {
  background: rgba(0, 0, 0, 0.25);
  border-color: var(--check-color, var(--border));
  border-style: dashed;
  font-size: 15px;
  color: inherit;
}
.allday-check.skip:hover { background: rgba(0, 0, 0, 0.35); }

/* Daily stats */
.daily-stats {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.daily-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.daily-stats-titles {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.stats-range-toggle {
  display: inline-flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.stats-range-toggle button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.stats-range-toggle button:hover { color: var(--text-primary); }
.stats-range-toggle button.active {
  background: var(--accent);
  color: #fff;
}
.stats-bar-row.no-data { opacity: 0.55; }
.stats-bar-row.no-data .stats-bar-pct { color: var(--text-muted); }
.daily-stats-month {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}
.daily-stats-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}
.daily-stats-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
}
.stats-block-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  margin-bottom: 10px;
}

.stats-bars { display: flex; flex-direction: column; gap: 6px; }
.stats-bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(80px, 2fr) 36px auto;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.stats-bar-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-bar-track {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.stats-bar-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-primary);
}
.stats-bar-tally {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--text-muted);
}
.stats-bar-tally .untagged { opacity: 0.6; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.donut::after {
  content: '';
  position: absolute;
  inset: 22%;
  background: var(--bg-secondary);
  border-radius: 50%;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.donut-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.donut-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.donut-legend { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; }
.donut-legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.donut-legend-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
}
.stats-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 16px 0;
}

@media (max-width: 760px) {
  .daily-stats-grid { grid-template-columns: 1fr; }
  .stats-bar-row { grid-template-columns: 1fr 36px; row-gap: 4px; }
  .stats-bar-track { grid-column: 1 / -1; }
  .stats-bar-tally { grid-column: 1 / -1; }
  .donut-wrap { justify-content: center; }
}

/* Skip-reason popover */
.skip-popover {
  position: absolute;
  z-index: 250;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
}
.skip-popover-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 8px 12px;
  text-align: left;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
}
.skip-popover-btn:hover { background: var(--bg-tertiary); }
.skip-popover-btn.active {
  background: var(--gold-dim, rgba(212,168,67,0.2));
  color: var(--text-primary);
}
.skip-popover-icon { font-size: 16px; min-width: 18px; text-align: center; }

/* Description popover */
.allday-popover {
  position: absolute;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  min-width: 240px;
  max-width: 360px;
  overflow: hidden;
}
.allday-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.allday-popover-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.allday-popover-close:hover { color: var(--text-primary); }
.allday-popover-body {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 280px;
  overflow-y: auto;
}
.allday-popover-body table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 4px 0;
  font-size: 11px;
  background: transparent !important;
}
.allday-popover-body th,
.allday-popover-body td {
  border: 1px solid var(--border) !important;
  padding: 3px 6px !important;
  background: transparent !important;
  color: var(--text-secondary) !important;
}
.allday-popover-body th {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
}
.allday-popover-body ul,
.allday-popover-body ol { padding-left: 16px; margin: 3px 0; }
.allday-popover-body p { margin: 3px 0; }

/* ========== ROUTINES TAB ========== */
.routines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.routines-header h2 {
  font-size: 18px;
  font-weight: 700;
}
.btn-add {
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-add:hover { background: var(--accent-bright); }

/* ========== ROUTINE CARDS ========== */
.routines-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.routine-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.routine-card:hover { background: var(--bg-tertiary); border-color: var(--border-glow); }
.routine-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.routine-info { flex: 1; min-width: 0; }
.routine-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.routine-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
}
.routine-desc:empty { display: none; }
/* Rich content inside routine cards — !important overrides Notion inline styles */
.routine-desc table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 4px 0;
  font-size: 11px;
  background: transparent !important;
}
.routine-desc th,
.routine-desc td {
  border: 1px solid var(--border) !important;
  padding: 3px 6px !important;
  text-align: left;
  background: transparent !important;
  color: var(--text-secondary) !important;
}
.routine-desc th {
  background: var(--bg-tertiary) !important;
  font-weight: 600;
  color: var(--text-primary) !important;
}
.routine-desc ul,
.routine-desc ol {
  padding-left: 16px;
  margin: 2px 0;
}
.routine-desc p { margin: 2px 0; }
.routine-days {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.routine-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.routine-time-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.routine-freq {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-bright);
  background: rgba(124, 111, 247, 0.15);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.routine-category {
  margin-top: 18px;
}
.routine-category:first-of-type { margin-top: 0; }
.routine-category-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
  padding-left: 0;
  padding-right: 0;
}
.routine-category-header:hover .routine-category-chevron { opacity: 0.7; }
.routine-category-header:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}
.routine-category-chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
  transform-origin: center;
  width: 10px;
}
.routine-category.collapsed .routine-category-chevron {
  transform: rotate(-90deg);
}
.routine-category.collapsed .routine-category-items {
  display: none;
}
.routine-category-count {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 10px;
}
.routine-category-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.routines-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.routines-empty p { font-size: 14px; margin-top: 8px; }
.routines-empty .empty-icon { font-size: 32px; }

/* ========== LAB CASA ========== */
.labcasa-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.labcasa-search {
  margin-bottom: 16px;
}
.labcasa-search input[type="search"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.labcasa-search input[type="search"]::placeholder {
  color: var(--text-muted);
}
.labcasa-search input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,111,247,0.18);
}
.labcasa-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.labcasa-category {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.labcasa-category-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-bright);
  cursor: pointer;
  user-select: none;
  text-align: left;
}
.labcasa-category-header:hover .labcasa-category-chevron { opacity: 0.7; }
.labcasa-category-header:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 2px;
}
.labcasa-category-chevron {
  display: inline-block;
  font-size: 11px;
  transition: transform 0.15s ease;
  width: 12px;
}
.labcasa-category.collapsed .labcasa-category-chevron {
  transform: rotate(-90deg);
}
.labcasa-category-count {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}
.labcasa-category.collapsed .recipe-grid,
.labcasa-category.collapsed .ritual-grid {
  display: none;
}
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.recipe-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: 4px solid;
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.recipe-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-glow);
  border-top-color: inherit;
}
.recipe-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.recipe-card-icon {
  font-size: 1.1rem;
}
.recipe-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.recipe-card-ingredients {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 10px;
}
.recipe-card-footer {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ========== RITUALS ========== */
.rituals-section {
  margin-top: 32px;
}
.ritual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.ritual-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.ritual-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-glow);
}
.ritual-card-trigger {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.ritual-card-icons {
  font-size: 1rem;
  margin-bottom: 10px;
}
.ritual-card-action {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.ritual-card-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.ritual-card-note:empty { display: none; }

/* Ritual form textarea */
#ritual-form textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
#ritual-form textarea:focus { border-color: var(--accent); }
#ritual-form label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
#ritual-form label:first-of-type { margin-top: 0; }
#ritual-form input[type="text"] {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
#ritual-form input:focus { border-color: var(--accent); }

/* Recipe form textarea */
#recipe-form textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
#recipe-form textarea:focus { border-color: var(--accent); }
#recipe-form label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
#recipe-form label:first-of-type { margin-top: 0; }
#recipe-form input[type="text"] {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
#recipe-form input:focus { border-color: var(--accent); }

/* ========== MODAL ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--accent-bright);
}

/* ========== FORM ========== */
#routine-form label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
#routine-form label:first-of-type { margin-top: 0; }
#routine-form input[type="text"],
.rich-editor {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
#routine-form input:focus,
.rich-editor:focus { border-color: var(--accent); }

/* Rich text editor */
.rich-editor {
  min-height: 80px;
  max-height: 240px;
  overflow-y: auto;
  line-height: 1.5;
  cursor: text;
}
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.rich-editor table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 6px 0;
  font-size: 0.8rem;
  background: transparent !important;
}
.rich-editor th,
.rich-editor td {
  border: 1px solid var(--border) !important;
  padding: 4px 8px !important;
  text-align: left;
  background: transparent !important;
  color: var(--text-primary) !important;
}
.rich-editor th {
  background: var(--bg-hover) !important;
  font-weight: 600;
  color: var(--text-primary) !important;
}
.rich-editor ul,
.rich-editor ol {
  padding-left: 18px;
  margin: 4px 0;
}
.rich-editor p { margin: 4px 0; }

/* ========== DAY PICKER ========== */
.day-picker {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.day-btn {
  flex: 1;
  padding: 8px 2px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.day-btn:hover { border-color: var(--accent); color: var(--text-secondary); }
.day-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* ========== TIME OF DAY PICKER ========== */
.time-picker {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.time-btn {
  flex: 1;
  padding: 8px 2px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.time-btn:hover { border-color: var(--accent); color: var(--text-secondary); }
.time-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* ========== FREQUENCY PICKER ========== */
.freq-picker {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.freq-btn {
  flex: 1;
  padding: 8px 2px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.freq-btn:hover { border-color: var(--accent); color: var(--text-secondary); }
.freq-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* ========== COLOR PICKER ========== */
.color-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* ========== ICON PICKER ========== */
.icon-picker {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.icon-option {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.icon-option:hover { border-color: var(--accent); transform: scale(1.1); }
.icon-option.selected { border-color: var(--accent); background: var(--bg-hover); box-shadow: 0 0 8px rgba(124,111,247,0.2); }

/* ========== MODAL ACTIONS ========== */
.modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  gap: 10px;
}
.btn-save {
  background: #238636;
  color: #fff;
  border: none;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-left: auto;
  transition: all 0.15s;
}
.btn-save:hover { filter: brightness(1.1); }
.btn-delete {
  background: var(--bg-tertiary);
  color: #da3633;
  border: 1px solid #3a2020;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-delete:hover { background: #2a1515; }

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
  main { padding: 0 8px 12px; }
  .day-cell { min-height: 72px; padding: 5px; }
  .day-check { width: 20px; height: 20px; font-size: 9px; }
  .day-check.done { font-size: 10px; }
  .day-number { font-size: 0.6rem; }
  .routine-desc { display: none; }
  .routine-days { display: none; }
  .modal { padding: 20px; }
  .month-progress { padding: 14px 16px 12px; }
  .month-progress-stats { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .month-stat-num { font-size: 1.15rem; }
  .month-progress-rutilio { padding: 8px 10px; gap: 10px; }
  .month-progress-rutilio-avatar { width: 26px; height: 34px; }
  .month-progress-rutilio-quote { font-size: 0.72rem; }
  .day-btn { font-size: 0.6rem; padding: 6px 1px; }
}
