/* Система обміну та повернення — стилі */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --line: #e3e6ec;
  --brand: #1f6feb;
  --brand-dark: #1554b8;
  --green: #147d3c;
  --green-bg: #e7f6ec;
  --red: #b4232b;
  --red-bg: #fdecec;
  --amber: #8a5a00;
  --amber-bg: #fdf3e0;
  --violet: #5b3fb5;
  --violet-bg: #efeaff;
  --blue-bg: #e8f1fe;
  --gray-bg: #eceef2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
body.is-admin .wrap { max-width: 1400px; }

/* ---- Topbar ---- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 650; color: var(--text); text-decoration: none; }
.logo__mark {
  display: grid; place-items: center; width: 28px; height: 28px;
  background: var(--brand); color: #fff; border-radius: 8px; font-size: 15px;
}
.topnav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover { color: var(--brand); }
.topnav__user { color: var(--text); font-weight: 600; }
.topnav__exit { color: var(--red) !important; }

.main { padding: 26px 16px 48px; }
.footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); font-size: 13px; background: #fff; }
.footer p { margin: 0; }

/* ---- Typography ---- */
h1 { font-size: 26px; margin: 0 0 14px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 26px 0 12px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
.lead { font-size: 16px; color: #414753; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }

/* ---- Card ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card__title { margin: 0 0 14px; font-size: 15px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---- Alerts ---- */
.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert--success { background: var(--green-bg); color: var(--green); border-color: #bfe5cd; }
.alert--error { background: var(--red-bg); color: var(--red); border-color: #f3c4c4; }
.alert--info { background: var(--blue-bg); color: var(--brand-dark); border-color: #c5dcfb; }
.alert--warn { background: var(--amber-bg); color: var(--amber); border-color: #f2dcb0; }

.notice {
  border-left: 4px solid var(--amber); background: var(--amber-bg);
  padding: 14px 16px; border-radius: 6px; margin: 16px 0; color: #6d4700;
}
.notice strong { color: #513400; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.label .req { color: var(--red); }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd4dd; border-radius: 8px;
  background: #fff; font: inherit; color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 111, 235, .14);
}
.textarea { min-height: 92px; resize: vertical; }
.input--error, .select--error, .textarea--error { border-color: var(--red); background: #fffafa; }
.error-text { color: var(--red); font-size: 13px; margin-top: 5px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .12s;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--ghost { background: #fff; color: var(--text); border-color: #cfd4dd; }
.btn--ghost:hover { background: #f6f7f9; }
.btn--green { background: var(--green); } .btn--green:hover { background: #0f6330; }
.btn--red { background: var(--red); } .btn--red:hover { background: #931a21; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 13px 26px; font-size: 16px; }
.btn--block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Steps ---- */
.step { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 14px; box-shadow: var(--shadow); }
.step__head { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.step__num {
  display: grid; place-items: center; width: 25px; height: 25px; flex: none;
  border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; font-weight: 700;
}
.step__title { font-weight: 650; }
.step__body { padding: 18px; }
.step.is-locked { opacity: .5; pointer-events: none; }
.step.is-locked .step__num { background: #b9bfc9; }

/* ---- Вкладений блок усередині кроку (реквізити) ---- */
.subblock {
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 8px; padding: 16px; margin: 4px 0 16px; background: #fbfcfd;
}
.subblock__title { font-weight: 650; margin-bottom: 14px; font-size: 14px; }

/* ---- Розгортна підказка (нативний <details>, без JS) ---- */
.help { border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 16px; }
.help summary {
  cursor: pointer; padding: 10px 13px; font-size: 13.5px; font-weight: 600;
  color: var(--brand); list-style: none; user-select: none;
}
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: '＋'; margin-right: 7px; font-weight: 400; }
.help[open] summary::before { content: '－'; }
.help summary:hover { color: var(--brand-dark); }
.help__body { padding: 0 13px 13px; font-size: 13.5px; color: #414753; border-top: 1px solid var(--line); padding-top: 11px; }
.help__body ul { margin: 8px 0; padding-left: 20px; }
.help__body li { margin-bottom: 4px; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-weight: 650; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: #fafbfc; position: sticky; top: 0; z-index: 1; }
.table tbody tr:hover { background: #fafbfd; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.table a { text-decoration: none; font-weight: 600; }

.kv { width: 100%; font-size: 14px; border-collapse: collapse; }
.kv td { padding: 6px 0; vertical-align: top; border-bottom: 1px solid #f1f2f5; }
.kv td:first-child { color: var(--muted); width: 42%; padding-right: 12px; }
.kv tr:last-child td { border-bottom: none; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.badge--blue { background: var(--blue-bg); color: var(--brand-dark); }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--red { background: var(--red-bg); color: var(--red); }
.badge--amber { background: var(--amber-bg); color: var(--amber); }
.badge--violet { background: var(--violet-bg); color: var(--violet); }
.badge--gray { background: var(--gray-bg); color: #4b5563; }

/* ---- Photos ---- */
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photo { width: 118px; }
.photo img { width: 118px; height: 118px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photo__cap { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; }

.uploader { border: 2px dashed #cfd4dd; border-radius: var(--radius); padding: 18px; background: #fafbfc; }
.uploader.is-over { border-color: var(--brand); background: var(--blue-bg); }
.upload-list { margin-top: 12px; display: grid; gap: 8px; }
.upload-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.upload-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 5px; flex: none; }
.upload-item__name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item select { padding: 5px 7px; border: 1px solid #cfd4dd; border-radius: 6px; font-size: 12.5px; }
.upload-item__del { background: none; border: none; color: var(--red); cursor: pointer; font-size: 17px; padding: 0 5px; }

/* ---- Product picker ---- */
.product { display: flex; gap: 11px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; align-items: flex-start; }
.product:hover { border-color: #b9c6dd; }
.product input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--brand); }
/* name/meta — інлайнові span, тому display:block обовʼязковий,
   інакше артикул приклеюється до назви в той самий рядок */
.product__body { flex: 1; min-width: 0; }
.product__name { display: block; font-weight: 600; line-height: 1.4; cursor: pointer; }
.product__meta { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.product__qty { display: flex; align-items: center; gap: 9px; margin-top: 9px; font-size: 13px; flex-wrap: wrap; }
.product__qty > label { color: var(--muted); cursor: default; }
.product__qty-of { color: var(--muted); }

/* Степер: кнопки та поле склеєні в одну пігулку */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid #cfd4dd; border-radius: 7px; overflow: hidden; background: #fff; }
.stepper:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 111, 235, .14); }
.stepper__btn {
  width: 28px; border: none; background: #f6f7f9; color: var(--text);
  font-size: 15px; line-height: 1; cursor: pointer; user-select: none;
  display: grid; place-items: center; transition: background .12s;
}
.stepper__btn:hover { background: #e9ebef; }
.stepper__btn:active { background: #dfe2e7; }
.stepper input {
  width: 42px; border: none; border-left: 1px solid #e3e6ec; border-right: 1px solid #e3e6ec;
  padding: 5px 0; font: inherit; font-weight: 600; text-align: center; background: #fff; color: var(--text);
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input:focus { outline: none; }
/* прибираємо рідні стрілки — вони ламають вигляд пігулки */
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- Filters ---- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.filters .input, .filters .select { padding: 8px 10px; font-size: 13.5px; }
.filters .label { font-size: 12px; color: var(--muted); }

/* ---- Workflow (дії менеджера) ---- */
.wf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.wf-set { display: flex; align-items: center; gap: 6px; }
.wf-set__lbl { font-size: 12px; color: var(--muted); }
.wf-set__sel {
  padding: 4px 8px; border: 1px solid #cfd4dd; border-radius: 6px;
  background: #fff; font-size: 12.5px; color: var(--muted); max-width: 190px;
}
.wf-set__sel:hover { color: var(--text); }
.wf-set__sel:focus { outline: none; border-color: var(--brand); }

.wf__now { display: flex; align-items: center; gap: 9px; }
.wf__label { color: var(--muted); font-size: 14px; }
.wf__hint { margin: 8px 0 0; color: #414753; font-size: 14px; }
.wf__next {
  margin-top: 14px; padding: 10px 12px; border: 1px solid #cfe0c9;
  background: #f2f9ef; border-radius: 8px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.wf__next-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--green); white-space: nowrap;
}
.wf__next .btn-row { margin: 0; }
.wf__next .btn { font-size: 14px; padding: 8px 16px; }
.wf__more { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.wf__more summary {
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted);
  list-style: none; user-select: none;
}
.wf__more summary::-webkit-details-marker { display: none; }
.wf__more summary::before { content: '⚙ '; }
.wf__more[open] summary { color: var(--text); margin-bottom: 14px; }
.wf__more-body .grid2 { margin-bottom: 8px; }
.wf__manual { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

/* ---- Згортний блок у картці ---- */
.fold summary { list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: '▸ '; color: var(--muted); }
.fold[open] summary::before { content: '▾ '; }

/* ---- Рядок товару у формі менеджера ---- */
.m-item { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.m-item .input { width: auto; }
.m-item__name { flex: 1 1 auto; min-width: 0; }
.m-item__sku { flex: 0 0 150px; }
.m-item__qty { flex: 0 0 70px; text-align: center; }
.m-item__price { flex: 0 0 100px; }
.m-item-del { flex: none; }
@media (max-width: 700px) {
  .m-item { flex-wrap: wrap; }
  .m-item__name { flex: 1 1 100%; }
}

/* ---- Компактні фільтри списку ---- */
.filters-top { display: flex; gap: 8px; align-items: center; }
.filters-top .input { flex: 1; }
.filters-top .btn { white-space: nowrap; }
.filters-adv > summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--muted);
  margin-top: 12px; user-select: none;
}
.filters-adv > summary:hover { color: var(--text); }
.filters-adv .badge { margin-left: 4px; }

/* ---- Пошук відділень НП ---- */
.np-search-list { border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; overflow: hidden; }
.np-search-list:empty { display: none; }
.np-search-item { padding: 8px 11px; font-size: 13.5px; cursor: pointer; border-bottom: 1px solid #f1f2f5; }
.np-search-item:last-child { border-bottom: none; }
.np-search-item:hover { background: var(--blue-bg); }
.np-search-item.muted { cursor: default; color: var(--muted); }
.np-search-item.muted:hover { background: none; }

/* ---- Timeline ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 9px 0 9px 16px; border-left: 2px solid var(--line); position: relative; font-size: 13.5px; }
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: 15px;
  width: 8px; height: 8px; border-radius: 50%; background: #b9bfc9;
}
.timeline li:first-child::before { background: var(--brand); }
.timeline__time { color: var(--muted); font-size: 12px; }

.comment { border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; margin-bottom: 9px; background: #fff; }
.comment--client { border-left: 3px solid var(--brand); }
.comment--internal { border-left: 3px solid #b9bfc9; }
.comment--system { border-left: 3px solid var(--violet); background: #fbfaff; }
.comment__head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.comment__text { font-size: 14px; white-space: pre-wrap; }

/* ---- Stats ---- */
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat__value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.stat__label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }

.bar { height: 7px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar__fill { height: 100%; background: var(--brand); border-radius: 4px; }

/* ---- Misc ---- */
.pagination { display: flex; gap: 5px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px;
  text-decoration: none; color: var(--text); background: #fff; font-size: 13.5px;
}
.pagination .is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.hidden { display: none !important; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; }

.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-box { max-width: 380px; margin: 60px auto; }

@media print {
  .topbar, .footer, .btn, .btn-row { display: none; }
  body { background: #fff; }
}
