/* VERTO Web — «смуга як герой».
   Інтерфейс тихий і світлий; головний візуальний елемент — смуга прогресу, де видно, що перекладено, що на вичитці й де зараз працюють люди. */

:root {
  --bg: #eef1f6;
  --surface: #f7f8fb;
  --raised: #ffffff;
  --ink: #121a2b;
  --ink-2: #46526a;
  --ink-3: #76829a;
  --rule: #d3dae5;
  --rule-soft: #e3e8f0;
  --focus: #3355ff;
  --focus-soft: #e1e7ff;
  --on-focus: #ffffff;
  --none: #c3cbd8;
  --review: #e0a100;
  --review-soft: #fbf0cc;
  --done: #12997a;
  --done-soft: #d5f0e8;
  --danger: #d6443a;
  --danger-soft: #fbe0dd;
  --shadow-sm: 0 1px 2px rgba(18, 26, 43, .06), 0 1px 1px rgba(18, 26, 43, .04);
  --shadow-md: 0 8px 24px rgba(18, 26, 43, .12), 0 2px 6px rgba(18, 26, 43, .06);
  --r-s: 8px; --r-m: 12px; --r-l: 16px;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: var(--sans); /* шрифти без засічок */
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111c; --surface: #111827; --raised: #172033; --ink: #e8edf5; --ink-2: #a8b3c7; --ink-3: #7b879d;
    --rule: #2a3550; --rule-soft: #1f2942; --focus: #8199ff; --focus-soft: #222f5a; --on-focus: #0c111c;
    --none: #38435b; --review: #f0b429; --review-soft: #3a3016; --done: #34c29e; --done-soft: #153a31;
    --danger: #f07a6e; --danger-soft: #3d1f1b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 10px 30px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  --bg: #0c111c; --surface: #111827; --raised: #172033; --ink: #e8edf5; --ink-2: #a8b3c7; --ink-3: #7b879d;
  --rule: #2a3550; --rule-soft: #1f2942; --focus: #8199ff; --focus-soft: #222f5a; --on-focus: #0c111c;
  --none: #38435b; --review: #f0b429; --review-soft: #3a3016; --done: #34c29e; --done-soft: #153a31;
  --danger: #f07a6e; --danger-soft: #3d1f1b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 10px 30px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; text-size-adjust: 100%;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 650; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.025em; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 17px; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* ── Верхня панель ── */
.topbar {
  position: sticky; top: 0; z-index: 30; flex: none; height: var(--top-h);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.topbar a { color: var(--ink); }
.topbar a:hover { text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: 0.01em; }
.brand-mark { display: inline-flex; gap: 2px; align-items: flex-end; height: 18px; }
.brand-mark i { display: block; width: 4px; border-radius: 1.5px; background: var(--done); }
.brand-mark i:nth-child(1) { height: 18px; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 12px; background: var(--review); }
.brand-mark i:nth-child(4) { height: 7px; background: var(--none); }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink-3); font-size: 14px; }
.crumbs > * + *::before { content: "/"; margin-right: 6px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); white-space: nowrap; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .here { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: none; font-size: 28px; line-height: 1; padding: 0 6px 4px 0; color: var(--ink-2) !important; }
.who { display: flex; align-items: center; gap: 6px; }
.top-link { padding: 6px 10px; border-radius: var(--r-s); color: var(--ink-2) !important; font-size: 14px; }
.top-link:hover { background: var(--rule-soft); }

/* ── Аватари ── */
.avatar {
  width: var(--s, 28px); height: var(--s, 28px); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; color: #fff; font-size: calc(var(--s, 28px) * .4); font-weight: 650; letter-spacing: 0;
  background: hsl(var(--h, 220) 52% 44%); box-shadow: 0 0 0 2px var(--bg);
}
:root[data-theme="dark"] .avatar { background: hsl(var(--h, 220) 45% 38%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h, 220) 45% 38%); } }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -6px; }
.avatar.more { background: var(--rule); color: var(--ink-2); }

/* ── Меню ── */
.menu-root { position: relative; display: inline-block; }
.menu-panel {
  position: absolute; top: calc(100% + 6px); z-index: 40; min-width: 230px; max-width: calc(100vw - 24px); padding: 6px;
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r-m); box-shadow: var(--shadow-md);
}
.menu-panel.right { right: 0; }
.menu-panel.left { left: 0; }
.menu-panel hr { border: 0; border-top: 1px solid var(--rule-soft); margin: 6px 0; }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--ink); cursor: pointer; font-size: 14px; white-space: normal;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--rule-soft); text-decoration: none; outline: none; }
.menu-item.danger { color: var(--danger); }
.user-btn { letter-spacing: 0 !important; font-size: 14px !important; gap: 8px !important; padding: 3px 10px 3px 4px !important; border-radius: 999px !important; font-weight: 600; }
.user-btn .avatar { box-shadow: none; }

/* ── Сторінки ── */
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px 72px; }
.page.narrow { max-width: 580px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin-top: 6px; max-width: 64ch; }

/* ── Кнопки та поля ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; min-height: 38px;
  border-radius: var(--r-s); cursor: pointer; font-weight: 550; font-size: 14px;
  background: var(--raised); border: 1px solid var(--rule); color: var(--ink); text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--focus); border-color: var(--focus); color: var(--on-focus); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 11px; min-height: 30px; font-size: 13px; }
.btn.icon { padding: 0 10px; min-width: 38px; font-size: 18px; line-height: 1; letter-spacing: 1px; }
.btn.review { border-color: var(--review); background: var(--review-soft); }
.btn.done { border-color: var(--done); background: var(--done-soft); }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn.ghost:hover { border-color: var(--rule); }
.row-actions { display: flex; gap: 8px; align-items: center; }

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r-s); padding: 8px 12px; min-height: 38px; width: 100%;
}
input[type=search] { -webkit-appearance: none; appearance: none; }
select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
label.field { display: block; margin-bottom: 16px; }
label.field > span { display: block; margin-bottom: 5px; font-size: 14px; color: var(--ink-2); font-weight: 550; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--focus); margin: 0; }

.notice { padding: 12px 16px; border-left: 3px solid var(--focus); background: var(--focus-soft); margin: 12px 0; border-radius: 0 var(--r-s) var(--r-s) 0; }
.notice.warn { border-color: var(--review); background: var(--review-soft); }
.notice.error { border-color: var(--danger); background: var(--danger-soft); }
.error-text { color: var(--danger); min-height: 1.4em; margin: 8px 0; }

/* ── Вхід ── */
.login {
  width: min(440px, calc(100% - 32px)); margin: 9vh auto 0; padding: 32px; background: var(--raised);
  border: 1px solid var(--rule-soft); border-radius: var(--r-l); box-shadow: var(--shadow-md);
}
.login h1 { font-size: 34px; margin-bottom: 6px; }
.login .strip-wrap { margin: 22px 0 26px; }
.login .tabs { margin-bottom: 20px; }
.login .btn.primary { width: 100%; padding: 11px; }

/* ── Вкладки ── */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; padding: 4px; background: var(--rule-soft); border-radius: var(--r-m); width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 7px 16px; cursor: pointer; color: var(--ink-2); border-radius: var(--r-s); white-space: nowrap; font-weight: 550;
}
.tabs button[aria-selected=true] { color: var(--ink); background: var(--raised); box-shadow: var(--shadow-sm); }

/* ── Картки ── */
.card {
  background: var(--raised); border: 1px solid var(--rule-soft); border-radius: var(--r-m); padding: 18px 20px; box-shadow: var(--shadow-sm); color: inherit;
}
a.card:hover { border-color: var(--focus); text-decoration: none; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.project-card { display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 19px; overflow-wrap: anywhere; }
.card-desc { color: var(--ink-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 60ch; }
.card-progress { display: flex; align-items: center; gap: 16px; margin-top: auto; }
.card-foot { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); padding-top: 12px; border-top: 1px solid var(--rule-soft); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--done); font-weight: 550; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--done); }

.big-pct { font-size: 40px; line-height: 1; font-weight: 700; letter-spacing: -0.035em; white-space: nowrap; }
.big-pct small { font-size: 20px; font-weight: 600; color: var(--ink-3); margin-left: 2px; letter-spacing: 0; }
.fig-line { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.fig-line i, .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
i.k-none { background: var(--none); } i.k-review { background: var(--review); } i.k-done { background: var(--done); }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--rule-soft); color: var(--ink-2); }
.pill.on { background: var(--done-soft); color: var(--done); }
.pill.admin { background: var(--focus-soft); color: var(--focus); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); max-width: 52ch; margin: 0 auto; }
.empty strong { display: block; font-size: 20px; color: var(--ink); margin-bottom: 6px; font-weight: 650; }

/* ── Смуга прогресу ── */
.strip { position: relative; height: 22px; width: 100%; }
.strip canvas { display: block; width: 100%; height: 100%; border-radius: 6px; }
.strip.tall { height: 38px; cursor: pointer; }
.strip.tall canvas { border-radius: 10px; }
.strip .pin {
  position: absolute; top: -4px; width: 0; height: 0; transform: translateX(-5px);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--ink);
}
.strip .pin:hover::after, .strip .pin:focus::after {
  content: attr(data-name); position: absolute; top: -28px; left: -4px; transform: translateX(-30%);
  background: var(--ink); color: var(--bg); font-size: 12px; padding: 2px 8px; border-radius: 6px; white-space: nowrap;
}
.strip .cursor { position: absolute; top: -2px; bottom: -2px; width: 3px; border-radius: 2px; background: var(--focus); box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.bar { display: flex; height: 10px; width: 100%; background: var(--none); border-radius: 999px; overflow: hidden; }
.bar.tall { height: 16px; }
.bar > i { display: block; height: 100%; }
.bar > i.k-done { background: var(--done); } .bar > i.k-review { background: var(--review); }

/* ── Проєкт ── */
.hero { background: var(--raised); border: 1px solid var(--rule-soft); border-radius: var(--r-l); padding: 24px 26px; box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.hero-top { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.hero .sub { color: var(--ink-2); margin-top: 8px; max-width: 70ch; }
.hero-figs { display: flex; align-items: center; gap: 24px; margin-top: 22px; }
.hero .big-pct { font-size: 52px; }
.hero .stat-line { margin-top: 14px; font-size: 14px; color: var(--ink-2); }

.file-list { display: grid; gap: 12px; }
.file-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(220px, 1fr) auto; gap: 14px 28px; align-items: center; padding: 16px 20px; }
.file-name { overflow-wrap: anywhere; }
.file-name .dir { color: var(--ink-3); font-size: 13px; display: block; }
.file-name .base { font-weight: 650; font-size: 16px; }
.file-meta { font-size: 13px; color: var(--ink-2); margin-top: 6px; display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; }
.file-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.who-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }

.dropzone {
  border: 2px dashed var(--rule); border-radius: var(--r-m); padding: 18px 20px; margin: 0 0 18px; color: var(--ink-2);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--surface);
}
.dropzone.over { border-color: var(--focus); background: var(--focus-soft); }
.upload-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.upload-list li { display: flex; gap: 10px; padding: 2px 0; }
.upload-list .ok { color: var(--done); } .upload-list .bad { color: var(--danger); }

.member { background: var(--raised); border: 1px solid var(--rule-soft); border-radius: var(--r-m); padding: 14px 18px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.member-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.member-head .name { font-weight: 650; min-width: 150px; }
.member-files { margin-top: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--rule-soft); border-radius: var(--r-s); }
.file-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 18px; margin-top: 10px; max-height: 280px; overflow: auto; }
.file-checks .check { font-size: 14px; word-break: break-all; }
.saved { font-size: 13px; color: var(--done); }

table.plain { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--raised); border: 1px solid var(--rule-soft); border-radius: var(--r-m); overflow: hidden; }
table.plain th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 13px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--rule-soft); }
table.plain td { padding: 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.plain tr:last-child td { border-bottom: 0; }
td.contacts { font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.log-line { padding: 10px 4px; border-bottom: 1px solid var(--rule-soft); font-size: 14px; display: grid; grid-template-columns: 130px 140px 1fr; gap: 12px; }
.log-line .txt { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-line { display: flex; justify-content: space-between; gap: 24px; padding: 6px 0; border-bottom: 1px solid var(--rule-soft); }

dialog { border: 1px solid var(--rule); background: var(--raised); color: var(--ink); padding: 24px; width: min(460px, 92vw); border-radius: var(--r-l); box-shadow: var(--shadow-md); }
dialog::backdrop { background: rgba(8, 12, 22, .55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
dialog h3 { margin-bottom: 14px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
dialog .check { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 8px); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-m); font-size: 14px; max-width: min(460px, 90vw); opacity: 0; pointer-events: none; z-index: 60;
  box-shadow: var(--shadow-md); transition: opacity .15s, transform .15s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* ── Редактор ── */
body.editor-page { height: 100%; overflow: hidden; }
.editor { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; }
.editor-top { background: var(--raised); border-bottom: 1px solid var(--rule); padding: 10px 24px 8px; flex: none; }
.editor-stats { display: flex; gap: 8px 28px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; font-size: 14px; color: var(--ink-2); }
.stat-main { display: flex; align-items: baseline; gap: 10px; }
.editor-stats .big-pct { font-size: 30px; }
.editor-stats .big-pct small { font-size: 16px; }
.stat-extra { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.editor-stats b { color: var(--ink); font-weight: 650; }
.editor-stats i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.editor-stats .peers { margin-left: auto; display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; }
.peer { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.peer .avatar { box-shadow: none; }
.editor-strip-row { padding-top: 6px; }
.editor-top .legend { margin-top: 6px; font-size: 12px; }
.editor-top .hint-click { margin-left: auto; }

.toolbar { flex: none; padding: 8px 24px; background: var(--bg); border-bottom: 1px solid var(--rule); }
.toolbar-row { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 0 1 260px; min-width: 150px; }
.toolbar input.goto { width: 100px; flex: none; }
.toolbar .chips { flex: 1 1 360px; min-width: 0; }
.toolbar .menu-root { margin-left: auto; }
.toolbar .sel-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.toolbar .count { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; cursor: pointer;
  background: var(--raised); border: 1px solid var(--rule); color: var(--ink-2); font-size: 13px; font-weight: 550; white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); }
.chip[aria-selected=true] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { font-size: 12px; opacity: .75; }
.chip .n:empty { display: none; }

.grid { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--raised); }
.grid-head, .grid-row { display: grid; grid-template-columns: 56px minmax(120px, 0.7fr) minmax(0, 1.5fr) minmax(0, 1.5fr) 44px; }
.grid-head { background: var(--surface); border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--ink-3); font-weight: 600; flex: none; padding-right: 15px; }
.grid-head > div { padding: 8px 12px; }
.grid-body { flex: 1; overflow-y: scroll; position: relative; min-height: 0; outline-offset: -2px; -webkit-overflow-scrolling: touch; }
.grid-spacer { position: relative; width: 100%; }
.grid-row { position: absolute; left: 0; right: 0; height: 54px; border-bottom: 1px solid var(--rule-soft); cursor: default; background: var(--raised); }
.grid-row > div { padding: 6px 12px; overflow: hidden; font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.grid-row > .c-n { color: var(--ink-3); font-size: 12px; padding-top: 8px; display: block; }
.grid-row > .c-id { color: var(--ink-3); font-size: 12px; word-break: break-all; }
.grid-row > .c-st { display: flex; align-items: center; justify-content: center; padding: 0; }
.grid-row:hover { background: var(--surface); }
.grid-row.st-1 { box-shadow: inset 4px 0 0 var(--review); }
.grid-row.st-2 { box-shadow: inset 4px 0 0 var(--done); }
.grid-row.sel { background: var(--focus-soft); }
.grid-row.active { background: var(--focus-soft); outline: 2px solid var(--focus); outline-offset: -2px; z-index: 1; }
.grid-row .peer-tag { position: absolute; right: 52px; top: 5px; font-size: 11px; background: var(--ink); color: var(--bg); padding: 0 7px; border-radius: 8px; z-index: 2; }
.grid-row.loading > div { color: transparent; }
.grid-row.loading .c-tr { background: linear-gradient(90deg, var(--rule-soft), transparent); }
.tok { background: var(--focus-soft); border-radius: 3px; padding: 0 3px; color: var(--ink); }
.glyph { width: 18px; height: 18px; display: block; }

.dock { flex: none; background: var(--raised); border-top: 1px solid var(--rule); box-shadow: 0 -6px 18px rgba(18, 26, 43, .06); padding: 14px 24px 16px; }
.dock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dock .src-box { background: var(--surface); border: 1px solid var(--rule-soft); border-radius: var(--r-s); padding: 9px 12px; min-height: 88px; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.dock textarea { min-height: 88px; max-height: 150px; resize: vertical; font-family: var(--sans); }
.dock-label { font-size: 13px; color: var(--ink-2); margin-bottom: 5px; display: flex; gap: 10px; align-items: baseline; font-weight: 550; }
.dock-label .id { color: var(--ink-3); word-break: break-all; font-weight: 400; }
.dock-label .sheet-close { display: none; margin-left: auto; }
.dock-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.dock-actions .hint { color: var(--ink-3); font-size: 12px; margin-left: auto; }
.warnings { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; min-height: 22px; }
.warnings .w { font-size: 12px; background: var(--review-soft); color: var(--ink); padding: 2px 9px; border-left: 3px solid var(--review); border-radius: 0 6px 6px 0; }
.conflict { margin-top: 8px; }
.ro-note { color: var(--ink-2); font-size: 13px; margin-top: 8px; }

/* ── Планшет ── */
@media (max-width: 1000px) {
  .file-card { grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr); }
  .file-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .dock-actions .hint { display: none; }
}

/* ── Телефон ── */
@media (max-width: 760px) {
  :root { --top-h: 52px; }
  body { font-size: 16px; }
  h1 { font-size: 25px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .back { display: block; }
  .brand-name, .crumbs a, .top-link, .who-name, .crumbs > *::before { display: none !important; }
  .crumbs .here { font-size: 16px; }
  .crumbs { flex: 1; }
  .spacer { display: none; }
  .page { padding: 18px 16px 56px; }
  .page-head { margin-bottom: 18px; }
  .card-grid { grid-template-columns: 1fr; }
  .hero { padding: 18px; border-radius: var(--r-m); }
  .hero-figs { flex-direction: column; align-items: stretch; gap: 14px; }
  .hero .big-pct { font-size: 44px; }
  .hero-top .row-actions { width: 100%; }
  .hero-top .row-actions .btn:first-child { flex: 1; }
  .file-card { grid-template-columns: 1fr; padding: 16px; }
  .file-actions .btn.primary { flex: 1; min-height: 44px; }
  .login { margin-top: 5vh; padding: 24px 20px; }

  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; }
  input[type=text], input[type=password], input[type=search], input[type=number], select, textarea { min-height: 44px; font-size: 16px; }
  .menu-item { padding: 13px 14px; font-size: 15px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; padding: 10px 12px; }

  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-l) var(--r-l) 0 0; padding: 22px 18px calc(22px + var(--safe-b)); }
  dialog .row { flex-direction: column-reverse; }
  dialog .row .btn { width: 100%; }
  #toast { bottom: calc(16px + var(--safe-b)); }

  /* таблиці адмінки стають картками */
  table.plain, table.plain tbody, table.plain tr, table.plain td { display: block; }
  table.plain { background: none; border: 0; }
  table.plain thead { display: none; }
  table.plain tr { background: var(--raised); border: 1px solid var(--rule-soft); border-radius: var(--r-m); margin-bottom: 10px; padding: 6px 4px; box-shadow: var(--shadow-sm); }
  table.plain td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 7px 12px; text-align: right; }
  table.plain td::before { content: attr(data-label); color: var(--ink-3); font-size: 13px; text-align: left; flex: none; }
  table.plain td:first-child { font-size: 16px; }
  table.plain td:last-child { display: block; }
  table.plain td:last-child::before { display: none; }
  .actions { justify-content: flex-start; }
  table.users-table td:first-child::before { display: none; }
  table.users-table td:first-child { text-align: left; }
  table.users-table td.num { width: auto; padding-right: 12px; }
  table.users-table tbody tr:hover td { background: none; }
  table.users-table td.actions-cell { width: auto; }
  .log-line { grid-template-columns: 1fr; gap: 2px; }

  /* редактор */
  .editor-top { padding: 10px 14px 8px; }
  .editor-stats { margin-bottom: 8px; gap: 6px 14px; }
  .editor-stats .big-pct { font-size: 26px; }
  .stat-extra { display: none; }
  .editor-stats .peers { margin-left: 0; width: 100%; }
  .editor-top .legend { display: none; }
  .strip.tall { height: 30px; }
  .toolbar { padding: 8px 14px; }
  .toolbar input[type=search] { flex: 1 1 0; }
  .toolbar input.goto { display: none; }
  .toolbar .chips { order: 3; flex: 1 0 100%; margin: 0 -14px; padding: 0 14px 2px; scroll-snap-type: x proximity; }
  .toolbar .menu-root { order: 2; }
  .toolbar .count { order: 4; flex: 1 0 100%; }
  .toolbar .sel-actions { order: 5; flex: 1 0 100%; margin: 0; }
  .chip { scroll-snap-align: start; min-height: 36px; }

  .grid-head { display: none; }
  .grid-row { grid-template-columns: minmax(0, 1fr) 40px; grid-template-rows: 1fr 1fr; grid-template-areas: "src st" "tr st"; }
  .grid-row > .c-n, .grid-row > .c-id { display: none; }
  .grid-row > .c-src { grid-area: src; align-self: start; -webkit-line-clamp: 1; padding: 10px 6px 0 14px; font-size: 14px; }
  .grid-row > .c-tr { grid-area: tr; align-self: start; -webkit-line-clamp: 1; padding: 0 6px 0 14px; margin-bottom: 8px; font-size: 14px; color: var(--ink-2); }
  .grid-row > .c-st { grid-area: st; }
  .grid-row.loading > .c-tr { background: none; }
  .grid-row .peer-tag { right: 44px; top: 3px; }

  /* поки відкрита панель редагування, зайве зверху ховаємо — рядки лишаються видимими */
  .editor.has-active .editor-top, .editor.has-active .toolbar { display: none; }
  .dock { padding: 10px 14px calc(10px + var(--safe-b)); border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: 0 -10px 30px rgba(18, 26, 43, .18); max-height: 62dvh; max-height: 62vh; overflow-y: auto; }
  .editor:not(.has-active) .dock { display: none; }
  .dock-grid { grid-template-columns: 1fr; gap: 8px; }
  .dock-label { flex-wrap: nowrap; white-space: nowrap; margin-bottom: 4px; }
  .dock-label .id { display: none; }
  .dock-label .sheet-close { display: inline-flex; min-height: 32px; padding: 2px 10px; }
  .dock .src-box { min-height: 0; max-height: 64px; font-size: 15px; padding: 6px 10px; }
  .dock textarea { min-height: 84px; max-height: 30vh; }
  .warnings { min-height: 0; }
  .dock-actions { gap: 6px; margin-top: 8px; }
  .dock-actions .btn { flex: 1 1 auto; min-height: 38px; font-size: 13px; padding: 4px 10px; }
  .dock-actions .btn.primary { flex: 1 1 100%; order: -1; min-height: 48px; font-size: 15px; }
  .dock-actions .btn.ghost { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
  .btn:active { transform: none; }
}

/* Адмінка: користувачі */
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.user-search { flex: 1 1 260px; max-width: 360px; }
table.users-table { overflow: visible; }
table.users-table th.num, table.users-table td.num { text-align: right; width: 1%; white-space: nowrap; padding-right: 20px; }
table.users-table tr:first-child th:first-child { border-top-left-radius: var(--r-m); }
table.users-table tr:first-child th:last-child { border-top-right-radius: var(--r-m); }
table.users-table tbody tr:hover td { background: var(--surface); }
table.users-table tr.row-off .user-cell { opacity: .6; }
.user-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-info { min-width: 0; }
.user-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-sub { font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere; }
td.actions-cell { width: 1%; white-space: nowrap; }
td.actions-cell .actions { flex-wrap: nowrap; align-items: center; }

/* Активність: фільтри й сторінки */
.activity .filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 14px; }
.activity .f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 130px; }
.activity .f.grow { flex: 1 1 260px; }
.activity .f input, .activity .f select { width: 100%; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0; font-size: 13px; }
.pager-btns { display: inline-flex; align-items: center; gap: 6px; }
.pager-cur { padding: 0 6px; color: var(--ink-2); }
@media (max-width: 640px) { .activity .f { flex: 1 1 45%; } .activity .f.grow { flex-basis: 100%; } .pager { justify-content: center; } }
.activity .f input, .activity .f select { height: 38px; box-sizing: border-box; }
.activity .f { justify-content: flex-end; min-width: 0; }
.activity .f.reset .btn { height: 38px; }
.activity .f:not(.grow):not(.reset) { flex: 0 1 150px; }
.activity .f.grow { flex: 1 1 180px; }
.activity .f:not(.grow):not(.reset) { flex: 0 1 140px; }
.activity .f.reset { flex: 0 0 auto; }
.activity input[type=date] { border: 1px solid var(--rule); border-radius: 10px; background: var(--raised); color: var(--ink); font: inherit; padding: 0 10px; }
/* Фільтри активності: усі елементи рівно 38px, кнопка «Скинути» вирівняна по нижньому краю */
.activity .filters { align-items: flex-end; }
.activity .f input, .activity .f select, .activity .f.reset .btn { height: 38px; min-height: 38px; max-height: 38px; box-sizing: border-box; margin: 0; }
.activity .f.reset { align-self: flex-end; justify-content: flex-end; }
.activity .f.reset .btn { padding: 0 18px; font-size: 14px; line-height: 1; }
.activity .f.reset > span { display: none; }

/* Ролі: іконки й вибір ролі */
.role-ic { flex: none; display: inline-block; vertical-align: -0.2em; }
.pill.role { display: inline-flex; align-items: center; gap: 5px; }
.role-select { position: relative; display: inline-block; }
.role-trigger {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 12px; min-width: 160px;
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r-s); color: var(--ink); font: inherit; cursor: pointer; text-align: left;
}
.role-trigger:hover:not(:disabled) { border-color: var(--ink-3); }
.role-trigger:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
.role-trigger:disabled { opacity: .55; cursor: not-allowed; }
.role-trigger .role-name { flex: 1; }
.role-trigger .chev { color: var(--ink-3); font-size: 12px; }
.role-panel { min-width: 220px; z-index: 30; }
.role-opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.role-opt .role-name { flex: 1; }
.role-opt .tick { color: var(--ink-2); }
.role-opt[aria-selected=true] { font-weight: 600; }
