:root {
  --bg: #f4f6f8; --card: #fff; --ink: #16222c; --muted: #66737f; --line: #e3e8ec;
  --brand: #0b4f6c; --brand-2: #0e6b8f; --gold: #e0a800; --sky: #00a3c4;
  --green: #1f8a4c; --blue: #1d64c2; --violet: #6b4bc4; --red: #c23a3a; --amber: #b7791f; --gray: #5d6b78;
  --r: 14px; --shadow: 0 1px 2px rgba(16,34,48,.06), 0 4px 16px rgba(16,34,48,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f161c; --card: #172129; --ink: #e6edf2; --muted: #93a2ae; --line: #26333d;
    --brand: #4fb3d9; --brand-2: #6cc4e4; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
body.noscroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  outline: none; min-height: 44px;
}
input:focus, select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 8px 0; }
.err { color: var(--red); font-size: 14px; min-height: 1em; margin: 4px 0; }
.lbl { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
code { font-size: 12px; word-break: break-all; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; font-size: 15px; white-space: nowrap; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost:hover { background: color-mix(in srgb, var(--brand) 6%, var(--card)); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); flex: none; }
.iconbtn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

.seg { display: inline-flex; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg.lang button { padding: 6px 9px; font-size: 12px; letter-spacing: .02em; }

/* Шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.top .logo { width: 36px; height: 36px; border-radius: 9px; }
.top .ttl { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top .ttl b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ttl small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wrap { max-width: 820px; margin: 0 auto; padding: 14px 16px 40px; }
.wrap.narrow { max-width: 620px; }
.demo { background: #fff3cd; color: #6b5100; border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600; margin-bottom: 10px; text-align: center; }

/* Баннеры */
.banner { border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; line-height: 1.45; }
.banner.warn { background: color-mix(in srgb, var(--amber) 13%, var(--card)); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); }
.banner.notif { display: flex; gap: 12px; align-items: center; background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line); flex-wrap: wrap; }
.banner.notif .bell { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--amber); flex: none; }
.banner.notif .txt { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.banner.notif .txt span { color: var(--muted); font-size: 13px; }

/* Статистика */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.worktime { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 2px; }
.worktime i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }
.worktime.quiet i { background: var(--gray); box-shadow: none; }

/* Фильтры */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.searchbox input { padding-left: 38px; }
.row { display: flex; gap: 10px; overflow-x: auto; }
.row.two > * { flex: 1; min-width: 0; }
.row .seg { flex: none; }

/* Лента */
.day { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 4px 8px; font-weight: 700; }
.day::first-letter { text-transform: uppercase; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px; }
.item:hover { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.line1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.line1 b { font-size: 15px; }
.line2 { display: flex; align-items: center; gap: 7px; min-width: 0; }
.fname { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; align-self: flex-start; padding-top: 2px; }

.avatar { --h: 200; width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: hsl(var(--h) 55% 90%); color: hsl(var(--h) 55% 28%); }
.avatar.big { width: 44px; height: 44px; font-size: 15px; }
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h) 35% 26%); color: hsl(var(--h) 60% 85%); } }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.green  { background: color-mix(in srgb, var(--green) 13%, transparent);  color: var(--green); }
.badge.blue   { background: color-mix(in srgb, var(--blue) 13%, transparent);   color: var(--blue); }
.badge.violet { background: color-mix(in srgb, var(--violet) 13%, transparent); color: var(--violet); }
.badge.red    { background: color-mix(in srgb, var(--red) 13%, transparent);    color: var(--red); }
.badge.amber  { background: color-mix(in srgb, var(--amber) 15%, transparent);  color: var(--amber); }
.badge.gray   { background: color-mix(in srgb, var(--gray) 13%, transparent);   color: var(--gray); }
@media (prefers-color-scheme: dark) { .badge { filter: brightness(1.5); } }

.ficon { width: 20px; height: 20px; border-radius: 4px; flex: none; display: grid; place-items: center; font-size: 8px; color: #fff; }
.ficon b { font-weight: 800; letter-spacing: -.02em; }
.ficon svg { width: 18px; height: 18px; fill: #8a9aa8; stroke: none; }
.ficon-pdf { background: #d93025; } .ficon-word { background: #2b579a; font-size: 10px; } .ficon-gdoc { background: #4285f4; font-size: 10px; }
.ficon-sheet { background: #1e7145; font-size: 10px; } .ficon-slides { background: #c55a11; font-size: 10px; } .ficon-image { background: #8e44ad; font-size: 11px; }
.ficon-file { background: #8a9aa8; } .ficon-folder { background: none; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty svg { width: 40px; height: 40px; opacity: .5; }
.empty b { color: var(--ink); }

/* Карточка события (нижний лист на телефоне, окно на компьютере) */
.sheet-bg { position: fixed; inset: 0; background: rgba(10,20,28,.42); z-index: 40; animation: fade .15s; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92vh; background: var(--card); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; animation: up .2s ease-out; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 720px) {
  .sheet { left: 50%; top: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%); width: 560px; max-height: 86vh; border-radius: 18px; animation: fade .15s; }
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 8px 20px; border-bottom: 1px solid var(--line); position: relative; }
.sheet-head b { flex: 1; font-size: 17px; }
.grab { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 36px; height: 4px; border-radius: 2px; background: var(--line); }
@media (min-width: 720px) { .grab { display: none; } }
.sheet-body { overflow-y: auto; padding: 8px 20px 24px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: 12px 0; border-bottom: 1px solid var(--line); margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { font-size: 15px; min-width: 0; word-break: break-word; }
@media (max-width: 420px) { .kv { grid-template-columns: 1fr; } .kv dt { border: 0; padding-bottom: 0; font-size: 12px; } }
.who { display: flex; align-items: center; gap: 10px; }
.who small { display: block; color: var(--muted); font-size: 13px; }
.filecell { display: flex; gap: 8px; align-items: flex-start; }
.filecell .ficon { margin-top: 1px; }
.sheet-body h4 { margin: 24px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; }
.hitem { display: flex; gap: 10px; align-items: center; padding: 8px 0; font-size: 14px; }
.hitem small { display: block; color: var(--muted); font-size: 12px; }
.hitem .avatar { width: 30px; height: 30px; font-size: 11px; }

/* Настройки */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 16px; margin: 0 0 6px; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; font-size: 15px; }
.setrow span { color: var(--muted); }
.ok { color: var(--green); } .bad { color: var(--red); }
.inline { display: flex; gap: 8px; }
.people { display: flex; flex-direction: column; gap: 10px; }
.person small { color: var(--muted); font-size: 12px; display: block; margin-top: 3px; }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center; }
.login-card form { text-align: left; }
.login-top { display: flex; justify-content: flex-end; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; margin: 4px auto 12px; display: block; }
.login-card h1 { font-size: 22px; margin: 0; }
.login-card p.muted { margin: 4px 0 8px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #16222c; color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.loading { min-height: 100vh; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 480px) {
  .stat b { font-size: 20px; }
  .top .ttl small { display: none; }
  .top .ttl b { font-size: 16px; }
}

/* Путь к файлу */
.line3 { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.line3 { align-items: flex-start; }
.line3 span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.line3 .fsvg { margin-top: 1px; }
.fsvg { width: 14px; height: 14px; flex: none; fill: color-mix(in srgb, var(--gold) 55%, transparent); stroke: none; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 14px; }
.crumbs a { padding: 3px 8px; border-radius: 7px; background: color-mix(in srgb, var(--brand) 8%, transparent); color: var(--brand); font-weight: 600; }
.crumbs a.root { font-weight: 500; color: var(--muted); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.crumbs span { color: var(--muted); }
#volume[hidden] { display: none; }

/* Изменения текста */
.w { font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.w.plus { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.w.minus { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); margin-left: 4px; }
.snip { display: flex; gap: 6px; font-size: 13px; line-height: 1.4; padding: 6px 9px; border-radius: 8px; margin-top: 2px; min-width: 0; }
.snip b { flex: none; }
.snip span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.snip.plus { background: color-mix(in srgb, var(--green) 9%, transparent); color: color-mix(in srgb, var(--green) 70%, var(--ink)); }
.snip.minus { background: color-mix(in srgb, var(--red) 8%, transparent); color: color-mix(in srgb, var(--red) 70%, var(--ink)); }
.sheet-body h4 .w { text-transform: none; letter-spacing: 0; margin-left: 6px; }
.tdiff { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.tblock { border-radius: 10px; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; }
.tblock.add { border-left-color: var(--green); }
.tblock.del { border-left-color: var(--red); }
.tblock.mod { border-left-color: var(--blue); }
.tblock small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tblock small:empty { display: none; }
.tblock p { margin: 0; font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
ins { text-decoration: none; background: color-mix(in srgb, var(--green) 20%, transparent); color: color-mix(in srgb, var(--green) 55%, var(--ink)); border-radius: 3px; padding: 0 1px; }
del { background: color-mix(in srgb, var(--red) 14%, transparent); color: color-mix(in srgb, var(--red) 60%, var(--ink)); text-decoration: line-through; border-radius: 3px; padding: 0 1px; }

/* Отчёт */
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; }
.rhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 22px 2px 12px; flex-wrap: wrap; }
.rhead h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.rhead p { margin: 4px 0 0; color: var(--muted); }
.rsub { margin: 0 0 8px; font-size: 15px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.rtable th:first-child, .rtable td:first-child { text-align: left; }
.rtable td { text-align: right; padding: 8px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rtable td.plus { color: var(--green); font-weight: 600; } .rtable td.minus { color: var(--red); font-weight: 600; }
.who.sm .avatar { width: 28px; height: 28px; font-size: 11px; }
.rfile-h { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.rfile-h .ficon { margin-top: 2px; }
.rfile-h b { font-size: 16px; }
.rday { margin: 14px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rev { padding: 8px 0 4px; border-bottom: 1px dashed var(--line); }
.rev:last-child { border-bottom: 0; }
.rev-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rev-h time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 40px; }
.rev-h .avatar { width: 26px; height: 26px; font-size: 10px; }
.rev-h .more { margin-left: auto; color: var(--muted); font-size: 20px; padding: 0 8px; }
.rev .tdiff { margin-left: 0; }
@media print {
  .top, .noprint, #toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: auto; }
  .rev { break-inside: avoid; }
  .wrap { max-width: none; padding: 0; }
  ins, del, .w, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.snip.mod { background: color-mix(in srgb, var(--ink) 4%, transparent); color: var(--ink); }
.scroll { overflow-x: auto; }
@media (max-width: 480px) { .rtable { font-size: 13px; } .rtable th { font-size: 11px; } }
.who.link, .filecell.link { color: inherit; }
.who.link:hover b, .filecell.link:hover b, a.rfile-h:hover b, a.who.sm:hover b { color: var(--brand); text-decoration: underline; }
.go { display: block; color: var(--brand) !important; font-size: 13px; margin-top: 3px; font-weight: 600; }
a.who.sm { display: inline-flex; align-items: center; gap: 8px; color: inherit; }
a.rfile-h { color: inherit; }
.rtitle { display: flex; gap: 12px; align-items: center; }
