:root {
  --accent: #1b6b55; --accent-ink: #fff; --accent-soft: #d9ece5;
  --bg: #e8ecef; --panel: #f3f5f7; --surface: #fff; --ink: #1c2328; --muted: #66727d;
  --line: #d5dbe0; --danger: #c0392b; --warn: #b7791f; --ok: #1e8e5a;
  --shadow: 0 1px 2px rgba(20,30,40,.14);
  --r: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2f9c7d; --accent-soft: #1d3a32;
    --bg: #14171a; --panel: #1c2024; --surface: #272c32; --ink: #e6eaed; --muted: #94a0ab;
    --line: #353c44; --shadow: 0 1px 2px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; }
#app { height: 100dvh; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }

.btn { background: var(--accent); color: var(--accent-ink); padding: 9px 14px; border-radius: 8px; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.field { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea.field { resize: vertical; min-height: 70px; line-height: 1.4; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

/* верхняя панель */
.top { display: flex; align-items: center; gap: 4px; background: var(--accent); color: #fff;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px; flex: none; }
.top h1 { font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.top button { color: #fff; min-width: 40px; height: 40px; border-radius: 8px; font-size: 14px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.top button:active, .top button:hover { background: rgba(255,255,255,.16); }
.top svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* вход */
.login { margin: auto; width: min(340px, 90vw); display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 26px; text-align: center; margin-bottom: 8px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* список досок */
.home { overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); flex: 1; }
.home h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border-radius: var(--r); padding: 14px; text-align: left; box-shadow: var(--shadow); min-height: 74px; display: flex; flex-direction: column; justify-content: space-between; border-left: 4px solid var(--accent); }
.tile b { font-size: 16px; font-weight: 600; }
.tile small { color: var(--muted); }
.tile.closed { opacity: .55; border-left-color: var(--muted); }
.tile.new { border: 1px dashed var(--line); border-left-width: 1px; box-shadow: none; background: transparent; color: var(--muted); justify-content: center; align-items: center; }

/* доска */
.board { flex: 1; display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; overflow-y: hidden;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.list { flex: none; width: 290px; max-height: 100%; background: var(--panel); border-radius: var(--r); display: flex; flex-direction: column; }
.list > header { display: flex; align-items: flex-start; gap: 6px; padding: 10px 6px 6px 12px; }
.list h2 { font-size: 14px; flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; cursor: grab; }
.list .count { color: var(--muted); font-size: 12px; padding-top: 2px; }
.list .more { width: 30px; height: 26px; border-radius: 6px; color: var(--muted); font-size: 18px; line-height: 1; }
.list .more:hover { background: var(--line); }
.cards { flex: 1; overflow-y: auto; padding: 2px 8px; min-height: 28px; display: flex; flex-direction: column; gap: 7px; -webkit-overflow-scrolling: touch; }
.kcard { background: var(--surface); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); cursor: pointer; overflow-wrap: anywhere; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.kcard:hover { outline: 1.5px solid var(--accent); }
.kcard .name { line-height: 1.35; }
.kcard.ghost { opacity: .35; }
/* старение: карточка без движения выцветает и желтеет, при наведении возвращается */
.kcard.age1 { opacity: .8; background: color-mix(in srgb, #d9c38a 14%, var(--surface)); }
.kcard.age2 { opacity: .62; background: color-mix(in srgb, #d9c38a 26%, var(--surface)); }
.kcard.age3 { opacity: .45; background: color-mix(in srgb, #c9a95a 38%, var(--surface)); }
.kcard[class*="age"]:hover, .kcard[class*="age"].drag { opacity: 1; }
/* огонёк на просроченной карточке */
.kcard { position: relative; }
.kcard.hot { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--danger) 55%, transparent), var(--shadow); }
.kcard.hot .name { padding-right: 22px; }
.flame { position: absolute; top: 4px; right: 6px; font-size: 17px; line-height: 1; transform-origin: 50% 90%;
  animation: flame 1.1s ease-in-out infinite; filter: drop-shadow(0 0 4px rgba(255,120,0,.75)); pointer-events: none; }
@keyframes flame {
  0%, 100% { transform: scale(1) rotate(-4deg); filter: drop-shadow(0 0 3px rgba(255,120,0,.6)); }
  30% { transform: scale(1.18, 1.28) rotate(3deg); filter: drop-shadow(0 0 8px rgba(255,80,0,.95)); }
  60% { transform: scale(.94, 1.08) rotate(-2deg); filter: drop-shadow(0 0 5px rgba(255,160,0,.8)); }
}
@media (prefers-reduced-motion: reduce) { .flame { animation: none; } }
.kcard.drag { transform: rotate(2deg); box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.labs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.lab { height: 8px; min-width: 36px; border-radius: 4px; font-size: 0; }
.lab.named { height: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; color: #fff; }
.lab-green { background: #3c9d63; } .lab-yellow { background: #c9a50d; } .lab-orange { background: #d9822b; }
.lab-red { background: #cf513d; } .lab-purple { background: #8f6bc4; } .lab-blue { background: #3d7fd1; }
.lab-sky { background: #3aa3c4; } .lab-lime { background: #7fae3a; } .lab-pink { background: #cf5f9c; } .lab-black { background: #56616b; }
.badges { display: flex; flex-wrap: wrap; gap: 4px 9px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.badges:empty { display: none; }
.badge { display: inline-flex; align-items: center; gap: 3px; }
.badge.due { padding: 1px 6px; border-radius: 5px; background: var(--panel); }
.badge.due.over { background: var(--danger); color: #fff; }
.badge.due.soon { background: #e0b43a; color: #2b2100; }
.badge.due.done { background: var(--ok); color: #fff; }
.badge.full { color: var(--ok); font-weight: 600; }
.avas { margin-left: auto; display: flex; gap: 3px; }
.ava { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.add-card { margin: 6px 8px 8px; padding: 8px; border-radius: 8px; text-align: left; color: var(--muted); }
.add-card:hover { background: var(--line); color: var(--ink); }
.add-form { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.list.new { background: transparent; border: 1px dashed var(--muted); }
.list.new button { padding: 12px; color: var(--muted); width: 100%; text-align: left; }

/* диалоги */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(10,15,20,.55); }
.small-dlg { width: min(420px, 94vw); max-height: 86dvh; }
.small-dlg .body { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 86dvh; overflow-y: auto; }
.small-dlg h3 { font-size: 17px; }
.small-dlg .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.pick { display: flex; flex-direction: column; gap: 2px; }
.pick button { text-align: left; padding: 10px 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 10px; }
.pick button:hover { background: var(--line); }
.pick button.cur { background: var(--accent-soft); font-weight: 600; }

.card-dlg { width: min(760px, 100vw); max-height: 92dvh; margin-top: 4dvh; }
.card-dlg .wrap { display: flex; flex-direction: column; max-height: 92dvh; }
.card-dlg .head { display: flex; align-items: flex-start; gap: 6px; padding: 12px 10px 4px 14px; flex: none; }
.card-dlg .title { flex: 1; font-size: 19px; font-weight: 600; border: 0; background: transparent; resize: none; padding: 4px; border-radius: 6px; line-height: 1.3; min-height: 0; field-sizing: content; }
.card-dlg .title:focus { background: var(--surface); outline: 2px solid var(--accent); }
.x { width: 38px; height: 38px; border-radius: 8px; font-size: 22px; color: var(--muted); flex: none; }
.x:hover { background: var(--line); }
.card-dlg .scroll { overflow-y: auto; padding: 0 18px calc(18px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.where { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.where select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); max-width: 60vw; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 16px; border: 1px solid var(--line); font-size: 13px; }
.chip:not(.lab-chip) { background: var(--surface); }
.card-dlg .scroll:focus { outline: 0; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.chip.lab-chip { color: #fff; border: 0; font-weight: 600; min-height: 28px; min-width: 44px; }
.chip.lab-chip.off { opacity: .35; }
.sec { margin-top: 18px; }
.sec > h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sec > h4 .sp { flex: 1; }
.link { color: var(--accent); font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.link.red { color: var(--danger); }
.desc { background: var(--surface); border-radius: 8px; padding: 10px 12px; line-height: 1.45; overflow-wrap: anywhere; min-height: 44px; cursor: text; }
.desc.empty { color: var(--muted); }
.cl-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.cl-bar i { display: block; height: 100%; background: var(--ok); }
.item { display: flex; align-items: flex-start; gap: 10px; padding: 6px 4px; border-radius: 6px; }
.item:hover { background: var(--surface); }
.item input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.item .grow { line-height: 1.35; overflow-wrap: anywhere; cursor: pointer; }
.item.done .itxt { text-decoration: line-through; color: var(--muted); }
.imeta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 3px; font-size: 12px; color: var(--muted); }
.imeta .who { display: inline-flex; align-items: center; gap: 4px; }
.imeta .ava { width: 18px; height: 18px; font-size: 9px; }
.addr { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: 8px; padding: 9px 12px; margin: 6px 0; line-height: 1.35; overflow-wrap: anywhere; }
.addr .row { gap: 16px; }
.addr-go { text-align: left; font-weight: 600; color: var(--accent); line-height: 1.35; overflow-wrap: anywhere; }
.small-dlg .acts { flex-wrap: wrap; }
.small-dlg .body { overflow-x: hidden; }
.row .field { min-width: 0; }
.addr a { font-weight: 600; text-decoration: none; }
.small-dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.item .del, .cm .del { color: var(--muted); font-size: 18px; width: 26px; height: 24px; opacity: .6; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.file { background: var(--surface); border-radius: 8px; overflow: hidden; position: relative; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.file .pv { height: 90px; display: flex; align-items: center; justify-content: center; background: var(--line); font-weight: 700; color: var(--muted); font-size: 14px; }
.file img { width: 100%; height: 90px; object-fit: cover; display: block; }
.file .nm { font-size: 12px; padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 1; }
.cm { background: var(--surface); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
.cm .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.cm .meta b { color: var(--ink); }
.cm .txt { margin-top: 3px; line-height: 1.4; overflow-wrap: anywhere; }
.act { font-size: 12.5px; color: var(--muted); padding: 3px 0; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.urow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.urow:last-child { border: 0; }

/* виды доски: таблица, календарь, хронология, панель */
.alt { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); gap: 8px; -webkit-overflow-scrolling: touch; }
.vhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: none; }
.vhead .field { max-width: 380px; flex: 1 1 200px; }
.vtitle { font-size: 16px; min-width: 130px; text-align: center; text-transform: capitalize; }
.dates { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 6px 0; }
.dates label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.tbl-wrap { overflow: auto; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); flex: 1; min-height: 0; }
.tbl { border-collapse: collapse; width: 100%; min-width: 760px; }
.tbl th { position: sticky; top: 0; background: var(--panel); text-align: left; z-index: 1; white-space: nowrap; }
.tbl th button, .tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.tbl th button { padding: 9px 10px; width: 100%; text-align: left; } .tbl th:not(:has(button)) { padding: 9px 10px; }
.tbl td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.tbl tr[data-card] { cursor: pointer; } .tbl tr[data-card]:hover td { background: var(--accent-soft); }
.tbl .t-name { min-width: 240px; font-weight: 500; overflow-wrap: anywhere; }
.tbl .labs { margin: 0; } .tbl .who { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; margin-right: 6px; }
.cal-wd { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; font-size: 12px; color: var(--muted); text-align: center; flex: none; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; flex: 1; min-height: 420px; }
.day { background: var(--surface); border-radius: 8px; padding: 3px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.day.other { opacity: .5; } .day.wkend { background: var(--panel); }
.day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.dn { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 2px 4px; display: flex; justify-content: space-between; }
.day.today .dn { color: var(--accent); }
.more-n { background: var(--line); border-radius: 8px; padding: 0 5px; font-size: 11px; }
.dchips { flex: 1; display: flex; flex-direction: column; gap: 2px; min-height: 26px; }
.cchip { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 4px; padding: 2px 4px; font-size: 11.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; user-select: none; -webkit-user-select: none; }
.cchip.over { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
.cchip.soon { border-left-color: #e0b43a; } .cchip.done { border-left-color: var(--ok); opacity: .6; text-decoration: line-through; }
.cchip.hid { display: none; }
.tl { overflow: auto; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); flex: 1; min-height: 0; }
.tl-row { display: flex; border-bottom: 1px solid var(--line); }
.tl-lab { position: sticky; left: 0; z-index: 2; flex: none; width: 140px; padding: 8px; font-size: 12.5px; font-weight: 600; background: var(--panel); border-right: 1px solid var(--line); overflow-wrap: break-word; hyphens: auto; line-height: 1.25; }
.tl-track { position: relative; flex: 1; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: var(--dw) 100%; }
.tl-days { position: sticky; top: 0; z-index: 3; background: var(--panel); }
.tl-days .tl-track { display: flex; background-image: none; }
.tl-d { width: var(--dw); flex: none; text-align: center; font-size: 10px; color: var(--muted); padding: 3px 0; display: flex; flex-direction: column; line-height: 1.2; position: relative; }
.tl-d b { font-size: 13px; color: var(--ink); } .tl-d.wkend b { color: var(--danger); } .tl-d i { font-style: normal; color: var(--accent); font-weight: 700; }
.tl-d.today { background: var(--accent); border-radius: 6px; } .tl-d.today, .tl-d.today b { color: #fff; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .5; }
.tl-bar { position: absolute; height: 24px; line-height: 24px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 12px; padding: 0 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tl-bar.over { background: var(--danger); } .tl-bar.soon { background: #c9971a; } .tl-bar.done { background: var(--ok); opacity: .65; }
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; align-content: start; }
.tiles3 { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat, .dcard { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; }
.stat b { font-size: 28px; display: block; line-height: 1.1; } .stat span { color: var(--muted); font-size: 13px; } .stat.bad b { color: var(--danger); }
.dcard h3 { font-size: 14px; margin-bottom: 10px; }
.brow { display: grid; grid-template-columns: minmax(0, 38%) 1fr 34px; gap: 8px; align-items: center; padding: 3px 0; font-size: 13px; }
.bl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .brow b { text-align: right; }
.bt { height: 14px; background: var(--panel); border-radius: 4px; overflow: hidden; } .bt i { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
@media (max-width: 640px) { .tl-lab { width: 96px; font-size: 11.5px; } .cchip { font-size: 10px; padding: 2px 2px; border-left-width: 2px; } .cal-grid { gap: 2px; } .cal-wd { gap: 2px; } }

/* карта */
#map { flex: 1; min-height: 0; background: var(--bg); font: inherit; z-index: 0; }
.pin { width: 0 !important; height: 0 !important; }
.pin-in { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; cursor: pointer; padding-bottom: 7px; }
.pin-in .cap { background: #fff; color: #1c2328; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 9px; box-shadow: 0 1px 4px rgba(0,0,0,.35); max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.pin-in .ph { width: 50px; height: 50px; border-radius: 10px; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.45); background: var(--accent) center/cover; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.pin-in::after { content: ""; position: absolute; bottom: 0; width: 0; height: 0; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; filter: drop-shadow(0 2px 1px rgba(0,0,0,.3)); }
.pin-in.over .ph { border-color: var(--danger); }
.leaflet-popup-content { margin: 10px 12px; font: inherit; font-size: 14px; color: #1c2328; }
.mc { display: flex; flex-direction: column; gap: 6px; min-width: 210px; }
.mc .phs { display: flex; gap: 4px; }
.mc .phs img { flex: 1; min-width: 0; height: 74px; object-fit: cover; border-radius: 6px; background: #dde2e6; }
.mc b { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.mc small { color: #66727d; line-height: 1.3; }
.mc .row { flex-wrap: wrap; gap: 6px 12px; margin-top: 2px; }
.mc .btn { color: #fff; }
.mc a, .mc .link { color: #1b6b55; font-weight: 600; text-decoration: none; font-size: 13px; }
.lost { position: absolute; z-index: 500; left: 10px; bottom: calc(22px + env(safe-area-inset-bottom)); background: #fff; color: #1c2328; padding: 8px 12px; border-radius: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.35); font-weight: 600; font-size: 13px; }
.map-wrap { flex: 1; min-height: 0; position: relative; display: flex; }

.toast { z-index: 3000; position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #22282e; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 99; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.35); }

@media (max-width: 640px) {
  .board { scroll-snap-type: x proximity; gap: 8px; padding-left: 8px; padding-right: 8px; scroll-padding: 8px; }
  .list { width: 86vw; scroll-snap-align: start; }
  .kcard { padding: 10px 11px; }
  .card-dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .card-dlg .wrap { max-height: 100dvh; height: 100dvh; }
  .card-dlg .head { padding-top: calc(env(safe-area-inset-top) + 10px); }
  .top .lbl { display: none; }
  .field, .card-dlg .title, .where select { font-size: 16px; }
}

/* фильтр и сводка по человеку */
.top button.lit { background: #fff; color: var(--accent); }
.fbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 7px 12px; background: var(--accent-soft); font-size: 13px; flex: none; line-height: 1.35; }
.fgrp { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.fgrp .chips { margin: 2px 0; }
.small-dlg .chip.lab-chip.on { outline: 2px solid var(--ink); outline-offset: 1px; opacity: 1; }
.pstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; font-size: 11.5px; color: var(--muted); }
.pstats span { background: var(--surface); border-radius: 8px; padding: 8px 2px; display: flex; flex-direction: column; }
.pstats b { font-size: 20px; color: var(--ink); } .pstats .bad b, .ph4.bad { color: var(--danger); }
.ph4 { margin: 8px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pick button { align-items: center; }

/* уведомления */
.top button { position: relative; }
.nb { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; padding: 0 4px; }
.top button.dot::after { content: ""; position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; border: 2px solid var(--accent); }
.pbox { background: var(--surface); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.4; }
.pbox.ok { color: var(--ok); } .pbox .btn { width: 100%; }
.nlist button { text-align: left; line-height: 1.35; font-size: 13.500px; border-left: 3px solid transparent; }
.nlist button.unread { border-left-color: var(--accent); background: var(--surface); }
.nlist button b { font-size: 14px; }

/* журнал действий */
.small-dlg.wide { width: min(720px, 96vw); }
.jrow { padding: 6px 4px; border-bottom: 1px solid var(--line); line-height: 1.4; font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.jrow[data-open] { cursor: pointer; } .jrow[data-open]:hover { background: var(--surface); }

/* вложение, помеченное неактуальным */
.file .del { font-size: 17px; line-height: .6; padding-bottom: 6px; }
.file.void img, .file.void .pv { opacity: .35; filter: grayscale(1); }
.file.void .nm { text-decoration: line-through; color: var(--muted); }
.file.void::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 90px; pointer-events: none;
  background: linear-gradient(to top right, transparent calc(50% - 2px), var(--danger) calc(50% - 2px), var(--danger) calc(50% + 2px), transparent calc(50% + 2px)); }
.vnote { font-size: 11.5px; line-height: 1.3; padding: 0 8px 7px; color: var(--ink); overflow-wrap: anywhere; }
.vnote b { color: var(--danger); } .vnote span { color: var(--muted); }

/* чаты в мессенджерах */
.mi { width: 18px; height: 18px; flex: none; }
.badge .mi { width: 14px; height: 14px; }
.chip .mi + .mi { margin-left: -9px; }
.chats { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.chat { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 8px; padding: 8px 6px 8px 12px; text-decoration: none; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.chat .mi { width: 28px; height: 28px; }
.chat small { display: block; font-weight: 400; color: var(--danger); font-size: 11.5px; }
.chat.void .grow { text-decoration: line-through; color: var(--muted); } .chat.void small { text-decoration: none; display: block; }
.chat.void .mi { filter: grayscale(1); opacity: .5; }
.chat .del { color: var(--muted); font-size: 18px; width: 34px; height: 30px; flex: none; }

/* ---------- деньги ---------- */
:root { --s-in: #2a78d6; --s-out: #eb6834; }
@media (prefers-color-scheme: dark) { :root { --s-in: #3987e5; --s-out: #d95926; } }
.top button.rub { font-size: 18px; font-weight: 700; }
.badge.fin { background: var(--panel); padding: 1px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.badge.fin .pos { color: var(--ok); } .badge.fin .neg, .ftbl .neg { color: var(--danger); }
.fin-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 6px; margin-bottom: 8px; }
.fs { background: var(--panel); border-radius: 8px; padding: 7px 10px; text-align: left; display: block; }
.fs span { display: block; font-size: 12px; color: var(--muted); } .fs b { font-size: 15.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
button.fs:hover { outline: 1.5px solid var(--accent); }
.fs.good b { color: var(--ok); } .fs.bad b { color: var(--danger); } .fs.warn b, .ftbl .warn { color: var(--warn); }
.fin-rows { display: flex; flex-direction: column; }
.fr { display: flex; gap: 10px; align-items: baseline; text-align: left; padding: 7px 4px; border-top: 1px solid var(--line); width: 100%; }
.fr:hover { background: var(--accent-soft); }
.fr .d { color: var(--muted); font-size: 12.5px; min-width: 76px; } .fr .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fr .amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fr .amt.in { color: var(--ok); }
.fin { padding: 14px; max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; height: calc(100% - 52px); }
.fin .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.fin .stat b { font-size: 21px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fbox { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; }
.fbox h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; } .fbox h2 .sp { flex: 1; }
.fin-year { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 8px; padding: 8px 10px; font-size: 15px; }
.fin-year option { color: #000; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
i.s-in, .cb i.s-in { background: var(--s-in); } i.s-out { background: var(--s-out); }
.chart { width: 100%; height: auto; display: block; }
.chart .g { stroke: var(--line); stroke-width: 1; } .chart .ax { fill: var(--muted); font-size: 11px; }
.chart path.s-in { fill: var(--s-in); } .chart path.s-out { fill: var(--s-out); }
.chart .hit { fill: transparent; } .chart .mcol:hover .hit { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ftbl { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.ftbl th, .ftbl td { padding: 6px 8px; text-align: right; white-space: nowrap; border-top: 1px solid var(--line); }
.ftbl th:first-child, .ftbl td:first-child, .ftbl.obj td:nth-child(2), .ftbl.obj th:nth-child(2) { text-align: left; }
.ftbl tr:first-child th { border-top: 0; color: var(--muted); font-weight: 600; }
.ftbl tr.sum td, .ftbl tr.sum th, .ftbl .tot { font-weight: 700; }
.ftbl.obj td.nm { white-space: normal; min-width: 180px; max-width: 320px; }
.ftbl.obj tr[data-fin] { cursor: pointer; } .ftbl.obj tr[data-fin]:hover td { background: var(--accent-soft); } .ftbl.obj tr.arch td { opacity: .65; }
.ftbl th button { font: inherit; color: inherit; font-weight: 600; }
.cbars { display: flex; flex-direction: column; gap: 6px; }
.cb { display: grid; grid-template-columns: minmax(110px, 200px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.cb .t { background: var(--panel); border-radius: 4px; height: 12px; overflow: hidden; } .cb .t i { display: block; height: 100%; background: var(--s-out); border-radius: 0 4px 4px 0; }
.cb .v { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; } .cb .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fin-tip { position: fixed; z-index: 50; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 6px 9px; border-radius: 6px; pointer-events: none; max-width: 280px; }

/* обложка карточки */
.kcard .cover { margin: -8px -10px 8px; border-radius: 8px 8px 0 0; overflow: hidden; background: var(--panel); }
.kcard .cover img { display: block; width: 100%; height: 132px; object-fit: cover; pointer-events: none; }
.kcard[class*="age"] .cover img { filter: saturate(.75); }
.file.is-cover { outline: 2px solid var(--accent); }
.pin-in .ph { position: relative; } .pin-in .flame { top: -13px; right: -13px; font-size: 20px; }
.badge.fin { white-space: nowrap; }

/* ---------- просмотр вложений ---------- */
.viewer { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #16181b; color: #fff; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: #000; }
.v-top { display: flex; align-items: center; gap: 10px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; background: #22262b; flex: none; }
.v-x { background: #fff; color: #16181b; font-weight: 700; font-size: 15px; padding: 10px 16px; border-radius: 10px; white-space: nowrap; }
.v-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: #c9d1d9; }
.v-dl { color: #fff; font-size: 22px; text-decoration: none; padding: 6px 12px; border-radius: 8px; }
.v-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); text-align: center; touch-action: pan-x pan-y pinch-zoom; }
.v-body .v-pg { display: block; width: 100%; max-width: 1100px; height: auto; margin: 0 auto 8px; background: #fff; cursor: zoom-in; }
.v-body[data-kind="image"] .v-pg { background: none; max-height: calc(100dvh - 90px); width: auto; max-width: 100%; object-fit: contain; }
.v-body.zoom .v-pg { width: 260%; max-width: none; max-height: none; cursor: zoom-out; }
.v-body video { width: 100%; max-height: calc(100dvh - 90px); background: #000; }
.v-body audio { width: min(520px, 92%); margin-top: 30vh; }
.v-wait, .v-count { padding: 14px; color: #9aa4ae !important; font-size: 13px; }
.v-msg { padding: 60px 20px; line-height: 2.2; }
.v-body[data-kind="stl"] { padding: 0; overflow: hidden; position: relative; }
.v-3d { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.v-dims { position: absolute; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 14px; color: #e6eaed; pointer-events: none; text-shadow: 0 1px 3px #000; }
.v-dims span { font-size: 12px; color: #9aa4ae; }
.v-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.v-labels span { position: absolute; transform: translate(-50%, -50%); background: #fff; color: #16181b; font-size: 13px; font-weight: 700; padding: 2px 7px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.v-dims b { font-weight: 600; }
