:root {
  color-scheme: dark;
  --bg: #0b1117;
  --bg-soft: #101823;
  --panel: #121b26;
  --panel-strong: #172231;
  --line: #243346;
  --text: #f5f6f9;
  --muted: #a7b3c6;
  --accent: #f7b64d;
  --accent-2: #5fd0ff;
  --success: #5ce1a2;
  --danger: #f96f6f;
  --shadow: 0 20px 60px rgba(7, 11, 18, 0.45);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  background: radial-gradient(circle at 15% 20%, rgba(95, 208, 255, 0.18), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(247, 182, 77, 0.2), transparent 45%),
    linear-gradient(160deg, #0b1117 0%, #0d141f 40%, #0c111a 100%);
  color: var(--text);
}

.bg-glow {
  position: fixed;
  inset: -20% -20% auto auto;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(95, 208, 255, 0.12), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  z-index: 1;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 32px 24px;
  background: linear-gradient(180deg, rgba(18, 27, 38, 0.96), rgba(12, 18, 27, 0.9));
  border-right: 1px solid rgba(36, 51, 70, 0.8);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand .logo {
  font-family: "Fraunces", serif;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link,
.nav-logout {
  text-decoration: none;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid transparent;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-link:hover,
.nav-logout:hover {
  background: rgba(95, 208, 255, 0.08);
  border-color: rgba(95, 208, 255, 0.2);
}

.nav-link.active {
  background: rgba(247, 182, 77, 0.15);
  border-color: rgba(247, 182, 77, 0.4);
  box-shadow: 0 0 0 1px rgba(247, 182, 77, 0.3) inset;
}

.nav-logout {
  margin-top: 16px;
  background: rgba(249, 111, 111, 0.1);
  border-color: rgba(249, 111, 111, 0.4);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.main {
  padding: 24px 32px 60px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 20px;
  background: linear-gradient(180deg, rgba(11, 17, 23, 0.95), rgba(11, 17, 23, 0));
  backdrop-filter: blur(12px);
}

.topbar-title {
  font-family: "Fraunces", serif;
  font-size: 24px;
  letter-spacing: 0.4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(36, 51, 70, 0.6);
  background: rgba(18, 27, 38, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}

.icon-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
}

.icon-btn span + span {
  margin-top: 4px;
}

#openDrawer {
  display: none;
}

.pill {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}

.pill.outline {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(247, 182, 77, 0.5);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-weight: 600;
  cursor: pointer;
}

.view {
  display: none;
  animation: fadeIn 0.4s ease;
}

.view.is-active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.2fr) minmax(240px, 1fr);
  gap: 24px;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 24px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: linear-gradient(180deg, rgba(18, 27, 38, 0.98), rgba(16, 22, 32, 0.94));
  border-radius: var(--radius);
  border: 1px solid rgba(36, 51, 70, 0.8);
  padding: 22px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.6s ease forwards;
  animation-delay: var(--delay, 0s);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card h2,
.card h3 {
  margin: 0 0 4px;
  font-family: "Fraunces", serif;
}

.card h2 {
  font-size: 26px;
}

.card h3 {
  font-size: 20px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
}

.progress {
  margin-top: 8px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width 0.4s ease;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 16px;
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(12, 17, 25, 0.6);
  border: 1px solid rgba(36, 51, 70, 0.6);
}

.list-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.list-meta {
  font-size: 12px;
  color: var(--muted);
}

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(95, 208, 255, 0.15);
  color: var(--accent-2);
  font-weight: 600;
  white-space: nowrap;
}

.badge.workout {
  background: rgba(92, 225, 162, 0.15);
  color: var(--success);
}

.badge.food {
  background: rgba(247, 182, 77, 0.16);
  color: var(--accent);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  background: rgba(10, 14, 20, 0.7);
  border: 1px solid rgba(36, 51, 70, 0.8);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.field textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-add {
  border: 1px solid rgba(247, 182, 77, 0.4);
}

.file-input input {
  display: none;
}

.file-cta {
  border: 1px dashed rgba(95, 208, 255, 0.6);
  padding: 10px 12px;
  border-radius: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--accent-2);
}

.barcode-preview {
  display: none;
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(36, 51, 70, 0.8);
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 46px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-strong);
  border: 1px solid rgba(36, 51, 70, 0.8);
  border-radius: 14px;
  padding: 12px;
  min-width: 160px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.menu-panel button {
  background: transparent;
  border: 1px solid rgba(95, 208, 255, 0.2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
}

.profile-summary {
  display: grid;
  gap: 14px;
}

.profile-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(36, 51, 70, 0.8);
  background: rgba(10, 14, 20, 0.6);
}

.mobile-drawer,
.drawer-backdrop {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 1200px) {
  .dashboard-grid,
  .page-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 20px 20px 60px;
  }

  .topbar {
    padding-top: 10px;
  }

  #openDrawer {
    display: flex;
  }

  .mobile-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(78vw, 320px);
    background: rgba(15, 21, 31, 0.98);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 20;
  }

  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 12, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 15;
  }

  body.drawer-open .mobile-drawer {
    transform: translateX(0);
  }

  body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 720px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-title {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .view {
    animation: none;
  }
}
