*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0d14;
  --bg2:      #13131f;
  --bg3:      #1a1a2e;
  --border:   #1f1f35;
  --text:     #e2e2f0;
  --muted:    #6b6b8a;
  --accent:   #6366f1;
  --font:     'DM Sans', sans-serif;
  --mono:     'DM Mono', monospace;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* ── LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.brand-icon {
  color: var(--accent);
  font-size: 0.8rem;
}

.sidenav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent)22; color: var(--accent); font-weight: 500; }

.nav-icon { font-size: 0.7rem; }

.sidebar-date {
  padding: 1rem 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
}

.date-day {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.date-full {
  font-size: 0.8rem;
  color: var(--text);
  margin-top: 0.2rem;
}

/* ── MAIN ── */
.main {
  padding: 2.5rem 3rem;
  overflow-y: auto;
}

.view { display: none; }
.view.active { display: block; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-header .sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.2rem;
}

.streak-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  text-align: center;
  min-width: 80px;
}

.streak-badge span {
  display: block;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--mono);
  line-height: 1;
}

.streak-badge small {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.progress-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-bar-wrap span {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}

/* ── CATEGORIES ── */
.categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}

.category-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.cat-icon { font-size: 1.1rem; }

.cat-title {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: 1;
}

.cat-count {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── HABIT ROWS ── */
.habit-list { padding: 0.5rem 0; }

.habit-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}

.habit-row:hover { background: var(--bg3); }

.habit-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  color: transparent;
}

.habit-check svg {
  width: 12px;
  height: 12px;
}

.habit-row.checked .habit-check {
  background: var(--cat-color, var(--accent));
  border-color: var(--cat-color, var(--accent));
  color: #fff;
}

.habit-info {
  display: flex;
  flex-direction: column;
}

.habit-label {
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}

.habit-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.habit-row.checked .habit-label {
  color: var(--muted);
  text-decoration: line-through;
}

/* ── CHARTS ── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto auto;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.chart-card.wide {
  grid-column: 1 / -1;
}

.chart-card h3 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* ── HEATMAP ── */
.heatmap-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.heatmap-section h3 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 4px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: default;
  transition: transform 0.1s;
}

.heatmap-cell:hover { transform: scale(1.3); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 1rem 1.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidenav { flex-direction: row; flex: unset; gap: 0.5rem; }
  .sidebar-date { display: none; }
  .brand { padding-bottom: 0; margin-right: 1rem; }

  .main { padding: 1.5rem; }

  .charts-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: unset; }

  .heatmap-grid { grid-template-columns: repeat(15, 1fr); }
}
