/* agrodo: общий стиль кабинета, входа и лендинга.
   Палитра: белый и светло-серый фон, почти чёрный текст, жёлтый акцент. Жёлтым красим кнопки и отметки,
   текст на белом жёлтым не пишем: он не читается, для этого есть --accent-text. */
:root {
  --bg: #F5F6F8; --surface: #FFFFFF; --ink: #25282D; --muted: #777C85; --line: #E3E5E9;
  --accent: #FBC503; --accent-dark: #F2BE00; --accent-soft: #FFF3BF; --accent-text: #F0B400;
  --accent-ink: #25282D; --ok: #1F8A4C; --danger: #D8432E;
  --radius: 12px; --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #1B1D20; --surface: #26292D; --ink: #F1F2F4; --muted: #A3A8B0; --line: #3A3E44; --accent-soft: #4A4215; }
}
:root[data-theme="dark"] { --bg: #1B1D20; --surface: #26292D; --ink: #F1F2F4; --muted: #A3A8B0; --line: #3A3E44; --accent-soft: #4A4215; }
* { box-sizing: border-box; }
/* атрибут hidden должен прятать всегда: без этого правила его перебивали стили полей и подписей */
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--ink); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 44px; padding: 0 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); font: 500 1rem var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn[disabled] { opacity: .6; cursor: default; }

label { display: block; margin: 0 0 14px; font-size: .9rem; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 1rem var(--font); }
input::placeholder, textarea::placeholder { color: #B4B8BF; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { display: inline-block; width: 20px; height: 20px; margin: 0 8px 0 0; vertical-align: -4px; accent-color: var(--accent); }
label.check { color: var(--ink); font-size: 1rem; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: .95rem; }
.note.warn { background: var(--accent-soft); color: var(--ink); }
.note.err { background: #F8E3DE; color: #7C2A1B; }

/* вход и служебные страницы */
.center-page { display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; padding: 30px 26px; background: var(--surface); border: 1.5px solid var(--accent); border-radius: 22px; }
.auth-card .btn { width: 100%; }

/* кабинет */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100%; }
.loading { padding: 40px; color: var(--muted); }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px; background: var(--surface); }
.side .brand { display: block; padding: 4px 10px 14px; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.side .group { margin: 14px 10px 4px; font-size: .8rem; color: var(--muted); }
.side a.nav { display: block; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.side a.nav:hover { background: var(--bg); }
.side a.nav.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side .who { margin: 18px 10px 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.main { min-width: 0; padding: 24px clamp(16px, 3vw, 40px) 96px; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.head h1 { margin: 0; flex: 1 1 auto; }
.head input[type="search"] { width: 240px; max-width: 100%; margin: 0; }
.panel { background: var(--surface); border-radius: 20px; padding: 24px; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .85rem; font-weight: 500; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: .9rem; }
.form { max-width: 640px; }
.form .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat b { display: block; font-size: 1.5rem; }
.bar { height: 6px; margin-top: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar i.full { background: var(--danger); }
.perm td, .perm th { white-space: normal; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); padding: 10px 16px; border-radius: 8px; background: var(--ink); color: var(--bg); z-index: 50; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(20, 30, 18, .5); z-index: 40; }
.modal > div { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 26px; background: var(--surface); border-radius: 22px; }
.steps { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.tabbar { display: none; }
code.token { display: block; padding: 10px; background: var(--bg); border-radius: 8px; word-break: break-all; }

@media (max-width: 820px) {
  .shell { display: block; }
  .side { display: none; position: fixed; inset: 0; z-index: 30; height: auto; padding-bottom: 90px; }
  .side.open { display: block; }
  .main { padding: 16px 14px 96px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a { flex: 1; padding: 12px 4px; text-align: center; font-size: .78rem; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a.on { color: var(--ink); font-weight: 600; box-shadow: inset 0 3px 0 var(--accent); }
  /* на телефоне список превращается в карточки */
  .table-wrap { border: 0; background: none; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr { margin-bottom: 10px; padding: 14px 16px; background: var(--surface); border-radius: 16px; }
  td { padding: 2px 0; border: 0; white-space: normal; }
  td:first-child { font-weight: 600; font-size: 1.05rem; }
  td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted); }
  td:empty { display: none; }
  .head input[type="search"] { width: 100%; }
}

/* панели карточки: вложенные списки, фото, связи */
.muted { color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -6px 0 14px; font-size: .9rem; }
.filebtn { display: inline; margin: 0; color: var(--ink); font-size: inherit; cursor: pointer; text-decoration: underline; }
.btn.filebtn { display: inline-flex; color: var(--ink); text-decoration: none; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sub-head h2 { margin: 0; }
.panel .table-wrap { border-radius: 12px; border: 1px solid var(--line); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.thumbs figure { margin: 0; display: grid; gap: 6px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.thumbs .doc { display: grid; place-items: center; aspect-ratio: 1; padding: 8px; border: 1px solid var(--line); border-radius: 10px; font-size: .8rem; word-break: break-word; text-align: center; }
.links-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.link-add { display: grid; grid-template-columns: 200px 1fr; gap: 10px; }
.link-add select, .link-add input { margin: 0; }
.link-found { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.side input[type="search"] { margin: 0 0 10px; }
@media (max-width: 820px) { .link-add { grid-template-columns: 1fr; } }

/* складской документ */
.badge { padding: 4px 10px; border-radius: 8px; font-size: .85rem; font-weight: 600; background: var(--accent-soft); color: var(--ink); }
.badge.posted { background: #DDF3E4; color: #17683A; }
.lowmark { padding: 1px 6px; border-radius: 5px; background: #F8E3DE; color: #7C2A1B; font-size: .8rem; }
.doc-items input { margin: 0; min-width: 90px; }
.doc-items td:first-child input { min-width: 220px; }
.doc-items td { vertical-align: middle; }
.doc-items td .muted { white-space: nowrap; }
.doc-items td:nth-child(2) input { display: inline-block; width: 110px; }
.doc-total { margin: 12px 0 0; text-align: right; }
@media (max-width: 820px) { .doc-items td:first-child input { min-width: 0; } .doc-items td:nth-child(2) input { width: 60%; } }

/* выбор цвета кабинета */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 14px; }
.swatches button { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatches button.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
input[type="color"] { width: 64px; height: 44px; padding: 4px; }

.auth-logo { display: block; margin: 0 0 16px; border-radius: 14px; }
.qr { width: 240px; margin: 0 auto 12px; padding: 10px; background: #fff; border-radius: 12px; }
.qr svg { display: block; width: 100%; height: auto; }

/* доска заказов */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.board section { background: var(--surface); border-radius: 16px; padding: 12px; min-height: 120px; }
.board section.over { outline: 2px dashed var(--ink); }
.board h2 { font-size: 1rem; margin: 2px 4px 10px; }
.tkt { display: grid; gap: 2px; padding: 10px 12px; margin-bottom: 8px; border-radius: 12px; background: var(--bg); color: var(--ink); text-decoration: none; font-size: .92rem; cursor: grab; }
.tkt span { color: var(--muted); }

/* чаты */
.cnt { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 600; line-height: 20px; text-align: center; }
.chatbox { display: grid; grid-template-columns: 340px 1fr; gap: 14px; height: calc(100vh - 150px); min-height: 420px; }
.chatbox aside, .chatbox section { background: var(--surface); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.chatbox aside { padding: 14px 10px; }
.chatbox aside .tools { margin: 0 4px 10px; }
#chatList { overflow-y: auto; flex: 1; }
.chat-row { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.chat-row:hover, .chat-row.on { background: var(--bg); }
.chat-row .ch { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); font-size: .7rem; font-weight: 700; }
.chat-row .who { flex: 1; min-width: 0; display: grid; }
.chat-row .who b, .chat-row .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row small { color: var(--muted); }
.chat-row .meta { display: grid; justify-items: end; gap: 4px; font-size: .78rem; color: var(--muted); }
#thread header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
#thread header .tools { margin: 0 0 0 auto; }
#thread .back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.msg > div { max-width: 76%; padding: 9px 13px; border-radius: 16px; background: var(--bg); overflow-wrap: anywhere; }
.msg.out > div { background: var(--accent-soft); }
.msg small { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
#sendForm { display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); }
#sendForm textarea { margin: 0; min-height: 46px; flex: 1; }
#sendForm select { margin: 0; width: 150px; flex: none; }
@media (max-width: 820px) {
  .chatbox { display: block; height: auto; }
  .chatbox aside, .chatbox section { height: calc(100vh - 210px); min-height: 380px; }
  .chatbox.opened aside { display: none; }
  .chatbox:not(.opened) section { display: none; }
  #thread .back { display: inline-flex; }
  #sendForm { flex-wrap: wrap; } #sendForm select { width: 100%; }
}

/* отчёты и рабочий стол */
.tiles-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 4px; }
.tiles-row .stat { color: var(--ink); text-decoration: none; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.dash-grid .wide { grid-column: 1 / -1; }
.bignum { font-size: 2.4rem; font-weight: 600; margin: 4px 0; }
.bars-h { display: grid; gap: 8px; margin-bottom: 16px; }
.bars-h div { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: .92rem; }
.bars-h span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars-h i { height: 12px; border-radius: 6px; background: var(--accent); min-width: 3px; }
.bars-h i.neg { background: var(--danger); }
.bars-h b { font-weight: 500; white-space: nowrap; }
.chart { width: 100%; height: auto; margin-bottom: 14px; }
.pie { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; margin-bottom: 14px; }
.pie svg { width: 170px; height: 170px; flex: none; }
.pie ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .92rem; }
.pie li i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; }
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }

/* меню: перетаскивание пунктов */
.side a.nav[draggable="true"] { cursor: grab; }
.side a.nav.drop { box-shadow: inset 0 3px 0 var(--accent-text); }
.side .who a { display: inline-block; margin-top: 6px; }

/* сворачиваемые блоки карточки */
.fold > h2, .fold > .sub-head h2 { cursor: pointer; position: relative; padding-right: 26px; user-select: none; }
.fold > h2::after, .fold > .sub-head h2::after { content: ""; position: absolute; right: 4px; top: 50%; width: 9px; height: 9px; margin-top: -8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-135deg); transition: transform .15s; }
.fold.closed > h2::after, .fold.closed > .sub-head h2::after { transform: rotate(45deg); }
.fold.closed > :not(h2):not(.sub-head), .fold.closed > .sub-head > :not(h2) { display: none; }
.fold.closed > h2, .fold.closed > .sub-head, .fold.closed > .sub-head h2 { margin-bottom: 0; }
.fold > .sub-head h2 { flex: 1; }
.form-sub { margin: 18px 0 10px; font-size: 1.05rem; }

/* выбор файла: кнопка браузера в общем стиле */
input[type="file"] { padding: 8px; font-size: .92rem; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: 500 .9rem var(--font); cursor: pointer; }

@media (max-width: 820px) {
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 7px; font-size: .68rem; }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* меню: сворачиваемые группы */
.side .group { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 8px); margin: 10px 4px 2px; padding: 8px; border: 0; border-radius: 8px; background: none;
  font: 500 .82rem var(--font); color: var(--muted); cursor: pointer; text-align: left; }
.side .group:hover { background: var(--bg); }
.side .group::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.side .group.open::after, .side .group.has-on::after { transform: rotate(45deg); }
.side .gitems { display: none; }
.side .group.open + .gitems, .side .group.has-on + .gitems { display: block; }
.side .group.drop { box-shadow: inset 0 -3px 0 var(--accent-text); }

/* карточка записи: слева данные, справа вкладки со связанными блоками */
.card2 { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 18px; align-items: start; }
.c-left .panel.form { max-width: none; }
.c-left .form label:not(.check) { display: grid; grid-template-columns: 38% 1fr; gap: 10px; align-items: center; margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.c-left .form label:not(.check) > input, .c-left .form label:not(.check) > select, .c-left .form label:not(.check) > textarea { margin: 0; min-height: 38px; padding: 6px 10px; border-color: transparent; background: transparent; }
.c-left .form label:not(.check) > input:hover, .c-left .form label:not(.check) > select:hover, .c-left .form label:not(.check) > textarea:hover,
.c-left .form label:not(.check) > input:focus, .c-left .form label:not(.check) > select:focus, .c-left .form label:not(.check) > textarea:focus { border-color: var(--line); background: var(--surface); }
.c-left .form label.check { padding: 8px 0; margin: 0; }
.c-left .form .actions { margin-top: 16px; }
.c-right { background: var(--surface); border-radius: 20px; padding: 6px 20px 20px; min-height: 240px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { flex: none; padding: 14px 12px 12px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: 500 .95rem var(--font); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabpanels > .panel { padding: 0; margin: 0; background: none; border-radius: 0; }
.tabpanels > .panel > h2, .tabpanels > .panel > .sub-head > h2 { display: none; }       /* название уже написано на вкладке */
.tabpanels > .panel > .sub-head { justify-content: flex-end; }
@media (max-width: 1100px) { .card2 { grid-template-columns: 1fr; } }

/* строка действий под заголовком и переключатель вида */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; min-height: 40px; font-size: .9rem; }
.tools .btn.small { margin: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); margin-right: 6px; }
.seg a { padding: 7px 16px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
.seg a.on { background: var(--accent); color: var(--accent-ink); }
/* 3. кнопки внизу окон и форм всегда с промежутком */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.modal .check { margin: 0; padding: 7px 0; }

/* поле с поиском по справочнику */
.pick { position: relative; display: block; }
.pick .pick-q { margin: 0; }
.pick-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; max-height: 300px; overflow-y: auto; padding: 6px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .45); }
.pick-list button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: 1rem var(--font); text-align: left; cursor: pointer; }
.pick-list button:hover { background: var(--bg); }
.pick-list small { color: var(--muted); margin-left: 6px; }
.pick-list em { display: block; padding: 9px 10px; color: var(--muted); font-style: normal; }
label > .pick { margin-bottom: 14px; }
.c-left .form label:not(.check) > .pick { margin: 0; }
.c-left .form label:not(.check) > .pick .pick-q { min-height: 38px; padding: 6px 10px; border-color: transparent; background: transparent; }
.c-left .form label:not(.check) > .pick .pick-q:hover, .c-left .form label:not(.check) > .pick .pick-q:focus { border-color: var(--line); background: var(--surface); }
.c-left .doc-total { text-align: left; }
.c-right > .sub-head { padding-top: 14px; }

.pick-list .pick-new { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; font-weight: 600; }
.row-new { display: block; margin-top: 6px; }

/* Телефон: карточка не должна быть шире экрана.
   Причина была в сетке: столбец «1fr» не сжимается уже своего содержимого, а поля ввода и строка вкладок его распирали.
   minmax(0, 1fr) и min-width: 0 разрешают столбцам сжиматься, широкое содержимое (вкладки, таблицы) прокручивается внутри себя. */
.main { min-width: 0; }
.card2 > *, .c-left, .c-right, .tabpanels, .tabpanels > .panel { min-width: 0; }
.c-left .form label:not(.check) { grid-template-columns: minmax(0, 38%) minmax(0, 1fr); }
.c-left .form label:not(.check) > input, .c-left .form label:not(.check) > select, .c-left .form label:not(.check) > textarea, .pick .pick-q { min-width: 0; width: 100%; }
.tabs { max-width: 100%; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
@media (max-width: 1100px) {
  .card2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .main { overflow-x: hidden; }
  .c-right { padding: 4px 14px 16px; }
  .c-left .panel.form { padding: 16px; }
  .head { gap: 8px; }
  .head h1 { min-width: 0; overflow-wrap: anywhere; }
  .doc-items td:first-child input { min-width: 0; }
}

/* строки документа: все поля строки стоят на одной линии по верху, подпись под количеством («в резерве», «отгружено») строку не перекашивает */
.doc-items td { vertical-align: top; padding-top: 12px; padding-bottom: 12px; }
.doc-items input { height: 44px; min-height: 44px; margin: 0; }
.doc-items td:nth-child(2) { white-space: nowrap; }
.doc-items td:nth-child(2) input { vertical-align: top; }
.doc-items td:nth-child(2) [data-unit], .doc-items td:nth-child(2) > .muted { display: inline-block; line-height: 44px; vertical-align: top; margin-left: 4px; }
.doc-items td:nth-child(2) small { display: block; line-height: 1.3; margin-top: 4px; white-space: normal; }
.doc-items td[data-sum], .doc-items td[data-label="По учёту"] { line-height: 44px; white-space: nowrap; }
.doc-items td:last-child .btn { margin-top: 4px; }
.doc-items .row-new { height: auto; }

.side .group.sub { margin-left: 10px; width: calc(100% - 14px); }
.side .group.sub + .gitems { margin-left: 10px; }
.note.offer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.modal h3 { margin: 16px 0 6px; font-size: 1rem; }

.paircode { margin: 6px 0 14px; padding: 14px; border-radius: 12px; background: var(--accent-soft); font-size: 1.7rem; font-weight: 700; letter-spacing: .12em; text-align: center; }
.modal form + form, .modal form .btn { margin-top: 4px; }

/* задачи в карточке объекта */
.task-add { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto; gap: 8px; align-items: center; margin-bottom: 16px; }
.task-add input, .task-add select { margin: 0; min-width: 0; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task-list li.closed a { text-decoration: line-through; color: var(--muted); }
.task-list .muted { font-size: .88rem; }
@media (max-width: 820px) { .task-add { grid-template-columns: 1fr; } }

.bank { padding: 14px 0; border-bottom: 1px solid var(--line); }
.bank .tools { margin: 0; }

.callnum { display: inline-block; font-size: 1.25rem; font-weight: 700; white-space: nowrap; }

/* метки новых событий */
.side a.nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cnt { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center; }
.side .group .cnt { margin-left: auto; margin-right: 8px; }
.side .group.open .cnt, .side .group.has-on .cnt { display: none; }     /* группа раскрыта: числа видны у самих разделов */
.tabbar a { position: relative; }
.tabbar a .cnt { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; line-height: 17px; font-size: .64rem; }

/* быстрые фильтры списка: одна строка, на телефоне листается пальцем */
.filters { display: flex; align-items: center; gap: 8px; margin: -6px 0 16px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chips { display: inline-flex; gap: 6px; flex: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink);
  font: 500 .88rem var(--font); cursor: pointer; white-space: nowrap; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--st); }
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.filters select.flt { flex: none; width: auto; min-height: 36px; margin: 0; padding: 0 30px 0 12px; border-radius: 18px; font-size: .88rem; background-color: var(--surface); }
.filters select.flt.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
/* подсветка строки цветом статуса */
tr.st > td:first-child { box-shadow: inset 4px 0 0 var(--st); }
.st-badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: .86rem; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--st) 16%, transparent); color: color-mix(in srgb, var(--st) 72%, var(--ink)); }
@media (max-width: 820px) {
  .filters { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  tr.st > td:first-child { box-shadow: none; }
  tr.st { border-left: 5px solid var(--st) !important; }
}

/* фильтр с поиском в строке фильтров */
.flt-pick { flex: none; width: 190px; }
.flt-pick .pick-q { min-height: 36px; padding: 0 12px; border-radius: 18px; font-size: .88rem; background: var(--surface); }
.flt-pick.on .pick-q { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.filters { overflow: visible; flex-wrap: wrap; }
@media (max-width: 820px) { .filters { flex-wrap: nowrap; overflow-x: auto; } .flt-pick .pick-list { position: fixed; left: 14px; right: 14px; top: auto; } }

/* чат: поле ввода прижато к низу, значки вместо кнопок */
.icon-btn { position: relative; flex: none; display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; margin: 0; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.send { color: var(--accent-ink); background: var(--accent); }
.icon-btn.send:hover { background: var(--accent); filter: brightness(.95); }
.icon-btn select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#sendForm { display: flex; flex-wrap: nowrap; gap: 6px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
#sendForm textarea { flex: 1; min-width: 0; margin: 0; min-height: 42px; max-height: 132px; padding: 10px 14px; border-radius: 21px; resize: none; line-height: 1.35; overflow-y: auto; }
#sendForm select { width: 100%; }
.file-chip { padding: 8px 16px; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.file-chip button { border: 0; background: none; color: var(--danger); font-size: 1.1rem; cursor: pointer; }
#thread header { flex-wrap: wrap; gap: 8px 12px; }
#thread header b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#thread .back { display: none; }
.msg > div { max-width: min(76%, 640px); }
@media (max-width: 820px) {
  /* открытый диалог занимает весь экран: шапка сверху, сообщения прокручиваются, поле ввода всегда внизу */
  body.in-thread .tabbar, body.in-thread .main > .head { display: none; }
  body.in-thread .chatbox.opened section { position: fixed; inset: 0; z-index: 40; height: 100dvh; min-height: 0; border-radius: 0; }
  body.in-thread #sendForm { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  #thread .back { display: inline-grid; }
  #thread header { padding: 8px 10px; }
  #thread header .tools { width: 100%; margin: 0; font-size: .85rem; }
  .msgs { padding: 12px 10px; }
  .msg > div { max-width: 86%; }
  .chatbox aside { height: calc(100dvh - 190px); }
}

/* окно не выше экрана: длинное содержимое прокручивается внутри, кнопки не уезжают под край */
.modal > div { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }

/* шапка списка: справа переключатель вида и «Добавить» */
.head-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.head-right .seg { margin: 0; }
/* блок фильтров: условия строками */
.fpanel { background: var(--surface); border-radius: 16px; padding: 14px 16px; margin: -4px 0 16px; }
.frow { display: grid; grid-template-columns: minmax(150px, 240px) minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.frow select, .frow input { margin: 0; min-height: 40px; }
.frow select[multiple] { min-height: 0; padding: 4px; }
.fval { min-width: 0; }
.fval .pick-q { min-height: 40px; }
.frange { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips.wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.fpanel .actions { margin-top: 12px; }
.fsum { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.fsum .chip { cursor: default; min-height: 32px; font-size: .84rem; white-space: normal; text-align: left; }
.fsum .chip button { border: 0; background: none; color: var(--muted); font-size: 1.05rem; cursor: pointer; padding: 0 0 0 2px; }
@media (max-width: 820px) {
  /* телефон: заголовок, под ним поиск, под ним переключатель и «Добавить» у правого края; кнопки действий делят строку поровну */
  .head.lh h1 { flex: 1 1 100%; }
  .head.lh input[type="search"] { flex: 1 1 100%; }
  .head.lh .head-right { width: 100%; justify-content: flex-end; }
  .tools { gap: 6px; }
  .tools > .btn.small { flex: 1 1 auto; padding: 0 8px; font-size: .84rem; white-space: nowrap; }
  .frow { grid-template-columns: minmax(0, 1fr) auto; }
  .frow .fval { grid-column: 1 / -1; grid-row: 2; }
  .fpanel { padding: 10px 12px; }
}

/* блок «Фильтры»: полоса во всю ширину с заголовком, раскрывается по нажатию */
.fbar { background: var(--surface); border-radius: 16px; margin: 0 0 16px; }
.fbar-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 16px; border: 0; background: none; color: var(--ink); font: 600 1rem var(--font); cursor: pointer; text-align: left; }
.fbar-head svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fbar-head span { flex: 1; }
.fbar.has .fbar-head span { color: var(--accent-text); }
.fbar-head .chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; margin-right: 4px; }
.fbar.open .fbar-head .chev { transform: rotate(-135deg); }
.fbar .fpanel { margin: 0; padding: 0 16px 14px; border-radius: 0 0 16px 16px; background: none; }
.fbar .fsum { margin: 0; padding: 0 16px 12px; }
.tools.lt { margin-bottom: 12px; }
@media (max-width: 820px) {
  /* «Добавить» слева, переключатель вида у правого края */
  .head.lh .head-right { width: 100%; justify-content: space-between; }
  /* три кнопки действий всегда в одну строку */
  .tools.lt { flex-wrap: nowrap; gap: 6px; }
  .tools.lt > .btn.small { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fbar .fpanel { padding: 0 12px 12px; }
}

/* отметки в списке заказов и полоса действий с отмеченными */
.selc { width: 36px; }
.selc input { width: 20px; height: 20px; margin: 0; display: block; }
.bulkbar { position: fixed; left: 264px; right: 16px; bottom: 16px; z-index: 34; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 16px;
  background: var(--ink); color: var(--surface); box-shadow: 0 16px 36px -14px rgba(0, 0, 0, .55); }
.bulkbar b { margin-right: 6px; }
.bulkbar .btn { background: var(--surface); color: var(--ink); border-color: transparent; }
/* чат: кнопка «В заказ» и ссылка на созданный заказ у сообщения */
.msg-ord { display: inline-block; margin-right: 6px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: 600 .74rem var(--font); cursor: pointer; text-decoration: none; }
a.msg-ord { border-color: transparent; background: var(--accent); color: var(--accent-ink); }
@media (max-width: 820px) {
  .bulkbar { left: 8px; right: 8px; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); padding: 10px; gap: 6px; }
  .bulkbar b { flex: 1 1 100%; }
  .bulkbar .btn.small { flex: 1 1 auto; padding: 0 8px; font-size: .8rem; }
  table.has-sel tr { position: relative; }
  table.has-sel td.selc { position: absolute; top: 12px; right: 12px; width: auto; padding: 0; }
  table.has-sel td.selc::before { content: none; }
}

/* переход в карточку из поля с поиском */
/* значок стоит рядом с полем, а не поверх него: внутри поля справа живёт крестик очистки */
.pick { display: flex; align-items: center; gap: 6px; }
.pick .pick-q { flex: 1; min-width: 0; }
.pick-go { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.pick-go:hover { background: var(--bg); color: var(--ink); }
.pick-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.tabpanels > .panel > .sub-head { margin-bottom: 8px; }

/* итог отправки сообщений по заказам */
.res-list { list-style: none; margin: 12px 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.res-list li { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.res-list li b { font-size: .86rem; }
.res-list li.ok b { color: #2F9E5B; } .res-list li.weak b { color: #C98A1B; } .res-list li.fail b { color: var(--danger); } .res-list li.queued b { color: var(--muted); }
.res-list small { color: var(--muted); }
.mflag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 9px; font-size: .74rem; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); }
.mflag.fail { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.mflag.weak { background: color-mix(in srgb, #C98A1B 18%, transparent); color: #9A6A10; }
.mflag.c-yes { background: color-mix(in srgb, #2F9E5B 16%, transparent); color: #23794a; }
.mflag.c-no { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

/* блоки вкладки «Документы» */
.rel { margin-bottom: 22px; }
.rel h3 { margin: 0; font-size: 1.02rem; }
.rel h3 small { font-weight: 400; color: var(--muted); }
.rel .sub-head { margin-bottom: 6px; }
.rel > p { margin: 0 0 8px; }
.tabpanels > .panel > .sub-head > h2 + .btn { margin-left: auto; }

/* итоги над списком */
.totals { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: -4px 0 12px; font-size: .95rem; color: var(--muted); }
.totals b { color: var(--ink); }
.totals span { white-space: nowrap; }

/* админка: проверка товаров маркета */
.mm-pics { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.mm-pics img { width: 140px; height: 140px; object-fit: cover; border-radius: 12px; display: block; }
.mm-was { padding: 8px 12px; border-radius: 10px; background: var(--bg); font-size: .92rem; }

.row-acts { white-space: nowrap; }
.row-acts .btn { margin: 2px 4px 2px 0; }
@media (max-width: 820px) { .row-acts { white-space: normal; } }

/* следующий шаг в заказе */
.nextstep { margin: 0 0 16px; padding: 12px 16px; border-radius: 14px; background: var(--accent-soft); line-height: 1.5; }
.nextstep .btn { margin: 6px 6px 0 0; vertical-align: middle; }
@media (min-width: 821px) { .nextstep .btn { margin: 0 0 0 8px; } }
/* первые шаги на рабочем столе */
.start ul { list-style: none; margin: 0; padding: 0; }
.start li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.start li i { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.start li.done i { border-color: #2F9E5B; background: #2F9E5B url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/14px no-repeat; }
.start li.done b { font-weight: 500; color: var(--muted); text-decoration: line-through; }
.start li.done small { display: none; }
.start li span { flex: 1; min-width: 0; display: grid; }
.start li small { color: var(--muted); overflow-wrap: anywhere; }
.start li .btn { flex: none; }
.ob-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 10px; }
/* план закупки */
.plan-t input, .plan-t .pick-q { margin: 0; min-height: 40px; }
.plan-t td { vertical-align: middle; }
.plan-t .pl-sup.miss .pick-q { border-color: var(--danger); }
.plan-t .pl-sum { white-space: nowrap; font-weight: 600; }
.pl-total { margin: 14px 0 6px; font-weight: 600; }
.seg a { white-space: nowrap; }
@media (max-width: 820px) {
  .head.lh .head-right { flex-wrap: wrap; gap: 8px; }
  .head.lh .head-right .seg a { padding-left: 12px; padding-right: 12px; font-size: .9rem; }
  .ob-row { grid-template-columns: minmax(0, 1fr) 110px; }
  /* строка плана на телефоне: карточка в две колонки без подписей, подсказки стоят в самих полях */
  .plan { padding: 10px; }
  .plan-t tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; position: relative; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 14px; background: none; }
  .plan-t tbody td { display: block; padding: 0; border: 0; min-width: 0; }
  .plan-t tbody td::before { content: none; }
  .plan-t .pl-prod { grid-column: 1 / -1; padding-right: 38px; }
  .plan-t .pl-sup { grid-column: 1 / -1; }
  .plan-t td.selc { position: absolute; top: 20px; right: 12px; }
  .plan-t .pl-sum { align-self: center; }
  .plan-t .pl-sum span:not(:empty)::before { content: 'Сумма: '; font-weight: 400; color: var(--muted); }
  .plan-t .pl-state { align-self: center; }
  .plan-t .pl-state:empty { display: none; }
  .plan-t .pl-rm { grid-column: 2; justify-self: end; align-self: center; }
  .plan-t .pl-rm:empty { display: none; }
  .plan .actions .btn { width: 100%; }
}

/* редкие поля под «Дополнительно» */
details.more { margin: 6px 0 4px; }
details.more > summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: .92rem; color: var(--ink); list-style: none; display: flex; align-items: center; gap: 8px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
details.more[open] > summary::before { transform: rotate(45deg); }
details.more > summary .muted { font-weight: 400; }
/* выбор действия в окне правки остатка */
.seg-radio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: 0 0 10px; border-radius: 14px; background: var(--bg); }
.seg-radio label { margin: 0; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { display: block; padding: 9px 6px; border-radius: 10px; text-align: center; font-weight: 600; font-size: .92rem; cursor: pointer; color: var(--muted); }
.seg-radio input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--accent-text); }
.modal .pick { display: flex; }
/* сезоны поля */
.season { padding: 14px 0; border-top: 1px solid var(--line); }
.season:first-of-type { border-top: 0; }
.season h3 { margin: 0; font-size: 1.05rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 16px; margin: 10px 0; }
.kv dt { color: var(--muted); font-size: .8rem; }
.kv dd { margin: 0; }
.season .tools { margin: 10px 0 0; gap: 6px; }
/* табель на день */
.ts-date { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; flex-wrap: wrap; }
.ts-date input { width: auto; margin: 0; min-height: 42px; }
.ts-date .btn { margin-left: 6px; }
.panel.ts { max-width: 980px; } .ts-save { max-width: 980px; } .ts-hint { margin: -6px 0 12px; font-size: .9rem; }
.ts-emp { display: grid; grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); gap: 6px 16px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.ts-emp:first-child { border-top: 0; }
.ts-name { grid-row: span 6; display: flex; align-items: flex-start; gap: 10px; margin: 0; padding-top: 9px; cursor: pointer; }
.ts-name input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; }
.ts-name span { display: grid; gap: 2px; min-width: 0; } .ts-name b { font-weight: 600; color: var(--ink); }
.ts-name small { color: var(--muted); }
.ts-emp:not(.on) .ts-row, .ts-emp:not(.on) .ts-more { opacity: .45; }
.ts-row { grid-column: 2; display: grid; grid-template-columns: minmax(0, 1fr) 120px 40px; align-items: center; gap: 8px; }
.ts-row select { width: 100%; min-width: 0; margin: 0; min-height: 42px; }
.ts-row input[type="number"] { width: 100%; margin: 0; min-height: 42px; }
.ts-row .ts-dayh { font-size: .9rem; } .ts-row .ts-slot { display: block; }
.ts-row .icon-btn { justify-self: center; }
.ts-more { grid-column: 2; justify-self: start; border: 0; background: none; padding: 2px 0; color: var(--accent-text); font: 500 .86rem var(--font); cursor: pointer; }
.ts-save { position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 14px; padding: 10px 14px; border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .35); }
.m-save { display: none; }
@media (max-width: 820px) {
  /* вкладки карточки: все видны, переносятся на следующую строку */
  .tabs { flex-wrap: wrap; overflow: visible; gap: 6px; border-bottom: 0; padding: 12px 0 2px; margin-bottom: 12px; }
  .tabs button { padding: 8px 13px; border: 1px solid var(--line); border-radius: 18px; font-size: .9rem; }
  .tabs button.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
  /* в существующем документе сначала товары, потом шапка; кнопка сохранения продублирована под товарами */
  .card2.docx .c-right { order: -1; }
  .m-save { display: block; margin: 12px 0 0; }
  .m-save .btn { width: 100%; }
  /* строка документа: товар во всю ширину, под ним количество, цена и остальное в ряд, подписи мелко над полями */
  table.doc-items:not(.plan-t) tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; position: relative; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 14px; background: none; }
  table.doc-items:not(.plan-t) tbody td { display: block; padding: 0; border: 0; min-width: 0; line-height: 1.3; white-space: normal; font-size: 1rem; font-weight: 400; }
  table.doc-items:not(.plan-t) tbody td:first-child { grid-column: 1 / -1; padding-right: 44px; }
  table.doc-items:not(.plan-t) tbody td::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: .76rem; color: var(--muted); }
  table.doc-items:not(.plan-t) tbody td:not([data-label])::before { content: none; }
  table.doc-items:not(.plan-t) tbody td input { width: 100%; min-width: 0; display: block; }
  table.doc-items:not(.plan-t) tbody td:nth-child(2) { white-space: normal; }
  table.doc-items:not(.plan-t) tbody td:nth-child(2) input { width: 100%; display: block; }
  table.doc-items:not(.plan-t) tbody td:nth-child(2) [data-unit], table.doc-items:not(.plan-t) tbody td:nth-child(2) > .muted { display: block; line-height: 1.2; margin: 2px 0 0; font-size: .76rem; }
  table.doc-items:not(.plan-t) tbody td[data-sum], table.doc-items:not(.plan-t) tbody td[data-label="По учёту"] { line-height: 1.3; font-weight: 600; align-self: center; }
  table.doc-items:not(.plan-t) tbody td:last-child { position: absolute; top: 12px; right: 10px; }
  table.doc-items:not(.plan-t) tbody td:last-child .btn { margin: 0; width: 36px; height: 36px; min-height: 0; padding: 0; overflow: hidden; color: transparent; border-radius: 50%; position: relative; }
  table.doc-items:not(.plan-t) tbody td:last-child .btn::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 1.4rem; line-height: 1; }
  /* список с галочками: заголовком карточки служит первое поле, а не галочка */
  table.has-sel td.t-main { font-weight: 600; font-size: 1.05rem; }
  table.has-sel td.t-main::before { content: none; }
  .ts-emp { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .ts-name { grid-row: auto; padding-top: 0; }
  .ts-row, .ts-more { grid-column: 1; }
  .ts-row { grid-template-columns: minmax(0, 1fr) 96px 36px; }
  .ts-save { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); flex-direction: column; align-items: stretch; gap: 8px; }
  .ts-save .muted { font-size: .84rem; text-align: center; }
  td.row-acts { padding-top: 8px; }
  .kv { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .panel .table-wrap:has(> table.doc-items) { border: 0; border-radius: 0; }
}

/* деньги */
.pos { color: var(--ok); } .neg { color: var(--danger); }
.acc-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.acc { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.acc b { font-size: 1.35rem; white-space: nowrap; } .acc small { color: var(--muted); font-size: .85rem; }
.acc.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); } .acc.off { opacity: .6; }
.money-links a { text-decoration: none; border-bottom: 1px solid var(--line); }
.money-f { display: grid; gap: 12px; padding: 14px 16px; margin-bottom: 14px; }
.money-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.money-dates label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); }
.money-dates input, .money-dates select { margin: 0; width: auto; } .money-dates input[type=search] { flex: 1 1 220px; }
.money-sum { margin-bottom: 14px; } .money-sum .stat { margin: 0; } .money-sum b { font-size: 1.25rem; white-space: nowrap; }
.money-cats .panel { margin-bottom: 14px; }
.cat-list { display: grid; gap: 4px; }
.cat-list button { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 6px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.cat-list button:hover { background: var(--bg); } .cat-list .bar { grid-column: 1 / -1; margin: 0; } .cat-list .bar i.pos { background: var(--ok); } .cat-list .bar i.neg { background: var(--danger); }
.money-t td small { display: block; } .money-t td.num b { white-space: nowrap; } .money-t tbody tr { cursor: pointer; }
@media (max-width: 720px) {
  .acc-row { grid-template-columns: 1fr 1fr; } .acc b { font-size: 1.1rem; }
  .money-sum { grid-template-columns: 1fr 1fr; gap: 10px; } .money-cats { grid-template-columns: 1fr; }
  .money-dates label { flex: 1 1 40%; } .money-dates input[type=date] { flex: 1; min-width: 0; } .money-dates select { flex: 1 1 100%; }
}
@media (max-width: 720px) { .money-dates label { flex: 1 1 0; min-width: 0; } .money-dates input[type=date] { width: 100%; padding-left: 8px; padding-right: 6px; } }

/* загрузка из Excel */
.modal.wide > div { max-width: 820px; }
.imp-prev { margin: 10px 0; overflow-x: auto; } .imp-prev table { min-width: 100%; } .imp-prev th { padding: 6px; min-width: 150px; } .imp-prev th select { margin: 0; }
.imp-prev td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* быстрый заказ */
.qo-top { display: grid; gap: 10px; padding: 14px 16px; margin-bottom: 12px; } .qo-top label, .qo-top input { margin: 0; }
#qoList { display: grid; gap: 8px; padding-bottom: 90px; }
.qo-row { display: grid; grid-template-columns: 1fr 120px auto; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.qo-row.on { border-color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent-dark); }
.qo-name { min-width: 0; } .qo-name b { display: block; overflow-wrap: anywhere; } .qo-name small { font-size: .85rem; }
.qo-price { display: flex; align-items: center; gap: 6px; margin: 0; } .qo-price input { margin: 0; padding: 8px; text-align: right; } .qo-price small { color: var(--muted); white-space: nowrap; }
.qo-step { display: flex; align-items: center; gap: 4px; }
.qo-step button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.qo-step input { width: 72px; margin: 0; padding: 8px 4px; text-align: center; font-weight: 600; }
.qo-bar { position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--surface); box-shadow: 0 6px 24px rgba(0, 0, 0, .16); z-index: 5; }
@media (max-width: 720px) {
  .qo-row { grid-template-columns: 1fr auto; } .qo-name { grid-column: 1 / -1; } .qo-price input { width: 90px; }
  .qo-bar { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
#netBar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; padding: 8px 14px; background: var(--danger); color: #fff; font-size: .9rem; text-align: center; }
.qo-top .btn { height: auto; min-height: 40px; padding: 8px 12px; white-space: normal; text-align: left; justify-content: flex-start; }

/* рабочий стол: сегодня */
.td-acts { margin: 0 0 14px; } .td-tiles { margin-bottom: 14px; } .td-tiles .stat { margin: 0; display: grid; gap: 2px; } .td-tiles .stat b { font-size: 1.35rem; white-space: nowrap; }
.td-orders li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; } .td-orders a { text-decoration: none; }
@media (max-width: 720px) { .td-tiles { grid-template-columns: 1fr 1fr; gap: 10px; } .td-acts .btn { flex: 1 1 45%; } }

/* ноутбук: строки документа не помещались рядом с шапкой и уезжали вбок. Товары идут во всю ширину, шапка под ними в две колонки */
@media (min-width: 1101px) and (max-width: 1500px) {
  .card2.docx { grid-template-columns: minmax(0, 1fr); }
  .card2.docx .c-right { order: -1; }
  .card2.docx .c-left .form { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; align-items: start; }
  .card2.docx .c-left .form > .actions, .card2.docx .c-left .form > details, .card2.docx .c-left .form > p, .card2.docx .c-left .form > h2 { grid-column: 1 / -1; }
}

/* план закупки: список найденных поставщиков не обрезается рамкой таблицы; галочки обычного размера и на одной линии */
.panel.plan .table-wrap { overflow: visible; }
.doc-items input[type="checkbox"], .plan-t input[type="checkbox"] { width: 20px; min-width: 0; height: 20px; min-height: 0; margin: 0; display: block; }
.plan-t th.selc, .plan-t td.selc { width: 44px; padding-left: 14px; padding-right: 6px; }

/* рабочий стол: тариф одной строкой */
.tariff-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 18px; border-radius: 16px; background: var(--surface); font-size: .92rem; }
.tariff-box > a:last-child { margin-left: auto; }
.tariff-lim { display: inline-grid; gap: 3px; min-width: 130px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.tariff-lim .bar { margin: 0; height: 4px; } .tariff-lim.near { border-color: var(--accent-dark); } .tariff-lim.full { border-color: var(--danger); }
.doc-items td.selc input[type="checkbox"], .doc-items th.selc input[type="checkbox"] { width: 20px; min-width: 0; height: 20px; min-height: 0; }
.plan-t .pick-list { min-width: 260px; }
@media (min-width: 821px) {
  .plan-t { width: 100%; table-layout: fixed; }
  .plan-t th, .plan-t td { padding-left: 6px; padding-right: 6px; }
  .plan-t th:nth-child(3) { width: 96px; } .plan-t th:nth-child(4) { width: 158px; } .plan-t th:nth-child(6) { width: 96px; } .plan-t th:nth-child(7) { width: 104px; }
  .plan-t th:nth-child(8) { width: 84px; } .plan-t th:nth-child(9) { width: 44px; }
  .plan-t td input, .plan-t td .pick-q { width: 100%; min-width: 0 !important; }
  .plan-t td input[type="date"] { padding-left: 8px; padding-right: 4px; }
}
#feedBox a { overflow-wrap: anywhere; }
