/* WeightTrack — «предрассветная шкала»: тёмно-синий утренний фон, округлые цифры весов, зоны как сигнал, а не декор. */
:root{
  color-scheme:dark;
  --bg:#0f1725;--surface:#162133;--surface-2:#1d2b41;--line:#26364d;
  --ink:#eaf0f7;--muted:#8b9bb2;--accent:#7fd8e6;
  --green:#5ed3a0;--yellow:#f0c15c;--red:#f2777a;--missing:#26364d;
  --num:ui-rounded,"SF Pro Rounded",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:16px;line-height:1.45;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);-webkit-font-smoothing:antialiased}
button,input,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Шапка */
.top{display:flex;justify-content:space-between;align-items:center;gap:16px}
.brand{display:flex;align-items:center;gap:10px;font-weight:650;font-size:17px;letter-spacing:-.01em}
.brand img{width:30px;height:30px;border-radius:8px}
.top-actions,.conflict-actions{display:flex;gap:8px;flex-wrap:wrap}
.eyebrow{color:var(--muted);font-size:15px}
.subtle{color:var(--muted)}

/* Кнопки */
.ghost{border:1px solid var(--line);background:transparent;color:var(--ink);border-radius:10px;padding:8px 14px;font-size:15px}
.ghost:hover{background:var(--surface)}
.primary{border:0;border-radius:12px;background:var(--accent);color:#08222a;padding:12px 20px;font-weight:650}
.primary:hover{filter:brightness(1.08)}
.top button:disabled,.conflict-actions button:disabled{opacity:.5;cursor:wait}

/* Разделы: сегментированный переключатель */
.tabs{display:flex;gap:2px;padding:3px;margin:0;background:var(--surface);border-radius:12px}
.tab{flex:1;border:0;background:transparent;color:var(--muted);border-radius:9px;padding:8px 18px;font-weight:550}
.tab.active{background:var(--surface-2);color:var(--ink)}
.toolbar{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;margin:0 0 16px}
.toolbar h2,.month-head h2{margin:0;font-size:22px;font-weight:650;letter-spacing:-.015em}
.periods{display:flex;gap:2px;flex-wrap:wrap}
.period{border:0;background:transparent;color:var(--muted);border-radius:8px;padding:6px 10px;font-size:14px;font-weight:550}
.period.active{background:var(--surface-2);color:var(--ink)}

/* Поверхности */
.card{background:var(--surface);border-radius:18px;padding:24px}

/* Статистика графика: строка цифр без карточек */
.stats{display:flex;gap:40px;margin:0 0 16px}
.stat span{display:block;color:var(--muted);font-size:14px}
.stat strong{display:block;margin-top:2px;font-family:var(--num);font-size:28px;font-weight:600;font-variant-numeric:tabular-nums}
.stat-value.green{color:var(--green)}.stat-value.yellow{color:var(--yellow)}.stat-value.red{color:var(--red)}

/* График */
.chart-card{padding:18px 14px 12px}
.chart{width:100%;height:auto;display:block}
.chart-label{fill:var(--muted);font-size:12px;font-variant-numeric:tabular-nums}
.chart-point{fill:transparent;cursor:crosshair}
.chart-point:hover{fill:var(--ink);stroke:var(--bg);stroke-width:2}
.chart-point.visible.green{fill:var(--green)}.chart-point.visible.yellow{fill:var(--yellow)}.chart-point.visible.red{fill:var(--red)}
.legend{display:flex;align-items:center;gap:18px;flex-wrap:wrap;margin:10px 8px 2px;color:var(--muted);font-size:13px}
.swatch{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px;vertical-align:-1px}
.swatch.green{background:var(--green)}.swatch.yellow{background:var(--yellow)}.swatch.red{background:var(--red)}

/* Календарь */
.month-head{display:flex;justify-content:space-between;align-items:center;margin:0 0 14px}
.month-head button{border:0;background:var(--surface);color:var(--ink);border-radius:10px;width:40px;height:40px;font-size:20px}
.calendar{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.weekday{text-align:center;color:var(--muted);font-size:13px;padding:4px 0 8px}
.day{min-height:84px;padding:8px 9px;background:var(--surface);border:0;border-radius:10px;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-start;gap:4px;color:var(--muted);text-align:left;font-size:13px}
.day:hover{background:var(--surface-2)}
.day.empty{background:transparent;pointer-events:none}
.day.today{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--ink)}
.badge{display:inline-block;font-family:var(--num);font-size:17px;font-weight:600;font-variant-numeric:tabular-nums;line-height:1.1}
.badge.green{color:var(--green)}.badge.yellow{color:var(--yellow)}.badge.red{color:var(--red)}
.day .badge::before{content:"";display:block;width:16px;height:3px;border-radius:2px;background:currentColor;margin-bottom:5px}
.mini-count{color:var(--muted);font-size:11px}

/* Таблица */
.list-card{padding:4px 20px}
.row{display:grid;grid-template-columns:170px 90px 1fr auto;gap:16px;align-items:center;padding:12px 0;border-bottom:1px solid var(--line)}
.row:last-child{border:0}
.row .badge{width:max-content}
.row .comment{color:var(--muted);overflow-wrap:anywhere}
.row button{border:0;background:transparent;color:var(--accent);padding:6px}

/* Диалог, вход, уведомления */
.dialog-backdrop{position:fixed;inset:0;background:rgba(5,9,16,.78);display:grid;place-items:center;padding:20px;z-index:5}
.dialog{width:min(100%,420px);background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:24px}
.dialog h2{margin:0 0 16px;font-size:21px;font-weight:650}
.field{display:block;margin:12px 0;color:var(--muted);font-size:14px}
.field input,.field textarea{font-size:16px;display:block;width:100%;margin-top:6px;background:var(--bg);border:1px solid var(--line);color:var(--ink);border-radius:10px;padding:11px 12px}
.field input[name="weight"]{font-family:var(--num);font-size:28px;font-weight:600;padding:8px 12px}
.field textarea{min-height:80px;resize:vertical}
.dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}
.danger{color:var(--red)!important;margin-right:auto}
.error{color:#ff9d9d;min-height:19px;font-size:14px}
.login-wrap{min-height:100vh;display:grid;place-items:center;padding:20px}
.login{width:min(100%,400px)}
.login .brand{margin-bottom:28px}
.login h1{font-size:30px;font-weight:650;letter-spacing:-.02em;margin:4px 0 8px}
.login .primary{width:100%;margin-top:10px}
.empty-note{text-align:center;color:var(--muted);padding:60px 15px}
.toast{position:fixed;right:20px;bottom:max(20px,env(safe-area-inset-bottom));background:var(--surface-2);color:var(--ink);border-left:3px solid var(--green);border-radius:10px;padding:12px 16px;z-index:6;max-width:360px}
.sync-conflicts{margin-top:18px;box-shadow:inset 0 0 0 1px var(--yellow)}
.sync-conflicts h2{margin:0 0 8px}
.sync-conflict{border-top:1px solid var(--line);padding:15px 0;display:grid;gap:9px}
.conflict-actions{margin-top:4px}

@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}

/* Один экран: шапка, цель, вкладки, контент и кнопка внизу без прокрутки страницы */
html,body{height:100%;overflow:hidden;overscroll-behavior:none;touch-action:pan-y;-webkit-text-size-adjust:100%}
.shell{height:100dvh;max-width:760px;margin:auto;display:flex;flex-direction:column;gap:14px;padding:max(14px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left))}
.shell>*{flex:none}
#content{flex:1;min-height:0;display:flex;flex-direction:column}
.bottom-bar .primary{width:100%;padding:15px;font-size:17px;border-radius:14px}

/* Цель и серия — единственный акцентный блок; серия всегда справа от цели */
.hero-main{padding-bottom:14px;border-bottom:1px solid var(--line)}
.goal-summary{display:flex;align-items:flex-end;gap:22px}
.now-value.green{color:var(--green)}.now-value.yellow{color:var(--yellow)}.now-value.red{color:var(--red)}
.now-value .goal-caption{color:var(--muted)}
.goal-summary .streak{margin-left:auto}
.goal-value,.now-value{font-family:var(--num);font-size:clamp(36px,10.5vw,59px);font-weight:600;line-height:.9;letter-spacing:-.03em;font-variant-numeric:tabular-nums;margin:0;white-space:nowrap}
.goal-value small,.now-value small{font-size:.3em;font-weight:500;color:var(--muted);margin-left:.15em;letter-spacing:0}
.goal-caption{display:block;font-family:-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;font-weight:500;letter-spacing:0;color:var(--muted);margin-bottom:8px;line-height:1}
.streak{display:grid;gap:8px;justify-items:end;text-align:right;padding-bottom:2px}
.streak strong{font-family:var(--num);font-size:16px;font-weight:600;line-height:1.25;color:var(--green);max-width:11ch;text-wrap:balance}
.ticks{display:flex;gap:3px;margin-top:12px}.ticks .tick{flex:1}
.tick{display:block;width:8px;height:18px;border-radius:2px;background:var(--missing)}
.tick.green{background:var(--green)}.tick.yellow{background:var(--yellow)}.tick.red{background:var(--red)}
.tick:last-child{outline:1px solid var(--ink);outline-offset:1.5px}

/* Календарь растягивается на свободную высоту */
.month-head{margin:0 0 8px}
.month-head h2{font-size:19px}
.month-head button{width:36px;height:36px}
.calendar{flex:1;min-height:0;grid-template-rows:auto;grid-auto-rows:minmax(0,1fr);gap:3px}
.weekday{padding:0 0 4px;font-size:12px}
.day{min-height:0;padding:5px 6px;font-size:12px;border-radius:8px}
.badge{font-size:15px}
.day .badge::before{width:12px;margin-bottom:3px}

/* Таблица прокручивается внутри своей области */
.view-table .toolbar{margin-bottom:8px}
.list-card{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:2px 16px}
.view-table>p{margin:8px 0 0}
.row{grid-template-columns:auto 56px 1fr auto;gap:12px;padding:10px 0;font-size:14px}

/* График */
.view-chart .toolbar{margin-bottom:10px}
.toolbar h2{font-size:19px}
.stats{gap:28px;margin-bottom:10px}.stat strong{font-size:22px}
.chart-card{flex:1;min-height:0;display:flex;flex-direction:column;justify-content:space-between;padding:10px 8px 8px}
.chart{min-height:0;max-height:100%}

@media(max-width:420px){
  .view-chart .toolbar h2{display:none}
  .periods{width:100%;justify-content:space-between}
  .period{padding:6px 8px;font-size:13px}
  .row .comment{display:none}
  .row{grid-template-columns:1fr 56px auto}
}
@media(max-height:700px){.goal-caption{display:none}.goal-value,.now-value{font-size:34px}.shell{gap:10px}}

/* Альбомная ориентация телефона: только график */
@media(orientation:landscape) and (max-height:520px){
  .shell{max-width:none;padding-top:max(8px,env(safe-area-inset-top));padding-bottom:max(8px,env(safe-area-inset-bottom))}
  .top,.hero,.tabs,.bottom-bar,.sync-conflicts,.view-chart .toolbar,.view-chart .stats{display:none}
  .chart-card{background:transparent;padding:0}
  .legend{display:none}
}
