:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --card: var(--tg-theme-secondary-bg-color, #1f2b38);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #8b9aa8);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --green: #3ddc84;
  --red: #ff5c5c;
  --warn: #f5b83d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

#view {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
}

h2 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.muted { color: var(--hint); }
.big { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.line { margin: 4px 0; font-size: 16px; }
.line b { font-weight: 650; }
.small { font-size: 13px; color: var(--hint); }

.segs { display: flex; gap: 8px; margin: 12px 0 10px; }
.segs i {
  display: block;
  flex: 1;
  height: 28px;
  border-radius: 8px;
  background: rgba(139, 154, 168, .22);
}
.segs i.on { background: var(--green); }
.segs i.cur { background: var(--accent); opacity: .45; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { padding: 14px; }
.grid2 .big { font-size: 24px; }

button {
  font: inherit;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  padding: 14px 16px;
}
button.secondary { background: rgba(139, 154, 168, .16); color: var(--text); }
button.ghost { background: transparent; color: var(--hint); padding: 8px 10px; }
button:disabled { opacity: .5; }

.action-card { display: flex; gap: 12px; align-items: stretch; }
.action-main {
  flex: 1.15;
  min-height: 132px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  text-align: left;
}
.action-main .syringe { font-size: 34px; }
.action-site { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.site-name { font-size: 16px; font-weight: 600; }
.site-hint { font-size: 14px; color: var(--hint); margin-top: 2px; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid rgba(139, 154, 168, .14);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tab {
  flex: 1;
  background: transparent;
  color: var(--hint);
  border-radius: 10px;
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; }
.tab.active { color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; }
.chip {
  white-space: nowrap;
  background: rgba(139, 154, 168, .16);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 16px;
}
.chip.active { background: var(--accent); color: var(--accent-text); }

.month { color: var(--hint); font-size: 18px; margin: 10px 2px 4px; }
.event {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.event-head { display: flex; align-items: flex-start; gap: 12px; }
.event-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex: 0 0 auto;
}
.event-icon.shot { background: var(--accent); }
.event-icon.weight { background: #2f9e5f; }
.event-title { flex: 1; font-size: 20px; font-weight: 650; }
.event-when { color: var(--hint); font-size: 14px; white-space: nowrap; padding-top: 4px; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 600;
}
.pill.green { background: rgba(61, 220, 132, .2); color: var(--green); }
.pill.red { background: rgba(255, 92, 92, .2); color: var(--red); }
.pill.gray { background: rgba(139, 154, 168, .2); color: var(--hint); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.dot.good { background: var(--green); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--red); }

.stepper { display: flex; align-items: center; gap: 6px; background: rgba(139, 154, 168, .16); border-radius: 12px; padding: 4px; }
.stepper button { background: transparent; color: var(--text); font-size: 24px; padding: 4px 12px; }
.stepper span { min-width: 54px; text-align: center; font-size: 20px; font-weight: 650; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; }
.row + .row { border-top: 1px solid rgba(139, 154, 168, .14); }
.switch { width: 54px; height: 32px; border-radius: 16px; background: rgba(139, 154, 168, .3); position: relative; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 25px; }

.city-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.city {
  background: rgba(139, 154, 168, .16);
  color: var(--text);
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  text-align: left;
}
.city.active { border: 2px solid var(--accent); color: var(--accent); padding: 12px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; padding: 12px; z-index: 20; }
.modal.hidden, .hidden { display: none !important; }
.modal-card { width: 100%; max-width: 560px; background: var(--card); border-radius: 18px; padding: 16px; max-height: 86vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 18px; }

input {
  width: 100%;
  font: inherit;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid rgba(139, 154, 168, .35);
  background: var(--bg);
  color: var(--text);
  margin: 8px 0 12px;
}

.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 30; }

.spark { width: 100%; height: 60px; display: block; }
.chart { width: 100%; height: 170px; display: block; }

.body-svg { width: 92px; height: 132px; }
.zone { fill: rgba(139, 154, 168, .25); cursor: pointer; }
.zone.on { fill: var(--accent); }
.zone.rec { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; fill: rgba(46, 166, 255, .18); }
