:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #222);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f4f6f8);
  --line: color-mix(in srgb, var(--text) 14%, transparent);
  --cell: color-mix(in srgb, var(--text) 5%, var(--bg));
  --red: #e53935;
  --sel: #2481cc;
  --grey: #9aa0a6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { padding: 10px 6px 200px; max-width: 1200px; margin: 0 auto; }
.loading, .empty { text-align: center; color: var(--hint); padding: 40px 0; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Шапка */
.mon { display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 700; padding: 0 6px; }
.mon .ar { color: var(--link); font-weight: 400; font-size: 24px; background: none; border: 0; padding: 0 12px; }
.st { margin: 6px 4px 8px; font-size: 12px; border-radius: 8px; padding: 4px 8px; display: inline-block; background: #e6f6ea; color: #1b7f3b; }
.st.closed { background: #fff4e0; color: #9a5b00; }
.st.locked { background: #e7f0fb; color: #1d5fa8; }
.st.draft { background: var(--bg2); color: var(--hint); }
.boss-top { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 4px 8px; }
.flt { display: flex; gap: 5px; margin: 0 2px 8px; overflow-x: auto; scrollbar-width: none; }
.flt::-webkit-scrollbar { display: none; }
.chp { font-size: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; white-space: nowrap; background: var(--bg); }
.chp.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
select.chp { appearance: none; -webkit-appearance: none; padding-right: 10px; }

/* Календарь */
.wd, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.wd { font-size: 10px; font-weight: 600; color: var(--hint); margin: 0 0 3px; padding-left: 2px; }
.wd span:nth-child(n+6) { color: var(--red); }
.dc { background: var(--cell); border-radius: 7px; padding: 3px 3px 4px; min-height: 74px; border: 1.5px solid transparent; overflow: hidden; }
.dc.empty { background: transparent; }
.dc.on { border-color: var(--sel); background: color-mix(in srgb, var(--sel) 12%, var(--bg)); }
.dc.today .dn { text-decoration: underline; }
.dc.closed { background: color-mix(in srgb, var(--grey) 25%, var(--bg)); }
.dc.past { opacity: .55; }
.dn { font-size: 11.5px; font-weight: 700; margin: 0 0 2px 2px; }
.dn.we { color: var(--red); }
.dn small { font-size: 7.5px; font-weight: 600; color: var(--red); margin-left: 3px; vertical-align: 1px; }
.closed-label { font-size: 9px; color: var(--hint); text-align: center; margin-top: 10px; }
.ch { border-left: 3px solid; border-radius: 3px; padding: 1px 0 1px 3px; margin-bottom: 2px; line-height: 1.1; overflow: hidden; white-space: nowrap; }
.ch b { display: block; font-size: 9.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ch i { display: block; font-style: normal; font-size: 8px; color: var(--hint); }
.ch.mine b { text-decoration: underline; }
.ch.unconf b::after { content: ""; }
.ch.free { border: 1px dashed var(--grey); background: var(--bg); padding-left: 3px; }
.ch.free b { color: var(--hint); font-weight: 500; font-size: 8px; }
.ch.na { border-left-color: var(--grey); background: color-mix(in srgb, var(--grey) 22%, transparent); }
.ch.na b { color: var(--hint); font-weight: 500; }
@media (min-width: 700px) {
  .dc { min-height: 96px; padding: 5px; }
  .dn { font-size: 13px; }
  .ch { display: flex; gap: 6px; padding: 2px 4px; }
  .ch b, .ch i { display: inline; font-size: 12px; }
  .ch i { margin-left: auto; }
  .wd { font-size: 12px; }
}

/* Нижняя панель */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; border-top: 1px solid var(--line); padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: var(--bg2); box-shadow: 0 -2px 10px rgba(0,0,0,.08); z-index: 10; }
.sheet-in { max-width: 700px; margin: 0 auto; }
.sel2 { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 8px; }
.sel2 span:last-child { color: var(--hint); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.tr .tl { width: 66px; font-size: 12px; color: var(--hint); flex: none; }
.tb { flex: 1; height: 34px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 13px; font-weight: 600; }
.tb::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.tb.on { border-color: var(--sel); background: color-mix(in srgb, var(--sel) 12%, var(--bg)); box-shadow: inset 0 0 0 1px var(--sel); }
.tr.off .tb { opacity: .35; pointer-events: none; }
.who { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.who select { flex: 1; height: 34px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); color: var(--text); padding: 0 8px; font: inherit; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.bt { flex: 1; min-height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; border: 0; padding: 0 10px; }
.bt.sec { background: color-mix(in srgb, var(--btn) 12%, var(--bg)); color: var(--link); flex: 0 0 auto; }
.bt.pri { background: var(--btn); color: var(--btn-text); }
.bt.warn { background: color-mix(in srgb, var(--red) 14%, var(--bg)); color: var(--red); flex: 0 0 auto; }
.bt.small { min-height: 32px; font-size: 13px; border-radius: 8px; flex: 0 0 auto; }
.bt:disabled { opacity: .4; }

.toast { position: fixed; left: 12px; right: 12px; bottom: 20px; background: rgba(30,30,30,.92); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; z-index: 50; text-align: center; }

/* Разделы настроек */
.page h2 { font-size: 18px; margin: 4px 6px 10px; }
.page h3 { font-size: 15px; margin: 18px 6px 8px; }
.card { background: var(--bg2); border-radius: 10px; padding: 10px; margin: 0 4px 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row + .row { margin-top: 6px; }
.grow { flex: 1; min-width: 120px; }
.lbl { font-size: 12px; color: var(--hint); }
input[type=text], input[type=number], input[type=time], input[type=datetime-local], select.inp, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; min-height: 34px; }
input[type=number] { width: 90px; }
textarea { width: 100%; min-height: 80px; }
.sw { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.muted { color: var(--hint); font-size: 12px; }
.tabs { display: flex; gap: 5px; overflow-x: auto; margin: 0 2px 10px; }
