:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #faf9f6; --sunken: #efeee9;
  --ink: #15171b; --ink-2: #454a54; --ink-3: #6b707b; --line: #e3e1da; --line-2: #d4d1c8;
  --accent: #1e5a61; --accent-ink: #ffffff; --accent-soft: #e2eeef; --accent-line: #b9d3d6;
  --danger: #b3261e; --danger-soft: #fbeceb; --hot: #c2410c; --hot-soft: #fdf0e7;
  --ok: #2e7048; --ok-soft: #e7f2ea; --wait: #8a5a00; --wait-soft: #fbf2dc;
  --shadow: 0 1px 2px rgba(20, 22, 27, .06), 0 4px 16px rgba(20, 22, 27, .06);
  --shadow-lg: 0 8px 40px rgba(20, 22, 27, .18);
  --r: 8px; --r-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --side: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315; --surface: #191c1f; --surface-2: #1d2024; --sunken: #15181b;
    --ink: #eceef1; --ink-2: #b8bdc6; --ink-3: #8d939d; --line: #2a2e33; --line-2: #383d44;
    --accent: #7cc0c6; --accent-ink: #0d2427; --accent-soft: #1d3336; --accent-line: #2f5357;
    --danger: #f08a80; --danger-soft: #3a1f1d; --hot: #f59a5f; --hot-soft: #3a2618;
    --ok: #7cc893; --ok-soft: #1b3123; --wait: #e2b55a; --wait-soft: #352a14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 8px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); color: var(--ink); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.01em; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- каркас */
.app { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 12px; gap: 4px; z-index: 5; }
.brand { padding: 4px 12px 16px; }
.brand b { display: block; font-size: 17px; letter-spacing: -.01em; }
.brand span { font-size: 13px; color: var(--ink-3); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-height: 40px; border-radius: var(--r); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a .cnt { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 500; }
.nav a.on .cnt { color: var(--accent); }
.side .grow { flex: 1; }
.side .new { margin: 0 0 12px; }
.main { margin-left: var(--side); padding: 28px 40px 64px; max-width: 1280px; }
.tabbar, .fab { display: none; }

.vhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; min-height: 40px; }
.vhead h1 { margin-right: auto; }
.summary { color: var(--ink-2); margin: -8px 0 24px; font-size: 14px; }
.summary b { color: var(--ink); font-weight: 600; }
.summary .sep { color: var(--ink-3); margin: 0 2px; }
.summary .bad { color: var(--danger); }
.summary .nw { white-space: nowrap; }

/* ---------- кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--sunken); }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.pri:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.icon { padding: 0; width: 40px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.inp, select.inp { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); width: 100%; }
select.inp { padding-right: 28px; }
textarea.inp { resize: vertical; overflow: hidden; min-height: 64px; line-height: 1.45; }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp::placeholder { color: var(--ink-3); }
.search { position: relative; flex: 1 1 240px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--ink-3); }
.search .inp { padding-left: 38px; }
label.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); font-weight: 500; min-width: 0; }
label.fld .inp { font-size: 14px; color: var(--ink); }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 40px; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- метки */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--sunken); color: var(--ink-2); white-space: nowrap; line-height: 18px; }
.pill.st-work { background: var(--accent-soft); color: var(--accent); }
.pill.st-wait { background: var(--wait-soft); color: var(--wait); }
.pill.st-done { background: var(--ok-soft); color: var(--ok); }
.pill.st-cancel { background: var(--sunken); color: var(--ink-3); }
.pill.hot { background: var(--hot-soft); color: var(--hot); }
.pill svg.i { width: 13px; height: 13px; }
.due { white-space: nowrap; color: var(--ink-2); }
.due.over { color: var(--danger); font-weight: 550; }
.due.today { color: var(--accent); font-weight: 600; }
.num { color: var(--ink-3); font-size: 13px; font-weight: 500; white-space: nowrap; }

/* ---------- строки задач: таблица на компьютере, карточки на телефоне */
.tlist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.thead, .trow { display: grid; grid-template-columns: 56px minmax(0, 1fr) 176px 92px 108px 104px; gap: 16px; align-items: start; padding: 12px 16px; }
.thead { font-size: 12px; color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.trow { border-top: 1px solid var(--line); cursor: pointer; }
.thead + .trow, .ghead + .trow { border-top: 0; }
.trow:hover { background: var(--surface-2); }
.trow.sub { padding-left: 40px; background: var(--surface-2); }
.trow.sub:hover { background: var(--sunken); }
.trow.ctx .ttl { color: var(--ink-3); }
.trow .ttl { font-weight: 550; overflow-wrap: anywhere; }
.trow .ttl .pill { margin-left: 6px; vertical-align: 1px; }
.trow .step { color: var(--ink-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.trow .tp { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.trow .own { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; }
.trow .m-only { display: none; }
.ghead { display: flex; align-items: baseline; gap: 8px; padding: 16px 16px 8px; font-weight: 650; border-top: 1px solid var(--line); background: var(--surface); }
.tlist > .ghead:first-child { border-top: 0; }
.ghead .muted { font-weight: 500; font-size: 13px; }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-3); }

/* ---------- фильтры */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 16px; }
.filters label.fld { flex: 1 1 150px; max-width: 220px; }
.filters .chk { padding: 0 4px; }
.ftoggle { display: none; }
.listfoot { margin-top: 12px; font-size: 13px; color: var(--ink-3); }

/* ---------- «Сегодня» */
.today-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel > .ph { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.panel > .ph h2 { margin-right: auto; }
.panel > .ph .count { color: var(--ink-3); font-size: 13px; font-weight: 500; }
.panel .pb { padding: 4px 0; }
.panel .more { display: block; padding: 10px 16px 12px; font-size: 14px; font-weight: 500; text-decoration: none; border-top: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 24px; }
.mini { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; padding: 10px 16px; align-items: baseline; cursor: pointer; border-top: 1px solid var(--line); }
.pb > .mini:first-child { border-top: 0; }
.mini:hover { background: var(--surface-2); }
.mini .ttl { font-weight: 500; overflow-wrap: anywhere; }
.mini .sub2 { font-size: 13px; color: var(--ink-3); margin-top: 2px; overflow-wrap: anywhere; }
.mini .right { text-align: right; font-size: 13px; }
.pempty { padding: 16px; color: var(--ink-3); font-size: 14px; }
.daynav { display: flex; align-items: center; gap: 4px; }
.daynav .lbl { min-width: 112px; text-align: center; font-weight: 600; font-size: 14px; }
.plan-item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; padding: 8px 12px 8px 16px; border-top: 1px solid var(--line); align-items: center; }
.pb > .plan-item:first-child { border-top: 0; }
.plan-item input[type=time] { min-height: 36px; padding: 4px 8px; }
.plan-item .ttl { font-weight: 550; cursor: pointer; overflow-wrap: anywhere; }
.plan-item .note { border: 0; background: transparent; padding: 2px 0; width: 100%; font-size: 13px; color: var(--ink-2); min-height: 24px; }
.plan-item .note:focus { outline: none; box-shadow: inset 0 -1px 0 var(--accent); }
.plan-item .acts { display: flex; gap: 0; }
.plan-item.done .ttl { text-decoration: line-through; color: var(--ink-3); }
.plan-add { position: relative; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.suggest { position: absolute; left: 16px; right: 16px; top: calc(100% - 12px); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-lg); z-index: 20; max-height: 320px; overflow: auto; }
.suggest button { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; min-height: 44px; }
.suggest button:hover, .suggest button.act { background: var(--accent-soft); }
.hint { font-size: 13px; color: var(--ink-3); padding: 0 16px 12px; }

/* ---------- доска */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
.col { flex: 0 0 250px; background: var(--sunken); border-radius: var(--r-lg); display: flex; flex-direction: column; max-height: calc(100vh - 150px); scroll-snap-align: start; border: 1px solid transparent; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col .ch { display: flex; gap: 8px; align-items: baseline; padding: 12px 12px 8px; font-weight: 650; }
.col .ch .muted { font-weight: 500; font-size: 13px; }
.col .cb { overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.kcard:hover { border-color: var(--line-2); }
.kcard .ttl { font-weight: 550; font-size: 14px; overflow-wrap: anywhere; margin: 2px 0 6px; }
.kcard .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--ink-3); align-items: center; }
.kcard.dragging { opacity: .35; }
.kghost { position: fixed; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); transform: rotate(1.5deg); width: 256px; }

/* ---------- люди */
.people { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; align-items: center; min-height: 56px; }
.pb > .prow:first-child { border-top: 0; }
.prow:hover { background: var(--surface-2); }
.prow.on { background: var(--accent-soft); }
.prow .nm { font-weight: 550; }
.prow .rl { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .cn { font-size: 13px; text-align: right; white-space: nowrap; }
.prow.off .nm { color: var(--ink-3); }
.pdet .ph { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; flex-wrap: wrap; }
.pdet .ph h2 { margin-right: auto; }
.pdet .qsec { border-top: 1px solid var(--line); margin-top: 16px; }
.qbox { margin: 12px 16px 16px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.pdet .rolebox { padding: 12px 16px 0; display: grid; gap: 8px; }
.back { display: none; }

/* ---------- календарь */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.cal .dows, .cal .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal .dows div { padding: 8px 10px; font-size: 12px; color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--line); }
.cal .cell { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal .cell:nth-child(7n) { border-right: 0; }
.cal .cell.out { background: var(--surface-2); }
.cal .cell.out .d { color: var(--ink-3); }
.cal .cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .d { font-size: 13px; font-weight: 600; padding: 2px 4px; align-self: flex-start; border-radius: 6px; }
.cal .cell.now .d { background: var(--accent); color: var(--accent-ink); }
.ev { font-size: 12px; padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 18px; }
.ev.ctl { background: transparent; border: 1px dashed var(--accent-line); }
.ev.over { background: var(--danger-soft); }
.ev.stg { background: var(--wait-soft); }
.cal .plus { font-size: 12px; color: var(--ink-3); padding: 0 6px; }
.cal .dots { display: none; }
.daylist { margin-top: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--ink-3); margin-top: 12px; align-items: center; }
.legend .ev { display: inline-block; width: 28px; height: 12px; padding: 0; vertical-align: -1px; margin-right: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 14px; min-height: 38px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.weekcols { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekcols .wd { border-right: 1px solid var(--line); min-height: 320px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.weekcols .wd:last-child { border-right: 0; }
.weekcols .wd h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.weekcols .wd.now h3 { color: var(--accent); }
.weekcols .ev { white-space: normal; cursor: pointer; padding: 4px 6px; }

/* ---------- карточка задачи */
.scrim { position: fixed; inset: 0; background: rgba(15, 17, 20, .32); z-index: 30; }
.card { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100%); background: var(--surface); z-index: 31; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.card .chead { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 24px; border-bottom: 1px solid var(--line); min-height: 60px; }
.card .chead .num { font-size: 14px; margin-right: auto; }
.card .cbody { overflow-y: auto; padding: 20px 24px 40px; flex: 1; overscroll-behavior: contain; }
.card .title-inp { font-size: 20px; font-weight: 650; line-height: 1.3; border: 1px solid transparent; padding: 6px 8px; margin: -6px -8px 12px; width: calc(100% + 16px); resize: none; background: transparent; border-radius: var(--r); overflow: hidden; }
.card .title-inp:hover { border-color: var(--line); }
.card .title-inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card .row1 { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; align-items: center; }
.card .row1 select.inp { width: auto; }
.hotbtn.on { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-bottom: 20px; }
.fgrid .wide { grid-column: 1 / -1; }
.sec { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; }
.sec > .sh { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.sec > .sh .muted { font-size: 13px; }
.stage { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stage:last-of-type { border-bottom: 0; }
.stage input[type=checkbox] { width: 20px; height: 20px; margin: 10px 0 0 2px; accent-color: var(--accent); }
.stage .st-title { border: 0; background: transparent; padding: 8px 0 2px; width: 100%; font-weight: 500; resize: none; overflow: hidden; line-height: 1.4; display: block; }
.stage .st-title:focus { outline: none; box-shadow: inset 0 -1px 0 var(--accent); }
.stage.done .st-title { text-decoration: line-through; color: var(--ink-3); }
.stage .st-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-3); padding-bottom: 4px; }
.stage .st-edit { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px 0 8px; }
.stage .st-edit .wide { grid-column: 1 / -1; }
.addline { display: flex; gap: 8px; margin-top: 8px; }
.addline .inp { flex: 1; }
.subrow { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; align-items: baseline; }
.subrow .ttl { font-weight: 500; overflow-wrap: anywhere; }
.subrow .sub2 { font-size: 12px; color: var(--ink-3); }
.cmt { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cmt .who { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.cmt .tx { white-space: pre-wrap; overflow-wrap: anywhere; }
.hist { font-size: 13px; }
.hist div { padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); overflow-wrap: anywhere; }
.hist time { color: var(--ink-3); margin-right: 8px; }
.cfoot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--line); background: var(--surface); }
.closebox { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.closebox .inp { flex: 1 1 200px; }
.parentlink { display: inline-flex; gap: 6px; font-size: 13px; margin-bottom: 8px; color: var(--ink-3); cursor: pointer; }
.parentlink:hover { color: var(--accent); }

/* ---------- быстрое добавление, тосты, вход */
.qa { position: fixed; left: 50%; top: 14vh; transform: translateX(-50%); width: min(640px, calc(100% - 32px)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: 41; padding: 16px; }
.qa form { display: flex; gap: 8px; }
.qa .inp { font-size: 17px; min-height: 48px; }
.qa .btn { min-height: 48px; }
.qa .hint { padding: 8px 0 0; }
.qa-scrim { z-index: 40; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100% - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center; font-size: 14px; }
.toast.err { background: var(--danger); color: #fff; }
.toast button { background: none; border: 0; color: inherit; font-weight: 650; text-decoration: underline; cursor: pointer; padding: 4px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.login h1 { font-size: 24px; }
.login p { margin: -8px 0 4px; color: var(--ink-3); }
.login .btn { min-height: 48px; font-size: 16px; }
.login .inp { min-height: 48px; font-size: 16px; }
.login .err { color: var(--danger); font-size: 14px; min-height: 20px; margin: -4px 0; }
.more-sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 41; padding: 8px 8px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
.more-sheet a, .more-sheet button { display: flex; gap: 12px; align-items: center; width: 100%; padding: 0 16px; min-height: 52px; border: 0; background: none; text-decoration: none; color: var(--ink); font-size: 16px; border-radius: var(--r); cursor: pointer; }
.more-sheet a:hover, .more-sheet button:hover { background: var(--sunken); }

/* ---------- планшет */
@media (max-width: 1180px) {
  .main { padding: 24px 24px 64px; }
  .thead, .trow { grid-template-columns: 52px minmax(0, 1fr) 140px 88px 96px 96px; gap: 12px; }
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .people { grid-template-columns: 280px minmax(0, 1fr); }
}

/* ---------- телефон */
@media (max-width: 820px) {
  body { font-size: 16px; }
  .side { display: none; }
  .main { margin-left: 0; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .vhead { margin-bottom: 12px; }
  .summary { margin: -4px 0 16px; line-height: 1.6; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; font-size: 12px; color: var(--ink-3); text-decoration: none; border: 0; background: none; font-weight: 500; cursor: pointer; }
  .tabbar .on { color: var(--accent); }
  .tabbar svg.i { width: 22px; height: 22px; }
  .fab { display: flex; position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); border: 0; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); z-index: 21; cursor: pointer; }
  .fab svg.i { width: 26px; height: 26px; stroke-width: 2.2; }
  .inp, select.inp, label.fld .inp { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.icon { width: 44px; }
  .btn.sm { min-height: 40px; }
  .search { max-width: none; flex-basis: 100%; }

  .tlist { background: transparent; border: 0; overflow: visible; display: flex; flex-direction: column; gap: 8px; }
  .thead { display: none; }
  .trow { grid-template-columns: auto minmax(0, 1fr); gap: 0 10px; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; }
  .thead + .trow, .ghead + .trow, .trow { border-top: 1px solid var(--line); }
  .trow.sub { margin-left: 20px; padding-left: 14px; }
  .trow > .num { min-width: 24px; }
  .trow > .own, .trow > .ccell, .trow > .dcell, .trow > .scell { display: none; }
  .trow .m-only { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 8px; font-size: 14px; color: var(--ink-2); }
  .ghead { background: transparent; border: 0; padding: 12px 4px 0; }
  .filters { display: none; }
  .filters.open { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; }
  .filters.open label.fld { max-width: none; }
  .filters.open .full { grid-column: 1 / -1; }
  .ftoggle { display: inline-flex; }
  .vhead .wide-only { display: none; }

  .panel > .ph { padding: 12px 14px; }
  .mini { grid-template-columns: 40px minmax(0, 1fr); padding: 12px 14px; }
  .mini .right { grid-column: 2; text-align: left; }
  .plan-item { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 8px 10px 14px; gap: 4px 8px; }
  .plan-item input[type=time] { width: 124px; min-height: 40px; }
  .plan-item .mid { grid-column: 1 / -1; grid-row: 2; }
  .plan-item .acts { grid-row: 1; grid-column: 2; }
  .daynav .lbl { min-width: 88px; }

  .col { flex-basis: 84vw; max-height: none; }
  .board { margin: 0 -16px; padding: 0 16px 16px; scroll-padding: 0 16px; }

  .people { grid-template-columns: minmax(0, 1fr); }
  .people.has-sel .plist { display: none; }
  .people:not(.has-sel) .pdet { display: none; }
  .back { display: inline-flex; }

  .cal .cell { min-height: 56px; padding: 4px; align-items: center; }
  .cal .cell .ev, .cal .cell .plus { display: none; }
  .cal .dots { display: flex; gap: 3px; }
  .cal .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
  .cal .dots i.over { background: var(--danger); }
  .cal .dows div { padding: 8px 4px; text-align: center; }
  .cal .d { align-self: center; }
  .weekcols { grid-template-columns: minmax(0, 1fr); }
  .weekcols .wd { border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; }
  .weekcols .wd .ev { font-size: 14px; padding: 8px 10px; }
  .vhead .seg button { padding: 0 12px; min-height: 42px; }

  .card { width: 100%; }
  .card .chead { padding: 8px 8px 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .card .cbody { padding: 16px 16px 40px; }
  .card .title-inp { font-size: 19px; }
  .cfoot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .fgrid { gap: 12px; }
  .stage .st-edit { grid-template-columns: minmax(0, 1fr); }
  .qa { top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .qa form { flex-direction: column; }
  .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .fgrid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .card { animation: slidein .18s cubic-bezier(.2, .8, .2, 1); }
  .toast { animation: fadeup .18s ease-out; }
  @keyframes slidein { from { transform: translateX(24px); opacity: .6; } }
  @keyframes fadeup { from { transform: translateY(8px); opacity: 0; } }
}
@media (max-width: 820px) and (prefers-reduced-motion: no-preference) {
  .card { animation-name: slideup; }
  @keyframes slideup { from { transform: translateY(24px); opacity: .6; } }
}

/* телефон: поля карточки в одну колонку — длинные названия функций/проектов не обрезаются */
@media (max-width: 520px) { .fgrid { grid-template-columns: minmax(0, 1fr); } }

/* Справочник функций (Наталья 06.11): дерево Сфера → Функция → Проект */
.sp > summary, .sp3 { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 16px; min-height: 48px; border-top: 1px solid var(--line); }
.sp > summary { cursor: pointer; list-style: none; }
.sp > summary::-webkit-details-marker { display: none; }
.sp > summary .sp-t::before { content: "▸"; display: inline-block; width: 1em; margin-right: .2em; text-align: center; transform-origin: 50% 55%; color: var(--muted, #6b6b6b); transition: transform .15s; }
.sp[open] > summary .sp-t::before { transform: rotate(90deg); }
.sp1 > summary .sp-t { font-weight: 700; font-size: 16px; }
.sp2 > summary { padding-left: 36px; }
.sp2 > summary .sp-t { font-weight: 600; }
.sp3 { padding-left: 68px; }
.sp-n { color: var(--muted, #6b6b6b); font-size: 13px; white-space: nowrap; }
.sp-n b { color: inherit; font-weight: 700; }
@media (max-width: 520px) {
  .sp > summary, .sp3 { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .sp-n { grid-column: 1; grid-row: 2; }
  .sp > summary .btn, .sp3 .btn { grid-column: 2; grid-row: 1 / span 2; }
  .sp2 > summary { padding-left: 28px; } .sp3 { padding-left: 48px; }
}
.pb > .sp1:first-child > summary { border-top: 0; }

/* сортировка по колонкам (Наталья 06.11) */
.thead .sorth { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; font: inherit; color: inherit; min-height: 24px; border-radius: 4px; }
.thead .sorth:hover, .thead .sorth.on { color: var(--ink, #111); }
.thead .sorth:focus-visible { outline: 2px solid var(--accent, #1d5c63); outline-offset: 2px; }
.thead .sarr { font-size: 12px; opacity: .55; } .thead .sorth.on .sarr { opacity: 1; }

.trow .ccell { color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.acount { margin: 0 0 8px; font-size: 13px; }

/* ---------- регламентные задачи (шаблоны) */
.tpl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: start; }
.pb > .tpl:first-child { border-top: 0; }
.tpl.off .tpl-main { opacity: .6; }
.tpl .ttl { font-weight: 600; overflow-wrap: anywhere; }
.tpl .ttl .pill { margin-left: 6px; vertical-align: 1px; }
.tpl-ex, .tpl .tp { color: var(--ink-3); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.tpl-sched { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.tpl-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-3); margin-top: 6px; align-items: baseline; }
.tpl-meta b { color: var(--ink); font-weight: 600; }
.tpl-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; max-width: 380px; }
.tpl-acts .chk { min-height: 32px; font-size: 14px; margin-right: 4px; }
.tpl-confirm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.tpl-confirm span { margin-right: auto; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; text-align: left; overflow-wrap: anywhere; }
.tplline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -8px 0 4px; font-size: 14px; color: var(--ink-2); }
.tplfilter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; padding: 8px 12px; border-radius: var(--r); background: var(--accent-soft); font-size: 14px; }
.tplfilter span { margin-right: auto; overflow-wrap: anywhere; }
.tpl-preview { padding: 12px 14px; margin-bottom: 20px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 14px; display: grid; gap: 2px; }
.tpl-preview .ttl { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.tpl-ph { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: -4px; }
.tpl-ph .muted { font-size: 13px; margin-right: 2px; }
div.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); font-weight: 500; min-width: 0; }
div.fld .inp, .tpl-stage .inp { font-size: 14px; color: var(--ink); }
.tpl-rule-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.tpl-rule-row select.inp { flex: 1 1 100%; min-width: 0; }
.inp.num { width: 76px; flex: none; }
.tpl-note { min-height: 40px; display: flex; align-items: center; color: var(--ink-2); }
.tpl-flags { display: flex; flex-wrap: wrap; gap: 0 20px; }
/* этап шаблона: название и «удалить» в первой строке, «ждём от» и срок — во второй */
.tpl-stage { display: grid; grid-template-columns: minmax(0, 1fr) auto 40px; gap: 6px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tpl-stage > input.inp { grid-column: 1 / 3; }
.tpl-stage > .btn.icon { grid-column: 3; grid-row: 1; }
.tpl-stage > select.inp { grid-column: 1; grid-row: 2; }
.tpl-stage > .tpl-off { grid-column: 2 / 4; grid-row: 2; }
.tpl-off { display: flex; gap: 6px; align-items: center; white-space: nowrap; font-size: 13px; }
.sec > .tpl-stage + .btn, .sec > .sh + .btn { margin-top: 10px; }
@media (max-width: 820px) {
  .tpl { grid-template-columns: minmax(0, 1fr); }
  .tpl-acts { justify-content: flex-start; max-width: none; }
  div.fld .inp, .tpl-stage .inp { font-size: 16px; }
}
@media (max-width: 520px) {
  .tpl-stage { grid-template-columns: minmax(0, 1fr) 40px; }
  .tpl-stage > input.inp { grid-column: 1; }
  .tpl-stage > .btn.icon { grid-column: 2; }
  .tpl-stage > select.inp { grid-column: 1 / 3; }
  .tpl-stage > .tpl-off { grid-column: 1 / 3; grid-row: 3; }
  .colpanel .ph .count { display: none; }
}
/* этап с «ждём от» как задача человека */
.stmark { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.stmark .pill { white-space: normal; overflow-wrap: anywhere; }
.stgrow .ttl .pill { margin-left: 6px; vertical-align: 1px; }
.stgrow .right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.chk.sm { min-height: 28px; font-size: 13px; gap: 6px; color: var(--ink-2); }
.chk.sm input { width: 18px; height: 18px; }
.tpl-hint { font-size: 13px; margin: 0 0 8px; }
.tpl-sub { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; background: var(--surface-2); }
.tpl-sub-h { display: grid; grid-template-columns: auto minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.tpl-sub-h .num { color: var(--ink-3); font-size: 13px; min-width: 16px; }
.tpl-sub-f { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 8px 0 4px; }
.tpl-sub .tpl-stage:last-of-type { border-bottom: 0; }
@media (max-width: 520px) { .tpl-sub-f { grid-template-columns: minmax(0, 1fr); } }

/* ---------- настраиваемые колонки «Задач» и «Архива» (ширины ставит app.js в --cols/--minw) */
.tlist[data-view] { overflow: auto; max-height: calc(100vh - 150px); overscroll-behavior-x: contain; }
.tlist[data-view] > .thead, .tlist[data-view] > .trow, .tlist[data-view] > .ghead { grid-template-columns: var(--cols); min-width: var(--minw, 0); }
.tlist[data-view] > .thead { position: sticky; top: 0; z-index: 2; }
.tlist[data-view] .cell { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.tlist[data-view] .cell.c-num { color: var(--ink-3); }
.tlist[data-view] .thead .sorth { white-space: nowrap; }
.colpanel { margin-bottom: 16px; }
.colpanel .ph { flex-wrap: wrap; }
.colgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; padding: 8px 16px; }
.colrow { display: flex; align-items: center; gap: 2px; min-height: 40px; }
.colrow .chk { margin-right: auto; font-size: 14px; min-height: 36px; }
.colrow .btn.icon { width: 32px; min-height: 32px; }
.colrow.on .chk { font-weight: 600; }
.colhint { font-size: 13px; padding: 0 16px 12px; margin: 0; }
@media (max-width: 820px) {
  .tlist[data-view] { overflow: visible; max-height: none; }
  .tlist[data-view] > .trow { grid-template-columns: auto minmax(0, 1fr); min-width: 0; }
  .tlist[data-view] > .ghead { min-width: 0; }
  .tlist[data-view] > .trow > .cell { display: none; }
  .tlist[data-view] > .trow > .cell.c-num { display: block; order: -1; }
  .tlist[data-view] .m-only:empty { display: none; }
  .tlist[data-view] .m-only { gap: 2px 14px; }
}
.kidtog { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; padding: 0 6px; min-height: 24px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; vertical-align: 1px; }
.kidtog:hover, .kidtog.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.kidtog span { font-size: 12px; font-weight: 600; }
@media (max-width: 820px) { .kidtog { min-height: 32px; padding: 0 9px; } }
.filters .fcfg { order: 100; align-self: flex-end; color: var(--ink-2); }
.card .row1 #f-waiting_from { width: auto; max-width: 100%; }
.filters label.fld { max-width: 240px; }
.filters label.fld.fw { flex-basis: 320px; max-width: 340px; }
@media (max-width: 820px) { .filters label.fld.fw { max-width: none; } }
