/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --bg:           #F5F4F0;
  --bg2:          #FFFFFF;
  --bg3:          #EFEDE7;
  --bg4:          #E4E1D8;
  --orange:       #E85D00;
  --orange2:      #FF7A20;
  --orange-light: #FFF2E8;
  --orange-border:#FFCFA8;
  --text:         #111111;
  --text2:        #444444;
  --text3:        #9E9B96;
  --border:       #E8E5DE;
  --border2:      #D4D0C7;
  --success:      #16A34A;
  --danger:       #DC2626;
  --warning:      #D97706;
  --radius:       18px;
  --radius-sm:    12px;
  --radius-xs:    8px;
  --font:         -apple-system, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  --nav-h:        64px;
  --topbar-h:     52px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}
input, textarea, select, button { font-family: var(--font); }
input, textarea { user-select: text; -webkit-user-select: text; cursor: text; }
button { cursor: pointer; border: none; background: none; }
input { outline: none; border: none; }
input[type="text"], input:not([type]), textarea { text-transform: uppercase; }
textarea { outline: none; resize: none; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  width: 100%;
  max-width: 430px;
  height: 100%;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: absolute;
  inset: 0;
  bottom: var(--nav-h);
}
.screen.active { display: flex; }

.screen-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 16px;
}
.screen-body::-webkit-scrollbar { display: none; }


/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(245,244,240,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.topbar-logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--orange);
}
.topbar-clock {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.topbar-clock-time {
  font-size: 13px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text2);
  line-height: 1;
  letter-spacing: 0.02em;
}
.topbar-clock-date {
  font-size: 10px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text3);
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.topbar-back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg3);
  font-size: 16px;
  color: var(--text2);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.topbar-back:active { transform: scale(0.88); background: var(--bg4); }
.topbar-action {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg3);
  font-size: 16px;
  color: var(--text2);
  transition: transform 0.12s, background 0.12s;
}
.topbar-action:active { transform: scale(0.88); background: var(--bg4); }

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
#nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: var(--nav-h);
  background: rgba(250,249,246,0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 200;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  transition: opacity 0.15s, background 0.15s, transform 0.12s;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.nav-item:active {
  background: rgba(232,93,0,0.06);
  transform: scale(0.93);
}
.nav-icon {
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), filter 0.2s;
}
.nav-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.1px;
  pointer-events: none;
  transition: color 0.15s;
}
.nav-item.active {
  background: rgba(232,93,0,0.07);
}
.nav-item.active .nav-label {
  color: var(--orange);
  font-weight: 700;
}
.nav-item.active .nav-icon {
  transform: scale(1.12);
  filter: drop-shadow(0 2px 6px rgba(232,93,0,0.4));
}
/* Orange dot indicator */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--orange);
}


/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, var(--orange2), var(--orange));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s, transform 0.12s, box-shadow 0.12s;
  letter-spacing: -0.2px;
  box-shadow: 0 4px 16px rgba(232,93,0,0.28);
}
.btn-primary:active { opacity: 0.9; transform: scale(0.97); box-shadow: 0 2px 6px rgba(232,93,0,0.18); }

.btn-secondary {
  width: 100%;
  height: 44px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s, transform 0.12s;
}
.btn-secondary:active { opacity: 0.8; transform: scale(0.97); }

.btn-danger {
  background: #FEE2E2;
  color: var(--danger);
  border-color: #FCA5A5;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.prog-bg {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--orange2), var(--orange));
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}
.prog-fill.danger { background: var(--danger); }

/* ============================================================
   STAT GRID
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.stat-box {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.stat-lbl {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
}

/* ============================================================
   MACRO BARS
   ============================================================ */
.macro-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.macro-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  width: 16px;
  flex-shrink: 0;
}
.macro-bg {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
}
.macro-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}
.macro-fill.p { background: #3B82F6; }
.macro-fill.k { background: #F59E0B; }
.macro-fill.y { background: #10B981; }
.macro-fill.over { background: var(--danger); }
.macro-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}
.macro-val.good  { color: var(--success); }
.macro-val.bad   { color: var(--danger); }

/* ============================================================
   LIST ITEMS
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  cursor: default;
}
.list-item:last-child { border-bottom: none; }

.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: background 0.12s, transform 0.1s;
  cursor: pointer;
  user-select: none;
}
.menu-item:active { background: var(--bg3); transform: scale(0.99); }
.menu-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.menu-item:last-child  { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.menu-item:only-child  { border-radius: var(--radius); }
.menu-icon { font-size: 20px; }
.menu-text { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); }
.menu-sub  { font-size: 11px; color: var(--text3); margin-top: 1px; }
.menu-arrow { color: var(--text3); font-size: 14px; font-weight: 300; }
.menu-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--orange-light);
  color: var(--orange);
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--orange-border);
}


/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111;
  color: #fff;
  padding: 11px 20px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: all 0.28s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
  cursor: default;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  letter-spacing: -0.1px;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}
#toast.toast-action {
  background: var(--orange);
  padding: 12px 20px;
  border-radius: 16px;
  white-space: normal;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(232,93,0,0.35);
}

/* ============================================================
   DIVIDER
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.section-gap { height: 10px; }
.card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: none; }

/* ============================================================
   CANVAS CHART
   ============================================================ */
canvas { display: block; }

/* ============================================================
   UTILITY
   ============================================================ */
.txt-orange { color: var(--orange); }
.txt-green  { color: var(--success); }
.txt-red    { color: var(--danger); }
.txt-gray   { color: var(--text3); }
.fw7 { font-weight: 700; }
.fw8 { font-weight: 800; }
.fs12 { font-size: 12px; }
.fs13 { font-size: 13px; }
.fs14 { font-size: 14px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

