﻿:root {
  --bg: #f2f2f7; --card: #fff; --text: #111; --muted: #6b6b73; --line: #e2e2e8;
  --accent: #0a84ff; --red: #ff3b30; --orange: #ff9500; --green: #34c759;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --muted: #98989f; --line: #2c2c2e; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; font-size: calc(16px * var(--s, 1)); line-height: 1.35; }
body { padding-top: env(safe-area-inset-top); }
button, input, select, textarea { font: inherit; color: inherit; }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.top { padding: 14px 16px 6px; display: flex; align-items: center; justify-content: space-between; }
.top h1 { margin: 0; font-size: calc(28px * var(--s, 1)); }
.top .who { color: var(--muted); font-size: calc(14px * var(--s, 1)); background: none; border: 0; }
.chips { display: flex; gap: 8px; padding: 6px 16px 10px; overflow-x: auto; }
.chip { border: 0; background: var(--card); padding: 7px 14px; border-radius: 99px; color: var(--muted); white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; }
.search { margin: 4px 16px 10px; width: calc(100% - 32px); padding: 10px 14px; border-radius: 12px; border: 0; background: var(--card); }

.group { margin: 6px 16px 14px; }
.group h2 { font-size: calc(13px * var(--s, 1)); text-transform: uppercase; color: var(--muted); margin: 10px 4px 6px; font-weight: 600; }
.group h2.red { color: var(--red); }
.list { background: var(--card); border-radius: 14px; overflow: hidden; }
.row { display: flex; gap: 12px; align-items: center; padding: calc(12px * var(--s, 1)) 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: calc(13px * var(--s, 1)); margin-top: 2px; }
.row .sub.red, .red { color: var(--red); }
.row .sub.orange { color: var(--orange); }
.done .title { text-decoration: line-through; color: var(--muted); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: none; flex: none; padding: 0; }
.check.on { background: var(--green); border-color: var(--green); position: relative; }
.check.on::after { content: "✓"; color: #fff; position: absolute; inset: 0; font-size: calc(14px * var(--s, 1)); text-align: center; line-height: 20px; }
.badge { font-size: calc(12px * var(--s, 1)); padding: 3px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.work { background: #0a84ff22; color: var(--accent); }
.badge.done { background: #34c75922; color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

.card { background: var(--card); border-radius: 14px; margin: 0 16px calc(10px * var(--s, 1)); padding: calc(14px * var(--s, 1)) 14px; }
.card .name { font-weight: 600; font-size: calc(17px * var(--s, 1)); display: flex; justify-content: space-between; gap: 8px; }
.card .line { margin-top: 6px; font-size: calc(14px * var(--s, 1)); }
.card .line b { color: var(--muted); font-weight: 500; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs > div { display: flex; width: 100%; max-width: 720px; }
.tab { flex: 1; border: 0; background: none; padding: 9px 0 8px; color: var(--muted); font-size: calc(11px * var(--s, 1)); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: calc(22px * var(--s, 1)); line-height: 1; }
.tab.on { color: var(--accent); }
.fab { position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: calc(30px * var(--s, 1)); box-shadow: 0 4px 14px #0004; }

.overlay { position: fixed; inset: 0; background: #0006; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 12px; font-size: calc(20px * var(--s, 1)); }
.sheet .hd { display: flex; justify-content: space-between; align-items: center; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: calc(12px * var(--s, 1)); color: var(--muted); margin: 0 4px 4px; text-transform: uppercase; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border-radius: 10px; border: 0; background: var(--card); min-height: 44px; }
.field textarea { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { border: 0; border-radius: 12px; padding: 13px; background: var(--accent); color: #fff; font-weight: 600; width: 100%; }
.btn.ghost { background: var(--card); color: var(--accent); }
.btn.danger { background: var(--card); color: var(--red); }
.link { background: none; border: 0; color: var(--accent); padding: 6px; }
.note { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: calc(14px * var(--s, 1)); }
.note small { color: var(--muted); display: block; }
.sec { margin: 18px 0 8px; font-size: calc(13px * var(--s, 1)); text-transform: uppercase; color: var(--muted); font-weight: 600; }
.addline { display: flex; gap: 8px; }
.addline input { flex: 1; padding: 11px 12px; border-radius: 10px; border: 0; background: var(--card); }
.addline button { width: auto; padding: 0 16px; }

.login { padding: 60px 24px; text-align: center; }
.login h1 { font-size: calc(32px * var(--s, 1)); margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login .field { text-align: left; }
.err { color: var(--red); margin: 8px 0; min-height: 20px; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #000d; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 20; }

a.row { color: inherit; text-decoration: none; }
.row[data-folder], .row[data-client], .row[data-task] { cursor: pointer; }
.group.two { margin-top: 0; }

/* ===== Клиенты: список и дерево ===== */
.mini { border: 0; background: var(--bg); color: var(--accent); min-width: calc(34px * var(--s, 1)); height: calc(34px * var(--s, 1)); padding: 0 10px; border-radius: 10px; font-size: calc(18px * var(--s, 1)); line-height: 1; flex: none; }
.mini.txt { font-size: calc(13px * var(--s, 1)); font-weight: 600; white-space: nowrap; }
.mini.arrow { color: var(--muted); font-size: calc(22px * var(--s, 1)); }
.mini.dim { opacity: .35; }
.client { border-bottom: 1px solid var(--line); }
.client:last-child { border-bottom: 0; }
.crow { display: flex; align-items: center; gap: 8px; padding: calc(10px * var(--s, 1)) 12px; }
.cname { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.tree { background: color-mix(in srgb, var(--bg) 55%, transparent); padding: 2px 0 6px; }
.nrow { display: flex; align-items: center; gap: 6px; padding: calc(5px * var(--s, 1)) 10px calc(5px * var(--s, 1)) 6px; border-top: 1px solid var(--line); outline: none; }
.nrow:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.nrow.hl { background: #ff950022; }
.grip { color: var(--muted); font-size: calc(18px * var(--s, 1)); width: 22px; text-align: center; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; flex: none; }
.ntitle { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ntitle small { display: block; color: var(--muted); font-size: calc(11px * var(--s, 1)); margin-top: 1px; }
.tag { font-size: calc(12px * var(--s, 1)); background: #0a84ff22; color: var(--accent); border-radius: 99px; padding: 3px 8px; white-space: nowrap; flex: none; }
.addrow { padding: calc(10px * var(--s, 1)) 14px; color: var(--accent); font-size: calc(14px * var(--s, 1)); border-top: 1px solid var(--line); cursor: pointer; }
.node.dragging { opacity: .4; }
.nrow.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.nrow.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.nrow.drop-inside { background: #0a84ff22; box-shadow: inset 0 0 0 2px var(--accent); }

/* ===== В работе ===== */
.wcard .name { align-items: center; }
.wbtns { display: flex; gap: 8px; align-items: center; }
.wchain { margin: 8px 0 4px; font-size: calc(14px * var(--s, 1)); }
.wlevel { padding: 3px 0; color: var(--muted); }
.wlevel.last { color: var(--text); font-weight: 700; }
.wlevel span { color: var(--muted); font-weight: 400; }
.wdone { opacity: .55; }
.wdone .wlevel.last { text-decoration: line-through; }
.wfoot { margin-top: 8px; display: flex; justify-content: flex-end; }
.badge.done { background: #34c75922; color: var(--green); }
.badge.work { background: #0a84ff22; color: var(--accent); }

/* ===== Задачи: блоки ===== */
.tblock .list { overflow: visible; }
.thead { display: flex; align-items: center; gap: 10px; padding: calc(12px * var(--s, 1)) 12px; }
.thead .main { flex: 1; min-width: 0; }
.tline .trow { display: flex; align-items: center; gap: 8px; padding-top: calc(8px * var(--s, 1)); padding-bottom: calc(8px * var(--s, 1)); padding-right: 10px; border-top: 1px solid var(--line); }
.tline .trow .main { flex: 1; min-width: 0; }
.tline .trow .title { overflow-wrap: anywhere; }
.tdn .title { text-decoration: line-through; color: var(--muted); }
.tdone { opacity: .6; }
.tdone .title { text-decoration: line-through; }
.tdone .mini { opacity: 1; }
.row a { color: inherit; text-decoration: none; }

.sub { color: var(--muted); font-size: calc(12px * var(--s, 1)); margin-top: 2px; }
.check { flex: none; }
.tline .trow .mini, .thead .mini, .crow .mini, .nrow .mini { min-width: calc(30px * var(--s, 1)); height: calc(30px * var(--s, 1)); padding: 0 7px; font-size: calc(16px * var(--s, 1)); }
.tline .trow .mini.txt, .nrow .mini.txt, .crow .mini.txt { font-size: calc(12px * var(--s, 1)); }
.tline .trow .mini.arrow, .thead .mini.arrow { font-size: calc(19px * var(--s, 1)); }
.tline .trow .title { font-size: calc(15px * var(--s, 1)); }
.tline .trow { gap: 6px; }

/* свайп влево по клиенту: кнопка «Удалить» */
.cwrap { position: relative; overflow: hidden; }
.crow { position: relative; background: var(--card); transition: transform .2s ease; }
.cwrap.swiped .crow { transform: translateX(-92px); }
.cdel { position: absolute; right: 0; top: 0; bottom: 0; width: 92px; border: 0; background: var(--red); color: #fff; font-weight: 600; font-size: calc(14px * var(--s, 1)); }

/* выбор нескольких клиентов */
.crow { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.selrow { gap: 12px; cursor: pointer; }
.selrow.picked { background: #0a84ff1a; }
.selbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; padding: 8px 12px; background: var(--card); border-radius: 12px; box-shadow: 0 2px 10px #0002; }
.selbar span { flex: 1; font-weight: 600; }
.selbar .del { color: var(--red); }
.selbar .del[disabled] { opacity: .4; }

.row .mini.txt[disabled] { opacity: .55; color: var(--green); }

/* название блока выглядит как неактивная кнопка: заметно выделено, но не нажимается */
.pill { display: inline-block; max-width: 100%; padding: 6px 12px; border-radius: 10px; background: color-mix(in srgb, var(--muted) 18%, transparent); border: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); color: var(--text); font-weight: 700; line-height: 1.3; cursor: default; -webkit-user-select: none; user-select: none; overflow-wrap: anywhere; }
.wlevel.last .pill { font-size: calc(14px * var(--s, 1)); }
.tdone .pill { font-weight: 600; text-decoration: line-through; }

/* метка «в работе ✕» в дереве клиента: нажатие снимает запись с работы */
button.tag { border: 0; font: inherit; font-size: calc(12px * var(--s, 1)); cursor: pointer; }
button.tag.on:hover, button.tag.on:active { background: #ff3b3022; color: var(--red); }

/* ползунок в настройках */
.field input[type=range] { padding: 0; min-height: 32px; background: none; accent-color: var(--accent); }
.hbtns { display: flex; align-items: center; gap: 2px; }
.top .who.gear { font-size: calc(20px * var(--s, 1)); padding: 4px 8px; }

/* кнопка «Удалить» видна только после свайпа (иначе при дробных размерах просвечивает красная полоска) */
.cdel { visibility: hidden; }
.cwrap.swiped .cdel { visibility: visible; }

/* кнопка «Напомнить»: подсвечена, если напоминание поставлено */
.mini.bell { font-size: calc(14px * var(--s, 1)); opacity: .75; }
.mini.bell.on { opacity: 1; background: #ff950033; }
