/* Журнал заявок. Палитра и шрифты — системные, без внешних загрузок. */
:root {
  --bg: #F3F4F1; --panel: #FFFFFF; --line: #DCDFD8; --fg: #1C2321; --muted: #5F6B66;
  --accent: #1F5F5B; --accent-ink: #FFFFFF; --accent-soft: #E1ECE9;
  --s-new: #6B7280;   --s-new-bg: #ECEEF0;
  --s-work: #1F5F5B;  --s-work-bg: #DDEBE8;
  --s-rework: #B4462B; --s-rework-bg: #F6E3DC;
  --s-review: #8A6A12; --s-review-bg: #F4ECD2;
  --s-done: #2F6B2F;  --s-done-bg: #E0EEDC;
  --p-high: #C0262D; --p-high-bg: #FBE3E3; --p-med: #A87B0B; --p-med-bg: #F6EDD3; --p-low: #6B7280; --p-low-bg: #ECEEF0;
  --shadow: 0 1px 2px rgba(28,35,33,.06), 0 8px 24px rgba(28,35,33,.08);
  --font-ui: "Segoe UI", "SF Pro Text", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #141917; --panel: #1C2320; --line: #2E3834; --fg: #E6EAE7; --muted: #9AA6A0;
  --accent: #5FB3AA; --accent-ink: #0F1614; --accent-soft: #1F3531;
  --s-new: #A3AAB3; --s-new-bg: #262B2F; --s-work: #6CC2B8; --s-work-bg: #1D3430;
  --s-rework: #E98B6E; --s-rework-bg: #3A2520; --s-review: #D9B653; --s-review-bg: #36301C;
  --p-high: #F07A7E; --p-high-bg: #3D2224; --p-med: #DDBA5A; --p-med-bg: #35301E; --p-low: #A3AAB3; --p-low-bg: #262B2F;
  --s-done: #88C77F; --s-done-bg: #203323; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark; } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 1320px; margin: 0 auto; padding-inline: 16px; padding-block: 0 48px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1320px; margin: 0 auto; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.brand { display: flex; flex-direction: column; margin-right: auto; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.brand h1 a { color: inherit; text-decoration: none; }
.brand span { font-size: 13px; color: var(--muted); }
.who { font-size: 13px; color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; font-weight: 500; text-decoration: none; color: var(--fg); font-size: 14px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.warn { color: var(--s-rework); border-color: var(--s-rework); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.banner { margin-top: 16px; padding: 10px 14px; border-radius: 8px; background: var(--s-review-bg); color: var(--fg); font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 500; margin-top: 2px; }
.stat .h { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 24px; }
.toolbar input { flex: 1 1 220px; min-width: 0; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 12px; }
.toolbar select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel); font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--muted); }
.filters button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); font-weight: 600; }

.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 14px; align-items: start; }
@media (max-width: 1100px) { .board { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .board { grid-template-columns: minmax(0, 1fr); } }
.col { min-width: 0; }
.col-h { display: flex; align-items: center; gap: 8px; padding: 6px 4px 10px; border-bottom: 2px solid var(--c); margin-bottom: 10px; }
.col-h .cnt { margin-left: auto; font-size: 13px; color: var(--muted); }
.col-list { display: flex; flex-direction: column; gap: 8px; }
.col-empty { font-size: 13px; color: var(--muted); padding: 10px 4px; }

.card { text-align: left; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.card:hover { border-color: var(--muted); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.row1 { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.card .t { font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.card .c { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 8px; background: var(--bg); color: var(--muted); font-size: 12px; white-space: nowrap; }
.chip.ret { background: var(--s-rework-bg); color: var(--s-rework); }
.chip.type { background: var(--accent-soft); color: var(--fg); font-weight: 600; letter-spacing: .02em; }
.chip.max { background: var(--s-work-bg); color: var(--s-work); }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; background: var(--bg-c); color: var(--c); }

.st-new { --c: var(--s-new); --bg-c: var(--s-new-bg); }
.st-in_work { --c: var(--s-work); --bg-c: var(--s-work-bg); }
.st-rework { --c: var(--s-rework); --bg-c: var(--s-rework-bg); }
.st-review { --c: var(--s-review); --bg-c: var(--s-review-bg); }
.st-done { --c: var(--s-done); --bg-c: var(--s-done-bg); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 9; }
.sheet { position: fixed; top: 0; left: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); z-index: 10; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { margin: 4px 0 0; font-size: 18px; line-height: 1.3; text-wrap: balance; overflow-wrap: anywhere; }
.sheet-h .x { margin-left: auto; }
.sheet-b { overflow-y: auto; padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 22px; }
.sheet.drag { outline: 3px dashed var(--accent); outline-offset: -8px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.sec h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sec h3 .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.times { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.times div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.times .k { font-size: 12px; color: var(--muted); }
.times .v { font-size: 16px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions textarea { width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); resize: vertical; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hint { font-size: 13px; color: var(--muted); }
.err { font-size: 13px; color: var(--s-rework); }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--bg); display: grid; place-items: center; overflow: hidden; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.fname { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fname a { overflow-wrap: anywhere; color: var(--fg); text-decoration: none; font-weight: 500; }
.fname a:hover { text-decoration: underline; }
.fname .hint { font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fact { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.drop { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; text-align: center; font-size: 13px; color: var(--muted); }
.drop label { color: var(--accent); cursor: pointer; text-decoration: underline; }
.upl { font-size: 13px; color: var(--muted); }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 14px 22px; font-size: 14px; }
.tl li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); }
.tl li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.tl li:last-child::after { display: none; }
.tl .w { font-size: 12px; color: var(--muted); }
.tl .note { margin-top: 4px; padding: 6px 10px; background: var(--bg); border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

form.f { display: flex; flex-direction: column; gap: 12px; }
form.f label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
form.f input, form.f textarea, form.f select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); color: var(--fg); font-size: 15px; }
form.f textarea { min-height: 80px; resize: vertical; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex-direction: row !important; align-items: center; gap: 6px !important; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; color: var(--fg) !important; font-size: 14px !important; cursor: pointer; background: var(--bg); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.seg input { accent-color: var(--accent); margin: 0; }
fieldset.fs { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
fieldset.fs legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.req { color: var(--s-rework); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(-24px); opacity: .6; } } }

/* Вход и настройки */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.box { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.box h1 { margin: 0 0 4px; font-size: 22px; }
.page { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 0; font-size: 17px; }
.code { font-family: var(--font-num); font-size: 32px; letter-spacing: .2em; font-weight: 600; }
.ok { color: var(--s-done); } .bad { color: var(--s-rework); }
@media (max-width: 520px) {
  .files li { grid-template-columns: 44px minmax(0, 1fr); }
  .files li .fact { grid-column: 1 / -1; justify-content: flex-start; }
  .times .v { font-size: 14px; }
  .sheet-b { padding-inline: 14px; }
}
@media (max-width: 520px) {
  .stat { padding: 10px 12px; }
  .stat .k { font-size: 11px; }
  .stat .v { font-size: 20px; }
}

/* Просмотр фото на странице */
.thumb-btn { border: 0; padding: 0; cursor: zoom-in; }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: var(--fg); font-weight: 500; text-align: left; cursor: zoom-in; overflow-wrap: anywhere; }
.linklike:hover { text-decoration: underline; }
body.noscroll { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 30; background: rgba(10, 12, 11, .97); display: flex; flex-direction: column; color: #F2F4F3; }
.v-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.v-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.v-name { font-weight: 600; overflow-wrap: anywhere; }
.v-sub { font-size: 12px; color: rgba(242,244,243,.7); }
.v-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.vbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #F2F4F3; border-radius: 8px; padding: 6px 12px; font-size: 14px; text-decoration: none; }
.vbtn:hover { background: rgba(255,255,255,.16); }
.vbtn:disabled { opacity: .5; }
.v-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px 64px; overflow: hidden; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; user-select: none; background: #fff; box-shadow: 0 8px 40px rgba(0,0,0,.5); }
.v-stage.zoom { overflow: auto; display: block; padding: 12px; text-align: center; }
.v-stage.zoom img { max-width: none; max-height: none; cursor: zoom-out; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.45); color: #fff; font-size: 30px; line-height: 1; display: grid; place-items: center; padding-bottom: 4px; }
.v-nav:hover { background: rgba(0,0,0,.7); }
.v-nav.prev { left: 10px; } .v-nav.next { right: 10px; }
.viewer :focus-visible { outline: 2px solid #8FD3CB; outline-offset: 2px; }
@media (max-width: 520px) {
  .v-stage { padding: 8px; }
  .v-nav { top: auto; bottom: 16px; transform: none; }
  .vbtn { padding: 6px 10px; font-size: 13px; }
}
.chip.who { background: var(--panel); border: 1px solid var(--line); color: var(--fg); }
.tz { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; background: var(--bg); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 12px; }
form.f textarea.tall { min-height: 120px; }
.card .ppl { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--fg); }
.card .ppl .lbl { color: var(--muted); font-size: 12px; }
.row1 .based { font-size: 12px; color: var(--accent); }
dd.btns { gap: 4px 12px; }
.kv .linklike { color: var(--accent); font-weight: 500; cursor: pointer; }
/* Подпись поля и звёздочка — в одну строку, поле — под ней */
form.f label { display: block; }
form.f label > input, form.f label > textarea, form.f label > select { display: block; width: 100%; margin-top: 4px; }
form.f label > .hint { display: block; margin-top: 4px; }
.seg label { display: flex !important; }
form.f .seg label > input { display: inline-block; width: auto; margin: 0; }
/* Готовые документы — выше и выделены, чтобы сразу находить результат работы */
.docs-ready { background: var(--accent-soft); border-radius: 10px; padding: 12px; margin-inline: -4px; }
.docs-ready h3 { color: var(--accent); }
.docs-ready .files li { background: var(--panel); }
.docs-ready .drop { margin-top: 8px; background: var(--panel); }
.docs-src .drop { margin-top: 8px; }
.chip.ready { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* Видов заявок много — кнопки видов отдельной строкой под поиском */
.toolbar .filters { flex: 1 1 100%; }

/* приоритет */
.chip.pr { font-weight: 600; }
.chip.pr::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.pr-high { background: var(--p-high-bg); color: var(--p-high); }
.chip.pr-medium { background: var(--p-med-bg); color: var(--p-med); }
.chip.pr-low { background: var(--p-low-bg); color: var(--p-low); }
.card.pr-high { border-left: 4px solid var(--p-high); }
.card.pr-medium { border-left: 4px solid var(--p-med); }
.card.pr-low { border-left: 4px solid var(--p-low); }
.card .ppl .lbl.plan { font-style: italic; }
.seg.prio label:has(input:checked) { font-weight: 600; }

/* объект и стороны */
.deal .kv { margin-bottom: 10px; }
.dside { margin-top: 10px; }
.dside h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pcard { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel); }
.pcard .pn { font-weight: 600; }
.pcard .pm { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.pcard .miss { font-size: 12px; color: var(--s-rework); margin-top: 4px; }
.deal .btns { margin-top: 10px; }
form.deal-f { gap: 14px; }
form.deal-f .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
form.deal-f label.wide { grid-column: 1 / -1; }
form.deal-f textarea { min-height: 52px; }
form.deal-f .auto { background: var(--p-med-bg); border-color: var(--p-med); }
form.deal-f fieldset.fs { gap: 10px; }
form.deal-f fieldset.fs legend { font-weight: 600; color: var(--fg); font-size: 14px; }
.pform { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.pform .ph { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.deal-note { background: var(--p-med-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.deal-note .skipped { color: var(--muted); margin-top: 4px; }
.unassigned { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.unassigned li { border: 1px dashed var(--accent); border-radius: 8px; padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.unassigned .btns { margin: 0; align-items: center; }
.unassigned select { max-width: 100%; font-size: 13px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
@media (max-width: 520px) { form.deal-f .grid { grid-template-columns: 1fr; } }

