/* Смена — простой мобильный интерфейс: светлая и тёмная тема, крупные поля для пальца. */
:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1e2126; --muted: #6e747d; --line: #e1e4e8;
  --acc: #2563eb; --acc-ink: #fff; --warn: #c25a14; --warn-bg: #fff4ea; --ok: #157a3c; --bad: #b42318;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121417; --card: #1b1e23; --ink: #e8eaed; --muted: #9aa0a8; --line: #2c3037;
    --acc: #4f8cff; --warn: #f0a060; --warn-bg: #2d2016; --ok: #4cc27a; --bad: #ff7b6e; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.mb { margin-bottom: 12px; }
h2.first { margin-top: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--acc); }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
main.narrow { max-width: 480px; }
h1 { font-size: 1.45rem; margin: 4px 0 12px; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
nav.top { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
nav.top .brand { font-weight: 700; margin-right: auto; color: var(--ink); text-decoration: none; }
nav.top a { text-decoration: none; }
nav.top form { margin: 0; }
.flash { background: var(--card); border-left: 4px solid var(--acc); padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; }
.error { border-left-color: var(--bad); }
label { display: block; margin: 0 0 10px; font-weight: 600; font-size: .95rem; }
label .hint { font-weight: 400; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; margin-top: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); min-height: 44px;
}
textarea { min-height: 110px; }
button, .btn { display: inline-block; padding: 10px 16px; min-height: 44px; border-radius: 8px; border: 1px solid var(--acc);
  background: var(--acc); color: var(--acc-ink); cursor: pointer; text-decoration: none; font-weight: 600; }
button.ghost, .btn.ghost { background: transparent; color: var(--acc); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.small, .btn.small { padding: 4px 10px; min-height: 34px; font-size: .875rem; }
button.big { width: 100%; font-size: 1.1rem; padding: 14px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.choices label { margin: 0; font-weight: 500; }
.choices input { position: absolute; opacity: 0; }
.choices span { display: inline-block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.choices input:checked + span { border-color: var(--acc); background: var(--acc); color: var(--acc-ink); }
.choices input:focus-visible + span { outline: 2px solid var(--acc); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.row > * { flex: 1 1 140px; margin: 0; }
.row > .shrink { flex: 0 0 auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 0 0 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi b { display: block; font-size: 1.35rem; }
.kpi span { color: var(--muted); font-size: .85rem; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .85rem; border-bottom: 1px solid var(--line); padding: 6px; }
.tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; vertical-align: top; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); margin: 2px 2px 0 0; white-space: nowrap; }
.tag.ok { background: transparent; color: var(--ok); border: 1px solid var(--ok); }
.flag td { background: var(--warn-bg); }
.over { color: var(--warn); font-weight: 700; }
details { margin: 6px 0; }
details summary { cursor: pointer; color: var(--acc); }
details[open] summary { margin-bottom: 8px; }
.inline { display: inline; margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tabs a { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--card); }
.tabs a.on { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.person { border-top: 1px solid var(--line); padding: 10px 0; }
.person:first-child { border-top: 0; }
.person-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.person-head .pct { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.items { margin: 6px 0 0; padding: 0; list-style: none; }
.items li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; }
.items li .grow { flex: 1 1 200px; }
.items input[type=number] { width: 96px; min-height: 34px; padding: 4px 8px; margin: 0; }
.copy { word-break: break-all; background: var(--bg); padding: 10px; border-radius: 8px; border: 1px dashed var(--line); font-size: .9rem; }
.done { text-align: center; padding: 30px 14px; }
.done .big { font-size: 3rem; line-height: 1; }
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .tbl td, .tbl th { padding: 6px 4px; }
}

/* ---------- Рабочие страницы старших (есть верхнее меню): под компьютер, плотно ---------- */
body:has(nav.top) { font-size: 14px; }
nav.top { padding: 0 24px; min-height: 48px; gap: 4px 20px; }
nav.top a:not(.brand) { padding: 14px 2px; color: var(--muted); }
nav.top a:not(.brand):hover { color: var(--ink); }
nav.top ~ main { max-width: 1400px; padding: 20px 24px 40px; }
nav.top ~ main input[type=text], nav.top ~ main input[type=number], nav.top ~ main input[type=date], nav.top ~ main input[type=time],
nav.top ~ main input[type=search], nav.top ~ main select, nav.top ~ main textarea { min-height: 32px; padding: 5px 9px; margin-top: 0; border-radius: 6px; font-size: 14px; }
nav.top ~ main textarea { min-height: 96px; }
nav.top ~ main button, nav.top ~ main .btn, nav.top button { min-height: 32px; padding: 5px 12px; border-radius: 6px; font-size: 14px; }
nav.top ~ main label { font-size: 14px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.note { margin: 10px 0 0; }

/* Справочники: меню разделов слева, содержимое справа */
main.admin { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
.side { position: sticky; top: 16px; }
.side h1 { font-size: 1.15rem; margin: 2px 0 12px; }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav a { padding: 7px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.sidenav a:hover { background: var(--card); }
.sidenav a.on { background: var(--card); color: var(--acc); font-weight: 600; box-shadow: inset 2px 0 0 var(--acc); }
.pagehead { margin: 0 0 14px; }
.pagehead h2 { margin: 0 0 4px; font-size: 1.15rem; }
.pagehead h2 .muted { font-weight: 400; font-size: .9rem; margin-left: 6px; }
.pagehead p { margin: 0; max-width: 80ch; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.toolbar > * { flex: 0 0 auto; width: auto; }
.toolbar .w-search { width: 320px; }
.toolbar .check, label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 0 0 14px; }
.panel p { margin: 0 0 10px; }
.w-md { max-width: 760px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.copyrow { display: flex; gap: 8px; align-items: center; }
.copyrow code { flex: 1; padding: 6px 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow-wrap: anywhere; }

/* Таблица-редактор: строки 40px, поля выглядят как текст, рамка — при наведении и фокусе */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; table-layout: fixed; }
table.grid th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--card); white-space: nowrap; }
table.grid td { padding: 4px 10px; border-bottom: 1px solid var(--line); height: 40px; vertical-align: middle; }
table.grid tbody:last-child tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--acc) 4%, var(--card)); }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.act { text-align: right; white-space: nowrap; }
table.grid td.act > * { vertical-align: middle; }
table.grid td.empty { color: var(--muted); padding: 18px 10px; text-align: center; }
table.grid .c-grip { width: 34px; } table.grid .c-cat { width: 180px; } table.grid .c-norm { width: 120px; }
table.grid .c-flag { width: 110px; } table.grid .c-act { width: 190px; } table.grid .c-n { width: 90px; }
table.grid .c-name { width: 200px; } table.grid .c-src { width: 170px; } table.grid .c-dev { width: 100px; }
table.grid .c-when { width: 140px; } table.grid .c-what { width: 280px; }
table.grid tr.off td { color: var(--muted); }
table.grid tr.off .cell { color: var(--muted); }
table.grid tr.warnrow td { background: var(--warn-bg); }
table.grid tr.addrow td { background: var(--bg); }
table.grid input.cell, table.grid select.cell { width: 100%; border-color: transparent; background: transparent; padding-left: 6px; }
table.grid input.cell:hover, table.grid select.cell:hover { border-color: var(--line); }
table.grid input.cell:focus, table.grid select.cell:focus { border-color: var(--acc); background: var(--bg); outline: none; }
table.grid input.num { text-align: right; }
table.grid .tag { margin-left: 6px; }
table.grid form.merge { display: flex; gap: 6px; }
table.grid form.merge select { flex: 1; min-width: 0; }
.hint { font-size: 12.5px; }
button.link { background: none; border: 0; padding: 5px 6px; color: var(--acc); font-weight: 500; }
button.link.danger { color: var(--bad); }
button.link:hover { text-decoration: underline; }
/* «Сохранить» видна только у изменённой строки (static/app.js ставит .dirty) */
tr[data-dirty-row] button.save { visibility: hidden; }
tr[data-dirty-row].dirty button.save { visibility: visible; }
tr.dirty td { background: color-mix(in srgb, var(--acc) 8%, var(--card)) !important; }
.switch { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; cursor: pointer; }
.switch input { margin: 0; }

/* Перетаскивание порядка (роли, категории): за ⠿ — static/app.js, data-sortable */
.sortable td.grip { color: var(--muted); cursor: grab; text-align: center; font-size: 16px; -webkit-user-select: none; user-select: none; touch-action: none; }
.sortable td.grip:hover { color: var(--ink); }
.sortable tr.dragging td { background: var(--card) !important; }
.sortable tr.dragging { position: relative; z-index: 2; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); cursor: grabbing; }
.sortable.busy { opacity: .7; pointer-events: none; }
body.sorting, body.sorting * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 10; }

@media (max-width: 900px) {
  main.admin { grid-template-columns: 1fr; gap: 12px; }
  .side { position: static; }
  .sidenav { flex-direction: row; flex-wrap: wrap; }
  table.grid { table-layout: auto; }
}
/* Тише в покое: стрелка списка и «Удалить» — только у строки под мышью или в фокусе */
table.grid select.cell { -webkit-appearance: none; appearance: none; }
table.grid tr:hover select.cell, table.grid select.cell:focus { -webkit-appearance: auto; appearance: auto; }
table.grid td.act > .hint, table.grid td.act > form > .link.danger { opacity: 0; transition: opacity .12s ease; }
table.grid tr:hover td.act > .hint, table.grid tr:hover td.act > form > .link.danger, table.grid td.act .link.danger:focus-visible { opacity: 1; }
table.grid .withtag { display: flex; align-items: center; gap: 6px; } table.grid .withtag .cell { flex: 1; min-width: 0; } table.grid .withtag .tag { margin: 0; }

/* ---------- Смена (под компьютер) ---------- */
.shifthead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin: 0 0 14px; }
.shifthead h1 { margin: 0; font-size: 1.3rem; }
.shifthead h1 .muted { font-weight: 400; font-size: .95rem; }
.daynav { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.daynav input[type=date] { width: 150px; }
.daynav .btn { min-width: 34px; text-align: center; }
.stats { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.stats > div { padding: 10px 18px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stats span { display: block; color: var(--muted); font-size: 12.5px; }
.stats b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stats b.warn { color: var(--warn); }
.shiftgrid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.shiftside { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }
.shiftside .panel { margin: 0; }
.panel h2 { font-size: 1rem; margin: 0 0 10px; }
.field { margin: 0 0 10px; font-size: 13px; }
.field select[size] { min-height: 0; padding: 4px; }
.inlinefields { display: flex; gap: 8px; align-items: end; }
.inlinefields > .grow { flex: 1; margin: 0; }
.inlinefields > input, .inlinefields > select { flex: 1; min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
button.wide { width: 100%; }
table.grid.people { table-layout: fixed; }
table.grid .c-role { width: 130px; } table.grid .c-time { width: 110px; } table.grid .c-pct { width: 100px; } table.grid .c-more { width: 150px; }
.person-row { cursor: pointer; }
.person-row td { border-top: 1px solid var(--line); }
.person-block:first-of-type .person-row td { border-top: 0; }
.person-row.picked td { background: color-mix(in srgb, var(--acc) 12%, var(--card)) !important; }
.item-row td { height: 34px; border-bottom: 0; padding-top: 2px; padding-bottom: 2px; }
.item-row .item-name { padding-left: 16px; color: var(--muted); }
.item-row .item-name::before { content: ""; display: inline-block; width: 8px; height: 1px; background: var(--line); vertical-align: middle; margin: 0 8px 0 -16px; }
.qtyform { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.qtyform input { width: 74px; }
table.grid .item-row td.act > form > .link.danger { opacity: 0; }
table.grid .item-row:hover td.act > form > .link.danger { opacity: 1; }
details.menu { position: relative; display: inline-block; text-align: left; }
details.menu summary { list-style: none; display: inline-block; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; width: 300px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); padding: 12px; display: flex; flex-direction: column; gap: 10px; cursor: default; }
.menu-panel form { margin: 0; }
.menu-panel .field { margin: 0 0 6px; }
.menu-panel .hint { margin: 4px 0 0; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini td { padding: 4px 0; border-bottom: 1px solid var(--line); }
table.mini tr:last-child td { border-bottom: 0; }
table.mini .num { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; white-space: nowrap; }
.reports { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 460px)); gap: 14px; }
.reports .panel { margin: 0; }
@media (max-width: 1100px) {
  .shiftgrid { grid-template-columns: 1fr; }
  .shiftside { position: static; }
}
table.grid .c-qty { width: 90px; }
.qtyform input { width: 80px; }
.btn.quiet, button.quiet { background: transparent; border-color: var(--line); color: var(--muted); font-weight: 500; }
.btn.quiet:hover, details.menu[open] .btn.quiet { color: var(--ink); border-color: var(--muted); }
.stats { display: inline-flex; }
td.num .qtyform { display: flex; justify-content: flex-end; }
.person-row td:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qtyform input { -moz-appearance: textfield; padding-right: 0; }
.qtyform input::-webkit-outer-spin-button, .qtyform input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
table.grid.people .c-more { width: 90px; } table.grid.people .c-src { width: 130px; } table.grid.people .c-time { width: 100px; }
table.grid .c-role2 { width: 150px; } table.grid .c-status { width: 190px; } table.grid .c-save { width: 110px; }
button.tagbtn { min-height: 26px !important; padding: 2px 10px !important; border-radius: 999px !important; font-size: 12.5px !important;
  color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-bg); }
button.tagbtn:hover { border-color: var(--warn); }

/* Исправления 2026-10-24 (скрин пользователя): меню «Ещё» обрезалось таблицей (overflow:hidden), а текст полей
   в ячейках стоял правее заголовков колонок. */
table.grid { overflow: visible; }
table.grid thead tr:first-child th:first-child { border-top-left-radius: 8px; }
table.grid thead tr:first-child th:last-child { border-top-right-radius: 8px; }
table.grid tbody:last-child tr:last-child td:first-child { border-bottom-left-radius: 8px; }
table.grid tbody:last-child tr:last-child td:last-child { border-bottom-right-radius: 8px; }
/* Текст поля — ровно под заголовком колонки: поле выходит влево на свою рамку+отступ */
table.grid input.cell, table.grid select.cell { margin-left: -7px; width: calc(100% + 7px); padding-left: 6px; }
table.grid input.cell.num { margin-left: 0; margin-right: -7px; padding-right: 6px; }
details.menu[open] { z-index: 6; }
.menu-panel { white-space: normal; }
table.grid tr.locked td { color: var(--ink); }
.lockmark { display: inline-block; font-size: 12.5px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
/* Сортировка по заголовкам (data-sort) */
table.grid th[data-sort] { cursor: pointer; -webkit-user-select: none; user-select: none; }
table.grid th[data-sort]:hover { color: var(--ink); }
table.grid th[data-sort]::after { content: "↕"; margin-left: 5px; opacity: .35; font-weight: 400; }
table.grid th[aria-sort=ascending]::after { content: "▲"; opacity: .9; font-size: 10px; }
table.grid th[aria-sort=descending]::after { content: "▼"; opacity: .9; font-size: 10px; }
table.grid th[aria-sort=ascending], table.grid th[aria-sort=descending] { color: var(--ink); }
table.grid th[data-sort]:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
/* Фильтры по колонкам (data-filter) */
table.grid thead tr.filters th { padding: 4px 6px 8px; border-bottom: 1px solid var(--line); font-weight: 400; }
table.grid thead:has(tr.filters) tr:first-child th { border-bottom: 0; }
table.grid .filter { width: 100%; min-height: 28px !important; padding: 3px 7px !important; font-size: 13px !important; }
table.grid .filter.on { border-color: var(--acc); }
.tablebar { display: flex; align-items: center; gap: 12px; min-height: 32px; margin: 0 0 8px; }
table.grid tr[hidden] { display: none; }
/* Диалог объединения дублей */
dialog.dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
  padding: 18px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
dialog.dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog.dialog h2 { margin: 0 0 10px; font-size: 1.05rem; }
dialog.dialog p { margin: 0 0 10px; }
dialog.dialog input[type=text] { min-height: 34px; padding: 6px 10px; margin-top: 4px; border-radius: 6px; font-size: 14px; }
dialog.dialog button { min-height: 32px; padding: 5px 12px; border-radius: 6px; font-size: 14px; }
dialog.dialog button:disabled { opacity: .45; cursor: not-allowed; }
