/* Layout: phone-sized Telegram Mini App; bottom tabs, one main thing per screen, bottom sheets for editing. On desktop the app sits in a device frame. */
:root{
  --bg:#f3f4f6; --surface:#ffffff; --surface2:#eceef2; --line:#dde0e6;
  --fg:#15181e; --muted:#667085; --accent:#2b59d8; --accent-soft:#e4eafc; --on-accent:#fff;
  --good:#1c8a5a; --good-soft:#dcf3e7; --warn:#a96a00; --warn-soft:#fbefd2; --bad:#c23a30; --bad-soft:#fbe1de;
  --stage:#dfe2e8;
  --f-body:system-ui,-apple-system,'Segoe UI',Roboto,sans-serif; --f-data:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  /* Верхний отступ под кнопки Telegram («Закрыть», «⋯»), которые в режиме Fullsize рисуются поверх страницы.
     Размеры отдаёт сам Telegram; так же сделано в MyVK. */
  --app-top-inset:max(env(safe-area-inset-top,0px),calc(var(--tg-safe-area-inset-top,0px) + var(--tg-content-safe-area-inset-top,0px)));
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --bg:#12151b; --surface:#1a1e26; --surface2:#232833; --line:#2c323e;
  --fg:#eceff4; --muted:#98a2b3; --accent:#7c9cff; --accent-soft:#242e52; --on-accent:#0c1020;
  --good:#4cc790; --good-soft:#163527; --warn:#e8b04a; --warn-soft:#3a2d12; --bad:#ff8077; --bad-soft:#40201e; --stage:#0b0d11; color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#12151b; --surface:#1a1e26; --surface2:#232833; --line:#2c323e;
  --fg:#eceff4; --muted:#98a2b3; --accent:#7c9cff; --accent-soft:#242e52; --on-accent:#0c1020;
  --good:#4cc790; --good-soft:#163527; --warn:#e8b04a; --warn-soft:#3a2d12; --bad:#ff8077; --bad-soft:#40201e; --stage:#0b0d11; color-scheme:dark}

*{box-sizing:border-box}
body{background:var(--stage);color:var(--fg);font-family:var(--f-body);font-size:15px;line-height:1.4;margin:0}
button,input,textarea{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none;padding:0}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.stage{min-height:100vh;display:flex;align-items:center;justify-content:center;gap:40px;padding:24px 16px;flex-wrap:wrap}
.side{max-width:260px;display:flex;flex-direction:column;gap:12px}
.side h1{font-size:20px;margin:0;font-weight:700}
.side p{margin:0;color:var(--muted);font-size:13px}
.side .tog{align-self:flex-start;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:8px 12px;font-size:13px}
.hint{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:12px;font-size:13px;color:var(--muted)}
.hint b{color:var(--fg)}
.phone{width:390px;max-width:100%;height:780px;max-height:calc(100vh - 32px);background:var(--bg);border-radius:34px;border:1px solid var(--line);box-shadow:0 20px 60px rgba(0,0,0,.25);position:relative;overflow:hidden;display:flex;flex-direction:column}
@media (max-width:520px){.stage{padding:0;display:block}.side{display:none}.phone{width:100%;height:100vh;max-height:none;border-radius:0;border:0;box-shadow:none;padding-top:var(--app-top-inset)}}
.tghead{display:flex;align-items:center;justify-content:space-between;padding:14px 18px 8px;font-size:13px;color:var(--muted)}
.tghead b{color:var(--fg);font-weight:600}
.view{flex:1;overflow-y:auto;padding:4px 16px 24px;display:flex;flex-direction:column;gap:14px;min-height:0}
.nav{display:grid;grid-template-columns:repeat(4,1fr);background:var(--surface);border-top:1px solid var(--line);padding:6px 6px calc(8px + env(safe-area-inset-bottom,0px))}
.nav button{display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 0;font-size:11.5px;color:var(--muted);border-radius:10px;font-weight:500}
.nav button svg{width:22px;height:22px}
.nav button[aria-selected="true"]{color:var(--accent)}
h2{font-size:22px;margin:4px 0 0;font-weight:700;letter-spacing:-.01em}
.lbl{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600}
.mono{font-family:var(--f-data);font-variant-numeric:tabular-nums}
.card{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:14px}
.goal{display:flex;flex-direction:column;gap:10px}
.goal .t{font-size:18px;font-weight:700;line-height:1.25}
.bar{height:8px;background:var(--surface2);border-radius:8px;overflow:hidden;position:relative}
.bar i{display:block;height:100%;background:var(--accent);border-radius:8px}
.bar.good i{background:var(--good)} .bar.warn i{background:var(--warn)} .bar.bad i{background:var(--bad)}
.row{display:flex;align-items:center;gap:10px}
.sp{justify-content:space-between}
.pill{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:600;padding:3px 9px;border-radius:99px;background:var(--surface2);color:var(--muted);white-space:nowrap}
.pill.good{background:var(--good-soft);color:var(--good)} .pill.warn{background:var(--warn-soft);color:var(--warn)} .pill.bad{background:var(--bad-soft);color:var(--bad)} .pill.acc{background:var(--accent-soft);color:var(--accent)}
.pill::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.chain{display:flex;flex-direction:column;gap:0}
.chain .lvl{display:flex;gap:10px;padding:2px 0}
.chain .rail{display:flex;flex-direction:column;align-items:center;width:14px;padding-top:6px}
.chain .dot{width:9px;height:9px;border-radius:50%;background:var(--accent)}
.chain .ln{flex:1;width:2px;background:var(--line);margin-top:3px}
.chain .lvl:last-child .ln{display:none}
.chain .tx{padding-bottom:10px;min-width:0}
.chain .tx b{font-weight:600}
.chain .tx small{display:block;color:var(--muted);font-size:12.5px}
.tiles{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.tile{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:10px 6px;text-align:center;display:flex;flex-direction:column;gap:2px}
.tile b{font-size:20px;font-family:var(--f-data);font-weight:500}
.tile span{font-size:11px;color:var(--muted)}
.tile.alert b{color:var(--bad)}
.task{display:flex;gap:12px;align-items:flex-start;padding:12px 0;border-top:1px solid var(--line)}
.task:first-child{border-top:0}
.chk{width:26px;height:26px;border-radius:9px;border:2px solid var(--muted);flex:none;margin-top:1px;display:grid;place-items:center}
.chk svg{width:15px;height:15px;opacity:0}
.task.done .chk{background:var(--good);border-color:var(--good);color:#fff}
.task.done .chk svg{opacity:1}
.task.done .nm{text-decoration:line-through;color:var(--muted)}
.task .nm{font-weight:500}
.task .meta{display:flex;flex-wrap:wrap;gap:6px;margin-top:5px}
.tag{font-size:11.5px;color:var(--muted);background:var(--surface2);padding:2px 8px;border-radius:7px}
.tag.out{background:var(--warn-soft);color:var(--warn)}
.tag.why{background:var(--accent-soft);color:var(--accent)}
.seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;background:var(--surface2);border-radius:12px;padding:3px;gap:2px}
.seg button{padding:8px 4px;border-radius:9px;font-size:13.5px;font-weight:600;color:var(--muted)}
.seg button[aria-pressed="true"]{background:var(--surface);color:var(--fg);box-shadow:0 1px 3px rgba(0,0,0,.12)}
.seg.res button[aria-pressed="true"].y{background:var(--good-soft);color:var(--good)}
.seg.res button[aria-pressed="true"].p{background:var(--warn-soft);color:var(--warn)}
.seg.res button[aria-pressed="true"].n{background:var(--bad-soft);color:var(--bad)}
.week{display:grid;grid-template-columns:repeat(7,1fr);gap:5px;align-items:end}
.day{display:flex;flex-direction:column;align-items:center;gap:5px;font-size:11.5px;color:var(--muted)}
.day .col{width:100%;height:84px;background:var(--surface2);border-radius:8px;display:flex;align-items:flex-end;overflow:hidden}
.day .col i{display:block;width:100%;background:var(--accent);border-radius:8px 8px 0 0}
.day .col i.over{background:var(--bad)}
.day.today{color:var(--accent);font-weight:700}
.tl{display:flex;flex-direction:column}
.tl .it{display:grid;grid-template-columns:48px 1fr;gap:8px;padding:9px 0;border-top:1px solid var(--line)}
.tl .it:first-child{border-top:0}
.tl .tm{font-family:var(--f-data);font-size:12.5px;color:var(--muted);padding-top:2px}
.mic{width:96px;height:96px;border-radius:50%;background:var(--accent);color:var(--on-accent);display:grid;place-items:center;margin:6px auto;box-shadow:0 0 0 10px var(--accent-soft);transition:transform .15s}
.mic svg{width:38px;height:38px}
.mic.rec{animation:pulse 1.1s infinite;background:var(--bad);color:#fff;box-shadow:0 0 0 10px var(--bad-soft)}
@keyframes pulse{50%{transform:scale(1.07)}}
@media (prefers-reduced-motion:reduce){.mic.rec{animation:none}}
.field{display:flex;flex-direction:column;gap:5px}
.field label{font-size:12px;color:var(--muted);font-weight:600}
.inp{width:100%;background:var(--surface2);border:1px solid transparent;border-radius:11px;padding:10px 12px;resize:none}
.inp:focus{outline:none;border-color:var(--accent)}
.inp.err{border-color:var(--bad)}
.errmsg{font-size:12px;color:var(--bad)}
.btn{background:var(--accent);color:var(--on-accent);border-radius:13px;padding:13px;font-weight:700;width:100%}
.btn.ghost{background:var(--surface2);color:var(--fg)}
.btn[disabled]{opacity:.45;cursor:not-allowed}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{padding:6px 11px;border-radius:99px;background:var(--surface2);font-size:13px;font-weight:500}
.chip:hover{background:var(--accent-soft);color:var(--accent)}
.inb{display:flex;flex-direction:column;gap:9px;padding:12px 0;border-top:1px solid var(--line)}
.inb:first-child{border-top:0}
.inb .src{font-size:12px;color:var(--muted)}
.kpi{width:100%;height:auto;display:block}
.norm{display:grid;grid-template-columns:1fr 62px;gap:4px 10px;align-items:center;font-size:13px}
.norm .tr{height:7px;background:var(--surface2);border-radius:6px;position:relative}
.norm .tr i{position:absolute;left:0;top:0;bottom:0;border-radius:6px;background:var(--accent)}
.norm .tr u{position:absolute;top:-3px;bottom:-3px;width:2px;background:var(--fg)}
.norm .tr i.over{background:var(--warn)}
.sheetwrap{position:absolute;inset:0;background:rgba(8,10,14,.5);display:flex;align-items:flex-end;z-index:20}
.sheet{width:100%;max-height:92%;overflow-y:auto;background:var(--bg);border-radius:22px 22px 0 0;padding:10px 16px calc(18px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:12px}
.grab{width:38px;height:4px;border-radius:4px;background:var(--line);margin:0 auto 2px}
.toast{position:absolute;left:16px;right:16px;bottom:84px;background:var(--fg);color:var(--bg);padding:11px 14px;border-radius:12px;font-size:14px;z-index:30;display:flex;justify-content:space-between;gap:10px}
.menu{display:flex;flex-direction:column}
.menu button{display:flex;justify-content:space-between;align-items:center;padding:13px 2px;border-top:1px solid var(--line);text-align:left}
.menu button:first-child{border-top:0}
.menu small{color:var(--muted)}
.ico-btn{width:36px;height:36px;border-radius:11px;background:var(--surface);border:1px solid var(--line);display:grid;place-items:center}
.ico-btn svg{width:18px;height:18px}
.muted{color:var(--muted)} .small{font-size:13px}
.dec{display:flex;flex-direction:column;gap:7px;padding:12px 0;border-top:1px solid var(--line)}
.dec:first-child{border-top:0}
.fine{font-size:12px;color:var(--muted)}
.irow{display:grid;grid-template-columns:46px 1fr auto;gap:8px;width:100%;text-align:left;padding:11px 0;border-top:1px solid var(--line);align-items:start}
.irow:first-child{border-top:0}
.irow .tm{font-family:var(--f-data);font-size:12.5px;color:var(--muted);padding-top:2px}
.irow .nm{font-weight:500}
.irow.done .nm{text-decoration:line-through;color:var(--muted)}
.irow .mk{width:20px;height:20px;border-radius:7px;border:2px solid var(--line);display:grid;place-items:center;margin-top:1px}
.irow.done .mk{background:var(--good);border-color:var(--good);color:#fff}
.irow .mk svg{width:12px;height:12px;opacity:0}.irow.done .mk svg{opacity:1}
.irow .sub{display:flex;flex-wrap:wrap;gap:5px;margin-top:4px;font-size:12px;color:var(--muted)}
.dchips{display:grid;grid-template-columns:repeat(7,1fr);gap:5px}
.dchips button{display:flex;flex-direction:column;align-items:center;padding:6px 0;border-radius:11px;background:var(--surface);border:1px solid var(--line);font-size:11px;color:var(--muted);gap:1px}
.dchips button b{font-size:15px;color:var(--fg);font-family:var(--f-data);font-weight:500}
.dchips button[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.dchips button[aria-pressed="true"] b{color:var(--on-accent)}
.dchips button.td::after{content:"";width:5px;height:5px;border-radius:50%;background:var(--accent);margin-top:1px}
.dchips button[aria-pressed="true"].td::after{background:var(--on-accent)}
.dayhd{display:flex;justify-content:space-between;align-items:center;width:100%;text-align:left;padding:2px 0}
.focusline{background:var(--accent-soft);border-radius:12px;padding:10px 12px;font-size:13.5px}
.focusline b{display:block;color:var(--accent);font-size:11px;letter-spacing:.08em;text-transform:uppercase;margin-bottom:2px}
.sec{display:flex;flex-direction:column;gap:6px;padding:12px 0;border-top:1px solid var(--line)}
.sec:first-of-type{border-top:0}
.sec p{margin:0}
.sub-st{display:flex;gap:10px;align-items:flex-start;padding:5px 0;width:100%;text-align:left}
.sub-st .b{width:20px;height:20px;border-radius:6px;border:2px solid var(--muted);flex:none;display:grid;place-items:center;margin-top:1px}
.sub-st.on .b{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.sub-st .b svg{width:12px;height:12px;opacity:0}.sub-st.on .b svg{opacity:1}
.sub-st.on span{color:var(--muted);text-decoration:line-through}
.kv{display:grid;grid-template-columns:110px 1fr;gap:6px 10px;font-size:13.5px}
.kv dt{color:var(--muted)} .kv dd{margin:0;min-width:0}
.acts{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.acts .btn{padding:11px}
.prog{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:4px}
.prog i{height:4px;border-radius:4px;background:var(--line)} .prog i.on{background:var(--accent)}
.exp{background:var(--surface);border:1px dashed var(--line);border-radius:12px;padding:10px 12px;font-size:13.5px}
.exp b{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);display:block}
.sumbox{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:12px;font-size:13.5px;display:flex;flex-direction:column;gap:4px}
.chip.on{background:var(--accent-soft);color:var(--accent)}
.stepper{display:flex;align-items:center;gap:8px}
.stepper button{width:36px;height:36px;border-radius:10px;background:var(--surface2);font-weight:700}
.timer{font-family:var(--f-data)}
.wkr{display:grid;grid-template-columns:repeat(5,1fr);gap:4px}.wk{display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 0;border-radius:12px}.wk.sel{background:var(--accent-soft)}.cal{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.cal .wd{font-size:11px;color:var(--muted);text-align:center;padding:2px 0}.cal button.c{aspect-ratio:1/1.05;border-radius:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-family:var(--f-data);font-size:14px;background:var(--surface);border:1px solid var(--line)}.cal button.c.sel{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}.cal button.c.td:not(.sel){border-color:var(--accent);color:var(--accent);font-weight:600}.dots{display:flex;gap:3px;height:5px}.dots i{width:5px;height:5px;border-radius:50%;background:var(--accent)}.dots i.g{background:var(--good)}.dots i.w{background:var(--warn)}.cal .sel .dots i{background:var(--on-accent)}.dotl{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--accent);vertical-align:middle;margin-left:6px}.dotl.g{background:var(--good)}.dotl.w{background:var(--warn)}.cal .blank{visibility:hidden}
/* Рабочая страница: приложение занимает весь экран Telegram, рамки телефона нет. */
html,body{height:100%}
body.prod{background:var(--bg);display:flex;flex-direction:column}
body.prod .phone{width:100%;max-width:560px;height:auto;max-height:none;flex:1;min-height:0;margin:0 auto;border-radius:0;border:0;box-shadow:none}
.mockbar{background:var(--warn-soft);color:var(--warn);font-size:12px;text-align:center;padding:4px 8px}
