* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --text: #2d2a26;
  --muted: #8a8580;
  --accent: #e07a3a;
  --accent-hover: #c96a2e;
  --accent-light: #fff3ed;
  --border: #ebe8e4;
  --success: #4a9b6d;
  
  --potty: #fce4ec;
  --potty-border: #f8bbd9;
  --training: #fff3e0;
  --training-border: #ffcc80;
  --nap: #fffde7;
  --nap-border: #fff59d;
  --meal: #e8f5e9;
  --meal-border: #a5d6a7;
  --grooming: #e3f2fd;
  --grooming-border: #90caf9;
  --note: #f3e5f5;
  --note-border: #ce93d8;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  line-height: 1.4;
}

/* Desktop wrapper */
@media (min-width: 768px) {
  body {
    background: #e8e6e3;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
  }
  
  .app-wrapper {
    background: var(--bg);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    max-width: 480px;
    width: 100%;
    min-height: calc(100vh - 4rem);
  }
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.25rem;
  padding-bottom: 6rem;
}

/* Navigation */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0.5rem 1rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  z-index: 100;
}

@media (min-width: 768px) {
  .nav-bar {
    position: sticky;
    bottom: 0;
    border-radius: 0 0 24px 24px;
  }
}

.nav-btn {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 1rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.15s ease;
}

.nav-btn .icon {
  font-size: 1.375rem;
}

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-light);
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Header */
header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.logo-icon {
  font-size: 1.75rem;
}

.logo-icon i {
  color: var(--accent);
}

/* Font Awesome icon sizing */
.log-type-btn .icon i,
.vibe-btn .emoji i,
.pill-btn .emoji i {
  font-size: 1.5rem;
}

.vibe-btn .emoji i {
  font-size: 2rem;
}

.timeline-item .icon i {
  font-size: 1rem;
}

.vibe-grid-dash .emoji i {
  font-size: 1.5rem;
}

.tag i {
  font-size: 0.75rem;
}

.meta i {
  font-size: 0.875rem;
}

/* Vibe colors */
.fa-circle-check { color: #4a9b6d; }
.fa-face-meh { color: #f59e0b; }
.fa-circle-xmark { color: #ef4444; }

/* Activity colors */
.fa-poop { color: #8d6e63; }
.fa-drumstick-bite { color: #e07a3a; }
.fa-moon { color: #7c3aed; }
.fa-bullseye { color: #ef4444; }
.fa-wand-magic-sparkles { color: #06b6d4; }
.fa-note-sticky { color: #8b5cf6; }
.fa-droplet { color: #3b82f6; }
.fa-bone { color: #a3a3a3; }

header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.card-label .required {
  color: var(--accent);
  font-size: 0.75rem;
}

/* Log Type Grid */
.log-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.log-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 0.5rem;
  position: relative;
}

.log-type-btn:active {
  transform: scale(0.95);
}

.log-type-btn .icon {
  font-size: 1.5rem;
  line-height: 1;
}

.log-type-btn .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

/* Selected states with checkmark */
.log-type-btn[data-value="potty"].selected { background: var(--potty); border-color: var(--potty-border); }
.log-type-btn[data-value="training"].selected { background: var(--training); border-color: var(--training-border); }
.log-type-btn[data-value="nap"].selected { background: var(--nap); border-color: var(--nap-border); }
.log-type-btn[data-value="meal"].selected { background: var(--meal); border-color: var(--meal-border); }
.log-type-btn[data-value="grooming"].selected { background: var(--grooming); border-color: var(--grooming-border); }
.log-type-btn[data-value="note"].selected { background: var(--note); border-color: var(--note-border); }

.log-type-btn.selected::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pee/Poop Section */
.sub-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  display: none;
}

.sub-section.show {
  display: block;
}

.sub-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.625rem;
}

/* Pill Buttons */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.pill-btn {
  padding: 0.75rem 1.125rem;
  border: 2px solid var(--border);
  border-radius: 100px;
  background: var(--card);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text);
}

.pill-btn:active {
  transform: scale(0.96);
}

.pill-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.pill-btn .emoji {
  font-size: 1rem;
}

/* Vibe Grid */
.vibe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.vibe-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.875rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 0.375rem;
}

.vibe-btn:active {
  transform: scale(0.95);
}

.vibe-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
}

.vibe-btn.selected .label {
  color: white;
}

.vibe-btn .emoji {
  font-size: 1.375rem;
}

.vibe-btn .label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: capitalize;
}

/* Time & Date Row */
.time-date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.text-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
}

/* Notes */
.notes-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  resize: none;
  min-height: 80px;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.notes-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
}

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

/* Caregiver */
.caregiver-row {
  display: flex;
  gap: 0.625rem;
}

.caregiver-btn {
  flex: 1;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
}

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

.caregiver-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

/* Submit */
.submit-btn {
  width: 100%;
  padding: 1.125rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 0.75rem;
  box-shadow: 0 4px 12px rgba(224, 122, 58, 0.3);
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Success State */
.success-screen {
  display: none;
  text-align: center;
  padding: 4rem 1rem;
}

.success-screen.show {
  display: block;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--success) 0%, #3d8b5e 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 2.5rem;
  box-shadow: 0 8px 24px rgba(74, 155, 109, 0.3);
  color: white;
}

.success-screen h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.success-screen p {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.success-screen button {
  padding: 1rem 2rem;
  background: var(--text);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.success-screen button:active {
  transform: scale(0.97);
}

.form-content.hidden {
  display: none;
}

/* Setup Banner */
.setup-banner {
  background: #fffbeb;
  border: 2px solid #fcd34d;
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.setup-banner strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #92400e;
}

.setup-banner code {
  background: rgba(0,0,0,0.08);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* ==================== DASHBOARD STYLES ==================== */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.dashboard-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.refresh-btn {
  padding: 0.5rem 0.875rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

/* Date Filter */
.date-filter {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.date-inputs {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  margin-left: auto;
}

.date-input {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.75rem;
  width: 115px;
}

.entry-count {
  width: 100%;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem;
}

.stat-card .label {
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-card .value {
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-card .sub {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

/* Charts */
.chart-card {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.chart-card h3 {
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
  color: var(--text);
}

/* Activity Bars */
.activity-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.activity-bar .label {
  font-size: 0.75rem;
  font-weight: 600;
  width: 65px;
  text-transform: capitalize;
}

.activity-bar .bar-bg {
  flex: 1;
  height: 10px;
  background: #f0f0f0;
  border-radius: 5px;
  overflow: hidden;
}

.activity-bar .bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.activity-bar .count {
  font-size: 0.75rem;
  font-weight: 700;
  width: 24px;
  text-align: right;
}

.bar-potty { background: #ef9a9a; }
.bar-training { background: #ffcc80; }
.bar-nap { background: #fff59d; }
.bar-meal { background: #a5d6a7; }
.bar-grooming { background: #81d4fa; }
.bar-note { background: #ce93d8; }

/* Vibe Grid Dashboard */
.vibe-grid-dash {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.vibe-item {
  text-align: center;
  padding: 0.5rem;
  background: #f8f8f8;
  border-radius: 8px;
}

.vibe-item .emoji { font-size: 1.125rem; }
.vibe-item .count { font-size: 0.875rem; font-weight: 700; margin-top: 0.125rem; }
.vibe-item .label { font-size: 0.625rem; color: var(--muted); }

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.timeline-item {
  display: flex;
  gap: 0.625rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid #f0f0f0;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-item .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.icon-potty { background: var(--potty); }
.icon-training { background: var(--training); }
.icon-nap { background: var(--nap); }
.icon-meal { background: var(--meal); }
.icon-grooming { background: var(--grooming); }
.icon-note { background: var(--note); }

.timeline-item .content { flex: 1; min-width: 0; }

.timeline-item .top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.timeline-item .activity-name {
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: capitalize;
}

.timeline-item .datetime {
  font-size: 0.6875rem;
  color: var(--muted);
  white-space: nowrap;
}

.timeline-item .meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.timeline-item .notes {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  font-style: italic;
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  margin-right: 0.25rem;
}

.tag-pee { background: #ffecb3; }
.tag-poop { background: #d7ccc8; }
.tag-treat { background: #c8e6c9; }

.loading, .empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid #ddd;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.375rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover:not(:disabled) {
  background: #f5f5f5;
}

.page-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.5rem;
}

.entries-card {
  scroll-margin-top: 1rem;
}

.load-more-btn {
  width: 100%;
  padding: 0.75rem;
  margin-top: 1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.load-more-btn:hover {
  background: #f5f5f5;
  color: var(--text);
}
