:root {
  --bg: #eef2f4;
  --card: #fff;
  --text: #333;
  --muted: #828b95;
  --line: #dfe3e8;
  --accent: #2fc6f6;
  --accent-dark: #11a9d9;
  --primary: #bbed21;
  --primary-text: #535c69;
  --ok: #7bd500;
  --err-bg: #fff1f0;
  --err: #c0392b;
  --warn: #b26b00;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Open Sans", "Helvetica Neue", Arial, sans-serif; }
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 32px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 8px 0; }
h3 { font-size: 15px; margin: 0 0 10px; }
.sub, .muted { color: var(--muted); margin: 0; }
.head { margin-bottom: 14px; }
.card { background: var(--card); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); }
fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
legend { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 10px; padding: 0; }
label { display: block; font-size: 13px; color: #555; margin-bottom: 10px; }
label.inline { display: flex; align-items: center; gap: 10px; margin: 0; }
label.inline input { width: 140px; margin: 0; }
.req { color: var(--err); margin-left: 2px; }
.hint { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
select:disabled { background: #f5f7f8; color: var(--muted); }
input, select, textarea { width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,198,246,.15); }
.invalid { border-color: var(--err) !important; }
.grid { display: grid; gap: 0 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; }

.items-head, .item { display: grid; grid-template-columns: 1fr 80px 110px 100px 28px; gap: 8px; align-items: center; }
.items-head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.item { margin-bottom: 6px; }
.item input { margin: 0; }
.i-sum { text-align: right; font-variant-numeric: tabular-nums; }
.i-del { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }
.i-del:hover { color: var(--err); }
.totals { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); margin-top: 10px; padding-top: 12px; }
.total { font-size: 16px; }
.total b { font-variant-numeric: tabular-nums; }

.btn { font: inherit; font-weight: 600; border-radius: 20px; padding: 9px 22px; cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--primary); color: var(--primary-text); text-transform: uppercase; font-size: 12px; letter-spacing: .03em; }
.btn.primary:hover { background: #d2f95f; }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: #fff; border-color: #c6cdd3; color: var(--primary-text); text-transform: uppercase; font-size: 12px; }
.btn.ghost:hover { border-color: var(--primary-text); }
.btn.link { background: none; border: 0; color: var(--accent-dark); padding: 6px 0; font-weight: 600; }
.btn.link:hover { text-decoration: underline; }
.actions { display: flex; gap: 10px; }
.actions.center { justify-content: center; }

.alert { background: var(--err-bg); color: var(--err); border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; }
.setup { display: flex; justify-content: space-between; align-items: center; gap: 14px; border-left: 4px solid var(--accent); }
.done { text-align: center; }
.check { width: 56px; height: 56px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 30px;
  display: flex; align-items: center; justify-content: center; margin: 4px auto 0; }
.warn { color: var(--warn); }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent a { color: var(--accent-dark); text-decoration: none; cursor: pointer; }
.recent a:hover { text-decoration: underline; }
.recent .meta { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; border-radius: 10px; padding: 1px 8px; margin-left: 6px; background: #edf1f4; color: var(--muted); }
.badge.S { background: #e9f8d3; color: #4c8a00; }
.badge.F { background: #fde8e6; color: var(--err); }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 2px; }
.slot { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; cursor: pointer;
  text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.slot:hover:not(:disabled) { border-color: var(--accent); }
.slot.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,198,246,.18); background: #f3fcff; }
.slot:disabled { cursor: not-allowed; background: #f5f7f8; color: var(--muted); }
.slot .s-time { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.slot .s-free { font-size: 12px; color: #4c8a00; }
.slot .s-free.low { color: var(--warn); }
.slot .s-free.full { color: var(--err); }
.slot .s-bar { height: 4px; border-radius: 2px; background: #edf1f4; overflow: hidden; }
.slot .s-bar i { display: block; height: 100%; background: var(--accent); }
.slot:disabled .s-bar i { background: var(--err); }
.slot ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: 11px; color: var(--muted); }
.slot li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slots.invalid { outline: 1px solid var(--err); border-radius: 10px; }
.time-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: #555; }
.time-edit input { width: 110px; margin: 0; }

.set-head, .set-row { display: grid; grid-template-columns: 70px 120px 120px 90px; gap: 8px; align-items: center; }
.set-head { font-size: 12px; color: var(--muted); margin: 10px 0 2px; }
.set-row { margin-bottom: 6px; }
.set-row input { margin: 0; }

.field { margin-bottom: 12px; }
.field-label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; border-radius: 8px; }
.checks.invalid { outline: 1px solid var(--err); outline-offset: 3px; }
.check-pill { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 18px; cursor: pointer; color: var(--text); background: #fff; user-select: none; }
.check-pill input { width: auto; margin: 0; accent-color: var(--accent-dark); }
.check-pill:has(input:checked) { border-color: var(--accent); background: #f3fcff; }

.bk { font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.bk.cancelled { text-decoration: line-through; }
.btn.tiny { font-size: 12px; padding: 0 0 0 8px; }

@media (max-width: 760px) {
  .slots { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .items-head { display: none; }
  .item { grid-template-columns: 1fr 1fr 28px; }
  .item .i-name { grid-column: 1 / -1; }
  .item .i-sum { display: none; }
  .setup { flex-direction: column; align-items: flex-start; }
}

/* ---------- панель склада ---------- */
.wrap.wide { max-width: 1280px; }
.small { font-size: 12px; }
.mt { margin-top: 18px; }
.hint-block { font-size: 12px; margin: 8px 0 12px; }
.btn.sm { padding: 4px 12px; font-size: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { font: inherit; border: 0; background: transparent; padding: 8px 14px; border-radius: 18px; cursor: pointer; color: var(--primary-text); }
.tabs button:hover { background: #e2e8ec; }
.tabs button.active { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; }
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.weeknav input { width: auto; margin: 0; }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; background: #333; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: min(420px, calc(100vw - 32px)); box-shadow: 0 4px 16px rgba(0,0,0,.2); }

.req-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.rq { display: flex; flex-direction: column; gap: 3px; text-align: left; font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; width: 100%; min-width: 0; }
.rq:hover { border-color: var(--accent); }
.req-top { display: flex; justify-content: space-between; gap: 2px 8px; flex-wrap: wrap; }
.req-top b { white-space: nowrap; }
.req-client { font-weight: 600; }
.req-addr { color: #555; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rq.compact { padding: 8px 10px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 11px; border-radius: 10px; padding: 1px 8px; background: #edf1f4; color: var(--primary-text); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.ok { background: #e9f8d3; color: #4c8a00; }
.chip.warn { background: #fff3d6; color: var(--warn); }
.chip.new { background: #e0f6fd; color: var(--accent-dark); }
.chip.asm { background: #f1e9fd; color: #6b3fb0; }

.schedule { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.day { background: var(--card); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day-head { display: flex; justify-content: space-between; padding-bottom: 4px; border-bottom: 1px solid var(--line); }

.table-scroll { overflow-x: auto; }
.slot-table { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 640px; }
.slot-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; white-space: nowrap; }
.slot-table tbody th { text-align: left; color: var(--text); }
.cell { width: 100%; font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 8px 4px; cursor: pointer; font-variant-numeric: tabular-nums; }
.cell.free { background: #f2f9e6; color: #4c8a00; }
.cell.some { background: #e0f6fd; color: var(--accent-dark); }
.cell.busy { background: #fff3d6; color: var(--warn); }
.cell.full { background: #fde8e6; color: var(--err); }
.slot-cell { margin-top: 14px; display: grid; gap: 8px; }
.slot-cell h3 { margin: 0; }

.detail { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--text); }
.detail::backdrop { background: rgba(30,40,50,.45); }
.detail-head { position: sticky; top: 0; background: #fff; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); z-index: 1; }
.detail-head h2 { font-size: 17px; margin: 0; }
#dBody { padding: 6px 20px 20px; }
.d-sec { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.d-sec:first-child { border-top: 0; }
.d-sec h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px; padding: 3px 0; }
.kv a { color: var(--accent-dark); }
.items-table { width: 100%; border-collapse: collapse; }
.items-table td { padding: 4px 0; border-bottom: 1px solid #f0f2f4; }
.items-table .num { text-align: right; white-space: nowrap; padding-left: 12px; font-variant-numeric: tabular-nums; }
.grid.resched { grid-template-columns: 1.2fr 1.6fr 1fr 1fr; }
.send-status { font-size: 13px; color: #555; display: grid; gap: 2px; margin: 4px 0 10px; }

.people-head, .people-row { display: grid; grid-template-columns: 1.4fr 1fr 40px; gap: 8px; align-items: center; }
.people-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.people-row { margin-bottom: 6px; }
.people-row input { margin: 0; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

@media (max-width: 760px) {
  .kv { grid-template-columns: 1fr; gap: 0; padding: 4px 0; }
  .grid.resched { grid-template-columns: 1fr 1fr; }
  .people-head { display: none; }
  .people-row { grid-template-columns: 1fr 1fr; }
  .people-row input:first-child { grid-column: 1 / -1; }
}

.field-map { display: grid; gap: 6px; }
.fm-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: center; margin: 0; }
.fm-row select { margin: 0; }
@media (max-width: 760px) { .fm-row { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- занятость слотов на день (timeline.js) ---------- */
.tl-wrap { overflow-x: auto; }
.tl { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 520px; font-size: 12px; table-layout: fixed; }
.tl th { font-weight: 600; color: var(--muted); }
.tl thead .tl-name { width: 96px; }
.tl thead .tl-sum { width: 70px; }
.tl-col { text-align: center; font-variant-numeric: tabular-nums; color: var(--text) !important; font-size: 13px; }
.tl-name { text-align: left; white-space: nowrap; padding-right: 6px; color: var(--text) !important; }
.tl-name b { display: block; font-size: 13px; }
.tl-range { display: block; font-weight: 400; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tl-cell { height: 46px; border-radius: 8px; padding: 4px 8px; vertical-align: middle; text-align: left; border: 1px solid transparent; overflow: hidden; }
.tl-cell.free { background: #eef8e3; color: #4c8a00; }
.tl-cell.busy { background: #ffe9e4; color: #8a2b1d; border-color: #f7c6bb; }
.tl-cell.off { background: repeating-linear-gradient(45deg, #f2f4f6, #f2f4f6 4px, #e8ebee 4px, #e8ebee 8px); }
.tl-cell.clickable { cursor: pointer; }
.tl-cell.free.clickable:hover { background: #d9f0c2; }
.tl-cell.busy.clickable:hover { border-color: #e48f7c; }
.tl-cell.selected { background: #dff5fd; color: var(--accent-dark); border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,198,246,.25); }
.tl-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.tl-line:first-child { font-weight: 600; }
.tl-time { display: block; font-size: 11px; color: var(--muted); }
.tl-sum { white-space: nowrap; text-align: right; padding-left: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-sum.free { color: #4c8a00; }
.tl-sum.some { color: var(--accent-dark); }
.tl-sum.full { color: var(--err); }
.tl-row.full .tl-name { color: var(--muted) !important; }
.tl-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 6px; }
.tl-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.day-tl { margin-bottom: 14px; }
.day-tl h4 { margin: 0 0 4px; font-size: 13px; }
.slots-tl.invalid { outline: 1px solid var(--err); outline-offset: 2px; border-radius: 8px; }

/* ---------- таблицы заявок склада ---------- */
.list-table { width: 100%; border-collapse: collapse; min-width: 860px; font-size: 13px; }
.list-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.list-table td { padding: 8px; border-bottom: 1px solid #f0f2f4; vertical-align: top; }
.list-table tr.clickable { cursor: pointer; }
.list-table tr.clickable:hover td { background: #f6fbfd; }
.list-table a { color: var(--accent-dark); }
.list-table .goods { white-space: pre-line; max-width: 260px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.count.gray { background: #9aa4ad; }

/* ---------- файлы сделки ---------- */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.file-tile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; background: #fff; min-width: 0; }
.file-tile:hover { border-color: var(--accent); }
.file-tile img { width: 100%; height: 86px; object-fit: cover; border-radius: 6px; background: #f2f4f6; }
.file-ext { height: 86px; border-radius: 6px; background: #eef2f4; color: var(--muted); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.file-name { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.file-btn { display: inline-block; cursor: pointer; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.file-list a { color: var(--accent-dark); }
.compact-table { min-width: 0; margin-bottom: 10px; }

/* ---------- блоки недель в таблице заявок ---------- */
.list-table tr.week-row td { background: #f2f6f8; padding: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.list-table tr.week-row.current td { background: #e3f6fc; }
.list-table tr.week-row.past td { background: #f7f7f7; color: #8a8f94; }
.list-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.list-head h3 { margin: 0; }
.list-search { flex: 1 1 280px; max-width: 460px; margin-top: 0; }

/* ---------- права доступа ---------- */
.acl { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.acl h4 { margin: 0 0 2px; }
.acl .acl-mode { margin: 8px 0 4px; }
.acl .acl-users { margin: 4px 0 6px; }
.chip-x { border: 0; background: none; padding: 0 0 0 6px; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; }

/* ---------- удаление заявки ---------- */
.btn.danger { background: #e5484d; color: #fff; border-color: #e5484d; }
.btn.ghost.danger { background: transparent; color: #c62f34; border-color: #f0b4b6; }
.check-pill.block { display: flex; width: 100%; }
