/* ЗЯБ Конструкция — рекламации. Без внешних зависимостей. */
:root {
  --bg: #eef2f4;
  --panel: #ffffff;
  --text: #333b45;
  --muted: #828b95;
  --line: #e3e8ec;
  --line-2: #eef1f3;
  --blue: #2067b0;
  --blue-2: #2fc6f6;
  --link: #2067b0;
  --green: #00a64c;
  --green-h: #00924a;
  --orange: #f5a300;
  --red: #e5484d;
  --violet: #6c4fd1;
  --top-1: #1d2a5b;
  --top-2: #3a3fa0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- верхняя панель ---------- */
.topbar {
  background: linear-gradient(90deg, var(--top-1), var(--top-2));
  color: #fff;
  position: sticky; top: 0; z-index: 40;
}
.topbar-in { display: flex; align-items: center; gap: 24px; height: 56px; padding: 0 20px; max-width: 1680px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand:hover { text-decoration: none; opacity: .9; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.16); display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; font-size: 11px; opacity: .7; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: rgba(255,255,255,.85); padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.top-right { display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.badge-dot { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #ff5752; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.me { display: flex; align-items: center; gap: 8px; color: #fff; padding: 4px 8px; border-radius: 10px; }
.me:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.me-name { font-size: 13px; line-height: 1.2; text-align: right; }
.me-name small { display: block; opacity: .7; font-size: 11px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #dfe5ea; color: #535c69; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.topbar .avatar { background: rgba(255,255,255,.2); color: #fff; }

/* уведомления */
.notif-panel { position: absolute; right: 20px; top: 56px; width: 380px; max-width: calc(100vw - 24px); max-height: 70vh; overflow: auto; background: #fff; color: var(--text); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.18); z-index: 60; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.notif-item { display: block; padding: 10px 16px; border-bottom: 1px solid var(--line-2); color: var(--text); }
.notif-item:hover { background: #f6f8fa; text-decoration: none; }
.notif-item.unread { background: #eef6fe; }
.notif-item b { display: block; font-weight: 600; font-size: 13px; }
.notif-item span { display: block; font-size: 12px; color: var(--muted); white-space: pre-line; }

/* ---------- страница ---------- */
.page { max-width: 1680px; margin: 0 auto; padding: 20px; }
.page-narrow { max-width: 980px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; color: #1f2937; }
.spacer { flex: 1; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; background: #fff; color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1a5a9c; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-h); }
.btn-warning { background: var(--orange); color: #fff; }
.btn-warning:hover { background: #df9400; }
.btn-danger { background: #fff; color: var(--red); border-color: #f3c4c5; }
.btn-danger:hover { background: #fff3f3; }
.btn-light { border-color: var(--line); }
.btn-light:hover { background: #f5f7f9; }
.btn-ghost { background: transparent; border: 0; color: var(--link); padding: 0 6px; height: auto; font-weight: 500; }
.btn-ghost:hover { text-decoration: underline; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-create { background: #00b14f; color: #fff; }
.btn-create:hover { background: #009b45; }

/* ---------- поля ввода ---------- */
.input, .select, .textarea { width: 100%; height: 36px; padding: 0 11px; border: 1px solid #d5dbe1; border-radius: 9px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(32,103,176,.14); }
.input.invalid, .select.invalid, .textarea.invalid, .filebox.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(229,72,77,.12); }
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.req::after { content: " *"; color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.searchbox { position: relative; display: flex; align-items: center; min-width: 220px; flex: 0 1 340px; }
.searchbox .ic { position: absolute; left: 10px; color: var(--muted); }
.searchbox .input { padding-left: 34px; }

/* ---------- фильтры-чипы ---------- */
.chips { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.chip { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; color: #525c69; white-space: nowrap; }
.chip:hover { background: #f2f5f7; }
.chip.active { background: #e5effa; color: var(--blue); }
.chip .count { display: inline-block; margin-left: 4px; background: #ff5752; color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; }

/* ---------- панели ---------- */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 18px 20px; }
.section { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px 6px; margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #535c69; }
.kv { margin-bottom: 12px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 15px; color: #1f2937; word-break: break-word; }
.kv .v.empty { color: #a8adb4; font-size: 14px; }
.kv.missing .k { color: var(--red); }
.kv.missing .k::after { content: " — нужно заполнить"; }

/* ---------- таблица списка ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; min-width: 1100px; }
table.grid th { position: sticky; top: 0; background: #fff; text-align: left; font-weight: 500; color: #6a737f; font-size: 13px; padding: 12px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
table.grid td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.grid tr.row { cursor: pointer; }
table.grid tr.row:hover td { background: #f7fafc; }
table.grid tr.row.done td { background: #f4fbef; }
table.grid tr.row.cancelled td { color: #9aa1a9; }
.cell-title { min-width: 190px; }
.cell-title a { font-weight: 500; }
.cell-clip { max-width: 260px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.person .avatar { width: 26px; height: 26px; font-size: 10px; }
.list-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; color: var(--muted); font-size: 13px; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }

/* мини-полоса стадий в списке (как в Битриксе) */
.stagebar { display: flex; gap: 2px; width: 170px; }
.stagebar i { flex: 1; height: 8px; background: #eceff2; border-radius: 1px; }
.stagebar-label { font-size: 11px; color: #8a929c; margin-top: 4px; max-width: 180px; line-height: 1.25; }

/* ---------- канбан ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(205px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kcol { background: rgba(255,255,255,.55); border-radius: var(--radius); min-height: 200px; }
.kcol-head { padding: 10px 12px; color: #fff; font-weight: 600; font-size: 13px; border-radius: var(--radius) var(--radius) 0 0; display: flex; justify-content: space-between; gap: 8px; }
.kcol-body { padding: 8px; display: grid; gap: 8px; max-height: calc(100vh - 230px); overflow: auto; }
.kcard { background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer; border-left: 3px solid transparent; }
.kcard:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.kcard-num { font-weight: 600; color: var(--link); font-size: 13px; }
.kcard-obj { font-size: 13px; margin-top: 2px; }
.kcard-sit { font-size: 12px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); gap: 8px; }

/* ---------- карточка ---------- */
.card-title { font-size: 22px; font-weight: 700; margin: 0 0 14px; color: #1f2937; }
.stages { display: flex; gap: 3px; margin-bottom: 16px; overflow-x: auto; }
.stage { flex: 1 1 0; min-width: 120px; position: relative; height: 34px; display: flex; align-items: center; padding: 0 14px 0 18px; font-size: 12px; font-weight: 600; color: #535c69; background: #e7eaed; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 0; text-align: left; }
.stage:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 6px 0 0 6px; padding-left: 12px; }
.stage .u { position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; }
.stage.passed, .stage.current { color: #fff; }
.stage.clickable { cursor: pointer; }
.stage.clickable:hover { filter: brightness(.95); }
.stage-cancel { margin-left: 8px; flex: 0 0 auto; min-width: 100px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid #d9dee3; }
.tab { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; color: #535c69; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.card-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }

.action-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; border-top: 3px solid var(--blue); }
.action-box h3 { margin: 0 0 4px; font-size: 15px; }
.action-box .hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.alert { padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 10px; }
.alert-warn { background: #fff7e6; color: #8a5a00; border: 1px solid #ffe2a8; }
.alert-err { background: #fff1f1; color: #b42318; border: 1px solid #ffd2d2; }
.alert-ok { background: #ecfdf3; color: #067647; border: 1px solid #c6f0d6; }
.alert-info { background: #eef6fe; color: #1f5f9e; border: 1px solid #cfe3f8; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.file { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; background: #fff; display: block; color: var(--text); min-height: 112px; }
.file:hover { border-color: #b8c6d4; text-decoration: none; }
.file-thumb { height: 56px; display: grid; place-items: center; margin-bottom: 6px; overflow: hidden; border-radius: 6px; }
.file-thumb img { max-width: 100%; max-height: 56px; object-fit: cover; }
.file-ext { display: inline-block; font-size: 10px; font-weight: 800; color: #fff; padding: 2px 6px; border-radius: 3px; background: #8a96a3; }
.file-ext.pdf { background: #e5484d; } .file-ext.xls, .file-ext.xlsx { background: #1d9d57; } .file-ext.doc, .file-ext.docx { background: #2b6cd4; } .file-ext.link { background: #6c4fd1; }
.file-name { font-size: 12px; line-height: 1.25; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.file-del { position: absolute; top: 4px; right: 4px; border: 0; background: #fff; border-radius: 6px; color: var(--muted); cursor: pointer; padding: 2px; display: none; }
.file:hover .file-del { display: block; }
.file-del:hover { color: var(--red); }
.doc-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-files { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.doc-files a { font-size: 13px; }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.person-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; }
.person-card .nm { color: var(--link); font-weight: 500; }
.person-card .pos { font-size: 12px; color: var(--muted); }
.person-card .x { margin-left: auto; }

/* лента */
.feed-new { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; }
.timeline { position: relative; padding-left: 34px; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 2px; background: #dfe5ea; }
.tl { position: relative; background: #fff; border-radius: 10px; box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 10px; }
.tl-dot { position: absolute; left: -34px; top: 10px; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid #dfe5ea; display: grid; place-items: center; color: #8a929c; }
.tl-dot.comment { background: #2fc6f6; border-color: #2fc6f6; color: #fff; }
.tl-dot.st { background: #6c4fd1; border-color: #6c4fd1; color: #fff; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.tl-head b { color: #535c69; font-weight: 600; }
.tl-body { margin-top: 4px; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; }
.tl-chip { background: #eef1f4; padding: 3px 8px; border-radius: 12px; }
.tl-date { text-align: center; margin: 14px 0 10px -34px; }
.tl-date span { background: #dfe5ea; color: #535c69; font-size: 12px; padding: 3px 12px; border-radius: 12px; }

table.history { width: 100%; border-collapse: collapse; background: #fff; }
table.history th, table.history td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: 13px; }
table.history th { color: #6a737f; font-weight: 500; }

/* ---------- форма создания ---------- */
.form-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 16px; }
.form-card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: #535c69; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.filebox { border: 2px dashed #cfd7df; border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); position: relative; background: #fafbfc; }
.filebox input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filebox.drag { border-color: var(--blue); background: #f1f7fd; }
.file-list { list-style: none; padding: 0; margin: 8px 0 0; text-align: left; }
.file-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; color: var(--text); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* ---------- модальное окно, тост ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { padding: 16px 20px 0; font-weight: 700; font-size: 16px; }
.modal-body { padding: 12px 20px; }
.modal-foot { padding: 0 20px 16px; display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; }
.toast { background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 380px; font-size: 13px; }
.toast.err { background: #b42318; }
.toast.ok { background: #067647; }

/* ---------- админка ---------- */
.role-pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eef1f4; color: #535c69; }
.role-pill.admin { background: #ede9fe; color: #5b21b6; }
.role-pill.director { background: #fff4d6; color: #8a5a00; }
.role-pill.accountant { background: #f3e8ff; color: #7b3fa0; }
.role-pill.warehouse { background: #ffe4e6; color: #a3132b; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; }
.check-list label { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); cursor: pointer; }
.pw-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; background: #f3f5f7; padding: 10px 14px; border-radius: 8px; text-align: center; letter-spacing: 1px; user-select: all; }

/* ---------- вход ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 80% -10%, #5257c9 0, transparent 60%), linear-gradient(135deg, #18224d, #2f3a8f); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.login-card .brand-mark { background: linear-gradient(135deg, #2067b0, #6c4fd1); color: #fff; width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 20px; margin: 0; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 13px; }

@media (max-width: 1100px) {
  .card-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .page { padding: 12px; }
  .topbar-in { gap: 10px; padding: 0 12px; }
  .brand small, .me-name { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 19px; }
  .searchbox { flex: 1 1 100%; }
}
@media print {
  .topbar, .no-print { display: none !important; }
}

/* перетаскивание в канбане */
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .45; }
.kanban.is-dragging .kcol { transition: opacity .15s, box-shadow .15s; }
.kanban.is-dragging .kcol.drop-no { opacity: .45; }
.kanban.is-dragging .kcol.drop-ok { box-shadow: 0 0 0 2px #2fb344 inset; background: rgba(47,179,68,.08); }
.kanban.is-dragging .kcol.drop-over { box-shadow: 0 0 0 3px #2fb344 inset; background: rgba(47,179,68,.18); }
.kcol-hint { font-size: 11px; font-weight: 400; opacity: .9; }
