:root {
  --bg-page: #f6faf9;
  --surface: #ffffff;
  --navy: #0f2942;
  --emerald: #10b981;
  --emerald-light: #d1fae5;
  --cyan: #06b6d4;
  --cyan-light: #cffafe;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --text-main: #0f2942;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 4px 12px rgba(15, 41, 66, 0.04);
  --shadow-md: 0 12px 30px rgba(15, 41, 66, 0.07);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

body {
  background: var(--bg-page);
  background-image: radial-gradient(circle at top right, rgba(6, 182, 212, 0.08), transparent 40%),
                    radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.08), transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
}

/* LAYOUT DESKTOP */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 265px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.brand-box {
  padding: 6px 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  text-align: center;
}

.brand-logo {
  max-width: 100%;
  height: auto;
  max-height: 68px;
  object-fit: contain;
  border-radius: 10px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.side-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.side-nav .nav-item i { font-size: 1.3rem; }
.side-nav .nav-item:hover { background: #f1f5f9; color: var(--navy); }
.side-nav .nav-item.active {
  background: linear-gradient(135deg, var(--emerald), var(--cyan));
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.device-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.device-pill strong { display: block; font-size: 0.82rem; color: var(--navy); }
.device-pill small { font-size: 0.75rem; color: var(--text-muted); }

/* MAIN AREA */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 15;
}

.mobile-brand { display: none; }
.header-title h1 { font-size: 1.35rem; font-weight: 800; color: var(--navy); }
.header-title p { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--emerald-light);
  color: #065f46;
  font-weight: 700;
  font-size: 0.82rem;
  border-radius: 99px;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.content-area {
  padding: 28px 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.spa-view { display: none; }
.spa-view.active { display: block; animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.kpi-card.emerald .kpi-icon { background: var(--emerald-light); color: #059669; }
.kpi-card.cyan .kpi-icon { background: var(--cyan-light); color: #0891b2; }
.kpi-card.amber .kpi-icon { background: var(--amber-light); color: #d97706; }
.kpi-card.navy .kpi-icon { background: #e2e8f0; color: var(--navy); }

.kpi-info span { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.kpi-info h2 { font-size: 1.65rem; font-weight: 800; margin-top: 4px; color: var(--navy); }

/* CHART & GLASS CARD */
.glass-card {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card-header, .section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h3, .section-head h3 { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.card-header p { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

.tag-pill {
  background: #f1f5f9;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 99px;
}

.chart-container { position: relative; height: 300px; width: 100%; }

/* LOG GALERI */
.log-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.log-item {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
}
.log-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.log-thumb { position: relative; height: 195px; background: #e2e8f0; }
.log-thumb img { width: 100%; height: 100%; object-fit: cover; }
.weight-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 41, 66, 0.85);
  backdrop-filter: blur(6px);
  color: #fff;
  padding: 6px 12px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.85rem;
}

.log-body { padding: 16px; }
.log-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.log-time { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

.badge { padding: 4px 10px; border-radius: 99px; font-size: 0.73rem; font-weight: 700; background: var(--amber-light); color: #b45309; }
.badge.done { background: var(--emerald-light); color: #047857; }
.log-visual { font-size: 0.92rem; font-weight: 600; color: var(--navy); line-height: 1.4; }
.log-note { font-size: 0.83rem; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }

/* PREDIKSI LEVEL 3 HERO */
.prediction-hero {
  background: linear-gradient(135deg, var(--navy) 0%, #0d4a5e 60%, #0f766e 100%);
  color: #ffffff;
  padding: 36px 32px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(15, 41, 66, 0.18);
}

.pred-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.pred-label { font-size: 1rem; opacity: 0.85; }
.prediction-hero h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 800; margin: 8px 0 22px; color: #5eead4; }

.pred-advice-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.pred-advice-box i { font-size: 1.6rem; color: #fde047; flex-shrink: 0; }
.pred-advice-box p { font-size: 0.96rem; line-height: 1.55; }

/* BOTTOM NAV (Default Hidden di Desktop) */
.bottom-nav { display: none; }

/* RESPONSIVE TABLET & MOBILE */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-brand { display: block; }
  .mobile-logo { height: 40px; width: auto; object-fit: contain; border-radius: 6px; }
  .header-title { display: none; }

  .topbar { padding: 12px 18px; }
  .content-area { padding: 18px 16px 95px; }
  .chart-container { height: 240px; }
  .prediction-hero { padding: 26px 20px; }

  .bottom-nav {
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    z-index: 30;
  }

  .bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 14px;
    border-radius: 10px;
  }
  .bottom-nav .nav-item i { font-size: 1.4rem; }
  .bottom-nav .nav-item.active { color: var(--emerald); background: var(--emerald-light); }
}